Skip to content

Commit 7394d78

Browse files
ralyodioclaude
andcommitted
fix(actions/threatcrush-scan): ship the converter to an allowed destination
Every test in packages/actions failed with "Invalid action-pack manifest: 1 issue(s)" — the pack sent threatcrush-to-sarif.py to .github/, which the destination allowlist rejects. Because each test loads the whole catalog, one bad manifest took all 15 down, including the four unrelated packs. Move the converter to .github/scripts/ and update the workflow, README and test expectations to match. Also fix the pull_request_target assertion, which the manifest error had been masking: it substring-matched the entire rendered workflow, so the comment explaining why the pack deliberately stays on `pull_request` tripped it. Strip comments first and assert on the trigger block, so the check tests the directive rather than forbidding its own rationale. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 360055a commit 7394d78

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

packages/actions/src/index.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('built-in packs', () => {
4141
// Workflow plus the legacy-output converter it falls back to.
4242
expect(entry?.manifest.files.map((f) => f.destination)).toEqual([
4343
'.github/workflows/threatcrush-scan.yml',
44-
'.github/threatcrush-to-sarif.py',
44+
'.github/scripts/threatcrush-to-sarif.py',
4545
]);
4646
});
4747

@@ -215,7 +215,7 @@ describe('built-in packs', () => {
215215
expect(content).toContain('if [ ! -s threatcrush.sarif ]; then');
216216
// A CLI without --format takes the converter path rather than failing the
217217
// repo out of being scanned at all.
218-
expect(content).toContain('.github/threatcrush-to-sarif.py');
218+
expect(content).toContain('.github/scripts/threatcrush-to-sarif.py');
219219
expect(content).toContain('this diff was NOT scanned');
220220
// And the report must be fail-closed. Testing for status == "error" was
221221
// fail-open: when the capability check fails the scan step is *skipped*,
@@ -236,7 +236,16 @@ describe('built-in packs', () => {
236236
manifest: entry.manifest,
237237
inputs: {},
238238
});
239-
expect(result.files[0]?.content).not.toContain('pull_request_target');
239+
// Comments are stripped first: the workflow documents why it stays on
240+
// `pull_request`, and a raw substring check would forbid explaining the
241+
// very decision it exists to protect. What matters is that no directive
242+
// selects the event.
243+
const directives = (result.files[0]?.content ?? '')
244+
.split('\n')
245+
.filter((line) => !/^\s*#/.test(line))
246+
.join('\n');
247+
expect(directives).not.toContain('pull_request_target');
248+
expect(directives).toMatch(/^on:\n\s+pull_request:\s*$/m);
240249
expect(entry.manifest.security.allowPullRequestTarget).toBe(false);
241250
});
242251
});

packages/actions/threatcrush-scan/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ scanning, and picks accordingly:
3434
| CLI | Path |
3535
| --- | --- |
3636
| Has `--format` | Native SARIF. Preferred; nothing is parsed. |
37-
| Older | Runs the text scan and converts it with `.github/threatcrush-to-sarif.py`. |
37+
| Older | Runs the text scan and converts it with `.github/scripts/threatcrush-to-sarif.py`. |
3838

3939
The check happens up front because exit codes cannot tell the two failures
4040
apart. The published `0.2.2` has no `--format`: the scan died with

packages/actions/threatcrush-scan/sh1pt.actionpack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ files:
6363
# the native path whenever it is available — but shipping it means a repo is
6464
# scanned today rather than waiting on a release.
6565
- source: threatcrush-to-sarif.py
66-
destination: .github/threatcrush-to-sarif.py
66+
destination: .github/scripts/threatcrush-to-sarif.py
6767
mergeStrategy: replace-managed
6868
policies:
6969
installMode: pull-request

packages/actions/threatcrush-scan/workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
# every finding reads as out-of-scope.
9292
PREFIX="$SCAN_PATH"
9393
fi
94-
python3 .github/threatcrush-to-sarif.py \
94+
python3 .github/scripts/threatcrush-to-sarif.py \
9595
--input threatcrush-output.txt \
9696
--output threatcrush.sarif \
9797
--path-prefix "$PREFIX" \

0 commit comments

Comments
 (0)