Skip to content

fix(supply-chain): parse_package_args robustness (PEP 508 extras, inline #, flag values) #145

Closed

Description

@thehoff

Surfaced by agy peer review of #143. `parse_package_args` produces avoidable false positives that cause the gate to fail closed unnecessarily. Three orthogonal parse-quality issues:

1. PEP 508 extras suffix not stripped

`pip install celery[redis]` — the `[redis]` extras suffix is part of the package spec but PyPI's name-lookup endpoint only accepts the bare name. The current parser sends `celery[redis]` literally and gets a 404, which forces an Ask/Unavailable verdict on a perfectly normal pip install.

Fix sketch: in `split_name_version`, after stripping a pin: `let name = name.split('[').next().unwrap_or(&name).to_string();`. Mirror for the version-suffix branch.

2. Inline # comment not recognised as terminator

`pip install flask # comment` — the parser captures `#` and `comment` as additional packages. Both fail registry lookup → Ask cascades.

Fix sketch: in `parse_package_args`, break the loop on a token that starts with `#` (only when it's a standalone token, not embedded in a name).

3. Value-consuming flags' values parsed as packages

`pip install --platform linux_x86_64 foo`, `pip install --python-version 3.11 foo`, `pip install --trusted-host pypi.org foo` — the value tokens `linux_x86_64`, `3.11`, `pypi.org` are read as packages and fail lookup. Mirror in `uv pip install`.

This is the package-bearing equivalent of the #142/#143 BLOCKER (which fixed the bare-install variant via `accepts_packages`).

Fix sketch: maintain a per-ecosystem `VALUE_CONSUMING_FLAGS` allow-list — `--platform`, `--python-version`, `--implementation`, `--abi`, `--trusted-host`, `--index-url`, `--extra-index-url`, `--find-links`, `--prefix`, `--target`, `--root`, `--upgrade-strategy`, `--no-binary`, `--only-binary`, etc. — and skip-2 on encountering them in `parse_package_args`.

Acceptance criteria

  • One adversarial test per case (extras, #-comment, each value-consuming flag).
  • No regression in the existing `detect_*` test suite.
  • Clippy clean.

Out of scope

  • npm/pnpm/yarn equivalents (e.g. `npm install --prefix /opt foo` where `/opt` is a value) — open a separate issue if needed; npm rarely has value-consuming-flag arguments in real-world installs.

🤖 Generated with Claude Code

Activity

  1. thehoff commented on May 26, 2026

    @thehoff
    OwnerAuthor

    Fixed in v0.1.11 via #184.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions