Skip to content

Rust: Models-as-data for flow summaries #18231

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
Dec 11, 2024

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Dec 6, 2024

Adds support for writing model-as-data flow summaries for Rust. This includes flow through variants, records, arrays, and tuples. The format is as follows

string crate, string path, string input, string output, string kind, string provenance

For example, the flow summary for unwrap is

"lang:core", "<crate::option::Option>::unwrap", "Argument[self].Variant[crate::option::Option::Some(0)]", "ReturnValue", "value", "manual"

Although this PR also adds the extensible predicates for sources and sinks, they are not yet working.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Dec 6, 2024
@hvitved hvitved force-pushed the rust/models-as-data-summaries branch from 7d0e44d to 789abc3 Compare December 6, 2024 14:05
}

// has a flow model
fn get_struct_field(s: MyStruct) -> i64 {

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 's' is not used.
}

// has a flow model
fn set_struct_field(i: i64) -> MyStruct {

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'i' is not used.
}

// has a flow model
fn get_array_element(a: [i64; 1]) -> i64 {

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'a' is not used.
}

// has a flow model
fn set_array_element(i: i64) -> [i64; 1] {

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'i' is not used.
}

// has a flow model
fn get_tuple_element(a: (i64, i64)) -> i64 {

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'a' is not used.
}

// has a flow model
fn set_tuple_element(i: i64) -> (i64, i64) {

Check notice

Code scanning / CodeQL

Unused variable Note test

Variable 'i' is not used.
@hvitved hvitved force-pushed the rust/models-as-data-summaries branch from 789abc3 to 2f8b04b Compare December 9, 2024 12:42
@hvitved hvitved marked this pull request as ready for review December 9, 2024 13:18
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.

This looks fantastic, exactly what I'm looking for!

@hvitved hvitved requested a review from geoffw0 December 11, 2024 09:32
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.

LGTM.

* `"taint"` indicates a default additional taint step and `"value"` indicates a
* globally applicable value-preserving step.
* 5. The `provenance` column is mainly used internally, and should be set to `"manual"` for
* all custom models.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great, thanks for writing it up!

@hvitved hvitved merged commit 22aaf74 into github:main Dec 11, 2024
16 checks passed
@hvitved hvitved deleted the rust/models-as-data-summaries branch December 11, 2024 12:37
@github github deleted a comment from Carlosmictlan Dec 13, 2024
@github github deleted a comment from Carlosmictlan Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants