osv-scan: derive scan targets from git ls-files, never the directory walk - #26
Merged
Merged
Conversation
…walk Port of .github#102's fix into the reusable lane, closing .github#103 — the .gitignore blindness fixed in repo-standard.yml was still live here. osv-scanner's -r walk applies .gitignore patterns without git's tracked-file exemption, so a repo that gitignored its own committed lockfile scanned nothing, and --allow-no-lockfiles turned that into a green check (hooksmith#108: sixteen advisories behind a green hard-fail lane for months; the tell is "0 Extract calls" next to exit 0). - New "Discover scan targets" step: tracked lockfiles via git ls-files against repo-standard.yml's basename list (deno.lock deliberately absent, as there), plus the convert step's generated deno-lock.cdx.json SBOMs via find (untracked by construction). Explicit --lockfile= args replace `-r --allow-no-lockfiles .`; zero targets is a logged, explicit pass and the scan step is skipped, so "scanned nothing" and "scanned and clean" can never look alike. - Convert step's deno.lock discovery moves find -> git ls-files for the same authority principle. - Scan step refuses an empty target list (the if: gate should make that unreachable; if it isn't, red, not a scan of nothing). Exit-code triage, report-only grace, and grace-expires are untouched. - test_scan_posture.py: Discovery suite over synthesized git repos — the gitignored-but-tracked lockfile regression case, git-authority in both directions, SBOM pickup, exact-basename matching — plus the empty-TARGETS guard case. flake.nix lends the posture suite gitMinimal (same parity shape as env-record's nodejs). Verified end-to-end with the pinned v2.4.0 binary on a synthesized hooksmith-shape repo (tracked package-lock.json with lodash 4.17.20, gitignored): old invocation 0 Extract calls / exit 0; new invocation 2 Extract calls / 3 known vulnerabilities / exit 1 hard, exit 0 + warning under report-only. Against this repo itself: fixture SBOM converted and scanned, 1 Extract call, exit 0. Closes bounded-systems/.github#103 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016JEQgLpoVWWs82ykpqMBL3
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.
Closes bounded-systems/.github#103 — the class fixed in .github#102 for
repo-standard.yml, ported to the reusable lane everydeps.ymlcaller uses.The defect
osv-scanner's
-rwalk applies.gitignorepatterns without git's tracked-file exemption, so a repo that lists its own committed lockfile in.gitignorehas it silently skipped, and--allow-no-lockfilesconverts "extracted nothing" into exit 0. hooksmith#108 shipped sixteen advisories behind that green for months.The fix
Discover scan targetsstep — tracked lockfiles fromgit ls-filesagainst the same basename list asrepo-standard.yml(deno.lockdeliberately absent there and here), plus the convert step's generateddeno-lock.cdx.jsonSBOMs viafind(untracked by construction, so they can't come fromls-files). Explicit--lockfile=args replacescan source -r --allow-no-lockfiles ..::notice::explicit pass with the scan step skipped; an empty target list reaching the scan step anyway is a hard red.--allow-no-lockfilesis gone entirely.deno.lockdiscovery movesfind→git ls-files, same authority principle.report-only, andgrace-expiresbehavior untouched (all 13 existing posture/grace tests pass unchanged).Discoverytest suite intest_scan_posture.pyruns the step's actualrun:block against synthesized git repos — centered on the gitignored-but-tracked lockfile regression case.flake.nixlends the suitegitMinimal(same parity shape asenv-recordborrowing nodejs).Verification — the
Extract callscounter, as .github#103 asksSynthesized hooksmith-shape repo (tracked
package-lock.jsoncarrying lodash 4.17.20, listed in.gitignore, plus the syntheticdeno.lockfixture), scanned with the pinned v2.4.0 binary:scan source -r --allow-no-lockfiles .No package sources found::warning::underreport-onlyAgainst this repo itself (what self-test's
scanjob runs): fixturedeno.lockconverted →1 scan target→1 Extract calls→ 0 vulnerabilities → exit 0.Not in this PR
release-tag(paths include this workflow), which mints the next patch tag; Dependabot rewrites the fleet's SHA pins from there. No template bytes changed, so no caller drift is introduced.🤖 Generated with Claude Code
https://claude.ai/code/session_016JEQgLpoVWWs82ykpqMBL3