Skip to content

Commit de5b3a2

Browse files
authored
Merge pull request github#7660 from RasmusWL/deprecate-old-modeling
Python: Deprecate old points-to based modeling
2 parents 9c79a17 + 94f9656 commit de5b3a2

File tree

123 files changed

+367
-285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+367
-285
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: deprecated
3+
---
4+
* The old points-to based modeling has been deprecated. Use the new type-tracking/API-graphs based modeling instead.

python/ql/lib/semmle/python/Concepts.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,11 @@ class RegexEscaping extends Escaping {
534534

535535
/** Provides classes for modeling HTTP-related APIs. */
536536
module HTTP {
537-
import semmle.python.web.HttpConstants
537+
/** Gets an HTTP verb, in upper case */
538+
string httpVerb() { result in ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"] }
539+
540+
/** Gets an HTTP verb, in lower case */
541+
string httpVerbLower() { result = httpVerb().toLowerCase() }
538542

539543
/** Provides classes for modeling HTTP servers. */
540544
module Server {

python/ql/lib/semmle/python/security/ClearText.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import semmle.python.security.SensitiveData
44
import semmle.python.dataflow.Files
55
import semmle.python.web.Http
66

7-
module ClearTextStorage {
7+
deprecated module ClearTextStorage {
88
abstract class Sink extends TaintSink {
99
override predicate sinks(TaintKind kind) { kind instanceof SensitiveData }
1010
}
@@ -26,7 +26,7 @@ module ClearTextStorage {
2626
}
2727
}
2828

29-
module ClearTextLogging {
29+
deprecated module ClearTextLogging {
3030
abstract class Sink extends TaintSink {
3131
override predicate sinks(TaintKind kind) { kind instanceof SensitiveData }
3232
}

python/ql/lib/semmle/python/security/Crypto.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import semmle.python.dataflow.TaintTracking
33
private import semmle.python.security.SensitiveData
44
private import semmle.crypto.Crypto as CryptoLib
55

6-
abstract class WeakCryptoSink extends TaintSink {
6+
abstract deprecated class WeakCryptoSink extends TaintSink {
77
override predicate sinks(TaintKind taint) { taint instanceof SensitiveData }
88
}
99

1010
/** Modeling the 'pycrypto' package https://github.com/dlitz/pycrypto (latest release 2013) */
11-
module Pycrypto {
11+
deprecated module Pycrypto {
1212
ModuleValue cipher(string name) { result = Module::named("Crypto.Cipher").attr(name) }
1313

1414
class CipherInstance extends TaintKind {
@@ -58,7 +58,7 @@ module Pycrypto {
5858
}
5959
}
6060

61-
module Cryptography {
61+
deprecated module Cryptography {
6262
ModuleValue ciphers() {
6363
result = Module::named("cryptography.hazmat.primitives.ciphers") and
6464
result.isPackage()
@@ -128,7 +128,7 @@ module Cryptography {
128128
}
129129
}
130130

131-
private class CipherConfig extends TaintTracking::Configuration {
131+
deprecated private class CipherConfig extends TaintTracking::Configuration {
132132
CipherConfig() { this = "Crypto cipher config" }
133133

134134
override predicate isSource(TaintTracking::Source source) {

python/ql/lib/semmle/python/security/Exceptions.qll

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import python
77
import semmle.python.dataflow.TaintTracking
88
import semmle.python.security.strings.Basic
99

10-
private Value traceback_function(string name) { result = Module::named("traceback").attr(name) }
10+
deprecated private Value traceback_function(string name) {
11+
result = Module::named("traceback").attr(name)
12+
}
1113

1214
/**
1315
* This represents information relating to an exception, for instance the
1416
* message, arguments or parts of the exception traceback.
1517
*/
16-
class ExceptionInfo extends StringKind {
18+
deprecated class ExceptionInfo extends StringKind {
1719
ExceptionInfo() { this = "exception.info" }
1820

1921
override string repr() { result = "exception info" }
@@ -23,12 +25,12 @@ class ExceptionInfo extends StringKind {
2325
* A class representing sources of information about
2426
* execution state exposed in tracebacks and the like.
2527
*/
26-
abstract class ErrorInfoSource extends TaintSource { }
28+
abstract deprecated class ErrorInfoSource extends TaintSource { }
2729

2830
/**
2931
* This kind represents exceptions themselves.
3032
*/
31-
class ExceptionKind extends TaintKind {
33+
deprecated class ExceptionKind extends TaintKind {
3234
ExceptionKind() { this = "exception.kind" }
3335

3436
override string repr() { result = "exception" }
@@ -44,7 +46,7 @@ class ExceptionKind extends TaintKind {
4446
* A source of exception objects, either explicitly created, or captured by an
4547
* `except` statement.
4648
*/
47-
class ExceptionSource extends ErrorInfoSource {
49+
deprecated class ExceptionSource extends ErrorInfoSource {
4850
ExceptionSource() {
4951
exists(ClassValue cls |
5052
cls.getASuperType() = ClassValue::baseException() and
@@ -63,15 +65,15 @@ class ExceptionSource extends ErrorInfoSource {
6365
* Represents a sequence of pieces of information relating to an exception,
6466
* for instance the contents of the `args` attribute, or the stack trace.
6567
*/
66-
class ExceptionInfoSequence extends SequenceKind {
68+
deprecated class ExceptionInfoSequence extends SequenceKind {
6769
ExceptionInfoSequence() { this.getItem() instanceof ExceptionInfo }
6870
}
6971

7072
/**
7173
* Represents calls to functions in the `traceback` module that return
7274
* sequences of exception information.
7375
*/
74-
class CallToTracebackFunction extends ErrorInfoSource {
76+
deprecated class CallToTracebackFunction extends ErrorInfoSource {
7577
CallToTracebackFunction() {
7678
exists(string name |
7779
name in [
@@ -92,7 +94,7 @@ class CallToTracebackFunction extends ErrorInfoSource {
9294
* Represents calls to functions in the `traceback` module that return a single
9395
* string of information about an exception.
9496
*/
95-
class FormattedTracebackSource extends ErrorInfoSource {
97+
deprecated class FormattedTracebackSource extends ErrorInfoSource {
9698
FormattedTracebackSource() { this = traceback_function("format_exc").getACall() }
9799

98100
override string toString() { result = "exception.info.source" }

python/ql/lib/semmle/python/security/Paths.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import semmle.python.dataflow.Implementation
22

3-
module TaintTrackingPaths {
3+
deprecated module TaintTrackingPaths {
44
predicate edge(TaintTrackingNode src, TaintTrackingNode dest, string label) {
55
exists(TaintTrackingNode source, TaintTrackingNode sink |
66
source.getConfiguration().hasFlowPath(source, sink) and
@@ -11,6 +11,6 @@ module TaintTrackingPaths {
1111
}
1212
}
1313

14-
query predicate edges(TaintTrackingNode fromnode, TaintTrackingNode tonode) {
14+
deprecated query predicate edges(TaintTrackingNode fromnode, TaintTrackingNode tonode) {
1515
TaintTrackingPaths::edge(fromnode, tonode, _)
1616
}

python/ql/lib/semmle/python/security/SensitiveData.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ import semmle.python.web.HttpRequest
1515
import semmle.python.security.internal.SensitiveDataHeuristics
1616
private import HeuristicNames
1717

18-
abstract class SensitiveData extends TaintKind {
18+
abstract deprecated class SensitiveData extends TaintKind {
1919
bindingset[this]
2020
SensitiveData() { this = this }
2121

2222
/** Gets the classification of this sensitive data taint kind. */
2323
abstract SensitiveDataClassification getClassification();
2424
}
2525

26-
module SensitiveData {
26+
deprecated module SensitiveData {
2727
class Secret extends SensitiveData {
2828
Secret() { this = "sensitive.data.secret" }
2929

@@ -115,4 +115,4 @@ module SensitiveData {
115115
}
116116

117117
//Backwards compatibility
118-
class SensitiveDataSource = SensitiveData::Source;
118+
deprecated class SensitiveDataSource = SensitiveData::Source;

python/ql/lib/semmle/python/security/flow/AnyCall.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import python
22
import semmle.python.security.strings.Basic
33

44
/** Assume that taint flows from argument to result for *any* call */
5-
class AnyCallStringFlow extends DataFlowExtension::DataFlowNode {
5+
deprecated class AnyCallStringFlow extends DataFlowExtension::DataFlowNode {
66
AnyCallStringFlow() { any(CallNode call).getAnArg() = this }
77

88
override ControlFlowNode getASuccessorNode() { result.(CallNode).getAnArg() = this }

python/ql/lib/semmle/python/security/injection/Command.qll

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ import semmle.python.dataflow.TaintTracking
1111
import semmle.python.security.strings.Untrusted
1212

1313
/** Abstract taint sink that is potentially vulnerable to malicious shell commands. */
14-
abstract class CommandSink extends TaintSink { }
14+
abstract deprecated class CommandSink extends TaintSink { }
1515

16-
private ModuleObject osOrPopenModule() { result.getName() = ["os", "popen2"] }
16+
deprecated private ModuleObject osOrPopenModule() { result.getName() = ["os", "popen2"] }
1717

18-
private Object makeOsCall() {
18+
deprecated private Object makeOsCall() {
1919
exists(string name | result = ModuleObject::named("subprocess").attr(name) |
2020
name = ["Popen", "call", "check_call", "check_output", "run"]
2121
)
2222
}
2323

2424
/**Special case for first element in sequence. */
25-
class FirstElementKind extends TaintKind {
25+
deprecated class FirstElementKind extends TaintKind {
2626
FirstElementKind() { this = "sequence[" + any(ExternalStringKind key) + "][0]" }
2727

2828
override string repr() { result = "first item in sequence of " + this.getItem().repr() }
@@ -31,7 +31,7 @@ class FirstElementKind extends TaintKind {
3131
ExternalStringKind getItem() { this = "sequence[" + result + "][0]" }
3232
}
3333

34-
class FirstElementFlow extends DataFlowExtension::DataFlowNode {
34+
deprecated class FirstElementFlow extends DataFlowExtension::DataFlowNode {
3535
FirstElementFlow() { this = any(SequenceNode s).getElement(0) }
3636

3737
override ControlFlowNode getASuccessorNode(TaintKind fromkind, TaintKind tokind) {
@@ -43,7 +43,7 @@ class FirstElementFlow extends DataFlowExtension::DataFlowNode {
4343
* A taint sink that is potentially vulnerable to malicious shell commands.
4444
* The `vuln` in `subprocess.call(shell=vuln)` and similar calls.
4545
*/
46-
class ShellCommand extends CommandSink {
46+
deprecated class ShellCommand extends CommandSink {
4747
override string toString() { result = "shell command" }
4848

4949
ShellCommand() {
@@ -81,7 +81,7 @@ class ShellCommand extends CommandSink {
8181
* A taint sink that is potentially vulnerable to malicious shell commands.
8282
* The `vuln` in `subprocess.call(vuln, ...)` and similar calls.
8383
*/
84-
class OsCommandFirstArgument extends CommandSink {
84+
deprecated class OsCommandFirstArgument extends CommandSink {
8585
override string toString() { result = "OS command first argument" }
8686

8787
OsCommandFirstArgument() {
@@ -111,7 +111,7 @@ class OsCommandFirstArgument extends CommandSink {
111111
* A taint sink that is potentially vulnerable to malicious shell commands.
112112
* The `vuln` in `invoke.run(vuln, ...)` and similar calls.
113113
*/
114-
class InvokeRun extends CommandSink {
114+
deprecated class InvokeRun extends CommandSink {
115115
InvokeRun() {
116116
this = Value::named("invoke.run").(FunctionValue).getArgumentForCall(_, 0)
117117
or
@@ -127,12 +127,12 @@ class InvokeRun extends CommandSink {
127127
* Internal TaintKind to track the invoke.Context instance passed to functions
128128
* marked with @invoke.task
129129
*/
130-
private class InvokeContextArg extends TaintKind {
130+
deprecated private class InvokeContextArg extends TaintKind {
131131
InvokeContextArg() { this = "InvokeContextArg" }
132132
}
133133

134134
/** Internal TaintSource to track the context passed to functions marked with @invoke.task */
135-
private class InvokeContextArgSource extends TaintSource {
135+
deprecated private class InvokeContextArgSource extends TaintSource {
136136
InvokeContextArgSource() {
137137
exists(Function f, Expr decorator |
138138
count(f.getADecorator()) = 1 and
@@ -158,7 +158,7 @@ private class InvokeContextArgSource extends TaintSource {
158158
* A taint sink that is potentially vulnerable to malicious shell commands.
159159
* The `vuln` in `invoke.Context().run(vuln, ...)` and similar calls.
160160
*/
161-
class InvokeContextRun extends CommandSink {
161+
deprecated class InvokeContextRun extends CommandSink {
162162
InvokeContextRun() {
163163
exists(CallNode call |
164164
any(InvokeContextArg k).taints(call.getFunction().(AttrNode).getObject("run"))
@@ -187,7 +187,7 @@ class InvokeContextRun extends CommandSink {
187187
* A taint sink that is potentially vulnerable to malicious shell commands.
188188
* The `vuln` in `fabric.Group().run(vuln, ...)` and similar calls.
189189
*/
190-
class FabricGroupRun extends CommandSink {
190+
deprecated class FabricGroupRun extends CommandSink {
191191
FabricGroupRun() {
192192
exists(ClassValue cls |
193193
cls.getASuperType() = Value::named("fabric.Group") and
@@ -203,7 +203,7 @@ class FabricGroupRun extends CommandSink {
203203
// -------------------------------------------------------------------------- //
204204
// Modeling of the 'invoke' package and 'fabric' package (v 1.x)
205205
// -------------------------------------------------------------------------- //
206-
class FabricV1Commands extends CommandSink {
206+
deprecated class FabricV1Commands extends CommandSink {
207207
FabricV1Commands() {
208208
// since `run` and `sudo` are decorated, we can't use FunctionValue's :(
209209
exists(CallNode call |
@@ -228,7 +228,7 @@ class FabricV1Commands extends CommandSink {
228228
* An extension that propagates taint from the arguments of `fabric.api.execute(func, arg0, arg1, ...)`
229229
* to the parameters of `func`, since this will call `func(arg0, arg1, ...)`.
230230
*/
231-
class FabricExecuteExtension extends DataFlowExtension::DataFlowNode {
231+
deprecated class FabricExecuteExtension extends DataFlowExtension::DataFlowNode {
232232
CallNode call;
233233

234234
FabricExecuteExtension() {

python/ql/lib/semmle/python/security/injection/Deserialization.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import python
22
import semmle.python.dataflow.TaintTracking
33

44
/** `pickle.loads(untrusted)` vulnerability. */
5-
abstract class DeserializationSink extends TaintSink {
5+
abstract deprecated class DeserializationSink extends TaintSink {
66
bindingset[this]
77
DeserializationSink() { this = this }
88
}

0 commit comments

Comments
 (0)