fix(build): keep repository tooling and molecule scenarios out of the Collection archive #18

Merged
Defame1297 merged 6 commits from fix/collection-tarball-contents into main 2026-10-25 20:40:01 +00:00
Owner

What changed (head ad2e4aa, main at f271730 merged in)

  • galaxy.yml build_ignore: adds .ansible, .claude, .reuse, .venv, CLAUDE.md, HANDOFF.md, extensions, gitleaks-report.json, importer_result.json and roles/*/molecule. tests/scripts comes from main (#16), with no duplicate line here.
  • scripts/check_tarball.py (no shebang, not executable, because ansible-test sanity rejects one on a non-module file): allow-list check of the built archive.
    • top-level entries must be in ALLOWED_TOP; forbidden patterns compared case-insensitively: molecule dirs, *.pem, *.key, anything containing vault, *id_rsa*, *id_ed25519*, *.envrc, .env* variants, */.ssh and */.ssh/*, pycache, nested tarballs, importer_result.json. Widening to *vault* rejects any file name containing "vault" (none in the current build);
    • only regular files and directories (no symlinks, hardlinks, devices, fifos);
    • rejects absolute paths, empty/./.. components, backslashes, and control, zero-width, non-ASCII-space, surrogate, private-use and unassigned characters; the .git test compares after NFKC and case folding (full-width .git, .GIT);
    • rejects names that Windows or macOS extraction reads differently: a component ending in a space or dot, reserved device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9, with or without extension), ::, 8.3 aliases of .git (GIT~1), components longer than 255 bytes (such names, e.g. aux.yml, would be rejected if a role ever used them);
    • duplicates are compared case-insensitively, a name used as both file and directory (COPYING and COPYING/x) is rejected, and normalisation strips one leading ./ and one trailing / only (a//b stays rejected);
    • rejects an empty archive and one lacking MANIFEST.json, FILES.json, COPYING, README.md, meta/runtime.yml or changelogs/changelog.yaml; an unreadable archive is one line, exit 1.
    • The docstring states that ansible-galaxy dereferences FILE symlinks, so the archive check cannot see them: the "Refuse symlinks in the source tree" step of build.yml is the only guard.
  • build.yml: step "Refuse symlinks in the source tree" (find prunes ./.git and ./.venv, which is only safe because both are skipped by the build: .venv is in galaxy.yml build_ignore, .git is excluded by ansible-galaxy; a comment says the two lists must stay in step) and "Check the archive contents". Both the archive check and the galaxy-importer step now fail with a clear message unless exactly one /tmp/dist/mortis-kamino-*.tar.gz matches, and pass it as one quoted argument.
  • lint.yml: unchanged from main; the "Test the repository scripts" step comes from #16.
  • tests/scripts/test_check_tarball.py: 31 tests. Added: widened forbidden names, each ambiguity rule, ordinary names still pass, normalisation, a required file present only as ./COPYING passes, a//b and ./a/b, case-insensitive duplicates, file/directory clash, test_real_build_passes (builds a real tarball with ansible-galaxy from a copy of the checkout and checks it; skipped with a message when ansible-galaxy is not on PATH) and BuildWorkflowTest (every directory build.yml prunes is in galaxy.yml build_ignore or is excluded by ansible-galaxy itself). The old test_required_set_matches_a_real_build (it only compared the set with a copy of itself) is replaced by the real-build test.
  • Changelog fragment minor_changes updated.

Verified

  • git archive of the merged head into a directory outside the clone, ansible-galaxy collection build with the clone venv: check_tarball.py passes ("27 entries, all allowed"; main's new files add one entry).
  • On the merged tree python3 -I -m unittest discover -s tests/scripts runs 65 tests (main's 34 plus these 31), all pass, including the real-build test (not skipped locally).
  • ansible-test sanity --test pep8 --test pylint --test shebang run locally on the script and the test file: clean.
  • CI at head ad2e4aa, steps observed: Build job success with "Refuse symlinks in the source tree", "Build the Collection", "Check the archive contents", "Run galaxy-importer" and "Run ansible-test sanity" all success; Lint job success with pre-commit, Check image pins, Check image versions were bumped, "Test the repository scripts", gitleaks scan and Conventional Commits. The Molecule job was still running when this was written.

Not verified

  • Whether test_real_build_passes ran or skipped in CI (the step passed; the step log was not read).
  • The "exactly one tarball" guard was not exercised with two tarballs in CI.
  • File symlinks remain guarded only by the source-tree step.
  • roles/*/molecule ignore against a real role (no roles exist yet); a future ansible-galaxy that renames a required member would need REQUIRED updated.
  • Behaviour of the name rules on an actual Windows/macOS extraction (rules follow the documented reserved names, not tested there).

Merge order

#16 is merged; #15, #17 and this PR no longer conflict with main or each other on the script-test step. This PR touches a different region of build.yml than #17.

🤖 Generated with Claude Code

## What changed (head ad2e4aa, main at f271730 merged in) - galaxy.yml `build_ignore`: adds .ansible, .claude, .reuse, .venv, CLAUDE.md, HANDOFF.md, extensions, gitleaks-report.json, importer_result.json and `roles/*/molecule`. `tests/scripts` comes from main (#16), with no duplicate line here. - `scripts/check_tarball.py` (no shebang, not executable, because `ansible-test sanity` rejects one on a non-module file): allow-list check of the built archive. - top-level entries must be in ALLOWED_TOP; forbidden patterns compared case-insensitively: molecule dirs, `*.pem`, `*.key`, anything containing `vault`, `*id_rsa*`, `*id_ed25519*`, `*.envrc`, `.env*` variants, `*/.ssh` and `*/.ssh/*`, pycache, nested tarballs, importer_result.json. Widening to `*vault*` rejects any file name containing "vault" (none in the current build); - only regular files and directories (no symlinks, hardlinks, devices, fifos); - rejects absolute paths, empty/`.`/`..` components, backslashes, and control, zero-width, non-ASCII-space, surrogate, private-use and unassigned characters; the `.git` test compares after NFKC and case folding (full-width `.git`, `.GIT`); - rejects names that Windows or macOS extraction reads differently: a component ending in a space or dot, reserved device names (CON, PRN, AUX, NUL, COM1-9, LPT1-9, with or without extension), `::`, 8.3 aliases of .git (`GIT~1`), components longer than 255 bytes (such names, e.g. `aux.yml`, would be rejected if a role ever used them); - duplicates are compared case-insensitively, a name used as both file and directory (`COPYING` and `COPYING/x`) is rejected, and normalisation strips one leading `./` and one trailing `/` only (`a//b` stays rejected); - rejects an empty archive and one lacking MANIFEST.json, FILES.json, COPYING, README.md, meta/runtime.yml or changelogs/changelog.yaml; an unreadable archive is one line, exit 1. - The docstring states that ansible-galaxy dereferences FILE symlinks, so the archive check cannot see them: the "Refuse symlinks in the source tree" step of build.yml is the only guard. - build.yml: step "Refuse symlinks in the source tree" (`find` prunes ./.git and ./.venv, which is only safe because both are skipped by the build: .venv is in galaxy.yml build_ignore, .git is excluded by ansible-galaxy; a comment says the two lists must stay in step) and "Check the archive contents". Both the archive check and the galaxy-importer step now fail with a clear message unless exactly one `/tmp/dist/mortis-kamino-*.tar.gz` matches, and pass it as one quoted argument. - lint.yml: unchanged from main; the "Test the repository scripts" step comes from #16. - `tests/scripts/test_check_tarball.py`: 31 tests. Added: widened forbidden names, each ambiguity rule, ordinary names still pass, normalisation, a required file present only as `./COPYING` passes, `a//b` and `./a/b`, case-insensitive duplicates, file/directory clash, `test_real_build_passes` (builds a real tarball with ansible-galaxy from a copy of the checkout and checks it; skipped with a message when ansible-galaxy is not on PATH) and `BuildWorkflowTest` (every directory `build.yml` prunes is in galaxy.yml build_ignore or is excluded by ansible-galaxy itself). The old `test_required_set_matches_a_real_build` (it only compared the set with a copy of itself) is replaced by the real-build test. - Changelog fragment `minor_changes` updated. ## Verified - `git archive` of the merged head into a directory outside the clone, `ansible-galaxy collection build` with the clone venv: `check_tarball.py` passes ("27 entries, all allowed"; main's new files add one entry). - On the merged tree `python3 -I -m unittest discover -s tests/scripts` runs 65 tests (main's 34 plus these 31), all pass, including the real-build test (not skipped locally). - `ansible-test sanity --test pep8 --test pylint --test shebang` run locally on the script and the test file: clean. - CI at head ad2e4aa, steps observed: Build job success with "Refuse symlinks in the source tree", "Build the Collection", "Check the archive contents", "Run galaxy-importer" and "Run ansible-test sanity" all success; Lint job success with pre-commit, Check image pins, Check image versions were bumped, "Test the repository scripts", gitleaks scan and Conventional Commits. The Molecule job was still running when this was written. ## Not verified - Whether `test_real_build_passes` ran or skipped in CI (the step passed; the step log was not read). - The "exactly one tarball" guard was not exercised with two tarballs in CI. - File symlinks remain guarded only by the source-tree step. - `roles/*/molecule` ignore against a real role (no roles exist yet); a future ansible-galaxy that renames a required member would need REQUIRED updated. - Behaviour of the name rules on an actual Windows/macOS extraction (rules follow the documented reserved names, not tested there). ## Merge order #16 is merged; #15, #17 and this PR no longer conflict with main or each other on the script-test step. This PR touches a different region of build.yml than #17. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Claude added 1 commit 2026-10-25 18:24:09 +00:00
fix(build): keep repository tooling and molecule scenarios out of the Collection archive
Build / build (pull_request) Failing after 9s
Lint / lint (pull_request) Successful in 6s
Molecule / molecule (pull_request) Successful in 28s
e3acab9ca2
Extend galaxy.yml build_ignore (extensions, role molecule scenarios, CLAUDE.md, tool
directories, tests/scripts) and add scripts/check_tarball.py, an allow-list check run
by the Build workflow after the Collection build and before galaxy-importer.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 added 1 commit 2026-10-25 18:55:03 +00:00
fix(build): reject links, special files and unsafe paths in the Collection archive
Build / build (pull_request) Failing after 8s
Lint / lint (pull_request) Successful in 5s
Molecule / molecule (pull_request) Successful in 35s
580df0b892
check_tarball.py now iterates the tar members instead of their names. Only regular
files and directories are allowed, so a symlink or hardlink cannot smuggle a
file in under an allowed directory. Absolute paths and paths with an empty, '.',
'..' or '.git' component are rejected, so roles/../.venv/x no longer passes the
top-level allow list. Tests build crafted tarballs and run the script on them.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 added 1 commit 2026-10-25 19:22:24 +00:00
fix(build): harden the Collection archive check and refuse source symlinks
Build / build (pull_request) Successful in 9s
Lint / lint (pull_request) Successful in 6s
Molecule / molecule (pull_request) Successful in 30s
b5751e14d6
check_tarball.py now compares path components case-insensitively (.GIT,
Molecule), rejects backslashes and control or zero-width characters,
duplicate members, an empty archive and a missing REQUIRED file, and
reports an unreadable archive as one line. Drop the shebang and the
executable bit and pass check= to subprocess.run so ansible-test sanity
passes.

ansible-galaxy dereferences symlinks, which the archive check cannot see,
so the Build workflow fails when the source tree holds a symlink.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 added 1 commit 2026-10-25 19:57:47 +00:00
fix(ci): tighten the Collection archive check and make its guards testable
Build / build (pull_request) Successful in 9s
Lint / lint (pull_request) Successful in 8s
Molecule / molecule (pull_request) Successful in 29s
cab2187c89
The forbidden names widen to anything containing "vault", SSH keys, .envrc and
.env* files. Names that Windows or macOS extraction would read differently are
rejected (trailing space or dot, reserved device names, "::", 8.3 aliases of
.git, non-ASCII spaces, surrogate/private-use/unassigned characters, components
over 255 bytes), and the .git test compares after NFKC and case folding.
Duplicates are compared case-insensitively, a name that is both a file and a
directory is rejected, and only one slash is stripped. A unit test builds a real
tarball with ansible-galaxy, another asserts the directories build.yml prunes are
in galaxy.yml build_ignore, lint.yml runs tests/scripts, and the Build workflow
fails unless exactly one tarball matches. The docstring states that file
symlinks are invisible to the archive check.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 added 1 commit 2026-10-25 20:24:05 +00:00
merge: bring main into fix/collection-tarball-contents and keep one script-test step
Build / build (pull_request) Successful in 11s
Lint / lint (pull_request) Successful in 11s
Molecule / molecule (pull_request) Successful in 37s
ad2e4aa959
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
Defame1297 added 1 commit 2026-10-25 20:39:07 +00:00
Merge branch 'main' into fix/collection-tarball-contents
Build / build (pull_request) Successful in 10s
Lint / lint (pull_request) Successful in 10s
Molecule / molecule (pull_request) Successful in 31s
3852bce32a
Defame1297 scheduled this pull request to auto merge when all checks succeed 2026-10-25 20:39:17 +00:00
Defame1297 merged commit ce0a98a471 into main 2026-10-25 20:40:01 +00:00
Defame1297 deleted branch fix/collection-tarball-contents 2026-10-25 20:40:01 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#18