Skip to content

test(trust): make native plugin pin mode-change checks POSIX-only - #3987

Merged
Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-fix-3918-windows-native-pin
Nov 19, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
danielmeppiel-fix-3918-windows-native-pin

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Red-main repair. After #3918 (ee00d6a), the Windows unit tests fail (run 44596680888). Two tests in tests/unit/security/test_trust_admission.py re-gate a native plugin pin with Path.chmod(0o755) and expect (False, 'definition-changed'), but get (True, None):

  • test_native_plugin_seam_parks_on_any_byte_or_mode_change[mode-change]
  • test_native_plugin_pin_ignores_apm_normalization_output

Windows has no POSIX exec bit, so the chmod changes nothing the pin hashes. This is a test artifact, not a security gap: on Windows no change was made, so admitting the plugin is correct. Every byte change is still detected on Windows, and the other byte-change cases in the same test run there.

Changes (test-only):

  • The mode-change parameter is skipped on Windows, following the repo convention os.name == "nt", "POSIX file modes are not enforced on Windows". POSIX still asserts that a mode change re-gates.
  • The normalization-output test now re-gates through a publisher byte change outside APM's .apm/ copies.

Issue and approved scope

Issue: Fixes #3985

Human scope-approval comment: #3985 (comment)

Does this PR complete the issue, or what remains? It completes the issue. Whether the exec bit should be part of a pin committed to apm.yml across operating systems is a separate decision, raised with the maintainer.

Type of change

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

Testing

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

These checks emulate Windows chmod semantics by turning Path.chmod into a no-op, because Windows unit tests run only on main pushes:

  • Tests from main: pytest -k "mode_change or normalization_output" -> 2 failed, both assert (True, None) == (False, 'definition-changed'). This is the exact Windows failure.
  • Repaired tests: pytest tests/unit/security/test_trust_admission.py -k "not mode-change" -> 56 passed, 1 deselected.
  • Native POSIX run: .venv/bin/python -m pytest tests/unit/security/test_trust_admission.py -p no:xdist -q -> 57 passed.
  • uvx [email protected] check and format --check are clean.

Changelog

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

Spec conformance (OpenAPM v0.1)

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

Windows has no POSIX exec bit, so chmod cannot change what the native
plugin pin hashes, and the two #3918 tests that re-gated a pin through
chmod failed on the Windows unit lane. The mode-change case is skipped on
Windows, and the normalization-output test re-gates through a publisher
byte change instead.

Fixes #3985

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

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.

🟢 Approval recommended

No active review issues remain for this test-only repair to make native-plugin pin checks platform-independent.

No open issues 🎉

What changed in this PR

This test-only repair addresses #3985 by making native-plugin pin checks respect Windows file-mode behavior without changing production trust logic.

Changes:

  • Skip the executable-mode mutation case on Windows while retaining it on POSIX.
  • Use a publisher-file byte change to verify re-gating after APM normalization on all platforms.
File Description
tests/​unit/​security/​test_trust_admission.py Guards the POSIX-only mode assertion and makes the normalization regression check platform-independent.

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 8921f49 into main Nov 19, 2026
28 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-3918-windows-native-pin branch November 19, 2026 19:40
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.

[BUG] Windows unit tests fail on main: native plugin pin mode-change tests (#3918)

2 participants