Analyzing your code with AI, Part 1: Discovering Oasis

In short
  • Bringing together CI/CD, AI, GPUs, containers, and cybersecurity in a concrete illustration.
  • Oasis uses the LLMs of Ollama to detect vulnerabilities in code.
  • Implementation under Kubernetes with Jenkins and GitLab already in place.
  • Part 2 automates the analysis within a CI pipeline.

Introduction

CI/CD, AI, GPU, Container, Cybersecurity are not just marketing terms that every good consulting firm should now master...

For an engineer and a technology enthusiast, these are primarily tools, hardware, methods, and skills useful to apply in their work to best meet the requirements of their projects.

It's time to leverage several articles available on this site and gather the pieces to offer a complete and factual illustration of what is possible today with all this terminology.

The goal will be to build a Jenkins pipeline, triggered by a push event in a GitLab repository, to retrieve the associated code for analysis using various LLM (Large Language Model) models. All of this runs on a Kubernetes node with a GPU to optimize the execution of the AI engines.

Step 1 The user pushes code into a repository

The repository is hosted in GitLab.

↓
Step 2 GitLab triggers a Jenkins pipeline

GitLab uses a webhook to notify Jenkins to execute the pipeline.

↓
Step 3 (pipeline) The user's code is cloned into a shared directory

The folder is hosted on an NFS volume

↓
Step 4 (pipeline) A vulnerability scan of the code is launched

Jenkins executes an Oasis command.

↓
Step 5 (oasis/ollama) The code is analyzed by AI

Oasis uses Ollama to utilize the available LLM models. The server's GPU is used.

↓
Step 6 (oasis) An audit is provided in the form of several reports

The reports can be retrieved from the shared folder or via a web interface, in PDF, HTML, or Markdown format

To better understand the explanations and upcoming actions, it is recommended to review various articles already published.


The use of GitLab and Jenkins for CI/CD will serve to automate tasks and simplify analysis:

AI will enable rapid identification of code vulnerabilities and suggest corrections:

The GPU will be used to make analysis times reasonable and to allow the use of advanced LLM models:

The advantage of using containers through Kubernetes is the ability to leverage the modularity and scalability of the platform.

I will often refer to these links, as they already contain some explanations and various useful examples for better understanding what follows. I will also frequently reuse associated elements.

Regarding cybersecurity, I will present the tool Oasis, an open-source code vulnerability scanner designed to utilize an Ollama instance.

But before embarking on this adventure, here is, as usual, a diagram summarizing the target to be achieved.

Architecture and logic diagram

Click the image to enlarge.

It does not detail all the components, but expresses the essential objects to manipulate and the interactions between the elements (text in green).

My goal is to present one possible approach, based on my personal lab and reusing some deployments already made in the past. Feel free to adapt, correct, or improve what is proposed according to your own needs.

Oasis

To perform code analysis, we will use the Ollama Automated Security Intelligence Scanner, also known by its abbreviation, OASIS. It is an open-source software available for free from its GitHub repository.

Introduction to Oasis

Click the image to enlarge.

It relies on the open-source Ollama platform, which allows you to run AI models (LLMs) locally such as LLaMA 2, LLaMA 3, Mistral and Gemma, thanks to a simple command-line interface or an API.

I have already had the opportunity to introduce Ollama in this article. I will also rely on the instance (and the server) that I deployed as part of this tutorial.

Like OpenWebUI, which I also mention in my publication, Oasis will communicate with Ollama to take advantage of the LLM models it hosts.

It will use these to analyze the code submitted to it in order to identify potential cybersecurity issues and generate a comprehensive report on the subject.

Oasis can utilize many of the AI engines that have been installed on Ollama.

Principles

Oasis will proceed in two steps. First, it will rely on a "light" LLM for a quick code analysis, then it will move on to a more in-depth analysis to target what was identified during the first pass. During this second step, Oasis can utilize a more advanced LLM, but also one that consumes more resources.

This is where the GPU comes in handy, and specifically the tutorial for using a graphics card within a Kubernetes cluster.

Oasis can even submit the code to multiple LLMs to cross-reference the results and obtain an even more detailed analysis.

It can detect several types of vulnerabilities, such as XSS flaws, SQL injection, the use of remote execution code, authentication problems, and even the use of sensitive data, such as a password or token.

Types of vulnerabilities handled by Oasis

