Skip to content

Commit 9a39cc7

Browse files
committed
docs(bazel): clarify pypi parser scope
1 parent 552bfc8 commit 9a39cc7

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/commands/manifest/bazel/bazel-pypi-parser.mts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
/**
2-
* Parse `requirements_lock.txt`, `bazel query` output, and spoke-repo
3-
* `--output=build` tags into a uniform shape for PyPI requirements.txt
4-
* generation.
2+
* Parse Bazel PyPI extraction inputs into the pinned `name==version` lines
3+
* needed for generated `requirements.txt` output.
4+
*
5+
* This is deliberately not a general-purpose requirements.txt parser. It only
6+
* accepts pinned lockfile-style entries needed to map reached Bazel labels to
7+
* exact package versions; depscan remains the owner of full PEP 508
8+
* requirements ingestion during scan processing.
59
*
610
* Security gate: every regex uses bounded character classes to prevent
711
* catastrophic backtracking on hostile input.
@@ -113,7 +117,7 @@ export function resolveRequirementsLockPath(
113117
return resolved
114118
}
115119

116-
// Parses a single `name==version` line.
120+
// Parses a single pinned `name==version` lockfile line.
117121
// Group 1 = package name, Group 2 = version string (includes ==).
118122
const REQUIREMENT_LINE_RE = /^([A-Za-z0-9][A-Za-z0-9._-]*)==([A-Za-z0-9._+!]+)/
119123

@@ -149,8 +153,9 @@ function shouldSkipLine(line: string): boolean {
149153
return false
150154
}
151155

152-
// Parse a `requirements_lock.txt`-style file into a map keyed by
153-
// normalized PyPI name.
156+
// Parse a `requirements_lock.txt`-style file into a map keyed by normalized
157+
// PyPI name. This intentionally ignores unpinned PEP 508 requirement forms
158+
// because the Bazel extractor must emit exact package versions.
154159
export function parseRequirementsLock(
155160
text: string,
156161
): Map<string, ExtractedPypiPackage> {

0 commit comments

Comments
 (0)