Skip to content

fix: avoid subpath false positives for .git repository URLs - #2581

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
microsoft:mainfrom
aryansk:fix/2528-gitlab-dot-git-subpath-guard
Sep 2, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
microsoft:mainfrom
aryansk:fix/2528-gitlab-dot-git-subpath-guard

Conversation

@aryansk

Copy link
Copy Markdown
Contributor

Summary

Stop treating a primitive-named GitLab subgroup as an embedded APM subpath when the explicit repository URL already terminates in .git.

Changes

  • preserve the .git terminator signal in _check_no_embedded_subpath
  • return before the primitive-directory heuristic for explicit .git repository URLs
  • add a regression test for https://gitlab.com/ai/collections/core.git

Validation

The new test covers a depth-3 GitLab repository whose subgroup is named collections, while existing subpath-guard tests continue to cover shorthand malformed paths.

Fixes #2528

@aryansk

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@danielmeppiel

Copy link
Copy Markdown
Collaborator

APM Review Panel: needs_rework

PR #2581 must preserve provider-aware GitLab validation so explicit paths cannot bypass canonical host ownership or fixed-provider safety guards.

cc Aryan Singh K. (@aryansk) -- a fresh advisory pass is ready for your review.

The panel converges on a correctness and security boundary: a universal .git return accepts malformed explicit paths before canonical GitLab host providers and fixed-provider guards can classify them. That creates identity/source confusion, removes the actionable parse failure, and permits primitive-tail forms that must be rejected without network access. DependencyReference should own one pure provider-aware decision while consuming core/host_providers.

The intended contract is narrow: accept deep GitLab HTTPS and SCP ai/platform/collections/<repo>.git references as strings and objects; reject fixed-provider primitive tails and <repo>.git/<primitive>/<name> before any state transition. The lifecycle and hermetic before-state coverage must prove this.

Aligned with: Secure by default: reject ambiguous primitive-tail references before state. Multi-harness multi-host: preserve host-specific GitLab grammar without a universal bypass. Pragmatic as npm: keep the actionable parse error.

Panel summary

Persona B R N Takeaway
Python Architect 2 1 0 Universal bypass breaks fixed-provider validation and canonical ownership.
CLI Logging Expert 1 0 0 Restore the actionable validation error.
DevX UX Expert 1 1 0 Cover every required URL and manifest form.
Supply Chain Security Expert 1 0 0 Provider-agnostic bypass weakens source identity protection.
OSS Growth Hacker 0 0 0 Correct GitLab support improves compatibility without extra friction.
Auth Expert 1 0 0 Use canonical GitLab host classification.
Doc Writer 0 1 0 Clarify the repository/subpath boundary concisely.
Test Coverage Expert 0 1 0 Add a hermetic deep-GitLab lifecycle regression test.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top follow-ups

  1. [Supply Chain Security Expert] (blocking-severity) Replace the universal .git return with a pure provider-aware DependencyReference guard consuming core/host_providers. This preserves source identity without network access.
  2. [Python Architect] (blocking-severity) Add the canonical-owner extension, static boundary guard, and matching architecture test. This prevents a parallel provider/primitive heuristic from returning.
  3. [Test Coverage Expert] (blocking-severity) Add HTTPS/SCP and string/object deep-GitLab pack/install/frozen lifecycle coverage with before-state negative assertions. This proves the contract at the CLI boundary.
  4. [CLI Logging Expert] Retain the actionable embedded-subpath error for malformed explicit URLs. This prevents cryptic downstream failures.
  5. [Doc Writer] Add an in-place dependency-reference clarification. This makes the boundary discoverable.

Recommendation

Fold the provider-aware guard and the full regression matrix before shipping. The change is well-scoped, but the current universal bypass undermines predictable dependency resolution.


Full per-persona findings

Python Architect

  • [blocking] Terminal .git currently disables fixed-provider primitive validation at src/apm_cli/models/dependency/reference.py:657.
  • [blocking] Consume core/host_providers from a single pure DependencyReference decision and guard that ownership.

Supply Chain Security Expert

  • [blocking] A malformed explicit primitive tail can become a downstream source identity and lock/cache input.

Test Coverage Expert

  • [recommended] The existing parser unit test does not exercise the required hermetic CLI lifecycle or pre-mutation negative state.

Documentation

  • [recommended] Explain that deep GitLab namespace paths are repositories and primitive content belongs in path:.

This panel is advisory. It does not block merge. Re-apply the panel-review label after addressing feedback to re-run.

@danielmeppiel

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_now

PR #2581 preserves deep GitLab namespace support while rejecting unambiguous embedded primitive tails before any local state is written.

cc Aryan Singh K. (@aryansk) -- a fresh advisory pass is ready for your review.

The recovery fold resolves the correctness and security concerns: recursive decoding prevents encoded-tail bypasses, the GitLab .git boundary scan catches primitive tails at any later segment, and the established actionable diagnostic remains stable. The lifecycle guard proves failure occurs before lockfile, module, or cache writes. Exact-head validation passed 206 parser/architecture tests and 18 lifecycle tests.

Dissent. Descriptor centralization is deferred: the parser consumes the canonical host classifier, while URL-subpath interpretation remains its scoped policy. A broader host-provider API redesign is outside this PR.

Aligned with: portable manifests, secure-by-default parsing, pragmatic recovery guidance, and contributor-credit visibility.

Panel summary

