Add --debug flag, quiet default output, honor exclude config in pre-pass#54
Open
satoridev01 wants to merge 1 commit into
Open
Add --debug flag, quiet default output, honor exclude config in pre-pass#54satoridev01 wants to merge 1 commit into
satoridev01 wants to merge 1 commit into
Conversation
The scan command was unconditionally printing the banner, a JokeAPI HTTP
call, dozens of [*]-prefixed progress lines from both Python and the Rust
core, and per-file "Info: Skipped" notices. CI/automation consumers had no
way to suppress this, which buried the actual findings.
This change:
- Adds a `--debug` flag to `pyspector scan`. Without it, progress chatter
is suppressed and only the banner (name, version, credits, joke),
findings, warnings and errors are shown. With it, the previous verbose
output is restored, including println! output from the Rust core (which
is silenced by redirecting fd 1 to /dev/null around the run_scan and
scan_supply_chain calls).
- Reads the displayed version from package metadata via
importlib.metadata.version("pyspector") so it stays in sync with
setup.cfg automatically instead of being hardcoded in cli.py.
- Honors the `exclude` config list in the Python AST pre-pass. Previously
only the Rust core respected it, so `path.glob("**/*.py")` walked into
.venv/, node_modules/, etc. anyway and emitted "Info: Skipped ..." for
every test file inside them. A new `_is_path_excluded` helper matches
patterns against relative path, absolute path and individual components.
- Adds node_modules, bower_components and vendor to the default exclude
list in config.py alongside the existing .venv / __pycache__ / build /
dist entries.
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.
Summary
This PR adds an explicit
--debugflag and makes the default output focused on findings, warnings and errors.[
--debug]: identical to the old default outputChanges
pyspector scan --debug: new flag. Default output keeps the banner (name, version, credits, joke), findings, warnings and errors.--debugre-enables the previous verbose output, includingprintln!lines from the Rust core (silenced by redirecting fd 1 to/dev/nullaroundrun_scan/scan_supply_chain).importlib.metadata.version("pyspector")instead of being hardcoded incli.py, so it stays in sync withsetup.cfgon every bump.excludein the Python pre-pass:get_python_file_astsnow filterspath.glob("**/*.py")against the config'sexcludelist. Previously only the Rust core respected it, so the walker still entered.venv//node_modules/and emitted aInfo: Skippedper file inside them. New_is_path_excludedhelper matches patterns against relative path, absolute path and individual path components.node_modules,bower_components,vendortoDEFAULT_CONFIG.excludeinconfig.pyalongside the existing.venv/__pycache__/build/dist/*.egg-info/venventries.Before / After
Scanning a project containing a
.venv/:Before (truncated — actually printed ~150
Info: Skippedlines from setuptools/pbr tests inside .venv):After (default):