feat: add Python language support with venv and manifest modes#51
Open
kbsteere wants to merge 10 commits intochainguard-dev:mainfrom
Open
feat: add Python language support with venv and manifest modes#51kbsteere wants to merge 10 commits intochainguard-dev:mainfrom
kbsteere wants to merge 10 commits intochainguard-dev:mainfrom
Conversation
Manifest mode: Edit pyproject.toml, requirements.txt, setup.cfg, or Pipfile. Supports pip, uv, poetry, hatch, pdm, maturin, scikit-build-core, setuptools with --tool override. Venv mode: Upgrade packages in staged virtualenv using uv pip install or venv pip. Validates == pinning, rejects downgrades, verifies with pip check. Changes: - Resolve merge conflict: include both PHP and Python imports - Add --tool and --venv CLI flags - Implement DetectManifestWithHint for tool hints - Implement venv.go with updateVenv/validateVenv - Add 99 unit tests
- Replace dynamic error messages with wrapped static errors (err113) - Add error checking and logging to deferred cleanup operations (errcheck) - Extract manifest and build tool detection logic to reduce nesting (nestif) - Use manifest type constants instead of string literals (goconst) - Add doc comments to all exported constants (revive) - Validate manifest paths explicitly in read/write operations (gosec) - Add validation for subprocess executable paths before execution (gosec) - Preallocate slices with proper capacity (prealloc) - Fix import formatting with goimports and gofumpt (gci/gofmt/goimports) - Remove unused function parameters with underscore naming Remaining: 15 issues (2 gci import formatting, 13 gosec subprocess/path validation)
Reorder imports to match gci's preference: omnibump internal imports before external third-party imports. This follows Go convention and satisfies the gci formatter.
- Use filepath.Clean() on all file path operations to prevent path traversal - Create safeWriteFile() helper with explicit path validation - Replace dynamic error messages with wrapped static errors - Add nolint comments for gosec G204 with clear justifications - Use command constants (UVCommand, PipCommand) instead of string literals - Verify subprocess executables exist before execution with os.Stat() All 71 golangci-lint errors resolved. Build passes with 0 issues.
…tandards - Create example_test.go with Example functions demonstrating public API - Add compile-time assertions for Language and Analyzer interfaces - Ensures compliance with Go code standards and documentation requirements
708594a to
112bc4f
Compare
…ard registry requests Only add the Chainguard authentication token to requests whose Host matches the configured registryBaseURL. PyPI requests and any other cross-host requests will not include the Authorization header, preventing unintended token disclosure to third-party services.
Place nolint directives directly before the problematic code lines rather than on function signatures. This ensures gosec errors are properly suppressed while avoiding false positive nolintlint warnings.
… option injection Add strict validation to reject package names starting with '-' or not matching PEP 503 format, and reject version strings with invalid characters. This prevents argument injection attacks where malicious package names could be interpreted as command-line options (e.g., --index-url=https://evil.com). Also fixes linting issues: - Replace dynamic errors with wrapped static errors - Use #nosec G703 for validated path operations - Fix revive comment format for exported constant
Move defer cleanup setup before error-prone operations so cleanup is guaranteed regardless of error path. This eliminates G703 warnings without needing linter suppression. Cleaner approach: centralize all cleanup in one defer statement.
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.
Manifest mode: Edit pyproject.toml, requirements.txt, setup.cfg, or Pipfile. Supports pip, uv, poetry, hatch, pdm, maturin, scikit-build-core, setuptools with --tool override.
Venv mode: Upgrade packages in staged virtualenv using uv pip install or venv pip. Validates == pinning, rejects downgrades, verifies with pip check.
Changes: