Skip to main content

Convert Security Scanner Output to JUnit Format

Project description

SecScanner2JUnit

PyPI version Downloads

Open in Gitpod

GitLab offers security scanning and visualization directly via and on their platform.
One nice feature is direct insights on merge requests. However, this feature is only available with the Ultimate tier. To also use this feature on the free tier, one can build around it by taking the security tool output, converting it to the JUnit format, and uploading it as JUnit report.

To summarize, this tool is for you if:

  • You use GitLab's free tier
  • You use Gitlabs security templates
  • You want to easily access security tool output in merge requests

If you are on the GitLabs Ultimate tier, just use their tooling! No need to mess up your .gitlab-ci.yml file. :smile:

Which scanning types are supported?

All scanning types available under the free tier:

  • Secret Scanning
  • Static Application Security Testing
  • Infrastructure as Code Scanning

How to use?

Procedure:

  1. Overwrite the existing job so that the report can be used by future jobs.
  2. Convert report
  3. Upload converted report as junit report

Example for Secret Scanning
This example can be used as is.

stages:
  - test
  - convert
  
- include:
  - template: Security/Secret-Detection.gitlab-ci.yml
  
secret_detection:
  artifacts:
    paths:
      - gl-secret-detection-report.json
    when: always
    
secret_convert:
  stage: convert
  dependencies:
    - secret_detection
  script:
    - pip3 install SecScanner2JUnit
    - ss2ju secrets gl-secret-detection-report.json gl-secret-detection-report.xml
  artifacts:
    reports:
      junit: gl-secret-detection-report.xml

Example for SAST
Since GitLab decides dynamically which scanners to use depending on project languages, it makes sense to first perform a testrun only including the template. This way one can see which jobs are executed and then overwrite them.

stages:
  - test
  - convert
  
- include:
  - template: Security/SAST.gitlab-ci.yml
  
semgrep-sast:
  after_script:
    - cp gl-sast-report.json gl-sast-semgrep-report.json
  artifacts:
    paths:
      - gl-sast-semgrep-report.json
    when: always

brakeman-sast:
  after_script:
    - cp gl-sast-report.json gl-sast-brakeman-report.json
  artifacts:
    paths:
      - gl-sast-brakeman-report.json
    when: always

semgrep-sast-convert:
  stage: convert
  dependencies:
    - semgrep-sast
  script:
    - pip3 install SecScanner2JUnit
    - ss2ju sast gl-sast-semgrep-report.json gl-sast-semgrep-report.xml
  artifacts:
    reports:
      junit: gl-sast-semgrep-report.xml
      
brakeman-sast-convert:
  stage: convert
  dependencies:
    - brakeman-sast
  script:
    - pip3 install SecScanner2JUnit
    - ss2ju sast gl-sast-brakeman-report.json gl-sast-brakeman-report.xml
  artifacts:
    reports:
      junit: gl-sast-brakeman-report.xml

Suppression

You can provide a file with suppression which will allow to ignore some vulnerabilities.

You have to create a file ss2ju-config.yml f.e. in .gitlab directory which includes:

sast:
  suppressions:
    - type: "cwe"
      value: "2555"
    - type: "find_sec_bugs_type"
      value: "SPRING_ENDPOINT"

And now you can modify execution command as follows:

    - ss2ju sast gl-sast-semgrep-report.json gl-sast-semgrep-report.xml .gitlab/ss2ju-config.yml

Future Plans

  • Implement IaC Scanning

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secscanner2junit-0.1.7.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secscanner2junit-0.1.7-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file secscanner2junit-0.1.7.tar.gz.

File metadata

  • Download URL: secscanner2junit-0.1.7.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.2 Linux/5.15.0-1020-azure

File hashes

Hashes for secscanner2junit-0.1.7.tar.gz
Algorithm Hash digest
SHA256 7d1349b13fcd8636eb3cdf062326a9266344a4771df4fe63bc6d7d17ea665509
MD5 806a37163c73eb395049c484c6f7c8e3
BLAKE2b-256 52723d1949e73d663994c127003db24e01d84d8b615531d28cae1e15637a43e0

See more details on using hashes here.

File details

Details for the file secscanner2junit-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: secscanner2junit-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.1 CPython/3.10.2 Linux/5.15.0-1020-azure

File hashes

Hashes for secscanner2junit-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 5925264f0b564613973903fe8ebb6fd8068997fc34272a3dec87f09a4e7cfa1c
MD5 e3ebe5d3413b0e44df63c4b1241a7ca3
BLAKE2b-256 a7d5bf593a1bffa7aa2859dfebaf37b1f172ef9b119e4d241c568c0f1faaa324

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page