Repository navigation
Resolve Pip/Uv detection ambiguity in the shared detector - #880
Conversation
A pyproject.toml without a poetry/hatch/flit/pdm build-backend defaults to Pip detection, so a uv project (pyproject.toml + uv.lock) was detected as both Pip and Uv for the same target, collapsing the resolved technology to unknown for every vulnerability found there.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe change centralizes Pip and Uv promotion rules, applies them to both audit target-detection flows, and reuses them in curation audits. Tests cover overlapping descriptors, nested Uv projects, project-level UV signals, and global UV configuration. ChangesPip and Uv disambiguation
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Audit
participant TechUtils
participant Curation
Audit->>TechUtils: Resolve Pip and Uv per working directory
TechUtils-->>Audit: Return promoted technologies
Audit->>TechUtils: Filter overlapping target mappings
Curation->>TechUtils: Resolve technologies using OriginPath
TechUtils-->>Curation: Return promoted technologies
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…xclude list The previous commit on this branch excluded Pip whenever uv.lock was present, which unconditionally strips Pip from the shared base detector - breaking jf curation-audit's existing, more precise promotePipToUv rule (a genuine pip project with a stray leftover uv.lock should still audit as pip; only a project with no pip-exclusive files should be treated as uv). That rule never got a chance to run, since Pip was already gone from the candidate list by the time it did. Reverts the exclude-list change and instead promotes that same rule (pip-exclusive file wins over a stray uv.lock; otherwise uv wins) into techutils.PromotePipToUv, shared between jf curation-audit and the general jf audit/scan detection flow that previously had no disambiguation at all for this ambiguity. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The 'Old flow' comment describing detectScaTargetsFromTechnologies got left above the newly-inserted filterAmbiguousPipUvTargets instead, orphaning it from the function it documents and breaking symmetry with the 'New flow' comment above createScanTargetsFromConfigs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The comment just restated what the six-line function body already shows. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
attiasas
left a comment
There was a problem hiding this comment.
Nice job, check out my comments
…uv.toml Nested uv projects were still dual-detected because promotion ran against the scan root, and ~/.config/uv/uv.toml would rewrite pip-only PEP 621 projects on machines with uv installed. Co-authored-by: Cursor <cursoragent@cursor.com>
attiasas
left a comment
There was a problem hiding this comment.
LGTM, check out my last comments
Frogbot now applies PromotePipToUv even without uv.lock, and curation no longer Getwd()s when the project dir is missing. Co-authored-by: Cursor <cursoragent@cursor.com>
…ipToUvIn's OriginPath change promotePipToUvIn now resolves Pip/Uv ambiguity via ca.OriginPath instead of the process's cwd, and no-ops when OriginPath is empty. This test constructs CurationAuditCommand directly without going through the setup that normally populates OriginPath from absWd, so it stayed empty and the promotion was silently skipped - detection correctly found both pip and uv, but nothing collapsed pip out of the result. Set ca.OriginPath = projectDir before calling techsToAudit(), matching what production code does before reaching this point. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

devbranch.go vet ./....go fmt ./....A pyproject.toml with no [tool.poetry] / hatchling / flit / pdm build-backend section defaults to Pip detection (pyProjectTomlIndicatorContent). This means a uv-managed project — which has pyproject.toml + uv.lock and typically none of those build-backend markers — was detected as both Pip and Uv for the same scan target.
Impact of the bug
When a target has more than one detected technology sharing the same Xray ecosystem (pypi), techutils.ResolveIssueTechnology cannot disambiguate and collapses the resolved Technology to NoTech (empty/unknown) for every vulnerability found there. Verified live end-to-end against jf audit --static-sca:
Fix
jf curation-auditalready solves this exact ambiguity viapromotePipToUv: a pip-exclusive file (requirements.txt, setup.py, setup.cfg, Pipfile, poetry.lock) wins over a stray uv.lock; otherwise, any uv signal (uv.lock, pyproject.toml[tool.uv]/[[tool.uv.index]], or~/.config/uv/uv.toml) wins and Pip is dropped. That logic only ran for curation-audit, not for the generaljf audit/jf scanflow (and therefore not for Frogbot).An earlier version of this PR fixed the ambiguity by excluding
uv.lockfrom Pip's indicators inutils/techutils/techutils.go. That approach was reverted: it mutated the shared base detector used by every command, which broke curation-audit's ownpromotePipToUvrule for the "pip project with a stray leftover uv.lock" case (requirements.txt+uv.lockshould still resolve to pip, not uv) — that rule never got a chance to run since Pip was already stripped from the candidate list upstream.Instead, this PR extracts
promotePipToUv's rule into a shared, exportedtechutils.PromotePipToUv(techs []Technology, dir string), and wires it into both places:commands/curation/curationaudit.go— now delegates to the shared function; behavior is unchanged, existing tests pass as-is.commands/audit/audit.go— added to both detection flows (detectTechnologiesInTargetfor the new BOM-generator flow,detectScaTargetsFromTechnologiesfor the old flow Frogbot currently uses), which previously had no disambiguation at all for this ambiguity.Verification
Re-ran detection (
techutils.DetectTechnologiesDescriptors+techutils.PromotePipToUv) against one fixture per manager:Detection results per package manager
requirements.txt[pip][pip]Pipfile,Pipfile.lock[pipenv][pipenv]pyproject.toml([tool.poetry]),poetry.lock[poetry][poetry]pyproject.toml,uv.lock[pip, uv]❌[uv]✅uv.lockrequirements.txt,uv.lock(leftover)[pip, uv][pip]✅The last row is the regression case
TestPipWinsOverStrayUvLockalready guards: a genuine pip project with a stray leftoveruv.lockmust still resolve to pip, not uv. Also confirmedcommands/curation's existingTestPipWinsOverStrayUvLock,TestPureUvProjectNotReportedAsPip, andTestTechsToAuditQueuesPep723HintForDeferredLoggingall still pass unchanged.Summary by CodeRabbit