Skip to content

Begin dataflow lib upgrade generic portions #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,14 @@ class CqlClauseParserCallWithStringConcat instanceof CqlClauseParserCall {
* instead (notice the lack of parentheses around the template literal), then the `where` call
* becomes a parser call of the template literal following it and thus acts as a sanitizer.
*/
class CqlInjectionConfiguration extends TaintTracking::Configuration {
CqlInjectionConfiguration() { this = "CQL injection from untrusted data" }
module CqlInjectionConfiguration implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource }

override predicate isSource(DataFlow::Node node) { node instanceof RemoteFlowSource }
predicate isSink(DataFlow::Node node) { node instanceof CqlInjectionSink }

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

override predicate isSanitizer(DataFlow::Node node) { node instanceof SqlInjection::Sanitizer }

override predicate isAdditionalTaintStep(DataFlow::Node start, DataFlow::Node end) {
predicate isAdditionalFlowStep(DataFlow::Node start, DataFlow::Node end) {
/*
* 1. Given a call to a CQL parser, jump from the argument to the parser call itself.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ class CdsLogSink extends DataFlow::Node {
}
}

class CAPLogInjectionConfiguration extends LogInjectionConfiguration {
override predicate isSource(DataFlow::Node start) {
super.isSource(start)
module CAPLogInjectionConfiguration implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node start) {
LogInjectionConfig::isSource(start)
or
start instanceof RemoteFlowSource
}

override predicate isBarrier(DataFlow::Node node) {
predicate isBarrier(DataFlow::Node node) {
exists(HandlerParameterData handlerParameterData |
node = handlerParameterData and
not handlerParameterData.getType() = ["cds.String", "cds.LargeString"]
)
}

override predicate isSink(DataFlow::Node end) { end instanceof CdsLogSink }
predicate isSink(DataFlow::Node end) { end instanceof CdsLogSink }
}
9 changes: 6 additions & 3 deletions javascript/frameworks/cap/src/cqlinjection/CqlInjection.ql
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
*/

import javascript
import DataFlow::PathGraph
import advanced_security.javascript.frameworks.cap.CAPCqlInjectionQuery

from CqlInjectionConfiguration sql, DataFlow::PathNode source, DataFlow::PathNode sink
where sql.hasFlowPath(source, sink)
module CqlInjectionConfigurationFlow = TaintTracking::Global<CqlInjectionConfiguration>;

import CqlInjectionConfigurationFlow::PathGraph

from CqlInjectionConfigurationFlow::PathNode source, CqlInjectionConfigurationFlow::PathNode sink
where CqlInjectionConfigurationFlow::flowPath(source, sink)
select sink.getNode().(CqlInjectionSink).getQuery(), source, sink,
"This CQL query contains a string concatenation with a $@.", source.getNode(),
"user-provided value"
10 changes: 7 additions & 3 deletions javascript/frameworks/cap/src/loginjection/LogInjection.ql
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
*/

import javascript
import DataFlow::PathGraph
import advanced_security.javascript.frameworks.cap.dataflow.DataFlow
import advanced_security.javascript.frameworks.cap.CAPLogInjectionQuery

from CAPLogInjectionConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink)
module CAPLogInjectionConfigurationFlow = TaintTracking::Global<CAPLogInjectionConfiguration>;

import CAPLogInjectionConfigurationFlow::PathGraph

from
CAPLogInjectionConfigurationFlow::PathNode source, CAPLogInjectionConfigurationFlow::PathNode sink
where CAPLogInjectionConfigurationFlow::flowPath(source, sink)
select sink.getNode(), source, sink, "Log entry depends on a $@.", source.getNode(),
"user-provided value"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import javascript
import advanced_security.javascript.frameworks.cap.CDS
import advanced_security.javascript.frameworks.cap.CAPLogInjectionQuery
import DataFlow::PathGraph

EntityReferenceFromEntities entityAccesses(string entityNamespace) {
entityNamespace = result.getEntitiesCallNamespace()
Expand All @@ -40,18 +39,18 @@ class SensitiveExposureFieldSource instanceof PropRead {
string toString() { result = super.toString() }
}

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

override predicate isSource(DataFlow::Node source) {
source instanceof SensitiveExposureFieldSource
}

override predicate isSink(DataFlow::Node sink) { sink instanceof CdsLogSink }
predicate isSink(DataFlow::Node sink) { sink instanceof CdsLogSink }
}

from SensitiveLogExposureConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
where config.hasFlowPath(source, sink)
module SensitiveLogExposureConfigFlow = TaintTracking::Global<SensitiveLogExposureConfig>;

import SensitiveLogExposureConfigFlow::PathGraph

from SensitiveLogExposureConfigFlow::PathNode source, SensitiveLogExposureConfigFlow::PathNode sink
where SensitiveLogExposureConfigFlow::flowPath(source, sink)
select sink, source, sink,
"Log entry depends on the $@ field which is annotated as potentially sensitive.",
source.getNode().(SensitiveExposureFieldSource).getCdsField(),
Expand Down
Loading