Skip to content

feat: GitLab CI integration with SARIF output for Security Dashboard#43

Open
apex-cl wants to merge 1 commit intocounterspec:mainfrom
apex-cl:feature/gitlab-ci-integration
Open

feat: GitLab CI integration with SARIF output for Security Dashboard#43
apex-cl wants to merge 1 commit intocounterspec:mainfrom
apex-cl:feature/gitlab-ci-integration

Conversation

@apex-cl
Copy link
Copy Markdown

@apex-cl apex-cl commented Apr 5, 2026

Summary

Implements the GitLab CI/CD integration with SARIF output support for the ISNAD Scanner.

This resolves Issue #5: GitLab CI integration template

What's Included

1. SARIF Export Module (scanner/src/sarif.ts)

  • analysisResultToSarif() — Converts scan results to SARIF 2.1.0 format
  • Severity mapping: critical/high → error, medium → warning, low → note
  • Includes artifact locations, line numbers, code snippets, and rule definitions
  • Compatible with GitLab Security Dashboard and GitHub Code Scanning

2. CLI Enhancement (scanner/src/cli.ts)

  • New --sarif-output <path> flag on the batch command
  • Combines results from multiple files into a single SARIF report
  • Report auto-uploads as GitLab SAST artifact

3. GitLab CI Pipeline (.gitlab-ci.yml)

  • Ready-to-use pipeline configuration
  • Configurable via CI/CD variables:
    • SCAN_TARGETS — Directories/files to scan
    • SCAN_FAIL_LEVEL — Pipeline fail threshold (critical/high/medium/low)
    • ISNAD_SCANNER_VERSION — Scanner version to use
  • SARIF artifact uploaded for GitLab Merge Request security widget
  • Runs on push, merge requests, and scheduled pipelines

4. Advanced Templates (.gitlab-ci-templates.yml)

  • Auto-issue creation on critical/high findings via GitLab API
  • Weekly scheduled full-codebase scans
  • Extendable base jobs for custom pipelines

5. Documentation (docs/GITLAB_CI.md)

  • Quick start guide
  • Configuration reference
  • Example pipeline output
  • Advanced usage patterns

6. Unit Tests (scanner/tests/sarif.test.ts)

  • SARIF structure validation
  • Severity level mapping tests
  • Rule de-duplication tests
  • JSON serialization tests

Checklist

  • .gitlab-ci.yml template for isnad-scan
  • Support for configurable scan targets
  • SARIF output for GitLab Security Dashboard
  • Documentation with setup instructions
  • Example pipeline configuration
  • Tests passing
  • Scanner builds successfully (npm run build)

Testing

Built and tested locally:

cd scanner && npm run build
node dist/cli.js scan tests/test_malicious.js --json
node dist/cli.js batch 'tests/*.js' --sarif-output output.sarif

All 8 unit tests pass for SARIF export module. SARIF output validates against the official 2.1.0 schema.

Adds GitLab CI/CD pipeline integration for the ISNAD Scanner with SARIF
(Static Analysis Results Interchange Format) output compatible with
GitLab Security Dashboard and GitHub Code Scanning.

Changes:
- Add SARIF export module (scanner/src/sarif.ts)
  - analysisResultToSarif() converts scan results to SARIF 2.1.0 format
  - Maps severity levels: critical/high->error, medium->warning, low->note
  - Includes artifact locations, line numbers, code snippets, and rules

- Extend CLI with --sarif-output flag (scanner/src/cli.ts)
  - batch command now supports --sarif-output <path> option
  - Combines results from multiple files into a single SARIF report
  - Report appears in GitLab MR widget under Security tab

- Add .gitlab-ci.yml template
  - Ready-to-use pipeline with configurable SCAN_TARGETS and SCAN_FAIL_LEVEL
  - SARIF artifact uploaded for GitLab SAST reports
  - Runs on push, MR, and scheduled pipelines

- Add .gitlab-ci-templates.yml with advanced templates
  - Auto-issue creation on critical findings via GitLab API

- Add documentation (docs/GITLAB_CI.md)
  - Quick start guide, configuration reference, and pipeline examples

- Add unit tests for SARIF export (scanner/tests/sarif.test.ts)
  - Tests rule generation, severity mapping, and JSON serialization

Fixes: counterspec#5
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

@apex-cl is attempting to deploy a commit to the Rapi's projects Team on Vercel.

A member of the Team first needs to authorize it.

@apex-cl apex-cl mentioned this pull request Apr 5, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitLab CI integration template

1 participant