Skip to content

Commit 19c1088

Browse files
committed
fix(sbom): address review feedback for uv hash extraction
- Log errors when uv.lock cannot be read or parsed instead of silently ignoring, so issues are discoverable during troubleshooting - Align JSDoc graph parameter type with GraphEntry typedef - Skip hash assignment when entry already has hashes to avoid overwriting data from other pipeline stages Implements TC-4332 Assisted-by: Claude Code
1 parent 4fd5e20 commit 19c1088

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/providers/python_uv.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,22 @@ export default class Python_uv extends Base_pyproject {
4141
/**
4242
* Parse uv.lock and attach SHA-256 hashes to graph entries.
4343
* @param {string} lockFilePath - path to uv.lock
44-
* @param {Map<string, {name: string, version: string, children: string[]}>} graph
44+
* @param {Map<string, import('./base_pyproject.js').GraphEntry>} graph
4545
*/
4646
_attachHashesFromLockFile(lockFilePath, graph) {
4747
let lockContent
4848
try {
4949
lockContent = fs.readFileSync(lockFilePath, 'utf-8')
50-
} catch {
50+
} catch (e) {
51+
console.error(`uv: could not read lock file ${lockFilePath}: ${e.message}`)
5152
return
5253
}
5354

5455
let parsed
5556
try {
5657
parsed = parseToml(lockContent)
57-
} catch {
58+
} catch (e) {
59+
console.error(`uv: could not parse lock file ${lockFilePath}: ${e.message}`)
5860
return
5961
}
6062

@@ -68,7 +70,7 @@ export default class Python_uv extends Base_pyproject {
6870

6971
let key = this._canonicalize(pkg.name)
7072
let entry = graph.get(key)
71-
if (!entry) { continue }
73+
if (!entry || entry.hashes) { continue }
7274

7375
entry.hashes = [{alg: "SHA-256", content: hashStr.slice(7)}]
7476
}

0 commit comments

Comments
 (0)