Skip to content

Commit 3396438

Browse files
committed
add individual per-security-query counting queries
1 parent 728ccaf commit 3396438

File tree

6 files changed

+132
-0
lines changed

6 files changed

+132
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* For internal use only.
3+
*
4+
*
5+
* Count the number of sinks and alerts for the `CodeInjection` security query.
6+
*/
7+
8+
import javascript
9+
import semmle.javascript.security.dataflow.CodeInjectionQuery as CodeInjection
10+
import evaluation.EndToEndEvaluation
11+
12+
int numAlerts(DataFlow::Configuration cfg) {
13+
result =
14+
count(DataFlow::Node source, DataFlow::Node sink |
15+
cfg.hasFlow(source, sink) and not isFlowExcluded(source, sink)
16+
)
17+
}
18+
19+
select numAlerts(any(CodeInjection::Configuration cfg)) as numAlerts,
20+
count(DataFlow::Node sink |
21+
exists(CodeInjection::Configuration cfg | cfg.isSink(sink) or cfg.isSink(sink, _))
22+
) as numSinks
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* For internal use only.
3+
*
4+
*
5+
* Count the number of sinks and alerts for the `NosqlInection` security query.
6+
*/
7+
8+
import javascript
9+
import semmle.javascript.security.dataflow.NosqlInjectionQuery as NosqlInjection
10+
import evaluation.EndToEndEvaluation
11+
12+
int numAlerts(DataFlow::Configuration cfg) {
13+
result =
14+
count(DataFlow::Node source, DataFlow::Node sink |
15+
cfg.hasFlow(source, sink) and not isFlowExcluded(source, sink)
16+
)
17+
}
18+
19+
select numAlerts(any(NosqlInjection::Configuration cfg)) as numAlerts,
20+
count(DataFlow::Node sink |
21+
exists(NosqlInjection::Configuration cfg | cfg.isSink(sink) or cfg.isSink(sink, _))
22+
) as numSinks
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* For internal use only.
3+
*
4+
*
5+
* Count the number of sinks and alerts for the `SqlInection` security query.
6+
*/
7+
8+
import javascript
9+
import semmle.javascript.security.dataflow.SqlInjectionQuery as SqlInjection
10+
import evaluation.EndToEndEvaluation
11+
12+
int numAlerts(DataFlow::Configuration cfg) {
13+
result =
14+
count(DataFlow::Node source, DataFlow::Node sink |
15+
cfg.hasFlow(source, sink) and not isFlowExcluded(source, sink)
16+
)
17+
}
18+
19+
select numAlerts(any(SqlInjection::Configuration cfg)) as numAlerts,
20+
count(DataFlow::Node sink |
21+
exists(SqlInjection::Configuration cfg | cfg.isSink(sink) or cfg.isSink(sink, _))
22+
) as numSinks
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* For internal use only.
3+
*
4+
*
5+
* Count the number of sinks and alerts for the `TaintedPath` security query.
6+
*/
7+
8+
import javascript
9+
import semmle.javascript.security.dataflow.TaintedPathQuery as TaintedPath
10+
import evaluation.EndToEndEvaluation
11+
12+
int numAlerts(DataFlow::Configuration cfg) {
13+
result =
14+
count(DataFlow::Node source, DataFlow::Node sink |
15+
cfg.hasFlow(source, sink) and not isFlowExcluded(source, sink)
16+
)
17+
}
18+
19+
select numAlerts(any(TaintedPath::Configuration cfg)) as numAlerts,
20+
count(DataFlow::Node sink |
21+
exists(TaintedPath::Configuration cfg | cfg.isSink(sink) or cfg.isSink(sink, _))
22+
) as numSinks
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* For internal use only.
3+
*
4+
*
5+
* Count the number of sinks and alerts for the `DomBasedXss` security query.
6+
*/
7+
8+
import javascript
9+
import semmle.javascript.security.dataflow.DomBasedXssQuery as DomBasedXss
10+
import evaluation.EndToEndEvaluation
11+
12+
int numAlerts(DataFlow::Configuration cfg) {
13+
result =
14+
count(DataFlow::Node source, DataFlow::Node sink |
15+
cfg.hasFlow(source, sink) and not isFlowExcluded(source, sink)
16+
)
17+
}
18+
19+
select numAlerts(any(DomBasedXss::Configuration cfg)) as numAlerts,
20+
count(DataFlow::Node sink |
21+
exists(DomBasedXss::Configuration cfg | cfg.isSink(sink) or cfg.isSink(sink, _))
22+
) as numSinks
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* For internal use only.
3+
*
4+
*
5+
* Count the number of sinks and alerts for the `XssThroughDom` security query.
6+
*/
7+
8+
import javascript
9+
import semmle.javascript.security.dataflow.XssThroughDomQuery as XssThroughDom
10+
import evaluation.EndToEndEvaluation
11+
12+
int numAlerts(DataFlow::Configuration cfg) {
13+
result =
14+
count(DataFlow::Node source, DataFlow::Node sink |
15+
cfg.hasFlow(source, sink) and not isFlowExcluded(source, sink)
16+
)
17+
}
18+
19+
select numAlerts(any(XssThroughDom::Configuration cfg)) as numAlerts,
20+
count(DataFlow::Node sink |
21+
exists(XssThroughDom::Configuration cfg | cfg.isSink(sink) or cfg.isSink(sink, _))
22+
) as numSinks

0 commit comments

Comments
 (0)