Skip to content

Commit

Permalink
Rust: Adopt shared flow summaries library
Browse files Browse the repository at this point in the history
  • Loading branch information
hvitved committed Nov 27, 2024
1 parent 46abb90 commit 5812246
Show file tree
Hide file tree
Showing 6 changed files with 662 additions and 48 deletions.
67 changes: 67 additions & 0 deletions rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/** Provides classes and predicates for defining flow summaries. */

private import rust
// private import DataFlow
private import internal.FlowSummaryImpl as Impl
private import internal.DataFlowImpl

// import all instances below
private module Summaries {
private import codeql.rust.Frameworks
// private import codeql.ruby.frameworks.data.ModelsAsData
}

module LibraryCallable {

Check warning on line 14 in rust/ql/lib/codeql/rust/dataflow/FlowSummary.qll

View workflow job for this annotation

GitHub Actions / qldoc

Missing QLdoc for module FlowSummary::LibraryCallable
/** A callable defined in library code, identified by a unique string. */
abstract class Range extends string {
bindingset[this]
Range() { any() }

/** Gets a call to this library callable. */
CallExprBase getACall() {
exists(Resolvable r, string crate |
r = getCallResolvable(result) and
this = crate + r.getResolvedPath()
|
crate = r.getResolvedCrateOrigin() + "::_::"
or
not r.hasResolvedCrateOrigin() and
crate = ""
)
}
}
}

/** Gets a call to this library callable. */
CallExprBase gesftACall(string s) {
exists(Resolvable r, string crate |
r = getCallResolvable(result) and
s = crate + r.getResolvedPath()
|
crate = r.getResolvedCrateOrigin() + "::"
or
not r.hasResolvedCrateOrigin() and
crate = ""
)
}

final class LibraryCallable = LibraryCallable::Range;

/** A callable with a flow summary, identified by a unique string. */
abstract class SummarizedCallable extends LibraryCallable::Range, Impl::Public::SummarizedCallable {
bindingset[this]
SummarizedCallable() { any() }

override predicate propagatesFlow(
string input, string output, boolean preservesValue, string model
) {
this.propagatesFlow(input, output, preservesValue) and model = ""
}

/**
* Holds if data may flow from `input` to `output` through this callable.
*
* `preservesValue` indicates whether this is a value-preserving step or a taint-step.
*/
abstract predicate propagatesFlow(string input, string output, boolean preservesValue);
}
Loading

0 comments on commit 5812246

Please sign in to comment.