Skip to content

Rust: Update legacy MaD models 1 #19934

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 3 commits into from
Jul 3, 2025
Merged

Rust: Update legacy MaD models 1 #19934

merged 3 commits into from
Jul 3, 2025

Conversation

geoffw0
Copy link
Contributor

@geoffw0 geoffw0 commented Jun 30, 2025

Update some legacy MaD models to the new model format. This PR does perhaps a third of the models, I have more unfinished translations locally but I want to start pushing some of this work through CI + DCA and find out if there are going to be any issues there.

@geoffw0 geoffw0 added the Rust Pull requests that update Rust code label Jun 30, 2025
Copy link
Contributor Author

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

There were quite a lot of changes in tests - mostly trivial changes to MaD model strings and references, but also a handful of lost sources...

let path = e.path(); // $ MISSING: Alert[rust/summary/taint-sources]
let file_name = e.file_name(); // $ MISSING: Alert[rust/summary/taint-sources]
sink(path); // $ MISSING: hasTaintFlow
sink(file_name); // $ MISSING: hasTaintFlow
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hvitved I'm looking to get these results back. The sources go missing because there's no result for getCanonicalPath on lines 423 and 424, I'm guessing that means we haven't inferred the type of e / entry due to limitations of type inference on for loops (line 421).

If you agree that's the problem, do you have an idea what the general case for inferForLoopExprType should look like? I think we need to get the type of the Iterator (returned by fs::read_dir in this case) and pull it apart for it's Item type.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, it must be because we cannot currently infer the type of e, which means we cannot resolve the e.path() call (note that it is not e.path() itself that has a canonical path, it is the (missing) target that has a canonical path).

If you agree that's the problem, do you have an idea what the general case for inferForLoopExprType should look like? I think we need to get the type of the Iterator (returned by fs::read_dir in this case) and pull it apart for it's Item type.

Correct; I will give it a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Let me know if there's anything I can do to help.

@geoffw0
Copy link
Contributor Author

geoffw0 commented Jul 1, 2025

DCA results - interestingly enough DCA does not show a loss of sources, it actually recognises a handful more, though a significant number of query sinks and 4 query results are lost. The lost results are the FPs we gained in #19881, I'm not too worried about them right now. The lost sinks I've narrowed down to the <core::option::Option>::expect model but I'm fairly sure that model is correct. However getCanonicalPath() is rarely succeeding in this cases, I think many are quite complex (generated in macros) and do not have a found getStaticTarget().

I don't think we should insist on fixing these now. I do think we need continue putting effort into getting type inference, call targets and canonical paths working in more cases to recover these losses.

@geoffw0 geoffw0 added the no-change-note-required This PR does not need a change note label Jul 1, 2025
@geoffw0 geoffw0 marked this pull request as ready for review July 1, 2025 12:26
@geoffw0 geoffw0 requested a review from a team as a code owner July 1, 2025 12:26
let path = e.path(); // $ MISSING: Alert[rust/summary/taint-sources]
let file_name = e.file_name(); // $ MISSING: Alert[rust/summary/taint-sources]
sink(path); // $ MISSING: hasTaintFlow
sink(file_name); // $ MISSING: hasTaintFlow
Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, it must be because we cannot currently infer the type of e, which means we cannot resolve the e.path() call (note that it is not e.path() itself that has a canonical path, it is the (missing) target that has a canonical path).

If you agree that's the problem, do you have an idea what the general case for inferForLoopExprType should look like? I think we need to get the type of the Iterator (returned by fs::read_dir in this case) and pull it apart for it's Item type.

Correct; I will give it a try.

@geoffw0 geoffw0 merged commit 8315095 into github:main Jul 3, 2025
21 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