Click the image to enlarge.

However, the project is still very young at the time of writing this article. Its first release date is January 2025.

Oasis runs in the form of a specific command that takes different arguments and requires Python to function.

By default, there is no containerized installation available; therefore, you must retrieve the application directly from the repository.

Oasis allows you to generate multiple scan reports in various formats, such as PDF or HTML. Optionally, it is possible to expose them via a web server (Flask).

Creating the Docker image

I will create a Docker image of the application to run it on the Kubernetes cluster where Ollama is running.

Writing the Dockerfile is not complicated. You just need to reuse the installation commands provided on GitHub.

# Utiliser une image Python officielle
FROM python:3.13.3

# Installer les dépendances nécessaires
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

# Installer pipx et s'assurer qu'il est accessible
RUN python -m pip install --upgrade pip \
    && python -m pip install pipx \
    && python -m pipx ensurepath

# Définir les variables d'environnement pour pipx
ENV PIPX_HOME=/root/.local
ENV PATH="${PIPX_HOME}/bin:${PATH}"

# Cloner le dépôt et installer Oasis
WORKDIR /app
RUN git clone https://github.com/psyray/oasis.git \
    && cd oasis \
    && pipx install --editable .

# Script d'entrée pour garder le conteneur actif
CMD ["oasis", "-i", "/nfs/security_reports", "-w", "-we", "all", "-wp", "8080"]
    

We start with a Python image, install the necessary dependencies, and then retrieve the Oasis code.

For the container to keep running, the last instruction of the Dockerfile must be the command that starts the process keeping the container alive.

In this case, we launch the oasis command, indicating where to generate these reports (/nfs/security_reports) and with the execution of the integrated web server listening on port 8080.

It is thanks to this web server that the container will not stop. If we simply use the 'oasis' command, it will be launched and, since no source code is provided for analysis, it will terminate immediately, ending the container. This is a bit of a trick to keep the container running; we could have used a dummy command like CMD ["tail", "-f", "/dev/null"] if we didn't want to use the web server.

This remains a suggestion that can lead to optimizations... for example, using a dedicated user... it's up to each person to build the image that best suits them.

We can build the image with the following command:

docker build -t oasis-container .
Creating the Docker image

Click the image to enlarge.

For my part, I then push it to my registry:

docker tag oasis-container registry.gitlab.com/apps.coolcorp.priv/oasis:oasis-dck-4.0 docker push registry.gitlab.com/apps.coolcorp.priv/oasis:oasis-dck-4.0
Publishing the image in the registry

Click the image to enlarge.

Integration with Ollama

The second step will be to modify my Deployment for Ollama so that it includes Oasis.

It would be possible to run Oasis in a separate Deployment and then specify the URL of Ollama as an argument, but for my use case, I want to integrate it into the Ollama Pod to simplify communication.

Be careful, choosing this strategy implies having as many instances of Oasis as there are instances of Ollama, with both sharing the same port range. Since I am working with a single replica, this is not a problem. This will help highlight the concept of a Pod.

I will therefore reuse my YAML files that I used in my tutorial for installing Ollama and OpenWebUI.

Therefore, I will use the existing Namespace prd-mygptgpu-lan.

Before modifying the Ollama Deployment object, I will add a PV (PersistentVolume) and a PVC (PersistentVolumeClaim).

Indeed, the idea is to be able to clone the code that I want to scan from GitLab into a folder.

This folder must be accessible by Oasis because when the Jenkins pipeline executes the scan command from the Oasis container, it will be necessary to specify a path argument. This argument must point to the directory containing the code to be analyzed.

We will therefore use an NFS volume, which is itself connected to a PV called by a PVC and used by the pod containing the Oasis container. If you are not comfortable with the concept of storage under K8S, feel free to read my article from my Kubernetes cookbook as well as my article on the CSI (ContainerStorageInterface) NFS.

I will therefore create a dedicated directory on my NAS for this purpose.

In this case, it will be located at: /Volume1/nfsshare/rubikub.coolcorp.priv/namespaces/prd-jenkins-lan/pipelines/security-code-check/.

Folder on my NAS

Click the image to enlarge.

We generate a persistent volume that uses the NFS CSI and points to this folder via the file 03-pv-ollama-oasis-security-code-check:

---
apiVersion: v1
kind: PersistentVolume
metadata:
  annotations:
    pv.kubernetes.io/provisioned-by: nfs.csi.k8s.io
  name: pv-ollama-oasis-security-code-check
  labels:
      environment: prd
      network: lan
      application: ollama
      tier: oasis
spec:
  capacity:
    storage: 30Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  csi:
    driver: nfs.csi.k8s.io
    volumeHandle: /Volume1/nfsshare/rubikub.coolcorp.priv/namespaces/prd-jenkins-lan/pipelines/security-code-check/oasis
    volumeAttributes:
      server: 192.168.10.152
      share: /Volume1/nfsshare/rubikub.coolcorp.priv/namespaces/prd-jenkins-lan/pipelines/security-code-check
    

Then, we generate the persistent volume claim (PVC) associated with it using the file 04-pvc-ollama-oasis-security-code-check.yml:

    
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-ollama-oasis-security-code-check
  namespace: prd-mygptgpu-lan
  labels:
      environment: prd
      network: lan
      application: ollama
      tier: oasis
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 30Gi
  volumeName: pv-ollama-oasis-security-code-check
  storageClassName: ""

We apply both objects with the command: kubectl apply -f nom_yaml.yaml

Applying the persistent volume/persistent volume claim

Click the image to enlarge.

Now, we need to add this PVC and the reference to the Oasis image in my associated Deployment for Ollama.

I will not go over all the K8S objects used for Ollama. I invite you to read my dedicated article or to retrieve my files from my GitHub repository.

Here, I only need to modify the file 05-deploy-ollama-default.yml (called 03-deploy-ollama-default.yml in the original tutorial).

  
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: deploy-ollama-default
  namespace: prd-mygptgpu-lan
  labels:
    environment: prd
    network: lan
    application: mygpt
    tier: ollama
spec:
  replicas: 1
  selector:
    matchLabels:
      environment: prd
      network: lan
      application: mygpt
      tier: ollama
  template:
    metadata:
      labels:
        environment: prd
        network: lan
        application: mygpt
        tier: ollama
    spec: 
      tolerations:
        - key: "node-role.kubernetes.io/control-plane"
          operator: "Exists"
          effect: "NoSchedule"  
      containers:
        - name: ollama
          image: ollama/ollama:0.6.5
          resources:
           limits:
            nvidia.com/gpu: 1
          ports:
            - containerPort: 11434
          volumeMounts:
            - name: pv-ollama-default
              mountPath: "/root"
        - name: oasis
          image: registry.gitlab.com/apps.coolcorp.priv/oasis:oasis-dck-8.0 
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: pv-jenkins-pip-security-code-check
              mountPath: "/nfs" 
      imagePullSecrets: 
          - name: sec-mygptgpu-registry       
      volumes:
        - name: pv-ollama-default
          persistentVolumeClaim:
            claimName: pvc-ollama-default
        - name: pv-jenkins-pip-security-code-check
          persistentVolumeClaim:
            claimName: pvc-ollama-oasis-security-code-check
        

In terms of specifications, I have added a reference to the Oasis image (version 8) that we just created. Since it is hosted on my private registry, I also need to specify the secret sec-mygptgpu-registry, which contains my access credentials, in the "imagePullSecrets:" section.

I also add a reference to the newly created PVC that I use as a mount point /nfs within my Oasis container.

I specify the containerPort 8080 for the web server component.

Nothing else is needed.

For your information, I would like to draw your attention to the use of the nvidia.com/gpu: 1 option, which is already in place and associated with the Ollama container. To better understand this point, feel free to take a look here.

The GPU remains associated with Ollama. It is not directly Oasis that analyzes the code, but rather the LLM(s) present on Ollama that are controlled by Oasis.

I can now update my Ollama Deployment (kubectl apply -f ...).

By checking with the command: kubectl get pod -n prd-mygptgpu-lan

, we can now see that there are two containers in my Pod attached to my Deployment.

Listing of pods

Click the image to enlarge.

Tests and initial results

We connect within the context of the second container, which is Oasis, using the following command:

kubectl exec -it deploy-ollama-default-86754968cb-6z4gl -c oasis -n prd-mygptgpu-lan -- bash

From there, we can verify that the volume is properly mapped ( df -h ).

Checking the mount point

Click the image to enlarge.

Since we are in the context of the Oasis container, it makes sense to test its functionality.

To do this, I created a "repo" directory in my shared NFS folder, which is mounted within the container. I then placed a demo.py file there, generated by ChatGPT, containing a snippet of Python code with vulnerabilities.

Copying the demo file

Click the image to enlarge.

Here's its content:

  
import subprocess
import sqlite3
import requests

# ❌ 1. Donnée sensible codée en dur
API_KEY = "sk_test_51Lx0fFakeSecretHardcodedKey123456"

# ❌ 2. Mot de passe codé en dur
DB_PASSWORD = "P@ssw0rd123"

# ❌ 3. Requête SQL vulnérable à l'injection
def get_user_info(username):
    conn = sqlite3.connect("users.db")
    cursor = conn.cursor()
    # ⚠️ Injection SQL possible ici
    query = f"SELECT * FROM users WHERE username = '{username}'"
    cursor.execute(query)
    result = cursor.fetchall()
    conn.close()
    return result

# ❌ 4. Exécution de commande shell avec une entrée non filtrée
def run_ping(host):
    # ⚠️ Command injection possible ici
    cmd = f"ping -c 4 {host}"
    subprocess.call(cmd, shell=True)

# ❌ 5. Requête HTTP sans vérification SSL
def send_data(data):
    # ⚠️ Transmet potentiellement des données sensibles en clair
    response = requests.post("http://insecure.example.com/api", data=data, verify=False)
    return response.status_code

# Appels de test
if __name__ == "__main__":
    username = input("Enter username: ")
    print(get_user_info(username))

    host = input("Enter host to ping: ")
    run_ping(host)

    send_data({"api_key": API_KEY, "data": "some sensitive info"})

Within the Oasis container context, let's try to analyze this code using the following command:

oasis -i /nfs/repo -sm gemma3:4b -m llama3:8b --clear-cache-scan --vulns all

This immediately triggers the scan.

Starting the scan

Click the image to enlarge.

In the command, we first use the gemma3:4b LLM model for a quick analysis (-sm), and then switch to the llama3:8b model for in-depth analysis (-m), while also instructing Oasis to ignore any potential cache from previous scans (--clear-cache-scan) and to perform an analysis of all vulnerabilities (--vulns all).

Since Oasis shares the same pod as Ollama, there's no need to specify the API address of the latter

During the analysis, you can observe on the K8S node where the Pod running Ollama is executed that the GPU is heavily utilized (command: nvtop; feel free to review my article about GPU integration under Kubernetes).

GPU usage

Click the image to enlarge.

At the end of the scan, Oasis indicates that it has generated a set of reports.

End of the scan

Click the image to enlarge.

The reports are available on the NFS volume, in a subdirectory automatically created called "security_reports".

Making reports available

Click the image to enlarge.

You can navigate within the directory structure to, for example, retrieve all reports in PDF format.

Listing of reports in PDF format

Click the image to enlarge.

Once transferred to your workstation, you can browse them starting with _executive_summary.pdf.

In this example, Oasis detected 16 vulnerabilities.

Detection of 16 vulnerabilities

Click the image to enlarge.

For each vulnerability, it is possible to obtain the associated details by opening the dedicated PDF file.

Example of a PDF

Click the image to enlarge.

You will then find an explanation of the vulnerability and recommendations for correcting it.

Details of the vulnerability

Click the image to enlarge.

Recommendation

Click the image to enlarge.

This provides a set of reports that allow you to have a complete view of the security of your code.

Listing of all PDFs

Click the image to enlarge.

Note that, in this example, I used two LLM models:


  • gemma3:4b - The lightweight Google model derived from Gemini with 4 billion parameters
  • llama3:8b - The Meta (Facebook) model with 8 billion parameters

These models should be available within Ollama. If they are not, Oasis will automatically retrieve them.

You can verify this by connecting to the default ollama container instead of the oasis container using the following command:

kubectl exec -it deploy-ollama-default-86754968cb-6z4gl -n prd-mygptgpu-lan -- bash

With the ollama list instruction, we can obtain a list of all available Large Language Models (LLMs). We can confirm that those we have accessed through Oasis are indeed included in this list.

Listing of models on Ollama

Click the image to enlarge.

It is also a key strength of the solution, as it allows you to select different models based on your needs, hardware capabilities, and the type of code involved. You can find some recommendations directly on the Oasis GitHub repository to help you choose an LLM that best suits your requirements.

In my example, I have chosen a combination that allows processing all types of code with reasonable resource consumption. This is a general analysis, perhaps not optimized for a specific language, but it also does not use very powerful models that could saturate my graphics card (a modest 3060 TI).

The results are already very satisfactory.

Web interface

The case of the web interface remains. Currently, we are retrieving reports from the NAS interface.

However, our oasis container runs with the web instance.

To access it, you first need to generate a standard Service object and an Ingress object.

These principles are explained to you in my cookbook on Kubernetes.

Regarding the service, I will simply modify the existing Service named svc-ollama-default to add port 8080, which we declared in the Oasis container.

I am modifying my file 06-svc-ollama-default.yml (see my tutorial on Ollama).

  
---
  kind: Service
  apiVersion: v1
  metadata:
    name: svc-ollama-default
    namespace: prd-mygptgpu-lan
    labels:
      environment: prd
      network: lan
      application: mygpt
      tier: ollama
  spec:
    ports:
      - name: ollama
        port: 11434
        protocol: TCP
        targetPort: 11434
      #Ajout de l'exposition du serveur Web d'Oasis  
      - name: oasis
        port: 8080
        protocol: TCP
        targetPort: 8080 
    selector:
      environment: prd
      network: lan
      application: mygpt
      tier: ollama
    

Then, I can reapply the service (kubectl apply -f ...).

Reapplying the service

Click the image to enlarge.

Finally, I create a new Ingress object using the file 12-ing-ollama-oasis.yml.

 
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ing-ollama-oasis
  namespace: prd-mygptgpu-lan
  labels:
    environment: prd
    network: lan
    application: mygpt
    tier: oasis
  annotations:
    traefik.ingress.kubernetes.io/router.entrypoints: web,websecure
    ingressClassName: traefik-lan
    traefik.ingress.kubernetes.io/router.tls: "true"
spec:
  ingressClassName: traefik-lan
  tls:
  - hosts:
    - oasis.coolcorp.priv
    secretName: sec-oasis-cert
  rules:
  - host: oasis.coolcorp.priv
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: svc-ollama-default
            port:
              number: 8080
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: cert-oasis-default
  namespace: prd-mygptgpu-lan
  labels:
      environment: prd
      network: lan
      application: mygpt
      tier: oasis
spec:
  dnsNames:
    - oasis.coolcorp.priv
  commonName: oasis.coolcorp.priv
  secretName: sec-oasis-cert
  privateKey:
    algorithm: RSA
    size: 4096
  issuerRef:
    name: clusterissuer-acme2certifier 
    kind: ClusterIssuer     

This allows me to expose Oasis via the URL https://oasis.coolcorp.priv.. I add a certificate that is automatically generated using Cert-Manager. (Here, I also invite you to read my article dedicated to Cert-Manager, as well as my article on obtaining a certificate automatically from an internal PKI).

Creating the ingress

Click the image to enlarge.

Using this method (and remembering to create the associated DNS record), I can access the Oasis web interface.

This requires a password. To obtain this information, I need to consult the container's startup logs using the command kubectl logs deploy-ollama-default-86754968cb-6z4gl—c oasis—n prd-mygptgpu-lan

By default, the password is generated randomly when the web server starts. It is possible to set a fixed password in the arguments associated with Oasis. To do this, you would need to modify the Dockerfile and regenerate an image.

Retrieving the password for the GUI

Click the image to enlarge.

The web interface remains a "plus", but its use is not yet perfect at the time of writing this article. It is also specified that its use is exclusively for development. This part needs to be revised to optimize it.

Nevertheless, you can already get an idea of the interface by testing access to the URL with the generated password.

Oasis GUI

Click the image to enlarge.

You can retrieve reports directly using this method, with the possibility of filtering by type of vulnerability, by engine used, and by date.

Retrieving reports

Click the image to enlarge.

Conclusion

This is the end of this first part.

It has allowed us to set up the basic building blocks for integrating Oasis into an existing Ollama deployment.

At this stage, you can already see the advantages that such an integration can bring. Once again, thanks to the open-source ecosystem and the talent of some generous developers, we can obtain extremely powerful tools.

By combining different configurations, leveraging their expertise and existing infrastructure, we can give substance to all this "technobullshitmarketing" where hype often outweighs actual needs and reality.

Now it remains to automate all of this to make the scan operation simpler and integrate it into a CI/CD pipeline: more here.