mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
46 lines
1.2 KiB
Plaintext
46 lines
1.2 KiB
Plaintext
import python
|
|
import semmle.python.dataflow.TaintTracking
|
|
import semmle.python.security.strings.Untrusted
|
|
|
|
class FooSource extends TaintSource {
|
|
FooSource() { this.(CallNode).getFunction().(NameNode).getId() = "foo_source" }
|
|
|
|
override predicate isSourceOf(TaintKind kind) { kind instanceof UntrustedStringKind }
|
|
|
|
override string toString() { result = "FooSource" }
|
|
}
|
|
|
|
class FooSink extends TaintSink {
|
|
FooSink() {
|
|
exists(CallNode call |
|
|
call.getFunction().(NameNode).getId() = "foo_sink" and
|
|
call.getAnArg() = this
|
|
)
|
|
}
|
|
|
|
override predicate sinks(TaintKind kind) { kind instanceof UntrustedStringKind }
|
|
|
|
override string toString() { result = "FooSink" }
|
|
}
|
|
|
|
class FooConfig extends TaintTracking::Configuration {
|
|
FooConfig() { this = "FooConfig" }
|
|
|
|
override predicate isSource(TaintTracking::Source source) { source instanceof FooSource }
|
|
|
|
override predicate isSink(TaintTracking::Sink sink) { sink instanceof FooSink }
|
|
}
|
|
|
|
class BarSink extends TaintSink {
|
|
BarSink() {
|
|
exists(CallNode call |
|
|
call.getFunction().(NameNode).getId() = "bar_sink" and
|
|
call.getAnArg() = this
|
|
)
|
|
}
|
|
|
|
override predicate sinks(TaintKind kind) { kind instanceof UntrustedStringKind }
|
|
|
|
override string toString() { result = "BarSink" }
|
|
}
|