diff --git a/syft/pkg/cataloger/python/parse_requirements.go b/syft/pkg/cataloger/python/parse_requirements.go index ed3536d0f..cae087097 100644 --- a/syft/pkg/cataloger/python/parse_requirements.go +++ b/syft/pkg/cataloger/python/parse_requirements.go @@ -26,7 +26,7 @@ const ( // --hash=sha256:e9535b8c84dc9571a48999094fda7f33e63c3f1b74f3e5f3ac0105a58405bb65 # some comment // namePattern matches: requests[security] - namePattern = `(?P\w[\w\[\],\s-_\.]+)` + namePattern = `(?P\w[\w\[\],\s-_\.]*)` // versionConstraintPattern matches: == 2.8.* // the version token accepts every character PEP 440 versions can contain: digits and letters, diff --git a/syft/pkg/cataloger/python/parse_requirements_test.go b/syft/pkg/cataloger/python/parse_requirements_test.go index 1175f7e4d..01fe0dd6d 100644 --- a/syft/pkg/cataloger/python/parse_requirements_test.go +++ b/syft/pkg/cataloger/python/parse_requirements_test.go @@ -318,6 +318,21 @@ func Test_newRequirement(t *testing.T) { 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", raw: "urllib3===1.26.20",