chore: add per-venv scan logging to Python project detector#144
Open
swarit-stepsecurity wants to merge 1 commit into
Open
chore: add per-venv scan logging to Python project detector#144swarit-stepsecurity wants to merge 1 commit into
swarit-stepsecurity wants to merge 1 commit into
Conversation
Brings PythonProjectDetector to logging parity with NodeScanner.ScanProjects: search-dir progress, venv discovery count, truncation warning, per-venv scan progress, and pip-list failure warnings (previously dropped silently). Adds a logger field (no-op default) and a WithLogger chained method; wired in at the telemetry and scan call sites.
There was a problem hiding this comment.
Pull request overview
This PR brings PythonProjectDetector’s runtime logging up to parity with the Node project scanner by adding search-dir progress logs, venv discovery/truncation summaries, per-venv scan progress, and warnings when pip list fails (previously silent). It does so by introducing an injectable progress.Logger (defaulting to a no-op) and wiring it into the telemetry and scan entry points.
Changes:
- Add a
logfield plusWithLogger(...)chain method toPythonProjectDetector(no-op by default). - Emit progress/debug/warn logs for search-dir iteration, venv discovery counts, truncation, per-venv scans, and
pip listfailures. - Wire the logger into both telemetry and community scan call sites.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/telemetry/telemetry.go | Passes the run logger into PythonProjectDetector so telemetry runs surface per-dir/per-venv progress and warnings. |
| internal/scan/scanner.go | Passes the run logger into PythonProjectDetector for community scan runs. |
| internal/detector/pythonproject.go | Adds logger support and new logging for discovery/scan flow, plus warnings on pip list failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+191
to
196
| start := time.Now() | ||
| stdout, _, exitCode, err := d.exec.RunWithTimeout(ctx, 15*time.Second, pipPath, "list", "--format", "json") | ||
| duration := time.Since(start).Milliseconds() | ||
| if errMsg := pmRunError("pip list", exitCode, err); errMsg != "" { | ||
| d.log.Warn("python venv scan failed: %s (venv=%s, exit=%d, %dms) — results may be incomplete", errMsg, venvPath, exitCode, duration) | ||
| return nil |
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.
Brings PythonProjectDetector to logging parity with NodeScanner.ScanProjects: search-dir progress, venv discovery count, truncation warning, per-venv scan progress, and pip-list failure warnings (previously dropped silently).
Adds a logger field (no-op default) and a WithLogger chained method; wired in at the telemetry and scan call sites.
What does this PR do?
Type of change
Testing
./stepsecurity-dev-machine-guard --verbose./stepsecurity-dev-machine-guard --json | python3 -m json.toolmake lintmake testRelated Issues