Module ExternalFlow
INTERNAL use only. This is an experimental API subject to change without notice.
Provides classes and predicates for dealing with MaD flow models specified in data extensions and CSV format.
The CSV specification has the following columns:
- Sources:
namespace; type; subtypes; name; signature; ext; output; kind; provenance - Sinks:
namespace; type; subtypes; name; signature; ext; input; kind; provenance - Summaries:
namespace; type; subtypes; name; signature; ext; input; output; kind; provenance - Neutrals:
namespace; type; name; signature; kind; provenanceA neutral is used to indicate that a callable is neutral with respect to flow (no summary), source (is not a source) or sink (is not a sink).
The interpretation of a row is similar to API-graphs with a left-to-right reading.
-
The
namespacecolumn selects a namespace. -
The
typecolumn selects a type within that namespace. -
The
subtypesis a boolean that indicates whether to jump to an arbitrary subtype of that type. -
The
namecolumn optionally selects a specific named member of the type. -
The
signaturecolumn optionally restricts the named member. Ifsignatureis blank then no such filtering is done. The format of the signature is a comma-separated list of types enclosed in parentheses. The types can be short names or fully qualified names (mixing these two options is not allowed within a single signature). -
The
extcolumn specifies additional API-graph-like edges. Currently there are only a few valid values: "", “Attribute”, “Attribute.Getter” and “Attribute.Setter”. The empty string has no effect. “Attribute” applies ifnameandsignaturewere left blank and acts by selecting an element (except for properties and indexers) that is attributed with the attribute type selected by the first 4 columns. This can be another member such as a field, method, or parameter. “Attribute.Getter” and “Attribute.Setter” work similar to “Attribute”, except that they can only be applied to properties and indexers. “Attribute.Setter” selects the setter element of a property/indexer and “Attribute.Getter” selects the getter. -
The
inputcolumn specifies how data enters the element selected by the first 6 columns, and theoutputcolumn specifies how data leaves the element selected by the first 6 columns. For sinks, aninputcan be either "", “Argument[n]”, “Argument[n1..n2]”, or “ReturnValue”:- "": Selects a write to the selected element in case this is a field or property.
- “Argument[n]”: Selects an argument in a call to the selected element.
The arguments are zero-indexed, and
thisspecifies the qualifier. - “Argument[n1..n2]”: Similar to “Argument[n]” but select any argument in the given range. The range is inclusive at both ends.
- “ReturnValue”: Selects a value being returned by the selected element. This requires that the selected element is a method with a body.
For sources, an
outputcan be either "", “Argument[n]”, “Argument[n1..n2]”, “Parameter”, “Parameter[n]”, “Parameter[n1..n2]”, or “ReturnValue”:- "": Selects a read of a selected field or property.
- “Argument[n]”: Selects the post-update value of an argument in a call to the
selected element. That is, the value of the argument after the call returns.
The arguments are zero-indexed, and
thisspecifies the qualifier. - “Argument[n1..n2]”: Similar to “Argument[n]” but select any argument in the given range. The range is inclusive at both ends.
- “Parameter”: Selects the value of a parameter of the selected element.
- “Parameter[n]”: Similar to “Parameter” but restricted to a specific
numbered parameter (zero-indexed, and
thisspecifies the value ofthis). - “Parameter[n1..n2]”: Similar to “Parameter[n]” but selects any parameter in the given range. The range is inclusive at both ends.
- “ReturnValue”: Selects the return value of a call to the selected element.
For summaries,
inputandoutputmay be suffixed by any number of the following, separated by “.”:- “Element”: Selects an element in a collection.
- “Field[f]”: Selects the contents of field
f. - “Property[p]”: Selects the contents of property
p.
-
The
kindcolumn is a tag that can be referenced from QL to determine to which classes the interpreted elements should be added. For example, for sources “remote” indicates a default remote flow source, and for summaries “taint” indicates a default additional taint step and “value” indicates a globally applicable value-preserving step. For neutrals the kind can besummary,sourceorsinkto indicate that the neutral is neutral with respect to flow (no summary), source (is not a source) or sink (is not a sink). -
The
provenancecolumn is a tag to indicate the origin and verification of a model. The format is {origin}-{verification} or just “manual” where the origin describes the origin of the model and verification describes how the model has been verified. Some examples are:- “df-generated”: The model has been generated by the model generator tool.
- “df-manual”: The model has been generated by the model generator and verified by a human.
- “manual”: The model has been written by hand. This information is used in a heuristic for dataflow analysis to determine, if a model or source code should be used for determining flow.
Import path
import semmle.code.csharp.dataflow.internal.ExternalFlowImports
| Cached | |
| ExternalFlowExtensions | This module provides extensible predicates for defining MaD models. |
| csharp | The default C# QL library. |
Predicates
| getSignature | Gets the signature of |
| hasQualifiedMethodName | Holds if declaration |
| hasQualifiedTypeName | Holds if declaration |
| interpretBaseDeclaration | |
| interpretElement | Gets the source/sink/summary/neutral element corresponding to the supplied parameters. |
| interpretModelForTest | Holds if the given extension tuple |
| interpretNeutral | |
| modelCoverage | Holds if MaD framework coverage of |
| parameterQualifiedTypeNamesToString | Gets the string representation of the parameters of |
| partialModel | |
| sinkNode | Holds if |
| sourceNode | Holds if |
Classes
| UnboundCallable | An unbound callable. |
Modules
| ModelValidation | Provides a query predicate to check the MaD models for validation errors. |
Aliases
| SinkCallable | A callable that has a sink model. |
| SourceCallable | A callable that has a source model. |