This repository combines the different components of the SecAI SonarQube plugin, which integrates CogniCryptSAST.
You can access the documentation of the plugin using the docs folder.
Alternatively, you can build the documentation using the following commands and open the index page in /site/index.html:
# Install dependencies (you only need to do this once)
pip install -r requirements.txt
# Build documentation
mkdocs buildAnother method would be to serve the documentation locally. The output of the command will then provide a link to access the pages hosted on the localhost.
# Install dependencies (you only need to do this once)
pip install -r requirements.txt
# Serve documentation locally
mkdocs serveTo quickly download the documentation instead of cloning the repository check out the releases.
After running the following command in the root directory:
mvn clean package -DskipTestsA folder release will be created with the following contents:
secai-for-existing-sq-<version>.zip: zip archive containing the source code for AIFix and Confidence Score and the docker compose for just these containerssecai-for-new-sq-<version>.zip: zip archive containing the source code for AIFix and Confidence Score and the docker compose for a new SonarQube setupsecai-docs-<version>.zip: zip archive containing the Markdown files of the documentation
An up-to-date version of the plugin jar is generated in the SonarQubePlugin/target/ directory.
Before proceeding with the installation check out the prerequisites.
-
Download the following files from the release page:
- zip archive:
secai-for-exist-sqif you already have a SonarQube server,secai-for-new-sqif you intend to create a new one - SecAI plugin jar
Alternatively, you can generate the release files yourself using the above instructions
- zip archive:
-
Unzip the archive on the intended host machine in a location that all administrators can access.
-
In the file
Flaskapp/aifix/.env:- Replace the placeholders for the API keys of the LLMs you intend to use.
- Unless you are hosting all components including the projects to analyse on the same machine, change the
FLASK_IPto the IP address of the host machine
-
Configure SonarQube:
- For a new SonarQube server: The server configuration in the
docker-compose.ymlis not meant for production use. Please adjust the configuration to your needs using the official SonarQube documentation. You may also need to change the image used in theDockerfile. - If you are extending an existing SonarQube server: Add the file
Flaskapp/aifix/.envthrough theenv-fileattribute of your docker compose file or docker run command, or, if not using docker, define the environment variables on your host machine
- For a new SonarQube server: The server configuration in the
-
Run the following command within the unzipped directory. You may have to use
sudofor admin permissions.docker compose up -d --build
This creates two docker containers
nginxandflaskapp. If you are creating a new SonarQube server at the same time, asonarqubedocker should also now be running. -
Install the SecAI plugin:
- Add the plugin jar to the plugin folder:
-
With a SonarQube docker: If you used our docker compose file for your server there should be a
pluginsfolder in the base directory that is connected directly to the correct location inside the container. Copy the jar into this folder.Alternatively, use the command below to move the file to
/opt/sonarqube/extensions/plugins(on the running containersonarqube):docker cp ./secai-plugin-1.1.0.jar sonarqube:/opt/sonarqube/extensions/plugins
-
With SonarQube installed from a zip file: Locate the
extensions/pluginsfolder inside your SonarQube distribution and move the jar into it.
-
- Restart the SonarQube instance for the changes to take effect. You should receive a warning about third-party plugins and the plugin should be listed under Administration > Marketplace > Plugins > Installed.
- Add the plugin jar to the plugin folder:
Afterwards, you can run your first analysis.
In order to use all implemented functionality, multiple components have to be combined.
The directory SonarQubePlugin contains the code of the actual SecAI plugin. In order to add the plugin to a SonarQube instance a jar of this project is needed. For further details, consult the documentation.
The features AIFix and Confidence Score require an additional python backend. This directory contains a Flask app implementing the necessary functionality.
Note
The folder Flaskapp/confidence contains only the trained model used for the calculation of the confidence score. The code for training the model can be found in this repository.