Skip to content

feat: Implement SARIF output format for native GitHub Code Scanning integration #7

Closed

Description

@Nanle-code

Overview

GitHub Code Scanning natively ingests SARIF files and displays findings as inline annotations in pull request diffs and the Security tab. Adding SARIF output lets ChainProof integrate with this first-class security workflow instead of relying on custom PR comments.

Current Limitations

  • PR comments are noisy and do not persist in the Security tab
  • core.error() annotations disappear after the workflow run
  • No integration with GitHub's security dashboard

SARIF Structure

{
  "version": "2.1.0",
  "runs": [{
    "tool": {
      "driver": {
        "name": "ChainProof",
        "rules": [{ "id": "CP-107", "name": "Reentrancy", "helpUri": "https://swcregistry.io/docs/SWC-107" }]
      }
    },
    "results": [{
      "ruleId": "CP-107",
      "level": "error",
      "message": { "text": "Reentrancy vulnerability detected" },
      "locations": [{
        "physicalLocation": {
          "artifactLocation": { "uri": "contracts/Vault.sol" },
          "region": { "startLine": 42, "endLine": 48 }
        }
      }]
    }]
  }]
}

Severity Mapping

ChainProof SARIF Level
critical error
high error
medium warning
low note
info / gas none

Proposed Changes

  • Add generateSARIFReport(result: ScanResult): string to the report generator
  • CLI: --format sarif flag, defaults output to chainproof-results.sarif
  • GitHub Action: generate and upload SARIF via github/codeql-action/upload-sarif@v3, replacing core.error() annotations

Acceptance Criteria

  • generateSARIFReport() implemented and exported from core
  • SARIF output validates against SARIF 2.1.0 JSON schema
  • CLI --format sarif flag implemented
  • GitHub Action uploads SARIF, findings appear in Security tab
  • Rule metadata (id, name, helpUri) included in tool.driver.rules
  • Tested against GitHub SARIF validator

References


Maintainer Scope Upgrade

This issue is being expanded into a substantial, production-quality ChainProof enhancement. The implementation should be designed as maintainable platform work, not as a narrow proof of concept. A successful pull request must provide a cohesive user-facing capability, typed internal APIs, robust tests, documentation, and CI-safe behavior.

Expanded Objective

Deliver native GitHub Code Scanning integration through standards-compliant SARIF generation, validation, CLI support, and GitHub Action upload behavior. The feature should fit the existing monorepo architecture, reuse current scanner/report/CLI patterns where appropriate, and avoid introducing ad hoc subsystems that are difficult to test or maintain.

Required Implementation Depth

This issue is intentionally scoped to require more than 700 lines of meaningful implementation work. The line count expectation applies to purposeful source, tests, fixtures, and documentation that are necessary to deliver the feature. It must not be satisfied through generated output, lockfile churn, formatting-only changes, duplicated boilerplate, or artificial padding.

Expected work includes:

  • A SARIF 2.1.0 report generator with complete rule metadata, locations, severity mapping, and deterministic output.
  • CLI and GitHub Action wiring for --format sarif, default output paths, artifact retention, and upload through github/codeql-action/upload-sarif.
  • Schema validation fixtures and regression tests covering empty scans, multiple files, duplicate findings, gas/info filtering, and severity mapping.
  • Public or internal types/interfaces where they clarify behavior and reduce future integration risk.
  • Failure-mode handling for invalid input, missing configuration, unavailable optional dependencies, and degraded execution paths.
  • Documentation updates that explain how maintainers and users should operate the new capability in local and CI environments.

Professional Quality Bar

The implementation must be production-ready and reviewable in isolation. Contributors should include clear separation between parsing, analysis, reporting, CLI/action integration, and persistence or provider code where those concerns apply. The code should follow existing ChainProof conventions, keep behavior deterministic in tests, and avoid coupling core analysis to network-only services unless explicitly optional and mocked.

Acceptance Criteria

  • The delivered PR contains more than 700 meaningful lines of implementation across source, tests, fixtures, and docs, excluding generated files and lockfile-only changes.
  • The feature is integrated into the relevant package entrypoints, CLI commands, report formats, GitHub Action behavior, or documentation as appropriate for this issue.
  • Unit tests cover normal operation, edge cases, invalid inputs, and at least one realistic fixture or end-to-end workflow.
  • Any optional external service, model provider, database, or platform integration has deterministic mocks or fallbacks so CI does not depend on secrets or network availability.
  • User-facing output is documented and stable enough for downstream automation.
  • Backward compatibility is preserved unless the PR explicitly documents a migration path and the maintainer approves it.

