Skip to content

Commit 3e5f4b7

Browse files
committed
Rust: Add a model for unwrap
1 parent fbeb6f3 commit 3e5f4b7

File tree

4 files changed

+221
-191
lines changed

4 files changed

+221
-191
lines changed

rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ private import internal.DataFlowImpl
77
// import all instances below
88
private module Summaries {
99
private import codeql.rust.Frameworks
10+
11+
// TODO: Used models-as-data when it's available
12+
private class UnwrapSummary extends SummarizedCallable::Range {
13+
UnwrapSummary() { this = "lang:core::_::<crate::option::Option>::unwrap" }
14+
15+
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
16+
input = "Argument[self].Variant[crate::std::option::Option::Some(0)]" and
17+
output = "ReturnValue" and
18+
preservesValue = true
19+
}
20+
}
1021
}
1122

1223
/** Provides the `Range` class used to define the extent of `LibraryCallable`. */

0 commit comments

Comments
 (0)