-
Notifications
You must be signed in to change notification settings - Fork 2k
Align alphaNumericRegex() with the documented grouped SHA pattern
#21838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
ef1bde7
48b1dad
0620d34
562f415
2067113
f582680
ea29986
b49b8ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * The GitHub Actions analysis now recognizes more Bash regex checks that restrict a value to alphanumeric characters. This may reduce false positive results where command output is validated with grouped or optional alphanumeric patterns before being used. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -785,7 +785,22 @@ module Bash { | |||||
|
|
||||||
| /** | ||||||
| * Holds if the given regex is used to match an alphanumeric string | ||||||
| * eg: `^[0-9a-zA-Z]{40}$`, `^[0-9]+$` or `^[a-zA-Z0-9_]+$` | ||||||
| * eg: `^[0-9a-zA-Z]{40}([0-9a-zA-Z]{24})?$`, `^[0-9]+$` or `^[a-zA-Z0-9_]+$` | ||||||
| */ | ||||||
| string alphaNumericRegex() { result = "^\\^\\[([09azAZ_-]+)\\](\\+|\\{\\d+\\})\\$$" } | ||||||
| string alphaNumericRegex() { | ||||||
| exists(string r1, string r2, string r3, string r4 | | ||||||
| // An alphanumeric character class | ||||||
| r1 = "\\[([09azAZ_-]+)\\]" and | ||||||
| // The same as above, followed by a quantifier like `+` or `{20}` | ||||||
| r2 = r1 + "(\\+|\\{\\d+\\})" and | ||||||
| // The same as above, possibly with parentheses around it | ||||||
| r3 = "\\(?" + r2 + "\\)?" and | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if there is only an open or close parenthesis?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't that make it a malformed regex? I guess you could have just a close parenthesis in a later one. Do you think this would be better?
Suggested change
If I do that I should probably include the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, then it would be malformed. |
||||||
| // The same as above, possibly with a `?` after it | ||||||
| r4 = r3 + "\\??" | ||||||
| | | ||||||
| // The same as above, repeated one or more times, and with `^` at the | ||||||
| // beginning and `$` at the end | ||||||
| result = "^\\^(" + r4 + ")+\\$$" | ||||||
| ) | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * The `actions/unpinned-tag` query now recognizes 64-character SHA-256 commit hashes as properly pinned references, in addition to 40-character SHA-1 hashes. |
Uh oh!
There was an error while loading. Please reload this page.