Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Rust: Add ComparisonOperation library. #19535

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

Merged
merged 8 commits into from
May 22, 2025
Merged

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented May 20, 2025

Adds a ComparisonOperation library, filling out more of the Operation class tree.

Cleans up some out of place predicates (getGreaterOperand and getLesserOperand) in UncontrolledAllocationSizeExtensions.qll.

@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 09:29
@geoffw0 geoffw0 requested a review from a team as a code owner May 20, 2025 09:29
@geoffw0 geoffw0 added no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code labels May 20, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a new ComparisonOperation library to model comparison, equality, and relational operations in Rust QL, updates imports and cleans up legacy operand predicates, and extends library-tests to verify the new classes and operand tags.

  • Introduced ComparisonOperation.qll defining comparison, equality, and relational operations with getGreaterOperand/getLesserOperand.
  • Updated rust.qll import and refactored UncontrolledAllocationSizeExtensions.qll to use the new API.
  • Extended test.rs and Operations.ql to include new tags (ComparisonOperation, EqualityOperation, specific operation classes, and Greater/Lesser).

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rust/ql/lib/codeql/rust/elements/ComparisonOperation.qll New file defining ComparisonOperation, its subtypes, and operand accessors.
rust/ql/lib/rust.qll Imported ComparisonOperation into the Rust library root.
rust/ql/lib/codeql/rust/security/UncontrolledAllocationSizeExtensions.qll Removed old operand helpers and switched to the new RelationalOperation API.
rust/ql/test/library-tests/operations/Operations.ql Updated describe and test harness to recognize new operation tags.
rust/ql/test/library-tests/operations/test.rs Added expected tags for comparison operations and Greater/Lesser values.

rust/ql/lib/codeql/rust/elements/ComparisonOperation.qll Outdated Show resolved Hide resolved
rust/ql/lib/codeql/rust/elements/ComparisonOperation.qll Outdated Show resolved Hide resolved
/**
* The equal comparison operation, `==`.
*/
final class EqualOperation extends EqualityOperationImpl, BinaryExpr {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BinaryExpr can be removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer EqualityOperation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EqualityOperation is "an operation to do with equality", i.e. == or !=.

EqualOperation is specifically ==.

We can't use "EqualityOperation" to describe both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed redundant BinaryExpr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Then I think I slightly prefer Equal_s_Operation over EqualOperation, but I'll let you decide.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree that's a better name. Updated.

rust/ql/lib/codeql/rust/elements/ComparisonOperation.qll Outdated Show resolved Hide resolved
rust/ql/lib/codeql/rust/elements/ComparisonOperation.qll Outdated Show resolved Hide resolved
@geoffw0
Copy link
Contributor Author

geoffw0 commented May 21, 2025

Thanks for the review suggestions. I've implemented all but one (see above).

hvitved
hvitved previously approved these changes May 22, 2025
@geoffw0 geoffw0 merged commit d27596a into github:main May 22, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.