@@ -15,39 +15,85 @@ rule := poutine.rule(rego.metadata.chain())
15
15
16
16
github.events contains event if some event in {
17
17
" pull_request_target" ,
18
+ " issues" ,
18
19
" issue_comment" ,
19
20
" workflow_call" ,
20
21
}
21
22
22
23
github.workflow_run.parent.events contains event if some event in {
23
24
" pull_request_target" ,
24
25
" pull_request" ,
26
+ " issues" ,
27
+ " issue_comment" ,
25
28
}
26
29
27
30
build_github_actions[action] = {
28
- " pre-commit/action" : " pre-commit" ,
29
- " oxsecurity/megalinter" : " megalinter" ,
30
- " bridgecrewio/checkov-action" : " checkov" ,
31
- " ruby/setup-ruby" : " bundler" ,
31
+ " bundler" :{" ruby/setup-ruby" },
32
+ " cargo" :{" actions-rs/cargo" },
33
+ " checkov" :{" bridgecrewio/checkov-action" },
34
+ " docker" :{" docker/build-push-action" , " docker/setup-buildx-action" },
35
+ " eslint" :{" reviewdog/action-eslint" , " stefanoeb/eslint-action" , " tj-actions/eslint-changed-files" , " sibiraj-s/action-eslint" , " tinovyatkin/action-eslint" , " bradennapier/eslint-plus-action" , " CatChen/eslint-suggestion-action" , " iCrawl/action-eslint" , " ninosaurus/eslint-check" },
36
+ " golangci-lint" :{" golangci/golangci-lint-action" },
37
+ " goreleaser" : {" goreleaser/goreleaser-action" },
38
+ " gradle" : {" gradle/gradle-build-action" },
39
+ " maven" : {" qcastel/github-actions-maven-release" , " samuelmeuli/action-maven-publish" , " LucaFeger/action-maven-cli" },
40
+ " megalinter" :{" oxsecurity/megalinter" },
41
+ " mkdocs" : {" mhausenblas/mkdocs-deploy-gh-pages" , " athackst/mkdocs-simple-plugin" },
42
+ " msbuild" : {" MVS-Telecom/publish-nuget" },
43
+ " mypy" : {" ricardochaves/python-lint" , " jpetrucciani/mypy-check" , " sunnysid3up/python-linter" , " tsuyoshicho/action-mypy" },
44
+ " npm" : {" actions/setup-node" ," JS-DevTools/npm-publish" },
45
+ " phpstan" :{" php-actions/phpstan" },
46
+ " pip" : {" brettcannon/pip-secure-install" , " BSFishy/pip-action" },
47
+ " pre-commit" : {" dbt-checkpoint/dbt-checkpoint" , " pre-commit/action" , " pre-commit-ci/lite-action" , " browniebroke/pre-commit-autoupdate-action" , " cloudposse/github-action-pre-commit" },
48
+ " pre-commit" :{" pre-commit/action" },
49
+ " python" : {" hynek/build-and-inspect-python-package" },
50
+ " rake" : {" magefile/mage-action" },
51
+ " rubocop" : {" reviewdog/action-rubocop" , " andrewmcodes-archive/rubocop-linter-action" , " gimenete/rubocop-action" , " r7kamura/rubocop-todo-corrector" },
52
+ " sonar-scanner" : {" sonarsource/sonarqube-scan-action" },
53
+ " stylelint" :{" actions-hub/stylelint" },
54
+ " terraform" : {" OP5dev/TF-via-PR" , " dflook/terraform-plan" , " dflook/terraform-apply" },
55
+ " tflint" : {" reviewdog/action-tflint" , " devops-infra/action-tflint" },
56
+ " tofu" : {" dflook/tofu-plan" , " dflook/tofu-apply" },
57
+ " vale" : {" gaurav-nelson/github-action-vale-lint" , " errata-ai/vale-action" },
32
58
}[action]
33
59
34
60
build_commands[cmd] = {
35
61
" ant" : {" ^ant " },
62
+ " bash" : {" \\ S+\\ .sh\\ b" },
36
63
" bundler" : {" bundle install" , " bundle exec " },
37
- " cargo" : {" cargo build" , " cargo run" },
64
+ " cargo" : {" cargo build" , " cargo run" , " cargo test" , " cargo bench" },
65
+ " checkov" : {" checkov " },
66
+ " chmod" : {" ^\\ s*chmod\\ s+(?:.*\\ +x.*|\\ b(?:[0-7]{2}[1357]|[0-7][0-7]{2}[1357])\\ b)" }, # Unit test: https://regex101.com/r/tt7qzw/1
67
+ " docker" : {" docker build" }, # docker build need to also be run to have significant impact.
68
+ " eslint" : {" eslint " },
38
69
" go generate" : {" go generate" },
39
70
" gomplate" : {" gomplate " },
71
+ " goreleaser" : {" goreleaser build" , " goreleaser release" },
40
72
" gradle" : {" gradle " , " ./gradlew " , " ./gradlew.bat " }, # https://docs.gradle.org/current/userguide/gradle_wrapper_basics.html
41
73
" make" : {" make " },
42
74
" maven" : {" mvn " , " ./mvnw " , " ./mvnw.bat" , " ./mvnw.cmd" , " ./mvnw.sh " }, # https://maven.apache.org/wrapper/
43
75
" mkdocs" : {" mkdocs build" },
44
76
" msbuild" : {" msbuild " },
45
- " npm" : {" npm install" , " npm run " , " yarn " , " npm ci(\\ b|$)" },
77
+ " mypy" : {" mypy " },
78
+ " npm" : {" npm diff" , " npm restart" , " npm (rum|urn|run(-script)?)" , " npm start" , " npm stop" , " npm t(e?st)?" , " npm ver(si|is)on" ," npm (install|add|i|in|ins|inst|insta|instal|inst|isnta|isntal|isntall)" , " npm ci(\\ b|$)" },
79
+ " phpstan" : {" phpstan " },
46
80
" pip" : {" pip install" , " pipenv install" , " pipenv run " },
81
+ " powershell" : {" \\ S+\\ .ps1\\ b" },
47
82
" pre-commit" : {" pre-commit run" , " pre-commit install" },
83
+ " python" : {" ^\\ s*python(3)?\\ s+\\ S+\\ .py\\ b" }, # Unit test: https://regex101.com/r/tuap3y/1
84
+ " rake" : {" rails db:create" , " rails assets:precompile" , " ^rake " },
85
+ " rubocop" : {" rubocop" },
86
+ " sonar-scanner" : {" sonar-scanner" },
87
+ " stylelint" : {" stylelint " },
88
+ " tar" : {" tar (-?x-?P-?f|-?P-?x-?f|-?x -P -f|-?P -x -f) " }, # Unit test: https://regex101.com/r/pX85P8/1
48
89
" terraform" : {" terraform plan" , " terraform apply" },
90
+ " tflint" : {" tflint" },
49
91
" tofu" : {" tofu plan" , " tofu apply" },
92
+ " trivy" : {" trivy " },
93
+ " unzip" : {" unzip .*-:" },
50
94
" vale" : {" vale " },
95
+ " webpack" : {" webpack" },
96
+ " yarn" : {" yarn " },
51
97
}[cmd]
52
98
53
99
results contains poutine.finding (rule, pkg_purl, {
@@ -70,7 +116,24 @@ results contains poutine.finding(rule, pkg_purl, {
70
116
" event_triggers" : workflow_events,
71
117
}) if {
72
118
[pkg_purl, workflow_path, workflow_events, step] := _steps_after_untrusted_checkout[_]
73
- build_github_actions[step.action]
119
+ regex.match (
120
+ sprintf (" ([^a-z]|^)(%v)@" , [concat (" |" , build_github_actions[_])]),
121
+ step.uses,
122
+ )
123
+ }
124
+
125
+
126
+ results contains poutine.finding (rule, pkg_purl, {
127
+ " path" : workflow_path,
128
+ " line" : step.lines.uses,
129
+ " details" : sprintf (" Detected usage of a Local GitHub Action at path: `%s`" , [step.action]),
130
+ " event_triggers" : workflow_events,
131
+ }) if {
132
+ [pkg_purl, workflow_path, workflow_events, step] := _steps_after_untrusted_checkout[_]
133
+ regex.match (
134
+ ` ^\./` ,
135
+ step.action,
136
+ )
74
137
}
75
138
76
139
_steps_after_untrusted_checkout contains [pkg.purl, workflow.path, events, s.step] if {
0 commit comments