-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(python): add pylock.toml (PEP 751) parser #9632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a parser for pylock.toml
files according to PEP 751, extending Trivy's Python dependency parsing capabilities to support this new lock file format.
- Adds
pylock.toml
parser with TOML-based structure handling - Includes test data file with realistic package dependencies and wheel information
- Integrates the new parser into Trivy's Python dependency parsing framework
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
pkg/fanal/types/const.go | Adds PyLock constant for "pylock.toml" file identification |
pkg/dependency/parser/python/pylock/parse.go | Core parser implementation with TOML structures and parsing logic |
pkg/dependency/parser/python/pylock/parse_test.go | Unit tests validating parser functionality with expected package outputs |
pkg/dependency/parser/python/pylock/testdata/pylock.toml | Test data file containing sample pylock.toml structure with packages and wheels |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Marker string `toml:"marker"` | ||
} | ||
|
||
// Parser parses pylock.toml defined in PEP518. |
Copilot
AI
Oct 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment incorrectly references PEP 518. According to the PR description and line 31, this should reference PEP 751.
// Parser parses pylock.toml defined in PEP518. | |
// Parser parses pylock.toml defined in PEP 751. |
Copilot uses AI. Check for mistakes.
a46ca13
to
0eb4b58
Compare
} | ||
|
||
var pkgs []ftypes.Package | ||
var deps []ftypes.Dependency |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also analyze dependency relationships?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the parser to get dependencies as well
However I have one query, I tried setting up a pylock.toml
using pip
, uv
and poetry
and in all cases, the pylock.toml
had no dependencies. Does the format follow a flat dependency structure always?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried setting up a pylock.toml using pip, uv and poetry and in all cases, the pylock.toml had no dependencies.
Do you mean this field is always empty?
https://peps.python.org/pep-0751/#packages-dependencies
0eb4b58
to
8b3fb9f
Compare
Description
This PR adds a parser for
pylock.toml
file, check thisRelated issues
pylock.toml
(PEP 751) #9410Related PRs
Plan to create one more PR for
pylock.toml
analyzerChecklist