PR-05: Deterministic runner (scanner) - #28
Merged
Merged
Conversation
…-05) A single-file, stdlib-only-at-runtime CLI that runs the ruleset via rg --pcre2 and emits DSGAI-scan.json + SARIF 2.1.0 + a table, identically every run. - Value-bearing rules run location-only (rg -o --replace ''): ripgrep erases the match before emitting, so secrets never leave rg. Findings carry no match content by construction (no content/match_text/value fields exist). - Compound logic: subtract, requires_nearby (proximity + module scope), exclude_globs, gated_on (NOT APPLICABLE gating via a detect stage). - Per-control classification (PASS/WARN/FAIL/NOT VALIDATED/NOT APPLICABLE). - File discovery via git ls-files (honors .gitignore, includes tracked files like the fixture .env); os.walk fallback. --scope / --exclude. - Subcommands scan/detect/doctor; --version; exit codes 0/1/2 with --fail-on; SOURCE_DATE_EPOCH honored for reproducible artifacts. - detect adds raw-endpoint signals (api.openai.com etc.) and C# signals. tests/test_runner.py (9 tests): every PCRE compiles; the fixture scan matches expected-findings.yaml EXACTLY (25 findings); must_not_flag holds; known_bugs tracked; no content fields; no fixture secret substring in output; SARIF structure; source-level guard that value-bearing always passes --replace; JSON stays in sync with YAML. Also: requirements-dev.txt + dependabot pip for /dsgai_scanner_tool, and repair of the pre-existing broken wrapped comment that made dependabot.yml invalid YAML. Acceptance: pytest green; scan output matches the answer sheet; two runs are byte-identical with SOURCE_DATE_EPOCH fixed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 1 linchpin. A deterministic engine owns pattern matching; the LLM's job becomes orchestration and judgment. Everything in Phases 2–4 verifies against this. Depends on PR-03 (rules) + PR-04 (fixtures).
cli/dsgai_scan.py— single file, stdlib-only at runtimerg --pcre2, emitsDSGAI-scan.json+ SARIF 2.1.0 + a table summary — identically every run (SOURCE_DATE_EPOCHhonored; collections sorted).rg -o --replace ''so ripgrep erases the match text before emittingpath:line:. The secret never enters this program, the pipe, the checkpoint, or the report. Findings have nocontent/match_text/valuefield — by construction.subtract,requires_nearby(proximity + module scope),exclude_globs,gated_on(NOT APPLICABLE gating via adetectstage).git ls-files(honors.gitignore, still includes tracked files like the fixture.env);os.walkfallback;--scope/--exclude.scan/detect/doctorsubcommands;--version; exit codes 0/1/2 +--fail-on.detectadds raw-endpoint signals (api.openai.com, …) and C# signals (Semantic Kernel / Azure.AI.OpenAI) ahead of PR-15.tests/test_runner.py— 9 testsEvery PCRE compiles under
rg --pcre2; the fixture scan matchesexpected-findings.yamlexactly (25 findings, compound logic resolved);must_not_flagholds;known_bugs tracked; no content fields; no fixture-secret substring in output; SARIF structure valid; a source-level guard that value-bearing execution always passes--replace; and the JSON stays in sync with the YAML.Verification (all local)
pytest tests/ -q→ 9 passed.scantable + JSON match the answer sheet exactly (0 diff).SOURCE_DATE_EPOCHfixed.FAKEsubstring in JSON or SARIF (redaction proof).Also in this PR
requirements-dev.txt(PyYAML/pytest/jsonschema — dev only; runtime is stdlib) + dependabotpipfor/dsgai_scanner_tool..github/dependabot.yml: its Docs comment had wrapped onto a new line without a#, leaving a stray scalar (ndabot.yml-file) that made the whole file invalid YAML — so dependabot couldn't parse it and the new pip block would have been inert. Diff is limited to the comment + pip block.Follow-ups
rgbatching passes all candidate files on one command line; very large repos may want chunking (arg-length). Not needed for the fixture / typical repos.