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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Rust: Update legacy MaD models 1 #19934

wants to merge 3 commits into from

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
- ["core::panicking::panic_fmt", "Argument[0]", "log-injection", "manual"]
- ["core::panicking::assert_failed", "Argument[3].Field[core::option::Option::Some(0)]", "log-injection", "manual"]
- ["<core::option::Option>::expect", "Argument[0]", "log-injection", "manual"]
- ["<core::option::Option as log_err::LogErrOption>::log_expect", "Argument[0]", "log-injection", "manual"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We may be able to simplify / generalize paths such as this one, for the time being I'm trying to translate as close to mechanically as I can.

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.

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

1 participant