Skip to content

fix(install): org policy refuses a denied dependency before fetching it - #4534

Merged
Daniel Meppiel (danielmeppiel) merged 2 commits into
train/0.37-final-2from
danielmeppiel-s32-policy-deny-before-fetch
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 2 commits into
train/0.37-final-2from
danielmeppiel-s32-policy-deny-before-fetch

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

A blocking org policy now decides dependency deny and allow rules on the dependency identity before anything is fetched:

  • install/phases/resolve.py: the download callback refuses a denied identity before any network or cache access, for direct, transitive, registry and dry-run resolution. The refusal is recorded on the install context, and ref annotation skips refused identities.
  • install/phases/policy_gate.py: the gate reports refused identities with the existing violation output and exit code.
  • commands/install.py: apm install <pkg> validation does not probe the source of an identity the policy refuses.
  • policy/install_preflight.py: the policy is read once, silently, through the trust-policy routing owner (prefetch_identity_policy, identity_policy_denial, identity_policy_scope).

Warn or off enforcement, --no-policy and APM_POLICY_DISABLE keep their current behaviour.

Issue and approved scope

Issue: Refs #4092

Human scope-approval comment: private release coordination with the 0.37 steward.

Does this PR complete the issue, or what remains? One hardening item under the 0.37 trust and integrity umbrella; the umbrella stays open.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

New tests/lifecycle/security/test_policy_deny_before_fetch.py, run with the binary driver pinned to each tree through the host guard:

  • On the parent (train 5c33aa7), 3 of 4 cells fail: a direct denied dependency (manifest and CLI-spec forms) and a transitive one are contacted (commits API, info/refs, git-upload-pack). The 4th cell, frozen and audit agreement, already held.
  • On this branch, all 4 pass. The cells assert exit 1 with the violation line, zero requests to the denied repository, no cache entry for it, an unchanged cache tree digest (direct case) and unchanged project bytes.

Other local runs:

  • tests/unit/install + tests/unit/test_install_command.py: 3643 passed. The 2 failures are pre-existing on the base (test_mcp_retired_shape_heal, test_require_hashes redaction).
  • tests/lifecycle/world/test_world.py -k "policy or deny": 22 passed.
  • ruff check and ruff format --check (0.15.12): clean on changed files.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md:
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

If this PR changes behaviour that an OpenAPM v0.1 req-XXX covers,
confirm the three-step ritual in the
development guide:

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

A blocking org policy decides dependency deny and allow rules on the
dependency identity, so a refused direct or transitive dependency is never
contacted, cloned or cached: the resolve download callback refuses it before
any fetch, ref annotation skips it, and package validation for
'apm install <pkg>' does not probe its source. The policy gate reports the
refusal as before.

apm-spec-waiver: install-order hardening of an already documented guarantee (policy loads before any package is written)

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant