fix: local workflow recursion, recursive exclusions, and remote composite path handling#81
Conversation
- Handle local action paths and local reusable workflow paths separately, matching GitHub semantics. - Recurse into local reusable workflows during extraction. - Apply exclude-workflows inside that recursion. - Stop recursion on local reusable workflow cycles. - Reject workflow paths that escape the workspace.
Intent: - make exclude-workflows mean the same thing everywhere - let exclusions win even when workflows is set - skip excluded reusable workflows during recursive traversal Technical: - apply exclude-workflows after top-level workflow selection in both modes - drop excluded reusable workflow refs before adding them to the action set - propagate excludeWorkflowPatterns through remote recursion - add tests for workflows+exclude-workflows overlap and excluded remote reusable traversal
Background: - 12c5e55 added remote composite recursion - it also started resolving nested `./...` refs relative to the composite action directory Why: - `./...` is the local-path form in GitHub Actions - a remote ref only exists in `{owner}/{repo}/...@ref` form - so treating `./...` inside a remote composite action as action-directory-relative remote content cannot work under the documented syntax - for this scanner, such refs must be interpreted as repo-root paths if we expand them at all Technical: - stop joining remote composite local refs with `action.actionPath` - normalize `./...` directly from repo root - update regression coverage to use a repo-root `.github/actions/...` lookup
Replace the regex-based action reference parser with deterministic string parsing to avoid polynomial backtracking on malformed uses strings. Keep support for owner/repo, single-segment path, and multi-segment path references, and add parser coverage for invalid and multi-segment path cases.
9764080 to
b7eddf8
Compare
|
I would happily make you owner of the test and fixture repos if you want - I would then fork them. Just tell if you want that. Example of complexity: Change commit A in fixtures repo
|
…ecursion-and-exclusions
There was a problem hiding this comment.
Pull request overview
This PR improves recursive workflow/action traversal for the Ensure Immutable Actions GitHub Action by correctly distinguishing local reusable workflows from local actions, honoring exclude-workflows across traversal/expansion, and tightening uses: reference parsing.
Changes:
- Reworked
uses:parsing to deterministic string parsing (no regex backtracking) and added malformed-input test coverage. - Added local reusable workflow detection/recursion with cycle prevention, and threaded
exclude-workflowsthrough traversal. - Fixed remote composite
./...reference handling to resolve from repo root, and expanded tests/docs accordingly.
Show a summary per file
| File | Description |
|---|---|
| src/index.js | Core logic changes: hardened parsing, local reusable workflow recursion, exclude-workflows propagation, and remote composite ./... handling. |
| tests/index.test.js | Added/updated tests for multi-segment action paths, malformed uses parsing, local reusable workflow recursion/exclusion, and remote traversal behaviors. |
| README.md | Updated exclude-workflows input docs to reflect new behavior. |
| badges/coverage.svg | Updated coverage badge output. |
Copilot's findings
- Files reviewed: 3/4 changed files
- Comments generated: 5
|
Thanks for the thorough PR @Wuodan! I pushed a small fixup commit (44d5098) to address the review findings. Here's what I changed:
One thing I want to flag for discussion: the |
- Remove unused baseDir parameter from extractActionsFromLocalReusableWorkflow
- Move exclusion check before file I/O to prevent excluded+missing files
from surfacing as unsupported findings
- Handle normalize('./') edge case in remote composite expansion that
would produce malformed owner/repo/.@ref references
- Update action.yml exclude-workflows description to match new behavior
- Remove extra ignored argument in resolveLocalReusableWorkflowPath test
- Bump version to 2.5.3
1b046d6 to
44d5098
Compare
- Apply the same resolvedPath === '.' guard to expandRemoteReusableWorkflow (both job-level and step-level ./ refs) to prevent malformed owner/repo/.@ref references - Remove extra ignored argument in path traversal test
📦 Draft Release CreatedA draft release v2.5.3 has been created for this PR. Next Steps
|
Summary
This PR contains 3 functional fixes and 1 parser hardening change:
Fixes
1. Handle local reusable workflows separately from local actions
2. Respect exclude-workflows throughout traversal
3. Resolve remote composite local refs from repo root
4. Harden action reference parsing
Validation
I validated these changes using two companion repos for recursive test coverage:
Reference runs: