Skip to content

Commit

Permalink
Rust: Add a model for unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Nov 27, 2024
1 parent 5cd9ff4 commit 3bb1ae0
Show file tree
Hide file tree
Showing 4 changed files with 246 additions and 216 deletions.
11 changes: 11 additions & 0 deletions rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ private import internal.DataFlowImpl
// import all instances below
private module Summaries {
private import codeql.rust.Frameworks

// TODO: Used models-as-data when it's available
private class UnwrapSummary extends SummarizedCallable::Range {
UnwrapSummary() { this = "lang:core::_::<crate::option::Option>::unwrap" }

override predicate propagatesFlow(string input, string output, boolean preservesValue) {
input = "Argument[self].Variant[crate::std::option::Option::Some(0)]" and
output = "ReturnValue" and
preservesValue = true
}
}
}

/** Provides the `Range` class used to define the extent of `LibraryCallable`. */
Expand Down
Loading

0 comments on commit 3bb1ae0

Please sign in to comment.