@@ -17,7 +17,7 @@ import semmle.python.Concepts
17
17
module NoSqlInjection {
18
18
private newtype TFlowState =
19
19
TStringInput ( ) or
20
- TDictInput ( )
20
+ TInterpretedStringInput ( )
21
21
22
22
/** A flow state, tracking the structure of the input. */
23
23
abstract class FlowState extends TFlowState {
@@ -30,29 +30,33 @@ module NoSqlInjection {
30
30
override string toString ( ) { result = "StringInput" }
31
31
}
32
32
33
- /** A state where input is a dictionary. */
34
- class DictInput extends FlowState , TDictInput {
35
- override string toString ( ) { result = "DictInput" }
33
+ /**
34
+ * A state where input is a string that has been interpreted.
35
+ * For instance, it could have been turned into a dictionary,
36
+ * or evaluated as javascript code.
37
+ */
38
+ class InterpretedStringInput extends FlowState , TInterpretedStringInput {
39
+ override string toString ( ) { result = "InterpretedStringInput" }
36
40
}
37
41
38
42
/** A source allowing string inputs. */
39
43
abstract class StringSource extends DataFlow:: Node { }
40
44
41
- /** A source allowing dictionary inputs . */
42
- abstract class DictSource extends DataFlow:: Node { }
45
+ /** A source of interpreted strings . */
46
+ abstract class InterpretedStringSource extends DataFlow:: Node { }
43
47
44
48
/** A sink vulnerable to user controlled strings. */
45
49
abstract class StringSink extends DataFlow:: Node { }
46
50
47
- /** A sink vulnerable to user controlled dictionaries . */
48
- abstract class DictSink extends DataFlow:: Node { }
51
+ /** A sink vulnerable to user controlled interpreted strings . */
52
+ abstract class InterpretedStringSink extends DataFlow:: Node { }
49
53
50
- /** A data flow node where a string is converted into a dictionary . */
51
- abstract class StringToDictConversion extends DataFlow:: Node {
52
- /** Gets the argument that specifies the string to be converted . */
54
+ /** A data flow node where a string is being interpreted . */
55
+ abstract class StringInterpretation extends DataFlow:: Node {
56
+ /** Gets the argument that specifies the string to be interpreted . */
53
57
abstract DataFlow:: Node getAnInput ( ) ;
54
58
55
- /** Gets the resulting dictionary . */
59
+ /** Gets the result of interpreting the string . */
56
60
abstract DataFlow:: Node getOutput ( ) ;
57
61
}
58
62
@@ -68,14 +72,23 @@ module NoSqlInjection {
68
72
}
69
73
}
70
74
71
- /** A NoSQL query that is vulnerable to user controlled dictionaries . */
72
- class NoSqlExecutionAsDictSink extends DictSink {
73
- NoSqlExecutionAsDictSink ( ) { this = any ( NoSqlExecution noSqlExecution ) .getQuery ( ) }
75
+ /** A NoSQL query that is vulnerable to user controlled InterpretedStringionaries . */
76
+ class NoSqlExecutionAsInterpretedStringSink extends InterpretedStringSink {
77
+ NoSqlExecutionAsInterpretedStringSink ( ) { this = any ( NoSqlExecution noSqlExecution ) .getQuery ( ) }
74
78
}
75
79
76
- /** A JSON decoding converts a string to a dictionary. */
77
- class JsonDecoding extends Decoding , StringToDictConversion {
78
- JsonDecoding ( ) { this .getFormat ( ) in [ "JSON" , "NoSQL" ] }
80
+ /** A JSON decoding converts a string to a Dictionary. */
81
+ class JsonDecoding extends Decoding , StringInterpretation {
82
+ JsonDecoding ( ) { this .getFormat ( ) = "JSON" }
83
+
84
+ override DataFlow:: Node getAnInput ( ) { result = Decoding .super .getAnInput ( ) }
85
+
86
+ override DataFlow:: Node getOutput ( ) { result = Decoding .super .getOutput ( ) }
87
+ }
88
+
89
+ /** A NoSQL decoding interprets a string. */
90
+ class NoSqlDecoding extends Decoding , StringInterpretation {
91
+ NoSqlDecoding ( ) { this .getFormat ( ) = "NoSQL" }
79
92
80
93
override DataFlow:: Node getAnInput ( ) { result = Decoding .super .getAnInput ( ) }
81
94
0 commit comments