Data Theorem allows you to run our source code SAST analyzer directly in your environment , and on your hardware. This gives you full control over the scanning infrastructure: the scanning machine could be your own on-prem hardware, or it could be a CI runner (for example, from Github, Bitbucket, Gitlab, or Azure DevOps).
Data Theorem’s on-prem scanner allows you to leverage Data Theorem’s SAST scanning without sending any off your source code off-site. The security scan results will still be uploaded to the Data Theorem portal. However, this approach comes with a couple of important limitations:
Data Theorem’s SAST analyzer won’t be able to post source code annotations directly in the Github / Bitbucket / Gitlab UI. Security scan results will only be consumable within the Data Theorem portal, or via our Security Scan Results API.
If you don’t need to abide these specific requirementsprefer not to be limited by the above, we recommend utilising utilizing our dedicated Github / Bitbucket / Gitlab integrations, which are built around Data Theorem’s Cloud infrastructure and provide the most polished developer experience (see onboarding instructions at DevSecOps > SAST Code Analysis).
...
The machine running the scanner must have internet access
We can recommend a base of 8G memory 8GB RAM / 4 CPUs to run the scans, but note that scan time is proportional to the code base size so the specs that fit your needs may vary based on the size of your codebase.
Step 1: Generate a SAST Security Results API Key
...
DT_SAST_SCAN_HEAD_REF
: git ref of the head to scanDT_SAST_SCAN_TARGET_REF
: git ref of the target to scan
[Optional] If you want the process to
set
DT_SAST_FAIL_MODE=true
if set, the process will return a non
...
-zero status when issues are found
...
. This can be used to make Data Theorem SAST a blocking step of your workflow
...
set
DT_SAST_FAIL_MODE=true
.set
DT_SAST_NO_FORWARD_MODE=true
if you want to skip forwarding scan results/metadata to Data Theorem, note that this will mean that no scan results will be visible from the Data Theorem Portal
...
Code Block |
---|
Scanning completed in 15.65 seconds Scan results: 1 issues on commit=f719d004ef98254b46187c53ef1b3ed2f8643082 Total Issues: 1 Issues per types: - First Party Code: 1 - SCA: 1 Issues per severity: - High Severity: 1 - Medium Severity: 1 [ { "issue_title": "Unauthenticated Route Found for Flask API", "issue_description": "The security of this code is compromised due to the presence of unauthenticated access to specific routes within the Flask API. This vulnerability poses a significant risk as it can potentially expose sensitive data or allow unauthorized actions to be performed. To mitigate this risk, it is crucial to implement robust authentication mechanisms that ensure only authorized users can access the protected routes.\n\nBy allowing unauthenticated access, the code fails to validate the identity of users before granting them access to certain routes. This lack of authentication opens the door for malicious actors to exploit the system and gain unauthorized access to sensitive information or perform actions that they should not be able to.\n\nTo address this issue, it is recommended to implement a secure authentication process that verifies the identity of users before granting them access to protected routes. This can be achieved through various methods such as username/password authentication, token-based authentication, or integration with third-party authentication providers.\n\nAdditionally, it is important to consider implementing other security measures such as encryption of sensitive data, input validation to prevent injection attacks, and proper error handling to avoid leaking sensitive information.\n\nBy implementing these security measures, the code can ensure that only authenticated and authorized users can access the protected routes, significantly reducing the risk of unauthorized access or data breaches. It is essential to prioritize security in the development process to safeguard sensitive data and protect the integrity of the system.", "issue_type": "FIRST_PARTY_CODE", "severity": "HIGH", "detected_in_file_path": "sample_code/bad_python.py", "detected_on_line": 7, "issue_code_snippet": "@app.route(\"/\")\ndef index():\n cmd = request.args.get(\"cmd\", \"\")\n exec(cmd)\n return \"\"" }, { "issue_title": "jinja2 version 3.1.2 contains a known vulnerability (via PyPI dependency): Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter", "issue_description": "Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter", "issue_type": "SCA", "severity": "MEDIUM", "detected_in_file_path": "sample_code/requirements.txt", "detected_on_line": 1, "issue_code_snippet": "jinja2==3.1.2\n" } ] Visit https://www.securetheorem.com/api/v2/security/sast for more details |
...
GitHub Actions examples
Set the Data Theorem API Key as a secret variable
Go to your repository > Settings
> Security
> Secrets and variables
> Actions
> Secrets
Click on New repository secretRepository Secret
and create a secret variable named DT_SAST_API_KEY
with the value retrieved in step Step 1
Scans on pushes
Code Block |
---|
name: Data Theorem SAST on: push: branches: [ "main" ] workflow_dispatch: jobs: scan: runs-on: ubuntu-latest container: image: us-central1-docker.pkg.dev/prod-scandal-us/datatheorem-sast/datatheorem-sast:latest env: DT_SAST_API_KEY: ${{ secrets.DT_RESULTS_API_KEY }} steps: - uses: actions/checkout@v4 - name: Start Data Theorem SAST Scan run: data_theorem_sast_analyzer scan --name=$GITHUB_REPOSITORY --repo-platform=GITHUB --repo-id=$GITHUB_REPOSITORY_ID --repo-html-url="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" --repo-default-branch-name=${{ github.event.repository.default_branch }} --output-dir=$PWD # Optional step to make scan results available as a Github artifact - uses: actions/upload-artifact@v4 with: name: dt-sast-scan-result path: ./scan-results-sarif.json |
...