-
Notifications
You must be signed in to change notification settings - Fork 0
Rust: Make crate fallback logic more conservative in path resolution library #1
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: qa/agent-github-codeql/pr-01-22495/base
Are you sure you want to change the base?
Changes from all commits
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,57 @@ | ||
| /** | ||
| * Provides logic for working SemVer (Semantic Versioning). | ||
| */ | ||
| overlay[local?] | ||
| module; | ||
|
|
||
| bindingset[str] | ||
| private string leftPad(string str) { result = ("0000" + str).suffix(str.length()) } | ||
|
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. Shipwright · HIGH The new shared 'leftPad' uses '("0000" + str).suffix(str.length())', which pads to 4 digits, while the removed Go/Ruby implementations used '("000" + str).suffix(str.length())', pa Impact: The new shared 'leftPad' uses '("0000" + str).suffix(str.length())', which pads to 4 digits, while the removed Go/Ruby implementations used '("000" + str).suffix(str.length())', padding to 3 digits. This changes normalized version ordering for versions with 4+ digit components. For example, '1.2.1000' and '1.2.999' now compare differently than before, potentially producing incorrect 'maybeBefore'/'maybeAfter'/'maybe… Suggested fix: Fix the review finding before release. 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. Shipwright · HIGH The new 'padSemVer' uses 'leftPad' with 4-digit padding, but the removed Ruby 'normalizeSemver' used 3-digit padding. Impact: The new 'padSemVer' uses 'leftPad' with 4-digit padding, but the removed Ruby 'normalizeSemver' used 3-digit padding. This changes the normalized representation for Ruby Gemfile version comparisons, potentially altering 'before', 'equal', and 'after' results for versions with 4+ digit components. Suggested fix: Fix the review finding before release. 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. Shipwright · HIGH The shared SemVer utility silently changes behavior across Go, JavaScript, and Ruby by mixing previously different regex strictness and padding widths. Impact: The shared SemVer utility silently changes behavior across Go, JavaScript, and Ruby by mixing previously different regex strictness and padding widths. There is no comment or test evidence documenting that 4-digit padding and optional 'v' are intentional, making it hard for a newcomer to understand whether the behavioral changes are deliberate or accidental. Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright. |
||
|
|
||
| /** | ||
| * Gets the major number of a SemVer string. | ||
| */ | ||
| bindingset[s] | ||
| string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) } | ||
|
|
||
|
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. Shipwright · CRITICAL The new padSemVer regexes use '.*' after numeric components, so getMajor can match strings that are not valid SemVer, such as '123abc'. Impact: The new padSemVer regexes use '.*' after numeric components, so getMajor can match strings that are not valid SemVer, such as '123abc'. The removed Go and JavaScript implementations required a full SemVer pattern. This loosening can cause non-SemVer strings to be normalized and compared, producing incorrect version ordering results. Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright. 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. Shipwright · HIGH The new shared padSemVer accepts an optional leading 'v' in getMajor/getMinor/getPatch. Impact: The new shared padSemVer accepts an optional leading 'v' in getMajor/getMinor/getPatch. The removed JavaScript and Ruby implementations did not accept a leading 'v'. JavaScript dependency versions such as 'v1.2.3' that previously did not normalize now normalize and participate in version comparisons, changing query results for JavaScript and Ruby dependencies. Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright. 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. Shipwright · MEDIUM The new 'padSemVer' regexes in 'getMajor', 'getMinor', and 'getPatch' accept an optional leading 'v' ('v?(\d+)...'). Impact: The new 'padSemVer' regexes in 'getMajor', 'getMinor', and 'getPatch' accept an optional leading 'v' ('v?(\d+)...'). The removed Go 'normalizeSemver' also accepted 'v?', but the removed JavaScript 'normalizeSemver' did not. JavaScript dependency versions such as 'v1.2.3' that previously did not normalize now normalize and participate in version comparisons, changing query results for JavaScript dependencies. Suggested fix: Fix the review finding before release. 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. Shipwright · MEDIUM The new 'padSemVer' regexes use '.*' after the numeric component, so 'getMajor' can match a string that starts with digits but is not a valid SemVer (e.g., '123abc'). Impact: The new 'padSemVer' regexes use '.' after the numeric component, so 'getMajor' can match a string that starts with digits but is not a valid SemVer (e.g., '123abc'). The removed Go implementation required a full SemVer pattern 'v?(\d+)\.(\d+)\.(\d+)(\D.)?', and the removed JavaScript implementation required '(\d+)\.(\d+)\.(\d+)'. This loosening can cause non-SemVer strings to be normalized and compared,… Suggested fix: Fix the review finding before release. 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. Shipwright · MEDIUM The new 'padSemVer' regexes accept an optional leading 'v', but the removed Ruby 'getMajor', 'getMinor', and 'getPatch' did not. Impact: The new 'padSemVer' regexes accept an optional leading 'v', but the removed Ruby 'getMajor', 'getMinor', and 'getPatch' did not. Ruby Gemfile version strings such as 'v1.2.3' that previously did not normalize now normalize and participate in version comparisons, changing query results for Ruby dependencies. Suggested fix: Fix the review finding before release. 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. Shipwright · MEDIUM The new 'padSemVer' regexes use '.*' after the numeric component, so 'getMajor' can match a string that starts with digits but is not a valid SemVer. Impact: The new 'padSemVer' regexes use '.' after the numeric component, so 'getMajor' can match a string that starts with digits but is not a valid SemVer. The removed Go 'normalizeSemver' required a full SemVer pattern 'v?(\d+)\.(\d+)\.(\d+)(\D.)?'. This loosening can cause non-SemVer strings to be normalized and compared, producing incorrect version ordering results. Suggested fix: Fix the review finding before release. 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. Shipwright · MEDIUM The new 'padSemVer' regexes accept an optional leading 'v', but the removed JavaScript 'normalizeSemver' did not. Impact: The new 'padSemVer' regexes accept an optional leading 'v', but the removed JavaScript 'normalizeSemver' did not. JavaScript dependency versions such as 'v1.2.3' that previously did not normalize now normalize and participate in version comparisons, changing query results for JavaScript dependencies. Suggested fix: Fix the review finding before release. 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. Shipwright · MEDIUM The new 'padSemVer' regexes accept an optional leading 'v', but the removed Go 'normalizeSemver' also accepted 'v?', so this is not a new defect for Go. Impact: The new 'padSemVer' regexes accept an optional leading 'v', but the removed Go 'normalizeSemver' also accepted 'v?', so this is not a new defect for Go. However, the shared implementation now applies this looser matching to JavaScript and Ruby, which previously did not accept a leading 'v'. This can cause non-SemVer strings to be normalized and compared, producing incorrect version ordering results. Suggested fix: Fix the review finding before release. |
||
| /** | ||
| * Gets the minor number of a SemVer string. | ||
| */ | ||
| bindingset[s] | ||
| string getMinor(string s) { result = s.regexpCapture("v?(\\d+)\\.(\\d+).*", 2) } | ||
|
|
||
| /** | ||
| * Gets the patch number of a SemVer string. | ||
| */ | ||
| bindingset[s] | ||
| string getPatch(string s) { result = s.regexpCapture("v?(\\d+)\\.(\\d+)\\.(\\d+).*", 3) } | ||
|
|
||
| /** | ||
| * Normalizes a SemVer string such that the lexicographical ordering | ||
| * of two normalized strings is consistent with the SemVer ordering. | ||
| * | ||
| * Pre-release information and build metadata is not yet supported. | ||
| */ | ||
| bindingset[orig] | ||
| string padSemVer(string orig, string major, string minor, string patch) { | ||
| major = getMajor(orig) and | ||
| ( | ||
| minor = getMinor(orig) | ||
| or | ||
| not exists(getMinor(orig)) and minor = "0" | ||
| ) and | ||
| ( | ||
| patch = getPatch(orig) | ||
| or | ||
| not exists(getPatch(orig)) and patch = "0" | ||
| ) and | ||
| result = leftPad(major) + "." + leftPad(minor) + "." + leftPad(patch) | ||
| } | ||
|
|
||
| /** | ||
| * Normalizes a SemVer string such that the lexicographical ordering | ||
| * of two normalized strings is consistent with the SemVer ordering. | ||
| * | ||
| * Pre-release information and build metadata is not yet supported. | ||
| */ | ||
| bindingset[orig] | ||
| string padSemVer(string orig) { result = padSemVer(orig, _, _, _) } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shipwright · CRITICAL
The shared leftPad changed from 3-digit to 4-digit padding.
Impact: The shared leftPad changed from 3-digit to 4-digit padding. This alters lexicographic ordering for version components with 4+ digits. For example, 1.2.1000 vs 1.2.999 now compares differently than the previous Go/Ruby implementations, producing incorrect maybeBefore/maybeAfter/maybeBetween and before/equal/after results.
Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.