Skip to content

Commit 1904b02

Browse files
committed
Actions: Avoid blowup in quotation parser
The parser has an inherent N^2 blowup and will need a rewrite eventually. For now I'm just trying to make it not blow up as often.
1 parent e6b5040 commit 1904b02

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

actions/ql/lib/codeql/actions/Bash.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ class BashShellScript extends ShellScript {
8181
"qstr:" + k + ":" + i + ":" + j + ":" + quotedStr.length() + ":" +
8282
quotedStr.regexpReplaceAll("[^a-zA-Z0-9]", "")
8383
)
84-
)
84+
) and
85+
// Only do this for strings that might otherwise disrupt subsequent parsing
86+
quotedStr.regexpMatch("[\"'].*[$\n\r'\"" + Bash::separator() + "].*[\"']")
8587
}
8688

8789
private predicate rankedQuotedStringReplacements(int i, string old, string new) {

0 commit comments

Comments
 (0)