Skip to content

Commit 56866cb

Browse files
Merge pull request #220 from advanced-security/knewbury01/dataflow-lib-upgrade-simple
Begin dataflow lib upgrade generic portions
2 parents 2c5761a + 6db3707 commit 56866cb

File tree

22 files changed

+1087
-1611
lines changed

22 files changed

+1087
-1611
lines changed

javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/CAPCqlInjectionQuery.qll

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,14 @@ class CqlClauseParserCallWithStringConcat instanceof CqlClauseParserCall {
166166
* instead (notice the lack of parentheses around the template literal), then the `where` call
167167
* becomes a parser call of the template literal following it and thus acts as a sanitizer.
168168
*/
169-
class CqlInjectionConfiguration extends TaintTracking::Configuration {
170-
CqlInjectionConfiguration() { this = "CQL injection from untrusted data" }
169+
module CqlInjectionConfiguration implements DataFlow::ConfigSig {
170+
predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource }
171171

172-
override predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource }
172+
predicate isSink(DataFlow::Node node) { node instanceof CqlInjectionSink }
173173

174-
override predicate isSink(DataFlow::Node node) { node instanceof CqlInjectionSink }
174+
predicate isBarrier(DataFlow::Node node) { node instanceof SqlInjection::Sanitizer }
175175

176-
override predicate isSanitizer(DataFlow::Node node) { node instanceof SqlInjection::Sanitizer }
177-
178-
override predicate isAdditionalTaintStep(DataFlow::Node start, DataFlow::Node end) {
176+
predicate isAdditionalFlowStep(DataFlow::Node start, DataFlow::Node end) {
179177
/*
180178
* 1. Given a call to a CQL parser, jump from the argument to the parser call itself.
181179
*/

javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/CAPLogInjectionQuery.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ class CdsLogSink extends DataFlow::Node {
4343
}
4444
}
4545

46-
class CAPLogInjectionConfiguration extends LogInjectionConfiguration {
47-
override predicate isSource(DataFlow::Node start) {
48-
super.isSource(start)
46+
module CAPLogInjectionConfiguration implements DataFlow::ConfigSig {
47+
predicate isSource(DataFlow::Node start) {
48+
LogInjectionConfig::isSource(start)
4949
or
5050
start instanceof RemoteFlowSource
5151
}
5252

53-
override predicate isBarrier(DataFlow::Node node) {
53+
predicate isBarrier(DataFlow::Node node) {
5454
exists(HandlerParameterData handlerParameterData |
5555
node = handlerParameterData and
5656
not handlerParameterData.getType() = ["cds.String", "cds.LargeString"]
5757
)
5858
}
5959

60-
override predicate isSink(DataFlow::Node end) { end instanceof CdsLogSink }
60+
predicate isSink(DataFlow::Node end) { end instanceof CdsLogSink }
6161
}

javascript/frameworks/cap/src/cqlinjection/CqlInjection.ql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
*/
1212

1313
import javascript
14-
import DataFlow::PathGraph
1514
import advanced_security.javascript.frameworks.cap.CAPCqlInjectionQuery
1615

17-
from CqlInjectionConfiguration sql, DataFlow::PathNode source, DataFlow::PathNode sink
18-
where sql.hasFlowPath(source, sink)
16+
module CqlInjectionConfigurationFlow = TaintTracking::Global<CqlInjectionConfiguration>;
17+
18+
import CqlInjectionConfigurationFlow::PathGraph
19+
20+
from CqlInjectionConfigurationFlow::PathNode source, CqlInjectionConfigurationFlow::PathNode sink
21+
where CqlInjectionConfigurationFlow::flowPath(source, sink)
1922
select sink.getNode().(CqlInjectionSink).getQuery(), source, sink,
2023
"This CQL query contains a string concatenation with a $@.", source.getNode(),
2124
"user-provided value"

javascript/frameworks/cap/src/loginjection/LogInjection.ql

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
*/
1212

1313
import javascript
14-
import DataFlow::PathGraph
1514
import advanced_security.javascript.frameworks.cap.dataflow.DataFlow
1615
import advanced_security.javascript.frameworks.cap.CAPLogInjectionQuery
1716

18-
from CAPLogInjectionConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink
19-
where config.hasFlowPath(source, sink)
17+
module CAPLogInjectionConfigurationFlow = TaintTracking::Global<CAPLogInjectionConfiguration>;
18+
19+
import CAPLogInjectionConfigurationFlow::PathGraph
20+
21+
from
22+
CAPLogInjectionConfigurationFlow::PathNode source, CAPLogInjectionConfigurationFlow::PathNode sink
23+
where CAPLogInjectionConfigurationFlow::flowPath(source, sink)
2024
select sink.getNode(), source, sink, "Log entry depends on a $@.", source.getNode(),
2125
"user-provided value"

javascript/frameworks/cap/src/sensitive-exposure/SensitiveExposure.ql

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import javascript
1515
import advanced_security.javascript.frameworks.cap.CDS
1616
import advanced_security.javascript.frameworks.cap.CAPLogInjectionQuery
17-
import DataFlow::PathGraph
1817

1918
EntityReferenceFromEntities entityAccesses(string entityNamespace) {
2019
entityNamespace = result.getEntitiesCallNamespace()
@@ -40,18 +39,18 @@ class SensitiveExposureFieldSource instanceof PropRead {
4039
string toString() { result = super.toString() }
4140
}
4241

43-
class SensitiveLogExposureConfig extends TaintTracking::Configuration {
44-
SensitiveLogExposureConfig() { this = "SensitiveLogExposure" }
42+
module SensitiveLogExposureConfig implements DataFlow::ConfigSig {
43+
predicate isSource(DataFlow::Node source) { source instanceof SensitiveExposureFieldSource }
4544

46-
override predicate isSource(DataFlow::Node source) {
47-
source instanceof SensitiveExposureFieldSource
48-
}
49-
50-
override predicate isSink(DataFlow::Node sink) { sink instanceof CdsLogSink }
45+
predicate isSink(DataFlow::Node sink) { sink instanceof CdsLogSink }
5146
}
5247

53-
from SensitiveLogExposureConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
54-
where config.hasFlowPath(source, sink)
48+
module SensitiveLogExposureConfigFlow = TaintTracking::Global<SensitiveLogExposureConfig>;
49+
50+
import SensitiveLogExposureConfigFlow::PathGraph
51+
52+
from SensitiveLogExposureConfigFlow::PathNode source, SensitiveLogExposureConfigFlow::PathNode sink
53+
where SensitiveLogExposureConfigFlow::flowPath(source, sink)
5554
select sink, source, sink,
5655
"Log entry depends on the $@ field which is annotated as potentially sensitive.",
5756
source.getNode().(SensitiveExposureFieldSource).getCdsField(),

0 commit comments

Comments
 (0)