Skip to content

Rust: Make crate fallback logic more conservative in path resolution library - #1

Open
anurag6569201 wants to merge 1 commit into
qa/agent-github-codeql/pr-01-22495/basefrom
qa/agent-github-codeql/pr-01-22495/head
Open

Rust: Make crate fallback logic more conservative in path resolution library#1
anurag6569201 wants to merge 1 commit into
qa/agent-github-codeql/pr-01-22495/basefrom
qa/agent-github-codeql/pr-01-22495/head

Conversation

@anurag6569201

Copy link
Copy Markdown

When doing a QA run for github#21795, I noticed that our fallback logic for crate dependencies can sometimes lead to combinatorial explosions. This PR alleviates this by only applying the fallback logic to crates that have a unique latest version. DCA confirms that this PR resolves the performance issue, most notably on the reflaxe-rust project, where the hxrt crate exists in many test copies (e.g. https://github.com/fullofcaffeine/reflaxe.rust/blob/main/test/snapshot/abstracts_conversions/intended/hxrt/Cargo.toml).

Source merge-base: b0fa3e770386f18fd4d63225301ea4c41e7a5721
Source head: df7d49d1e0aff059ee3e93bd72434ca7813a0c3b

@shipwright-agent

Copy link
Copy Markdown

⛔ Shipwright · Blocked

Recommendation: do not merge PR #1 · Tier T2
Checks: 0 total · 0 needing attention

Next step: resolve the blocking findings before merge.

Findings (14)

  • CRITICAL The shared leftPad changed from 3-digit to 4-digit padding. · shared/util/codeql/util/SemVer.qll:8
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • CRITICAL The new padSemVer regexes use '.*' after numeric components, so getMajor can match strings that are not valid SemVer, such as '123abc'. · shared/util/codeql/util/SemVer.qll:15
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun 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 · shared/util/codeql/util/SemVer.qll:8
    • Fix: Fix the review finding before release.
  • HIGH The new 'padSemVer' uses 'leftPad' with 4-digit padding, but the removed Ruby 'normalizeSemver' used 3-digit padding. · shared/util/codeql/util/SemVer.qll:8
    • Fix: Fix the review finding before release.
  • HIGH The shared SemVer utility silently changes behavior across Go, JavaScript, and Ruby by mixing previously different regex strictness and padding widths. · shared/util/codeql/util/SemVer.qll:8
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • HIGH The new shared padSemVer accepts an optional leading 'v' in getMajor/getMinor/getPatch. · shared/util/codeql/util/SemVer.qll:15
    • Fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
  • MEDIUM The new 'padSemVer' regexes in 'getMajor', 'getMinor', and 'getPatch' accept an optional leading 'v' ('v?(\d+)...'). · shared/util/codeql/util/SemVer.qll:15
    • Fix: Fix the review finding before release.
  • 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'). · shared/util/codeql/util/SemVer.qll:15
    • Fix: Fix the review finding before release.
  • …and 6 more findings in the check details.

Fireworks usage: 13,727 input · 1,826 output · 15,553 total tokens · $0.0042 · 23s · 0 fix iteration(s)

Open the Shipwright check for full evidence and the audit bundle. Use /shipwright rerun to verify again.

module;

bindingset[str]
private string leftPad(string str) { result = ("0000" + str).suffix(str.length()) }

Copy link
Copy Markdown

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.

*/
bindingset[s]
string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

module;

bindingset[str]
private string leftPad(string str) { result = ("0000" + str).suffix(str.length()) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

module;

bindingset[str]
private string leftPad(string str) { result = ("0000" + str).suffix(str.length()) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

module;

bindingset[str]
private string leftPad(string str) { result = ("0000" + str).suffix(str.length()) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

*/
bindingset[s]
string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

*/
bindingset[s]
string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

*/
bindingset[s]
string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

*/
bindingset[s]
string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

*/
bindingset[s]
string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

*/
bindingset[s]
string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

*/
bindingset[s]
string getMajor(string s) { result = s.regexpCapture("v?(\\d+).*", 1) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant