5
5
6
6
import csharp
7
7
private import semmle.code.csharp.commons.QualifiedName
8
- private import semmle.code.csharp.dataflow.flowsources.Remote
8
+ private import semmle.code.csharp.security. dataflow.flowsources.FlowSources
9
9
private import semmle.code.csharp.frameworks.System
10
10
private import semmle.code.csharp.dataflow.FlowSummary
11
11
// SECLAB: Import CSV utils
@@ -19,9 +19,6 @@ predicate asPartialModel = ExternalFlow::asPartialModel/1;
19
19
*/
20
20
abstract class SafeExternalApiCallable extends Callable { }
21
21
22
- /** DEPRECATED: Alias for SafeExternalApiCallable */
23
- deprecated class SafeExternalAPICallable = SafeExternalApiCallable ;
24
-
25
22
private class SummarizedCallableSafe extends SafeExternalApiCallable instanceof SummarizedCallable {
26
23
}
27
24
@@ -40,7 +37,7 @@ private class DefaultSafeExternalApiCallable extends SafeExternalApiCallable {
40
37
this = any ( SystemStringClass s ) .getIsNullOrWhiteSpaceMethod ( ) or
41
38
this .getName ( ) .regexpMatch ( "Count|get_Count|get_Length" ) or
42
39
// SECLAB: Exclude all .NET methods
43
- this .getDeclaringType ( ) .getQualifiedName ( ) .matches ( [ "System.%" , "Microsoft.%" , "Azure.%" ] )
40
+ this .getDeclaringType ( ) .getFullyQualifiedName ( ) .matches ( [ "System.%" , "Microsoft.%" , "Azure.%" ] )
44
41
}
45
42
}
46
43
@@ -81,49 +78,41 @@ class ExternalApiDataNode extends DataFlow::Node {
81
78
82
79
/** Holds if the callable being use has name `name` and has qualifier `qualifier`. */
83
80
predicate hasQualifiedName ( string qualifier , string name ) {
84
- this .getCallable ( ) .hasQualifiedName ( qualifier , name )
85
- }
86
-
87
- /**
88
- * DEPRECATED: Use hasQualifiedName/2 instead.
89
- *
90
- * Gets the description of the callable being called.
91
- */
92
- deprecated string getCallableDescription ( ) {
93
- exists ( string qualifier , string name |
94
- this .hasQualifiedName ( qualifier , name ) and result = getQualifiedName ( qualifier , name )
95
- )
81
+ this .getCallable ( ) .hasFullyQualifiedName ( qualifier , name )
96
82
}
97
83
}
98
84
99
- /** DEPRECATED: Alias for ExternalApiDataNode */
100
- deprecated class ExternalAPIDataNode = ExternalApiDataNode ;
101
-
102
- /** A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s. */
103
- class UntrustedDataToExternalApiConfig extends TaintTracking:: Configuration {
85
+ /**
86
+ * DEPRECATED: Use `RemoteSourceToExternalApi` instead.
87
+ *
88
+ * A configuration for tracking flow from `RemoteFlowSource`s to `ExternalApiDataNode`s.
89
+ */
90
+ deprecated class UntrustedDataToExternalApiConfig extends TaintTracking:: Configuration {
104
91
UntrustedDataToExternalApiConfig ( ) { this = "UntrustedDataToExternalAPIConfig" }
105
92
106
- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
93
+ override predicate isSource ( DataFlow:: Node source ) { source instanceof ThreatModelFlowSource }
107
94
108
95
override predicate isSink ( DataFlow:: Node sink ) { sink instanceof ExternalApiDataNode }
109
96
}
110
97
111
- /** DEPRECATED: Alias for UntrustedDataToExternalApiConfig */
112
- deprecated class UntrustedDataToExternalAPIConfig = UntrustedDataToExternalApiConfig ;
98
+ /** A configuration for tracking flow from `ThreatModelFlowSource`s to `ExternalApiDataNode`s. */
99
+ private module RemoteSourceToExternalApiConfig implements DataFlow:: ConfigSig {
100
+ predicate isSource ( DataFlow:: Node source ) { source instanceof ThreatModelFlowSource }
101
+
102
+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof ExternalApiDataNode }
103
+ }
104
+
105
+ /** A module for tracking flow from `ThreatModelFlowSource`s to `ExternalApiDataNode`s. */
106
+ module RemoteSourceToExternalApi = TaintTracking:: Global< RemoteSourceToExternalApiConfig > ;
113
107
114
108
/** A node representing untrusted data being passed to an external API. */
115
109
class UntrustedExternalApiDataNode extends ExternalApiDataNode {
116
- private UntrustedDataToExternalApiConfig c ;
117
-
118
- UntrustedExternalApiDataNode ( ) { c .hasFlow ( _, this ) }
110
+ UntrustedExternalApiDataNode ( ) { RemoteSourceToExternalApi:: flow ( _, this ) }
119
111
120
112
/** Gets a source of untrusted data which is passed to this external API data node. */
121
- DataFlow:: Node getAnUntrustedSource ( ) { c . hasFlow ( result , this ) }
113
+ DataFlow:: Node getAnUntrustedSource ( ) { RemoteSourceToExternalApi :: flow ( result , this ) }
122
114
}
123
115
124
- /** DEPRECATED: Alias for UntrustedExternalApiDataNode */
125
- deprecated class UntrustedExternalAPIDataNode = UntrustedExternalApiDataNode ;
126
-
127
116
/** An external API which is used with untrusted data. */
128
117
private newtype TExternalApi =
129
118
/** An untrusted API method `m` where untrusted data is passed at `index`. */
@@ -148,13 +137,13 @@ class ExternalApiUsedWithUntrustedData extends TExternalApi {
148
137
149
138
/** Gets a textual representation of this element. */
150
139
string toString ( ) {
151
- exists ( Callable m , int index |
140
+ exists ( Callable m , int index , string indexString , string qualifier , string name |
141
+ if index = - 1 then indexString = "qualifier" else indexString = "param " + index
142
+ |
152
143
this = TExternalApiParameter ( m , index ) and
144
+ m .getDeclaringType ( ) .hasFullyQualifiedName ( qualifier , name ) and
153
145
// SECLAB: use the CSV library to get the 6 first columns
154
146
result = asPartialModel ( m .getUnboundDeclaration ( ) ) + index .toString ( )
155
147
)
156
148
}
157
149
}
158
-
159
- /** DEPRECATED: Alias for ExternalApiUsedWithUntrustedData */
160
- deprecated class ExternalAPIUsedWithUntrustedData = ExternalApiUsedWithUntrustedData ;
0 commit comments