Skip to content

Commit 3d44f0c

Browse files
author
Max Schaefer
committed
JavaScript: Autoformat new libraries.
1 parent fb53a69 commit 3d44f0c

File tree

11 files changed

+146
-185
lines changed

11 files changed

+146
-185
lines changed

javascript/ql/src/Security/Summaries/AllConfigurations.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
import javascript
6-
76
import semmle.javascript.security.dataflow.BrokenCryptoAlgorithm
87
import semmle.javascript.security.dataflow.CleartextLogging
98
import semmle.javascript.security.dataflow.CleartextStorage

javascript/ql/src/Security/Summaries/ExtractFlowStepSummaries.ql

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ import AllConfigurations
1313
import PortalExitSource
1414
import PortalEntrySink
1515

16-
from TaintTracking::Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink,
17-
Portal p1, Portal p2, DataFlow::FlowLabel lbl1, DataFlow::FlowLabel lbl2
18-
where cfg.hasFlowPath(source, sink) and
19-
p1 = source.getNode().(PortalExitSource).getPortal() and
20-
p2 = sink.getNode().(PortalEntrySink).getPortal() and
21-
lbl1 = sink.getPathSummary().getStartLabel() and
22-
lbl2 = sink.getPathSummary().getEndLabel() and
23-
// avoid constructing infeasible paths
24-
sink.getPathSummary().hasCall() = false and
25-
sink.getPathSummary().hasReturn() = false and
26-
// restrict to steps flow function parameters to returns
27-
p1.(ParameterPortal).getBasePortal() = p2.(ReturnPortal).getBasePortal() and
28-
// restrict to data/taint flow
29-
lbl1 instanceof DataFlow::StandardFlowLabel
30-
select p1.toString(), lbl1.toString(),
31-
p2.toString(), lbl2.toString(),
32-
cfg.toString()
16+
from
17+
TaintTracking::Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, Portal p1,
18+
Portal p2, DataFlow::FlowLabel lbl1, DataFlow::FlowLabel lbl2
19+
where
20+
cfg.hasFlowPath(source, sink) and
21+
p1 = source.getNode().(PortalExitSource).getPortal() and
22+
p2 = sink.getNode().(PortalEntrySink).getPortal() and
23+
lbl1 = sink.getPathSummary().getStartLabel() and
24+
lbl2 = sink.getPathSummary().getEndLabel() and
25+
// avoid constructing infeasible paths
26+
sink.getPathSummary().hasCall() = false and
27+
sink.getPathSummary().hasReturn() = false and
28+
// restrict to steps flow function parameters to returns
29+
p1.(ParameterPortal).getBasePortal() = p2.(ReturnPortal).getBasePortal() and
30+
// restrict to data/taint flow
31+
lbl1 instanceof DataFlow::StandardFlowLabel
32+
select p1.toString(), lbl1.toString(), p2.toString(), lbl2.toString(), cfg.toString()
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @name Extract sink summaries
3-
* @description Extracts sink summaries, that is, tuples `(p, lbl, cfg)` representing the fact
3+
* @description Extracts sink summaries, that is, tuples `(p, lbl, cfg)` representing the fact
44
* that data with flow label `lbl` may flow from a user-controlled exit node of portal
55
* `p` to a known sink for configuration `cfg`.
66
* @kind sink-summary
@@ -11,10 +11,10 @@ import AllConfigurations
1111
import PortalExitSource
1212
import SinkFromAnnotation
1313

14-
from TaintTracking::Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink,
15-
Portal p
16-
where cfg.hasFlowPath(source, sink) and
17-
p = source.getNode().(PortalExitSource).getPortal() and
18-
// avoid constructing infeasible paths
19-
sink.getPathSummary().hasReturn() = false
14+
from TaintTracking::Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, Portal p
15+
where
16+
cfg.hasFlowPath(source, sink) and
17+
p = source.getNode().(PortalExitSource).getPortal() and
18+
// avoid constructing infeasible paths
19+
sink.getPathSummary().hasReturn() = false
2020
select p.toString(), source.getPathSummary().getStartLabel().toString(), cfg.toString()

javascript/ql/src/Security/Summaries/ExtractSourceSummaries.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import AllConfigurations
1111
import PortalEntrySink
1212
import SourceFromAnnotation
1313

14-
from TaintTracking::Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink,
15-
Portal p
16-
where cfg.hasFlowPath(source, sink) and
17-
p = sink.getNode().(PortalEntrySink).getPortal() and
18-
// avoid constructing infeasible paths
19-
sink.getPathSummary().hasCall() = false
14+
from TaintTracking::Configuration cfg, DataFlow::PathNode source, DataFlow::PathNode sink, Portal p
15+
where
16+
cfg.hasFlowPath(source, sink) and
17+
p = sink.getNode().(PortalEntrySink).getPortal() and
18+
// avoid constructing infeasible paths
19+
sink.getPathSummary().hasCall() = false
2020
select p.toString(), sink.getPathSummary().getEndLabel().toString(), cfg.toString()

javascript/ql/src/Security/Summaries/ImportFromCsv.qll

Lines changed: 34 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,28 @@ private import Shared
1212
* An additional source specified in an `additional-sources.csv` file.
1313
*/
1414
class AdditionalSourceSpec extends ExternalData {
15-
AdditionalSourceSpec() {
16-
this.getDataPath() = "additional-sources.csv"
17-
}
15+
AdditionalSourceSpec() { this.getDataPath() = "additional-sources.csv" }
1816

1917
/**
2018
* Gets the portal of this additional source.
2119
*/
22-
Portal getPortal() {
23-
result.toString() = getField(0)
24-
}
20+
Portal getPortal() { result.toString() = getField(0) }
2521

2622
/**
2723
* Gets the flow label of this source.
2824
*/
29-
DataFlow::FlowLabel getFlowLabel() {
30-
sourceFlowLabelSpec(result, getField(1))
31-
}
25+
DataFlow::FlowLabel getFlowLabel() { sourceFlowLabelSpec(result, getField(1)) }
3226

3327
/**
3428
* Gets the configuration for which this is a source, or any
3529
* configuration if this source does not specify a configuration.
3630
*/
37-
DataFlow::Configuration getConfiguration() {
38-
configSpec(result, getField(2))
39-
}
31+
DataFlow::Configuration getConfiguration() { configSpec(result, getField(2)) }
4032

4133
override string toString() {
42-
exists (string config |
43-
if getField(2) = "" then
44-
config = "any configuration"
45-
else
46-
config = getConfiguration() |
34+
exists(string config |
35+
if getField(2) = "" then config = "any configuration" else config = getConfiguration()
36+
|
4737
result = getPortal() + " as " + getFlowLabel() + " source for " + config
4838
)
4939
}
@@ -52,9 +42,7 @@ class AdditionalSourceSpec extends ExternalData {
5242
private class AdditionalSourceFromSpec extends DataFlow::AdditionalSource {
5343
AdditionalSourceSpec spec;
5444

55-
AdditionalSourceFromSpec() {
56-
this = spec.getPortal().getAnExitNode(_)
57-
}
45+
AdditionalSourceFromSpec() { this = spec.getPortal().getAnExitNode(_) }
5846

5947
override predicate isSourceFor(DataFlow::Configuration cfg, DataFlow::FlowLabel lbl) {
6048
cfg = spec.getConfiguration() and lbl = spec.getFlowLabel()
@@ -65,40 +53,30 @@ private class AdditionalSourceFromSpec extends DataFlow::AdditionalSource {
6553
* An additional sink specified in an `additional-sinks.csv` file.
6654
*/
6755
class AdditionalSinkSpec extends ExternalData {
68-
AdditionalSinkSpec() {
69-
this.getDataPath() = "additional-sinks.csv"
70-
}
56+
AdditionalSinkSpec() { this.getDataPath() = "additional-sinks.csv" }
7157

7258
/**
7359
* Gets the portal specification of this additional sink.
7460
*/
75-
Portal getPortal() {
76-
result.toString() = getField(0)
77-
}
61+
Portal getPortal() { result.toString() = getField(0) }
7862

7963
/**
8064
* Gets the flow label of this sink, or any standard flow label if this sink
8165
* does not specify a flow label.
8266
*/
83-
DataFlow::FlowLabel getFlowLabel() {
84-
sinkFlowLabelSpec(result, getField(1))
85-
}
67+
DataFlow::FlowLabel getFlowLabel() { sinkFlowLabelSpec(result, getField(1)) }
8668

8769
/**
8870
* Gets the configuration for which this is a sink, or any configuration if
8971
* this sink does not specify a configuration.
9072
*/
91-
DataFlow::Configuration getConfiguration() {
92-
configSpec(result, getField(2))
93-
}
73+
DataFlow::Configuration getConfiguration() { configSpec(result, getField(2)) }
9474

9575
override string toString() {
96-
exists (string labels, string config |
76+
exists(string labels, string config |
9777
labels = strictconcat(getFlowLabel(), " or ") and
98-
if getField(2) = "" then
99-
config = "any configuration"
100-
else
101-
config = getConfiguration() |
78+
if getField(2) = "" then config = "any configuration" else config = getConfiguration()
79+
|
10280
result = getPortal() + " as " + labels + " sink for " + config
10381
)
10482
}
@@ -107,73 +85,59 @@ class AdditionalSinkSpec extends ExternalData {
10785
private class AdditionalSinkFromSpec extends DataFlow::AdditionalSink {
10886
AdditionalSinkSpec spec;
10987

110-
AdditionalSinkFromSpec() {
111-
this = spec.getPortal().getAnEntryNode(_)
112-
}
88+
AdditionalSinkFromSpec() { this = spec.getPortal().getAnEntryNode(_) }
11389

11490
override predicate isSinkFor(DataFlow::Configuration cfg, DataFlow::FlowLabel lbl) {
11591
cfg = spec.getConfiguration() and lbl = spec.getFlowLabel()
11692
}
11793
}
94+
11895
/**
11996
* An additional flow step specified in an `additional-steps.csv` file.
12097
*/
12198
class AdditionalStepSpec extends ExternalData {
122-
AdditionalStepSpec() {
123-
this.getDataPath() = "additional-steps.csv"
124-
}
99+
AdditionalStepSpec() { this.getDataPath() = "additional-steps.csv" }
125100

126101
/**
127102
* Gets the start portal of this additional step.
128103
*/
129-
Portal getStartPortal() {
130-
result.toString() = getField(0)
131-
}
104+
Portal getStartPortal() { result.toString() = getField(0) }
132105

133106
/**
134107
* Gets the start flow label of this additional step.
135108
*/
136-
DataFlow::FlowLabel getStartFlowLabel() {
137-
result.toString() = getField(1)
138-
}
109+
DataFlow::FlowLabel getStartFlowLabel() { result.toString() = getField(1) }
139110

140111
/**
141112
* Gets the end portal of this additional step.
142113
*/
143-
Portal getEndPortal() {
144-
result.toString() = getField(2)
145-
}
114+
Portal getEndPortal() { result.toString() = getField(2) }
146115

147116
/**
148117
* Gets the end flow label of this additional step.
149118
*/
150-
DataFlow::FlowLabel getEndFlowLabel() {
151-
result.toString() = getField(3)
152-
}
119+
DataFlow::FlowLabel getEndFlowLabel() { result.toString() = getField(3) }
153120

154121
/**
155122
* Gets the configuration to which this step should be added.
156123
*/
157-
DataFlow::Configuration getConfiguration() {
158-
configSpec(result, getField(4))
159-
}
124+
DataFlow::Configuration getConfiguration() { configSpec(result, getField(4)) }
160125

161126
override string toString() {
162-
exists (string config |
163-
if getField(4) = "" then
164-
config = "any configuration"
165-
else
166-
config = getConfiguration() |
167-
result = "edge from " + getStartPortal() + " to " + getEndPortal() +
168-
", transforming " + getStartFlowLabel() + " into " + getEndFlowLabel() +
169-
" for " + config
127+
exists(string config |
128+
if getField(4) = "" then config = "any configuration" else config = getConfiguration()
129+
|
130+
result = "edge from " + getStartPortal() + " to " + getEndPortal() + ", transforming " +
131+
getStartFlowLabel() + " into " + getEndFlowLabel() + " for " + config
170132
)
171133
}
172134
}
173135

174136
private class AdditionalFlowStepFromSpec extends DataFlow::Configuration {
175137
AdditionalStepSpec spec;
138+
176139
DataFlow::Node entry;
140+
177141
DataFlow::Node exit;
178142

179143
AdditionalFlowStepFromSpec() {
@@ -182,8 +146,10 @@ private class AdditionalFlowStepFromSpec extends DataFlow::Configuration {
182146
exit = spec.getEndPortal().getAnExitNode(_)
183147
}
184148

185-
override predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ,
186-
DataFlow::FlowLabel predlbl, DataFlow::FlowLabel succlbl) {
149+
override predicate isAdditionalFlowStep(
150+
DataFlow::Node pred, DataFlow::Node succ, DataFlow::FlowLabel predlbl,
151+
DataFlow::FlowLabel succlbl
152+
) {
187153
pred = entry and
188154
succ = exit and
189155
predlbl = spec.getStartFlowLabel() and

javascript/ql/src/Security/Summaries/ImportFromExternalPredicates.qll

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ external predicate additionalSinks(string portal, string flowLabel, string confi
2727
*
2828
* This predicate can be populated from the output of the `ExtractFlowStepSummaries` query.
2929
*/
30-
external predicate additionalSteps(string startPortal, string startFlowLabel, string endPortal, string endFlowLabel, string config);
30+
external predicate additionalSteps(
31+
string startPortal, string startFlowLabel, string endPortal, string endFlowLabel, string config
32+
);
3133

3234
/**
3335
* An additional source specified through the `additionalSources` predicate.
3436
*/
3537
private class AdditionalSourceFromSpec extends DataFlow::AdditionalSource {
3638
Portal portal;
39+
3740
string flowLabel;
41+
3842
string config;
3943

4044
AdditionalSourceFromSpec() {
@@ -52,7 +56,9 @@ private class AdditionalSourceFromSpec extends DataFlow::AdditionalSource {
5256
*/
5357
private class AdditionalSinkFromSpec extends DataFlow::AdditionalSink {
5458
Portal portal;
59+
5560
string flowLabel;
61+
5662
string config;
5763

5864
AdditionalSinkFromSpec() {
@@ -64,26 +70,33 @@ private class AdditionalSinkFromSpec extends DataFlow::AdditionalSink {
6470
configSpec(cfg, config) and sinkFlowLabelSpec(lbl, flowLabel)
6571
}
6672
}
73+
6774
/**
6875
* An additional flow step specified through the `additionalSteps` predicate.
6976
*/
7077
private class AdditionalFlowStepFromSpec extends DataFlow::Configuration {
7178
DataFlow::Node entry;
79+
7280
string startFlowLabel;
81+
7382
DataFlow::Node exit;
83+
7484
string endFlowLabel;
7585

7686
AdditionalFlowStepFromSpec() {
77-
exists (Portal startPortal, Portal endPortal, string config |
78-
additionalSteps(startPortal.toString(), startFlowLabel, endPortal.toString(), endFlowLabel, config) and
87+
exists(Portal startPortal, Portal endPortal, string config |
88+
additionalSteps(startPortal.toString(), startFlowLabel, endPortal.toString(), endFlowLabel,
89+
config) and
7990
configSpec(this, config) and
8091
entry = startPortal.getAnEntryNode(_) and
8192
exit = endPortal.getAnExitNode(_)
8293
)
8394
}
8495

85-
override predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ,
86-
DataFlow::FlowLabel predlbl, DataFlow::FlowLabel succlbl) {
96+
override predicate isAdditionalFlowStep(
97+
DataFlow::Node pred, DataFlow::Node succ, DataFlow::FlowLabel predlbl,
98+
DataFlow::FlowLabel succlbl
99+
) {
87100
pred = entry and
88101
succ = exit and
89102
predlbl = startFlowLabel and

javascript/ql/src/Security/Summaries/PortalEntrySink.qll

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@ import semmle.javascript.dataflow.Portals
88
class PortalEntrySink extends DataFlow::AdditionalSink {
99
Portal p;
1010

11-
PortalEntrySink() {
12-
this = p.getAnEntryNode(true)
13-
}
11+
PortalEntrySink() { this = p.getAnEntryNode(true) }
1412

1513
override predicate isSinkFor(DataFlow::Configuration cfg, DataFlow::FlowLabel lbl) {
1614
cfg instanceof TaintTracking::Configuration and
1715
lbl = any(DataFlow::FlowLabel l)
1816
}
1917

2018
/** Gets the portal of which this is an entry node. */
21-
Portal getPortal() {
22-
result = p
23-
}
19+
Portal getPortal() { result = p }
2420
}

0 commit comments

Comments
 (0)