Skip to content

Commit ba20880

Browse files
committed
feat: adapt rule to identify caching via actions/setup-node
1 parent c91dcd3 commit ba20880

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

rules/src/github-actions/publish-actions-cache-used.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,23 @@ rules:
1515
Using GitHub's Action Cache in publishing workflows, especially in open source repositories, can be dangerous. See
1616
https://github.com/MetaMask/MetaMask-planning/issues/3925 for more details and alternative recommendations.
1717
patterns:
18-
- pattern: "uses: $ACTION_NAME"
18+
- pattern-either:
19+
- patterns:
20+
- pattern: "uses: $ACTION_CACHE"
1921
- metavariable-regex:
20-
metavariable: $ACTION_NAME
21-
regex: actions/cache@.+
22+
metavariable: $ACTION_CACHE
23+
regex: (actions/cache@.+)
24+
- patterns:
25+
- pattern-inside: |
26+
...
27+
uses: $SETUP_NODE
28+
with:
29+
...
30+
- pattern: |
31+
cache: ...
32+
- metavariable-regex:
33+
metavariable: $SETUP_NODE
34+
regex: (actions/setup-node@.*)
2235
paths:
2336
include:
2437
- ".github/**/*publish*.yml"

rules/test/github-actions/publish-actions-cache-used.test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
uses: actions/setup-node@v4
2828
with:
2929
node-version-file: '.nvmrc'
30+
# ruleid: publish-actions-cache-used
3031
cache: yarn
3132
# ruleid: publish-actions-cache-used
3233
- uses: actions/cache@v4

0 commit comments

Comments
 (0)