Persona B R N Takeaway
Python Architect 2 0 0 Nested boundary and ownership concerns were folded; scoped ownership remains appropriate.
CLI Logging Expert 0 0 0 Actionable diagnostics remain stable.
DevX UX Expert 1 0 0 Explicit virtual-file forms still fail before state through canonical validation.
Supply Chain Security Expert 1 0 0 Recursive decoding closes encoded-tail bypasses.
OSS Growth Hacker 0 1 0 Unreleased changelog entry folded.
Auth Expert 0 0 0 No auth routing concern.
Doc Writer 0 0 0 No current documentation contradiction.
Test Coverage Expert 0 1 0 Deep GitLab lifecycle no-write case folded.
Performance Expert 0 0 0 No performance concern.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Recommendation

Ship the recovery fold. The originally raised bypass, lifecycle, diagnostic, and discoverability concerns are covered by the implementation, mutation checks, lifecycle no-write assertion, and exact-head validation.


Full per-persona findings
  • Python Architect: nested GitLab .git primitive tails are rejected; descriptor redesign deferred as cross-cutting.
  • DevX UX: generic GitLab virtual-file tests now assert the canonical validation error.
  • Supply Chain Security: double-encoded primitive tails are rejected.
  • OSS Growth: Unreleased compatibility entry added.
  • Test Coverage: deep GitLab pre-state lifecycle rejection added.
  • CLI Logging, Auth, Doc Writer, and Performance: no remaining findings.

This panel is advisory. It does not block merge. Re-apply the panel-review label after addressing feedback to re-run.

@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the fix/2528-gitlab-dot-git-subpath-guard branch from 2884555 to 6f759dc Compare August 23, 2026 16:13
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the fix/2528-gitlab-dot-git-subpath-guard branch from 6f759dc to 884d4d4 Compare September 2, 2026 03:40
pr-relay and others added 4 commits September 2, 2026 06:22
Classify explicit repository paths through the canonical host provider before deciding whether an APM primitive is embedded. This admits deep GitLab namespaces while retaining fixed-provider rejection and adds lifecycle and ownership regression coverage.

Co-authored-by: Copilot <[email protected]>
Reject encoded and nested primitive tails after an explicit repository boundary while preserving deep GitLab namespaces. Stabilize lifecycle diagnostics and record the compatibility repair.

addresses apm-review-panel follow-ups

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 81d14491-7c32-46fc-b045-b7cde2b2500a
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the fix/2528-gitlab-dot-git-subpath-guard branch from 884d4d4 to 7a45fea Compare September 2, 2026 10:24
@danielmeppiel
Daniel Meppiel (danielmeppiel) marked this pull request as ready for review September 2, 2026 10:30
Copilot AI lite review requested due to automatic review settings September 2, 2026 10:30
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 5bcfc16 into microsoft:main Sep 2, 2026
1 check passed

Copilot AI 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.

🟡 Changes recommended

The regression suite for the reported GitLab false-positive does not yet cover the no-.git URL variants that were part of the original reproduction matrix, leaving the fix partially unprotected against regression.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts DependencyReference’s early “embedded subpath” guard to be host-provider aware so GitLab’s arbitrarily deep subgroup namespaces (including subgroup names that collide with APM primitive directory names like collections) no longer false-positive, while still rejecting cases where a clear repository boundary (a .git segment) is followed by an APM primitive tail.

Changes:

  • Update _check_no_embedded_subpath to route parsing decisions through classify_host_provider(...), allowing GitLab deep namespaces while retaining strict fixed-boundary behavior for GitHub/others.
  • Add unit + integration regressions for deep GitLab paths and for “.git boundary + primitive tail” malformed URLs.
  • Extend architecture ownership metadata + linter checks to make embedded-subpath validation’s owner/shape enforceable.
File summaries
File Description
src/apm_cli/models/dependency/reference.py Makes embedded-subpath guard provider-aware; adds .git-boundary primitive-tail detection for GitLab; centralizes the canonical error raise.
tests/unit/test_generic_git_urls.py Adds regressions for deep GitLab namespaces with primitive-named subgroups; updates virtual-file rejection tests; adds boundary/tail rejection cases.
tests/integration/test_consume_source_ref_cache_matrix.py Adds lifecycle-smoke coverage ensuring deep GitLab repo boundaries pack/install/frozen-replay deterministically and malformed tails fail before writing state.
tests/integration/test_architecture_dependency_reference.py Adds architecture regression tests asserting single-owner/provider-aware embedded-subpath logic and guarding against bypass mutations.
scripts/architecture_linter/checks/contracts_test_taxonomy.py Extends the dependency-identity rule to enforce embedded-subpath ownership/routing and prevent _APM_PRIMITIVE_DIRS usage outside the owner.
.apm/architecture/owners/contracts-tooling.json Updates owner registry wording to include embedded git URL subpath validation under the same canonical owner set.
CHANGELOG.md Documents the GitLab deep-namespace acceptance and the preserved rejection for “boundary + primitive tail” malformed forms.
Review details

Suppressed comments (1)

tests/unit/test_generic_git_urls.py:79

  • The object-form type: gitlab regression test currently only covers .git-suffixed URLs; adding no-suffix variants would better lock in the intended behavior for providers with deep namespaces (matching the issue's observed matrix).
        (
            "https://code.example.invalid/ai/platform/collections/core.git",
            "[email protected]:ai/platform/collections/core.git",
        ),
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +64 to +67
(
"https://gitlab.com/ai/platform/collections/core.git",
"[email protected]:ai/platform/collections/core.git",
),
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.

Subpath guard false-positives on a GitLab subgroup legitimately named collections

3 participants