Skip to content

Record repository, commit and rule-source provenance in results (#67) - #98

Merged
james-d12 merged 2 commits into
mainfrom
feature/result-provenance-67
Oct 13, 2026
Merged

james-d12 merged 2 commits into
mainfrom
feature/result-provenance-67

Conversation

@james-d12

Copy link
Copy Markdown
Owner

Summary

Results now record which repository, commit and branch were analysed, and which rule sources (and rules-cache commit) were used, so a report can be reproduced.

JSON (validation-report.v1)

Additive optional fields. schemaVersion stays 1.0, and fields are omitted when unknown.

  • repository: normalised remote URL. Userinfo, query and fragment are removed, and .git is dropped. scp-style remotes become ssh://host/path.
  • commit, branch
  • ruleSources[]: kind (git or directory), location, and commit (rules-cache HEAD, git only)

The schema, ValidationReportV1, the mapper and docs/architecture/RESULT_CONTRACT.md are updated.

SARIF

  • tool.driver.version is the CodeGuard version.
  • run.versionControlProvenance carries repository, commit and branch. It is written only when the repository URI is known, because SARIF requires repositoryUri.
  • Rule sources go in the run property bag as ruleSources.

Gathering and layering

  • ValidationProvenanceGatherer (CLI) gathers values. CI variables win per field for GitHub Actions, GitLab CI and Azure Pipelines. Git fills the rest. GITHUB_HEAD_REF is preferred over GITHUB_REF_NAME so PRs report their source branch.
  • Repository access (IGitCommandRunner) and the environment lookup are injected, so precedence is unit-tested.
  • Reporters take a ValidationProvenance through their constructors and never shell out. Reporting depends only on Core.
  • Missing git or a non-repository directory yields nulls and never fails validation.
  • GitRuleSourceSync.RunCore is now internal and shared with the provenance runner, so there is one process helper.

Tests

  • Gatherer precedence for each CI provider, git fallback, detached HEAD, fake git, and credential stripping
  • RepositoryUrlNormalizer cases
  • JSON output with and without provenance validates against the v1 schema, and a schema test rejects credential-bearing fields
  • SARIF versionControlProvenance, driver version and rule-source property

Verification

  • dotnet build: 0 warnings, 0 errors
  • dotnet test: all test projects pass
  • dotnet format --verify-no-changes: clean

Closes #67

🤖 Generated with Claude Code

james-d12 and others added 2 commits October 13, 2026 20:37
Results now say which repository, commit and branch were analysed, and which
rule sources (and rules-cache commit) were used, so a report can be reproduced.

JSON (validation-report.v1, additive optional fields, schemaVersion stays 1.0):
repository, commit, branch, ruleSources[] (kind, location, commit). Omitted
when unknown.

SARIF: tool.driver.version is the CodeGuard version, run.versionControlProvenance
carries repository/commit/branch when the repository URI is known, and rule
sources are in the run property bag.

Gathering lives in the CLI (ValidationProvenanceGatherer): CI variables for
GitHub Actions, GitLab CI and Azure Pipelines win per field, and git fills the
rest. Repository access and environment lookup are injected for tests. Remote
URLs are normalised so credentials never reach a report. Reporters receive a
ValidationProvenance and never shell out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	docs/architecture/IMPLEMENTATION_STATUS.md
@sonarqubecloud

Copy link
Copy Markdown

@james-d12
james-d12 merged commit a41aee0 into main Oct 13, 2026
5 checks passed
@james-d12
james-d12 deleted the feature/result-provenance-67 branch October 13, 2026 20:23
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.

Repository, commit and rule-source provenance in results

1 participant