mirror of
https://github.com/anchore/syft.git
synced 2026-11-26 13:44:11 +01:00
fix(python): keep single-character names in requirements.txt (#5469)
namePattern required at least two characters, so a pinned line like "q==2.7" (the format pip freeze writes) didn't match and the package was dropped from the SBOM. PEP 508 allows one-character names (q, a, j and others exist on PyPI). Signed-off-by: protonnegativo <protonnegativo@users.noreply.github.com> Co-authored-by: protonnegativo <protonnegativo@users.noreply.github.com>
This commit is contained in:
co-authored by
protonnegativo
parent
1c76975600
commit
8db56e6800
@@ -26,7 +26,7 @@ const (
|
|||||||
// --hash=sha256:e9535b8c84dc9571a48999094fda7f33e63c3f1b74f3e5f3ac0105a58405bb65 # some comment
|
// --hash=sha256:e9535b8c84dc9571a48999094fda7f33e63c3f1b74f3e5f3ac0105a58405bb65 # some comment
|
||||||
|
|
||||||
// namePattern matches: requests[security]
|
// namePattern matches: requests[security]
|
||||||
namePattern = `(?P<name>\w[\w\[\],\s-_\.]+)`
|
namePattern = `(?P<name>\w[\w\[\],\s-_\.]*)`
|
||||||
|
|
||||||
// versionConstraintPattern matches: == 2.8.*
|
// versionConstraintPattern matches: == 2.8.*
|
||||||
// the version token accepts every character PEP 440 versions can contain: digits and letters,
|
// the version token accepts every character PEP 440 versions can contain: digits and letters,
|
||||||
|
|||||||
@@ -318,6 +318,21 @@ func Test_newRequirement(t *testing.T) {
|
|||||||
VersionConstraint: "==2.8",
|
VersionConstraint: "==2.8",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "single character name",
|
||||||
|
raw: "q==2.7",
|
||||||
|
want: &unprocessedRequirement{
|
||||||
|
Name: "q",
|
||||||
|
VersionConstraint: "==2.7",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "single character name without version",
|
||||||
|
raw: "q",
|
||||||
|
want: &unprocessedRequirement{
|
||||||
|
Name: "q",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "arbitrary equality",
|
name: "arbitrary equality",
|
||||||
raw: "urllib3===1.26.20",
|
raw: "urllib3===1.26.20",
|
||||||
|
|||||||
Reference in New Issue
Block a user