Skip to content

Commit c0152a4

Browse files
committed
rename getAReferencedExpression to getASimpleReferenceExpression and add examples of what it can parse
1 parent dc1dc2a commit c0152a4

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

javascript/ql/lib/semmle/javascript/Actions.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ module Actions {
237237
/**
238238
* Holds if `${{ e }}` is a GitHub Actions expression evaluated within this `run` command.
239239
* See https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions.
240+
* Only finds simple expressions like `${{ github.event.comment.body }}`, where the expression contains only alphanumeric characters, underscores, dots, or dashes.
241+
* Does not identify more complicated expressions like `${{ fromJSON(env.time) }}`, or ${{ format('{{Hello {0}!}}', github.event.head_commit.author.name) }}
240242
*/
241-
string getAReferencedExpression() {
243+
string getASimpleReferenceExpression() {
242244
// We use `regexpFind` to obtain *all* matches of `${{...}}`,
243245
// not just the last (greedy match) or first (reluctant match).
244-
// TODO: This only handles expression strings that refer to contexts.
245-
// It does not handle operators within the expression.
246246
result =
247247
this.getValue()
248248
.regexpFind("\\$\\{\\{\\s*[A-Za-z0-9_\\.\\-]+\\s*\\}\\}", _, _)

javascript/ql/src/Security/CWE-094/ExpressionInjection.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private predicate isExternalUserControlledDiscussion(string context) {
8080

8181
from Actions::Run run, string context, Actions::On on
8282
where
83-
run.getAReferencedExpression() = context and
83+
run.getASimpleReferenceExpression() = context and
8484
run.getStep().getJob().getWorkflow().getOn() = on and
8585
(
8686
exists(on.getNode("issues")) and

0 commit comments

Comments
 (0)