Skip to content

fix(python): improve Python project detection logic#44

Merged
ashishkurmi merged 2 commits intostep-security:mainfrom
shubham-stepsecurity:sm/fix
Apr 28, 2026
Merged

fix(python): improve Python project detection logic#44
ashishkurmi merged 2 commits intostep-security:mainfrom
shubham-stepsecurity:sm/fix

Conversation

@shubham-stepsecurity
Copy link
Copy Markdown
Member

What does this PR do?

Type of change

  • Bug fix
  • Enhancement
  • Documentation

Testing

  • Tested on macOS (version: ___)
  • Binary runs without errors: ./stepsecurity-dev-machine-guard --verbose
  • JSON output is valid: ./stepsecurity-dev-machine-guard --json | python3 -m json.tool
  • No secrets or credentials included
  • Lint passes: make lint
  • Tests pass: make test

Related Issues

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Python project detection by identifying virtual environments more reliably across different layouts and naming conventions.

Changes:

  • Adds venv detection via pyvenv.cfg (PEP 405) with fallback heuristics for legacy virtualenvs and Windows layouts.
  • Updates directory walking logic to report detected venvs and avoid descending into them.
  • Expands unit tests to cover arbitrary venv names, multiple venvs under one parent, legacy venvs, false positives, and Windows layout.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/detector/pythonproject.go Reworks Python “project” detection to key off venv structure (pyvenv.cfg / pip / activate) and changes reporting behavior to emit venv paths.
internal/detector/pythonpm_test.go Adds/updates tests validating the new Python venv detection behavior across several scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/detector/pythonproject.go Outdated
Comment thread internal/detector/pythonproject.go
Comment thread internal/detector/pythonproject.go Outdated
@ashishkurmi ashishkurmi merged commit b9b178e into step-security:main Apr 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants