Skip to content

Resolve Pip/Uv detection ambiguity in the shared detector - #880

Merged
orto17 merged 10 commits into
jfrog:devfrom
orto17:fix/uv-pip-detection-exclude
Sep 17, 2026
Merged

orto17 merged 10 commits into
jfrog:devfrom
orto17:fix/uv-pip-detection-exclude

Conversation

@orto17

@orto17 orto17 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor
  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • Updated the Contributing page / ReadMe page / CI Workflow files if needed.
  • All changes are detailed at the description. if not already covered at JFrog Documentation, new documentation have been added.

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:

  • Real uv project (pyproject.toml + uv.lock): detected as [pip, uv] → resolved technology for every vulnerability came back empty/unknown.
  • Equivalent minimal pip, pipenv, and poetry fixtures: each detected as a single, correct technology, unaffected.

Fix

jf curation-audit already solves this exact ambiguity via promotePipToUv: 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 general jf audit/jf scan flow (and therefore not for Frogbot).

An earlier version of this PR fixed the ambiguity by excluding uv.lock from Pip's indicators in utils/techutils/techutils.go. That approach was reverted: it mutated the shared base detector used by every command, which broke curation-audit's own promotePipToUv rule for the "pip project with a stray leftover uv.lock" case (requirements.txt + uv.lock should 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, exported techutils.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 (detectTechnologiesInTarget for the new BOM-generator flow, detectScaTargetsFromTechnologies for 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

Package manager Fixture files Raw detected After promotion
pip requirements.txt [pip] [pip]
pipenv Pipfile, Pipfile.lock [pipenv] [pipenv]
poetry pyproject.toml ([tool.poetry]), poetry.lock [poetry] [poetry]
uv pyproject.toml, uv.lock [pip, uv] ❌ [uv] ✅
pip + stray uv.lock requirements.txt, uv.lock (leftover) [pip, uv] [pip] ✅

The last row is the regression case TestPipWinsOverStrayUvLock already guards: a genuine pip project with a stray leftover uv.lock must still resolve to pip, not uv. Also confirmed commands/curation's existing TestPipWinsOverStrayUvLock, TestPureUvProjectNotReportedAsPip, and TestTechsToAuditQueuesPep723HintForDeferredLogging all still pass unchanged.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Python project detection so UV-managed projects are identified as UV instead of Pip when both indicators are present.
    • Prevented duplicate scanning of the same project as both Pip and UV.
    • Kept Pip detection when only Pip-specific files are present.
    • Ignored global UV configuration when determining a project’s technology.
    • Applied consistent Pip/UV detection across audit, scan, and curation workflows.

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.
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 9ad85328-e4f0-40ec-86fc-92e574103b0d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The 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.

Changes

Pip and Uv disambiguation

Layer / File(s) Summary
Shared promotion rules
utils/techutils/techutils.go, utils/techutils/techutils_test.go
Added PromotePipToUv. Pip-exclusive files retain Pip. uv.lock and supported pyproject.toml UV tables promote Pip to Uv. Global ~/.config/uv/uv.toml does not promote a project.
Audit target integration
commands/audit/audit.go, commands/audit/audit_test.go
Audit applies promotion per working directory in the new flow and filters overlapping Pip and Uv mappings in the old flow. Tests cover nested Uv projects and shared directories.
Curation audit integration
commands/curation/curationaudit.go, commands/curation/curationaudit_test.go
Curation delegates to the shared helper and passes ca.OriginPath. Tests update expectations for global UV configuration. One test change only normalizes formatting.

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
Loading

Suggested reviewers: attiasas

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: resolving Pip/Uv detection ambiguity in the shared detector.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@orto17 orto17 added improvement Automatically generated release notes safe to test Approve running integration tests on a pull request labels Sep 10, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 10, 2026
@orto17 orto17 added bug Something isn't working safe to test Approve running integration tests on a pull request and removed bug Something isn't working labels Sep 14, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 14, 2026
…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>
@orto17 orto17 changed the title Exclude UV-Managed Projects From Pip Detection Resolve Pip/Uv detection ambiguity in the shared detector Sep 14, 2026
The comment just restated what the six-line function body already
shows.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@attiasas attiasas added the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👍 Frogbot scanned this pull request and did not find any new security issues.


@attiasas attiasas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job, check out my comments

Comment thread commands/audit/audit.go Resolved
Comment thread utils/techutils/techutils.go Resolved
Comment thread commands/audit/audit.go Resolved
Comment thread utils/techutils/techutils.go Resolved
Comment thread utils/techutils/techutils.go Resolved
Comment thread commands/curation/curationaudit.go Resolved
…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>
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Sep 15, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 15, 2026

@attiasas attiasas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, check out my last comments

Comment thread commands/curation/curationaudit.go Resolved
Comment thread commands/audit/audit.go Resolved
Comment thread commands/audit/audit.go Resolved
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>
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Sep 16, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 16, 2026
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Sep 16, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 16, 2026
…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>
@orto17 orto17 added the safe to test Approve running integration tests on a pull request label Sep 16, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Sep 16, 2026
@orto17
orto17 merged commit e156e04 into jfrog:dev Sep 17, 2026
120 of 122 checks passed

This branch had an error being deployed

1 failed deployment
frogbot — 27b453c4 Deployed Sep 16, 2026 by orto17 via scan-pull-request #4552
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants