Skip to content

Shared: Make sure getMadRepresentation is unique #19777

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 2 commits into from
Jun 16, 2025

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Jun 16, 2025

No description provided.

@github-actions github-actions bot added Rust Pull requests that update Rust code DataFlow Library labels Jun 16, 2025
@hvitved hvitved force-pushed the shared/summary-stack-mad-repr-unique branch from 5cbbc13 to 8549c3b Compare June 16, 2025 11:51
@hvitved hvitved force-pushed the shared/summary-stack-mad-repr-unique branch from 8549c3b to 631b14a Compare June 16, 2025 12:28
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Jun 16, 2025
@hvitved hvitved marked this pull request as ready for review June 16, 2025 12:52
@Copilot Copilot AI review requested due to automatic review settings June 16, 2025 12:52
@hvitved hvitved requested a review from a team as a code owner June 16, 2025 12:52
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

This PR ensures that getMadRepresentation produces unique outputs by appending a delimiter and updates the Rust core model mappings to use a consistent argument identifier case.

  • Introduce getUniqueMadRepresentation to append a trailing slash for uniqueness
  • Replace direct calls to getMadRepresentation in the summary stack builder with the unique version
  • Normalize "Self" to "self" in iterator entries of lang-core.model.yml

Reviewed Changes

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

File Description
shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll Added getUniqueMadRepresentation and updated summary stack composition logic
rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml Changed iterator argument identifier from Self to self
Comments suppressed due to low confidence (3)

shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll:690

  • There are no tests covering the new getUniqueMadRepresentation logic; consider adding unit tests to validate its behavior and ensure uniqueness is enforced correctly.
private string getUniqueMadRepresentation(SummaryComponent c) {

rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml:7

  • Ensure the lowercase self identifier matches the case sensitivity expected in all model entries; consider reviewing other mappings for consistency.
- ["lang:core", "<[_]>::iter", "Argument[self].Element", "ReturnValue.Element", "value", "manual"]

shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll:691

  • Appending a static / at the end may introduce unexpected trailing delimiters; consider trimming or choosing a clearer delimiter strategy to avoid formatting issues.
result = strictconcat(string s | s = c.getMadRepresentation() | s, "/")

@@ -686,6 +686,11 @@ module Make<
derivedFluentFlowPush(_, _, _, head, tail, _)
}

pragma[nomagic]
Copy link
Preview

Copilot AI Jun 16, 2025

Choose a reason for hiding this comment

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

Add a doc comment explaining the purpose of getUniqueMadRepresentation and why it appends a trailing / delimiter to ensure uniqueness.

Suggested change
pragma[nomagic]
pragma[nomagic]
/**
* Generates a unique string representation of the given `SummaryComponent`.
*
* This representation is used in MaD (Model and Dataflow) models to uniquely
* identify components. A trailing `/` is appended to ensure that the resulting
* string is distinct from other potential string formats and avoids collisions
* when concatenated with other representations.
*
* @param c The `SummaryComponent` to generate a representation for.
* @return A unique string representation of the component.
*/

Copilot uses AI. Check for mistakes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I have to admit I would really appreciate a description of what's going on here. What would a collision look like?

@hvitved hvitved requested a review from geoffw0 June 16, 2025 17:26
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

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

Approving to get things moving, but I would appreciate more understanding of this issue.

- ["lang:core", "<[_]>::into_iter", "Argument[Self].Element", "ReturnValue.Element", "value", "manual"]
- ["lang:core", "<[_]>::iter", "Argument[self].Element", "ReturnValue.Element", "value", "manual"]
- ["lang:core", "<[_]>::iter_mut", "Argument[self].Element", "ReturnValue.Element", "value", "manual"]
- ["lang:core", "<[_]>::into_iter", "Argument[self].Element", "ReturnValue.Element", "value", "manual"]
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -686,6 +686,11 @@ module Make<
derivedFluentFlowPush(_, _, _, head, tail, _)
}

pragma[nomagic]
Copy link
Contributor

Choose a reason for hiding this comment

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

I have to admit I would really appreciate a description of what's going on here. What would a collision look like?

@hvitved hvitved merged commit 4576880 into github:main Jun 16, 2025
41 checks passed
@hvitved
Copy link
Contributor Author

hvitved commented Jun 16, 2025

I have to admit I would really appreciate a description of what's going on here. What would a collision look like?

@geoffw0 : For Rust, some struct fields have non-unique getCanonicalPaths right now. We may or may not be able to fix that, in all cases it is a good idea to safe-guard against it (for all languages).

@hvitved hvitved deleted the shared/summary-stack-mad-repr-unique branch June 16, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataFlow Library 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