Mandatory CI and Merge Requirements

A PR resolving this issue must not be merged until all repository CI checks pass. At minimum, reviewers should verify the following from a clean checkout:

  • npm ci
  • npm run lint
  • npm run build --workspaces --if-present
  • npm run test:ci --workspace=packages/core
  • npm test --workspaces --if-present
  • npm run build --workspace=packages/core && npm run docs --workspace=packages/core
  • Any package-specific tests, examples, validators, or integration checks introduced by the PR

If the PR adds a GitHub Action, report format, dashboard, persistence layer, or external integration, it must also include CI coverage or a documented local verification command for that path. Known warnings are acceptable only when they are documented and do not hide failures.

Review Expectations

Reviewers should reject PRs that only stub APIs, add superficial wrappers, omit tests for critical behavior, rely on live secrets in CI, or meet the line-count target through non-functional bulk changes. The preferred solution is a focused but complete vertical slice that leaves ChainProof more reliable, easier to operate, and easier to extend.

Activity

  1. Babigdk commented on Jun 19, 2026

    @Babigdk

    Proposal: SARIF Export Integration for ChainProof (GitHub Code Scanning Support)

    I’d like to implement SARIF 2.1.0 output support so ChainProof findings can integrate directly into GitHub Code Scanning and the Security tab.

    Scope of Work:

    • Implement generateSARIFReport(result: ScanResult): string in the report generator

    • Add CLI flag --format sarif (default output: chainproof-results.sarif)

    • Map ChainProof severities to SARIF levels:

      • critical/high → error
      • medium → warning
      • low → note
      • info/gas → omit
    • Include full rule metadata (id, name, helpUri) in driver.rules

    • Convert findings into SARIF results with accurate file + line mappings

    • Ensure compliance with SARIF 2.1.0 schema

    • Replace GitHub PR core.error() annotations with SARIF upload flow

    • Update GitHub Action to use github/codeql-action/upload-sarif@v3

    Deliverables:

    • SARIF generator module
    • CLI --format sarif support
    • GitHub Action integration for Security tab upload
    • Valid SARIF output compatible with GitHub Code Scanning
    • Schema validation tests against SARIF 2.1.0 spec

    Goal:
    Enable native GitHub Security tab integration and improve long-term visibility and traceability of ChainProof findings.

  2. Senorespecial commented on Jun 19, 2026

    @Senorespecial

    I would like to work on this issue, please assign

  3. guptakumarranjeet150 commented on Sep 15, 2026

    @guptakumarranjeet150
    Contributor

    Hello team,

    I can tackle feat: Implement SARIF output format for native GitHub Code Scanning integration. Proposed implementation roadmap:

    • Analysis: Inspect current behavior and edge cases in StellarChainproof/StellarChainproofs
    • Core Implementation: Deliver a clean, well-tested implementation for feat: Implement SARIF output format for native GitHub Code Scanning integration following StellarChainproof/StellarChainproofs conventions.
    • Quality Assurance: Ensure the change passes all existing lint, format, and CI verification pipelines.

    Happy to pick this up today—please assign to me!

  4. guptakumarranjeet150 commented on Sep 30, 2026

    @guptakumarranjeet150
    Contributor

    Hello @maintainers,

    I am interested in working on this issue.
    Plan:

    1. Deliver a clean, well-tested implementation for feat: Implement SARIF output format for native GitHub Code Scanning integration following StellarChainproof/StellarChainproofs conventions.
    2. Include automated test coverage verifying the implementation meets expected requirements.

    Looking forward to collaborating on this—please assign!

  5. grantfox-oss commented on Oct 9, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @guptakumarranjeet150's PR #119 was approved and merged by @Nanle-code.

    🏆 @guptakumarranjeet150: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (455 total points). Track your full progress on GrantFox.

    👏 Great work, @guptakumarranjeet150! Keep contributing to StellarChainproof.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardThird CampaignCampaign: Third CampaignenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions