mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Initial implementation of data flow through fields, using the algorithm of the
shared data flow implementation. Fields (and field-like properties) are covered,
and stores can be either
- ordinary assignments, `Foo = x`,
- object initializers, `new C() { Foo = x }`, or
- field initializers, `int Foo = x`.
For field initializers, we need to synthesize calls (`SynthesizedCall`),
callables (`SynthesizedCallable`), parameters (`InstanceParameterNode`), and
arguments (`SynthesizedThisArgumentNode`), as the C# extractor does not (yet)
extract such entities. For example, in
```
class C
{
int Field1 = 1;
int Field2 = 2;
C() { }
}
```
there is a synthesized call from the constructor `C`, with a synthesized `this`
argument, and the targets of that call are two synthesized callables with bodies
`this.Field1 = 1` and `this.Field2 = 2`, respectively.
A consequence of this is that `DataFlowCallable` is no longer an alias for
`DotNet::Callable`, but instead an IPA type.
18 lines
509 B
Plaintext
18 lines
509 B
Plaintext
import csharp
|
|
import DataFlow
|
|
import semmle.code.csharp.dataflow.internal.DataFlowPrivate
|
|
|
|
class ConfigAny extends Configuration {
|
|
ConfigAny() { this = "ConfigAny" }
|
|
|
|
override predicate isSource(Node source) {
|
|
source instanceof PostUpdateNode implies source.asExpr() instanceof ObjectCreation
|
|
}
|
|
|
|
override predicate isSink(Node sink) {
|
|
sink instanceof PostUpdateNode implies sink.asExpr() instanceof ObjectCreation
|
|
}
|
|
}
|
|
|
|
query predicate edges(PathNode a, PathNode b) { a.getASuccessor() = b }
|