Skip to content

Do not silently drop findings listed in a baseline inside the scanned tree - #94

Open
arpitjain099 wants to merge 1 commit into
ParzivalHack:mainfrom
arpitjain099:baseline-not-trusted-from-scan-tree
Open

Do not silently drop findings listed in a baseline inside the scanned tree#94
arpitjain099 wants to merge 1 commit into
ParzivalHack:mainfrom
arpitjain099:baseline-not-trusted-from-scan-tree

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

Opening this as a public PR per your note on GHSA-7875-p889-5wvx.

The baseline is read from .pyspector_baseline.json inside the directory being scanned, so when that directory came from somewhere else, the file that decides which findings to drop came from there too. The part that bothered me is not the trust question, which you have already called out of scope, but that it happens with no output at all: Baseline-ignored is only printed under --stats, so a scan can report clean while silently dropping results.

Two changes:

  • print the suppressed count whenever it is non-zero, naming the file that did it
  • add --no-baseline for callers that never want one picked up from the tree, which is mainly CI scanning branches it did not write

Behaviour is otherwise unchanged, and a baseline you put there yourself still works exactly as before. You just get told.

Checked in a python:3.12-slim container, built from source, on a file containing os.system and eval:

run 1  no baseline                findings: 1
run 2  baseline present           [!] 1 finding(s) suppressed by '/tmp/v/.pyspector_baseline.json'.
                                  Use --no-baseline to ignore it.        findings: 0
run 3  --no-baseline              findings: 1

Happy to change the wording or the colour of the notice if you would rather it read differently.

I used AI assistance while working on this. The three runs above are mine, built from source at 7492032 since the PyPI wheel needs pkg-config and libssl-dev to build.

… tree

The baseline is read from .pyspector_baseline.json inside the directory
being scanned, so when that directory came from somewhere else the file
that suppresses findings came from there too. A scan of a tree carrying a
baseline can therefore report clean while dropping results, and nothing
says so: the Baseline-ignored counter only prints under --stats.

Print the suppressed count unconditionally when it is non-zero, naming
the file, and add --no-baseline for callers that never want a baseline
picked up from the tree at all (CI scanning untrusted branches).

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants