Skip to content

Add APM package-manager detection and command support - #51

Merged
andrew merged 3 commits into
git-pkgs:mainfrom
abhinavgautam01:apm-manager
Nov 15, 2026
Merged

andrew merged 3 commits into
git-pkgs:mainfrom
abhinavgautam01:apm-manager

Conversation

@abhinavgautam01

@abhinavgautam01 abhinavgautam01 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #50.

Adds a definition for Microsoft APM, checked against the CLI help captured from APM 0.35.1 in references/apm/.

Detection

  • Manifest apm.yml, lockfiles apm.lock.yaml and legacy apm.lock. The current lockfile is listed first so it wins when conflicts are allowed.
  • New apm ecosystem, ordered after conda.
  • GitPkgsFileDetectionPolicy has a matching entry, so a directory with pyproject.toml and apm.yml returns both uv and apm from DetectAllFS.

Commands

Operation Command
init apm init --yes
install apm install, --frozen for frozen installs
add apm install owner/repo[#ref], --dev for development dependencies
remove apm uninstall owner/repo
list apm deps list
outdated apm outdated
update apm update [package] --yes
resolve apm deps tree

Notes:

  • apm list lists scripts, so dependency listing uses apm deps list.
  • init writes apm.yml in place, checked by running it in an empty directory.
  • update needs --yes because APM aborts the confirmation prompt without a TTY.
  • outdated was not in the issue but APM has it. It exits 0 whether or not anything is outdated.
  • No dependency command has JSON output, so json_output is not advertised. resolve returns the raw deps tree text. Parsing the lockfile is handled by the apm directory parser in resolve (Read APM dependency graphs from the lockfile resolve#17).
  • The minimum version is 0.35.1, the version tested.

Tests

apm_test.go loads the embedded definition and covers:

  • command translation for every operation, including frozen installs, development additions and adds with and without a ref
  • the advertised capabilities, with no json_output, path or vendor
  • detection from the manifest alone and from each lockfile name, with and without GitPkgsFileDetectionPolicy
  • DetectAllFS returning both uv and apm for pyproject.toml plus apm.yml

The README lists apm in the manager table and the init and resolve lists.

Summary by CodeRabbit

  • New Features
    • Added support for the APM package manager, including project detection from manifests and lockfiles, and commands for initializing, installing, managing, and resolving dependencies.
  • Bug Fixes
    • Package blocklist rules now also match names with version and ref suffixes, such as owner/repo#main.
  • Documentation
    • Added APM command-line help covering dependency management, installation options, updates, and common workflows.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

This pull request adds APM package-manager detection and command support, including command mappings, capability declarations, tests, CLI reference text, and README entries. It also updates package blocklist matching to recognize names with trailing version and ref suffixes.

Changes: APM manager support

Layer / File(s) Summary
APM identity and detection
definitions/apm.yaml, detection_policy.go, apm_test.go, README.md
Adds APM version and detection metadata, registers apm.yml, apm.lock.yaml, and apm.lock, and tests detection with and without Python project files. The README lists APM as supported and documents its init and resolve support.
Command mappings and capabilities
definitions/apm.yaml, validate.go, apm_test.go
Maps supported operations to APM commands and declares capabilities. Adds package-name validation and tests for command translation, required arguments, accepted and rejected package names, and capabilities.
APM CLI reference text
references/apm/*
Adds APM command help text and records the CLI version as 0.35.1.

Package blocklist matching

Layer / File(s) Summary
Match suffixed package names
policy.go, policy_test.go
Blocklist matching checks the original package name and forms without trailing @version, #ref, or both. Tests cover blocked and unblocked ref-suffixed names and keys containing #.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Suggested reviewers: andrew

Merge Risk: Minimal · up to 71866

This change adds APM detection and command support and broadens blocklist matching for package names with version or ref suffixes. No concrete merge-blocking issue was found in the supplied context, so it looks ready to merge after normal checks.

Security architecture risk: Minimal · up to 71866

APM uses the existing execution path, and blocklist matching preserves previous denials while adding support for ref-suffixed packages. No introduced or worsened security-boundary or failure-containment issue was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — APM operations run through the configured Runner in the manager's working directory. The built-in executor launches the binary directly with an argument array; the new definition does not introduce shell evaluation.

Trust Boundaries and Controls

  • inferred — For the same supplied package list and blocklist, suffix normalization cannot turn a previous denial into an allowance: the original identifier and previous version-stripped candidate are still checked. It additionally denies ref-suffixed identifiers such as owner/repo#main when owner/repo is blocked.
  • observed — RunWithContext checks caller-supplied Packages without deriving them from Command. A caller omitting or misrepresenting Packages can therefore avoid package-name matching. This trust responsibility exists at both base and head and is not an introduced PR concern; external caller behavior remains unverified.

Resilience and Maintainability Implications

  • observed — The changed matcher only constructs local candidates and reads the blocklist. It does not modify shared policy state or introduce a reservation, cleanup, or recovery lifecycle.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Add APM package-manager detection and command support" matches the main change. The PR adds an embedded APM definition (definitions/apm.yaml) with detection of apm.yml, apm.lock.yaml, and a…
Linked Issues check Passed Issue #50 is the only active directly linked issue. Issue #17 is closed and marked historical context only, so its criteria do not apply.

[#50 detection] The definition detects apm.yml, `apm.lock.y…
Out of Scope Changes check Passed Core changes map to #50: the APM definition, the detection policy entry and constant, apm_test.go, the README entries, and the references/apm/ help files. The outdated mapping is a related APM c…
Full details: Title check

Explanation

The title "Add APM package-manager detection and command support" matches the main change. The PR adds an embedded APM definition (definitions/apm.yaml) with detection of apm.yml, apm.lock.yaml, and apm.lock, command mappings, and a new apm ecosystem in detection_policy.go. The title does not mention the blocklist fixes in policy.go or the validator in validate.go, but those are secondary to the main change.

Full details: Linked Issues check

Explanation

Issue #50 is the only active directly linked issue. Issue #17 is closed and marked historical context only, so its criteria do not apply.

[#50 detection] The definition detects apm.yml, apm.lock.yaml, and legacy apm.lock. detection_policy.go adds an APM ecosystem entry with apm.yml as manifest and both lockfiles mapped to the APM manager.

[#50 command translation] The PR maps init (apm init --yes), install (apm install, --frozen), add (apm install owner/repo[#ref], --dev), remove (apm uninstall), list (apm deps list), update (apm update [package] --yes), and resolve (apm deps tree). The PR description states these were checked against captured APM 0.35.1 help in references/apm/, and the help files are present.

[#50 capabilities] json_output is not advertised. The issue requires capabilities to match command support. The PR states that no dependency command has JSON output, so this matches the requirement.

[#50 tests] apm_test.go covers command translation, frozen installs, development additions, adds with and without refs, both lockfile names, detection with and without GitPkgsFileDetectionPolicy, and DetectAllFS returning uv and apm for pyproject.toml plus apm.yml.

[#50 deferred item] The lockfile graph parser is deferred to git-pkgs/resolve#16/#17. The issue states that command translation can be implemented independently, so this deferral is allowed. Resolve uses raw apm deps tree output, as requested.

The changes since the previous review (blocklist #ref matching in policy.go, and the apm_package validator in validate.go) do not remove any #50 requirement. The validate.go and policy.go diffs were read directly. The apm_test.go and policy_test.go changes are assessed from the summary and PR description. The earlier conclusions are preserved.

Full details: Out of Scope Changes check

Explanation

Core changes map to #50: the APM definition, the detection policy entry and constant, apm_test.go, the README entries, and the references/apm/ help files. The outdated mapping is a related APM command. The PR discloses it, and it is the same manager.

policy.go adds trailing #ref stripping to PackageBlocklistPolicy.match. The diff was read. The code is generic and applies to all ecosystems, not only APM. It supports #50's optional #ref form for add, so it is related. It does change shared matching behavior. No current ecosystem in this repository is shown to use # in package names, so the scope is connected. The a#b test case documents the candidate-building behavior.

validate.go adds an apm_package pattern ^[^-]. The diff was read. It is applied only to APM add, remove, and update. It rejects leading-dash package arguments, which is the flag-injection concern from closed #17, and it accepts the APM argument forms listed in the code comment. Because the definition uses it for APM commands, it is connected to the APM work. Issue #17 is historical context, so this change is a related hardening step and not a new requirement.

No change was found that is unrelated to APM support or to the linked issues.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0440ca2a-2eaa-4f40-b72b-3f8ab86fc8db
Commits

Reviewing files that changed from the base of the PR and between 6850007 and 71866f1.

Files selected for processing: 2

  • policy.go
  • policy_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this. The command mappings match the captured help and the APM docs, and the detection entries look right. Two things need changing before it can merge.

PackageBlocklistPolicy does not match owner/repo#ref. match in policy.go strips only a trailing @version, and APM is the first definition with a different version suffix. With owner/repo on the blocklist, an add with version main builds apm install owner/repo#main and is allowed in enforce mode. match needs to strip a trailing #ref as well, with a case for it in policy_test.go.

The package arg on add, remove and update in definitions/apm.yaml has no validate, so a package value of --force becomes apm install --force, which the help describes as deploying despite critical security findings. PolicyRunner skips dash-prefixed args, so no policy sees it either. The existing package_name validator is too narrow here because APM also accepts Git URLs, local paths and NAME@MARKETPLACE. Please add an apm_package validator in validate.go that rejects a leading -, reference it from those three args, and add a test for it.

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

Thanks, both fixed.

  • match now strips a trailing #ref before the @version check, so owner/repo#main hits an owner/repo entry. Cases added to TestPackageBlocklistScopedAndVersioned.
  • Added an apm_package validator that rejects a leading - and used it on the package arg of add, remove and update. TestValidateAPMPackage covers the validator. TestAPMRejectsFlagPackages checks that --force is refused while URLs, local paths and NAME@MARKETPLACE still build.

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, both points from the first round are fixed: owner/repo#main now hits an owner/repo entry, and --force is refused as a package on add, remove and update.

One thing in the new match in policy.go needs changing. It strips the #ref first and then looks for @ only in what is left, so the candidate that main builds by stripping a trailing @version from the original string is gone. With a#b on the blocklist, a#b@c is blocked on main (it strips @c and finds a#b). On this branch the candidates are a#b@c and a, so it is allowed. match is shared by every manager, so any blocklist key containing # loses its versioned match.

Please build the candidates independently: pkg, pkg with a trailing @... stripped, pkg with a trailing #... stripped, and that last one with a trailing @... stripped. Add a case to TestPackageBlocklistScopedAndVersioned with a key containing # and an input that adds @version to it.

@abhinavgautam01

Copy link
Copy Markdown
Contributor Author

Thanks, fixed. match now builds the candidates independently from the original string: pkg, pkg without a trailing @..., pkg without a trailing #..., and that last one without a trailing @.... Added a a#b key to TestPackageBlocklistScopedAndVersioned with a#b@c (blocked) and a#c@d (allowed).

@andrew
andrew merged commit ff21566 into git-pkgs:main Nov 15, 2026
3 checks passed
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.

Add APM package-manager detection and command support

2 participants