JS: Port meta queries

This commit is contained in:
Asger F
2023-10-05 09:28:27 +02:00
parent c55300d4b0
commit 43be45207d
4 changed files with 25 additions and 25 deletions

View File

@@ -12,20 +12,20 @@
import javascript
import meta.internal.TaintMetrics
class BasicTaintConfiguration extends TaintTracking::Configuration {
BasicTaintConfiguration() { this = "BasicTaintConfiguration" }
module BasicTaintConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node node) { node = relevantTaintSource() }
override predicate isSource(DataFlow::Node node) { node = relevantTaintSource() }
override predicate isSink(DataFlow::Node node) {
predicate isSink(DataFlow::Node node) {
// To reduce noise from synthetic nodes, only count value nodes
node instanceof DataFlow::ValueNode and
not node.getFile() instanceof IgnoredFile
}
}
module BasicTaintFlow = TaintTracking::Global<BasicTaintConfig>;
// Avoid linking to the source as this would upset the statistics: nodes reachable
// from multiple sources would be counted multilpe times, and that's not what we intend to measure.
// from multiple sources would be counted multiple times, and that's not what we intend to measure.
from DataFlow::Node node
where any(BasicTaintConfiguration cfg).hasFlow(_, node)
where BasicTaintFlow::flowTo(node)
select node, "Tainted node"

View File

@@ -11,12 +11,12 @@
import javascript
import meta.internal.TaintMetrics
class BasicTaintConfiguration extends TaintTracking::Configuration {
BasicTaintConfiguration() { this = "BasicTaintConfiguration" }
module BasicTaintConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node node) { node = relevantTaintSource() }
override predicate isSource(DataFlow::Node node) { node = relevantTaintSource() }
override predicate isSink(DataFlow::Node node) { node = relevantSanitizerInput() }
predicate isSink(DataFlow::Node node) { node = relevantSanitizerInput() }
}
select projectRoot(), count(DataFlow::Node node | any(BasicTaintConfiguration cfg).hasFlow(_, node))
module BasicTaintFlow = TaintTracking::Global<BasicTaintConfig>;
select projectRoot(), count(DataFlow::Node node | BasicTaintFlow::flowTo(node))

View File

@@ -11,12 +11,12 @@
import javascript
import meta.internal.TaintMetrics
class BasicTaintConfiguration extends TaintTracking::Configuration {
BasicTaintConfiguration() { this = "BasicTaintConfiguration" }
module BasicTaintConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node node) { node = relevantSanitizerOutput() }
override predicate isSource(DataFlow::Node node) { node = relevantSanitizerOutput() }
override predicate isSink(DataFlow::Node node) { node = relevantTaintSink() }
predicate isSink(DataFlow::Node node) { node = relevantTaintSink() }
}
select projectRoot(), count(DataFlow::Node node | any(BasicTaintConfiguration cfg).hasFlow(_, node))
module BasicTaintFlow = TaintTracking::Global<BasicTaintConfig>;
select projectRoot(), count(DataFlow::Node node | BasicTaintFlow::flowTo(node))

View File

@@ -12,16 +12,16 @@
import javascript
import meta.internal.TaintMetrics
class BasicTaintConfiguration extends TaintTracking::Configuration {
BasicTaintConfiguration() { this = "BasicTaintConfiguration" }
module BasicTaintConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node node) { node = relevantTaintSource() }
override predicate isSource(DataFlow::Node node) { node = relevantTaintSource() }
override predicate isSink(DataFlow::Node node) {
predicate isSink(DataFlow::Node node) {
// To reduce noise from synthetic nodes, only count value nodes
node instanceof DataFlow::ValueNode and
not node.getFile() instanceof IgnoredFile
}
}
select projectRoot(), count(DataFlow::Node node | any(BasicTaintConfiguration cfg).hasFlow(_, node))
module BasicTaintFlow = TaintTracking::Global<BasicTaintConfig>;
select projectRoot(), count(DataFlow::Node node | BasicTaintFlow::flowTo(node))