Skip to content

Commit db30721

Browse files
authored
bugfix: template-injection: mark another context as safe (#675)
1 parent 07d2c24 commit db30721

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

docs/release-notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ of `zizmor`.
6363
location spans for YAML inputs with comments inside block sequences (#660)
6464
* The [template-injection] audit no longer considers
6565
`github.job` dangerous (#661)
66+
* The [template-injection] audit no longer considers
67+
`github.event.pull_request.head.repo.fork` dangerous (#675)
6668

6769
## v1.5.2
6870

src/audit/template_injection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const SAFE_CONTEXTS: &[&str] = &[
4646
"github.event.number",
4747
"github.event.pull_request.base.sha", // hexadecimal SHA ref
4848
"github.event.pull_request.head.sha", // hexadecimal SHA ref
49+
"github.event.pull_request.head.repo.fork", // boolean
4950
"github.event.pull_request.commits", // number of commits in PR
5051
"github.event.pull_request.number", // the PR's own number
5152
"github.event.workflow_run.id",

tests/integration/snapshot.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@ fn template_injection() -> Result<()> {
329329
.run()?
330330
);
331331

332+
insta::assert_snapshot!(
333+
zizmor()
334+
.input(input_under_test(
335+
"template-injection/false-positive-menagerie.yml"
336+
))
337+
.run()?
338+
);
339+
332340
Ok(())
333341
}
334342

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
source: tests/integration/snapshot.rs
3+
expression: "zizmor().input(input_under_test(\"template-injection/false-positive-menagerie.yml\")).run()?"
4+
---
5+
No findings to report. Good job!
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: false-positive-menagerie
2+
3+
on: pull_request
4+
5+
permissions: {}
6+
7+
jobs:
8+
false-positive-menagerie:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: false-positive-menagerie
13+
run: |
14+
# PR#402
15+
echo "${{ github.action_path }}"
16+
# PR#412
17+
echo "${{ github.server_url }}"
18+
# PR#445
19+
echo "${{ github.event.pull_request.base.sha }}"
20+
# PR#636
21+
echo "${{ github.event.pull_request.head.sha }}"
22+
# PR#661
23+
echo "${{ github.job }}"
24+
# PR#675
25+
echo "${{ github.event.pull_request.head.repo.fork }}"

0 commit comments

Comments
 (0)