|
| 1 | +/** Provides classes and predicates for defining flow summaries. */ |
| 2 | + |
| 3 | +private import rust |
| 4 | +private import internal.FlowSummaryImpl as Impl |
| 5 | +private import internal.DataFlowImpl |
| 6 | + |
| 7 | +// import all instances below |
| 8 | +private module Summaries { |
| 9 | + private import codeql.rust.Frameworks |
| 10 | +} |
| 11 | + |
| 12 | +/** Provides the `Range` class used to define the extent of `LibraryCallable`. */ |
| 13 | +module LibraryCallable { |
| 14 | + /** A callable defined in library code, identified by a unique string. */ |
| 15 | + abstract class Range extends string { |
| 16 | + bindingset[this] |
| 17 | + Range() { any() } |
| 18 | + |
| 19 | + /** Gets a call to this library callable. */ |
| 20 | + CallExprBase getACall() { |
| 21 | + exists(Resolvable r, string crate | |
| 22 | + r = getCallResolvable(result) and |
| 23 | + this = crate + r.getResolvedPath() |
| 24 | + | |
| 25 | + crate = r.getResolvedCrateOrigin() + "::_::" |
| 26 | + or |
| 27 | + not r.hasResolvedCrateOrigin() and |
| 28 | + crate = "" |
| 29 | + ) |
| 30 | + } |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +final class LibraryCallable = LibraryCallable::Range; |
| 35 | + |
| 36 | +/** Provides the `Range` class used to define the extent of `SummarizedCallable`. */ |
| 37 | +module SummarizedCallable { |
| 38 | + /** A callable with a flow summary, identified by a unique string. */ |
| 39 | + abstract class Range extends LibraryCallable::Range, Impl::Public::SummarizedCallable { |
| 40 | + bindingset[this] |
| 41 | + Range() { any() } |
| 42 | + |
| 43 | + override predicate propagatesFlow( |
| 44 | + string input, string output, boolean preservesValue, string model |
| 45 | + ) { |
| 46 | + this.propagatesFlow(input, output, preservesValue) and model = "" |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Holds if data may flow from `input` to `output` through this callable. |
| 51 | + * |
| 52 | + * `preservesValue` indicates whether this is a value-preserving step or a taint-step. |
| 53 | + */ |
| 54 | + abstract predicate propagatesFlow(string input, string output, boolean preservesValue); |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +final class SummarizedCallable = SummarizedCallable::Range; |
0 commit comments