Skip to content

Conversation

@paldepind
Copy link
Contributor

@paldepind paldepind commented Nov 25, 2025

This PR:

  • Changes the isStruct predicates for Struct and Enum. Including unit-like structs/enums in this was inconsistent with Rust terminology.
  • Adds predicates to Enum for fieldless and unit-only enums. I think the fieldless notion can be very useful as barriers, similar to what we have for numbers and booleans. A fieldless enum can't cary sensitive data or do injections. I also want to use it over in Rust: Lift content reads as taint steps #20879.

The DCA report is clean 👍

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Nov 25, 2025
@paldepind paldepind added the no-change-note-required This PR does not need a change note label Nov 25, 2025
@paldepind paldepind marked this pull request as ready for review November 25, 2025 13:22
@paldepind paldepind requested a review from a team as a code owner November 25, 2025 13:22
Copilot AI review requested due to automatic review settings November 25, 2025 13:22
Copilot finished reviewing on behalf of paldepind November 25, 2025 13:25
Copy link
Contributor

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

This PR refines the CodeQL Rust library's handling of enum and struct predicates to align with Rust terminology and adds new predicates for classifying enum types.

  • Changes isStruct() predicates to check for actual struct field lists rather than using negation logic
  • Adds isUnit() predicates for structs and variants without field lists
  • Introduces isFieldless() and isUnitOnly() predicates for enums with comprehensive test coverage

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rust/ql/test/library-tests/elements/enum/enums.rs Adds test data with four enum examples covering unit-only, fieldless, and field-containing enums
rust/ql/test/library-tests/elements/enum/Enum.ql Adds test queries for the new isFieldless() and isUnitOnly() predicates
rust/ql/test/library-tests/elements/enum/Enum.expected Defines expected test results showing correct classification of enums
rust/ql/test/library-tests/elements/enum/Cargo.lock Standard Cargo lock file for test project
rust/ql/lib/codeql/rust/elements/internal/VariantImpl.qll Refactors isStruct() to check field list type, adds isUnit() and getNumberOfFields() predicates
rust/ql/lib/codeql/rust/elements/internal/StructImpl.qll Refactors isStruct() to check field list type and adds isUnit() predicate
rust/ql/lib/codeql/rust/elements/internal/EnumImpl.qll Implements new isFieldless() and isUnitOnly() predicates with proper documentation
rust/ql/lib/codeql/rust/internal/TypeInference.qll Updates struct/variant declarations to include unit types alongside struct types
rust/ql/lib/codeql/rust/internal/PathResolution.qll Updates namespace resolution to use isStruct() predicate instead of checking field list type directly

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

LGTM

@paldepind paldepind merged commit 1c8cc39 into github:main Nov 26, 2025
29 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.

2 participants