Skip to content

Conversation

sneaky-potato
Copy link
Contributor

Description

This PR adds a parser for pylock.toml file, check this

Related issues

Related PRs

Plan to create one more PR for pylock.toml analyzer

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

Copy link
Contributor

@Copilot 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

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.
Copy link

Copilot AI Oct 13, 2025

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.

Suggested change
// Parser parses pylock.toml defined in PEP518.
// Parser parses pylock.toml defined in PEP 751.

Copilot uses AI. Check for mistakes.

}

var pkgs []ftypes.Package
var deps []ftypes.Dependency
Copy link
Collaborator

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?

Copy link
Contributor Author

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?

Copy link
Collaborator

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

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.

Add support for pylock.toml (PEP 751)

2 participants