|
| 1 | +/** |
| 2 | + * Provides classes and predicates for defining barriers and barrier guards. |
| 3 | + * |
| 4 | + * Flow sinks defined here feed into data flow configurations as follows: |
| 5 | + * |
| 6 | + * ```text |
| 7 | + * data from *.model.yml | QL extensions of FlowSink::Range |
| 8 | + * v v |
| 9 | + * FlowSink (associated with a models-as-data kind string) |
| 10 | + * v |
| 11 | + * sinkNode predicate | other QL defined sinks, for example using concepts |
| 12 | + * v v |
| 13 | + * various Sink classes for specific data flow configurations <- extending QuerySink |
| 14 | + * ``` |
| 15 | + * |
| 16 | + * New sinks should be defined using models-as-data, QL extensions of |
| 17 | + * `FlowSink::Range`, or concepts. Data flow configurations should use the |
| 18 | + * `sinkNode` predicate and/or concepts to define their sinks. |
| 19 | + */ |
| 20 | + |
| 21 | +private import rust |
| 22 | +private import internal.FlowSummaryImpl as Impl |
| 23 | +private import internal.DataFlowImpl as DataFlowImpl |
| 24 | + |
| 25 | +// import all instances below |
| 26 | +private module Barriers { |
| 27 | + private import codeql.rust.Frameworks |
| 28 | + private import codeql.rust.dataflow.internal.ModelsAsData |
| 29 | +} |
| 30 | + |
| 31 | +/** Provides the `Range` class used to define the extent of `FlowBarrier`. */ |
| 32 | +module FlowBarrier { |
| 33 | + /** A flow sink. */ |
| 34 | + abstract class Range extends Impl::Public::BarrierElement { |
| 35 | + bindingset[this] |
| 36 | + Range() { any() } |
| 37 | + |
| 38 | + override predicate isBarrier( |
| 39 | + string output, string kind, Impl::Public::Provenance provenance, string model |
| 40 | + ) { |
| 41 | + this.isBarrier(output, kind) and provenance = "manual" and model = "" |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Holds is this element is a flow barrier of kind `kind`, where data |
| 46 | + * flows out as described by `output`. |
| 47 | + */ |
| 48 | + predicate isBarrier(string output, string kind) { none() } |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +final class FlowBarrier = FlowBarrier::Range; |
| 53 | + |
| 54 | +predicate barrierNode = DataFlowImpl::barrierNode/2; |
0 commit comments