Skip to content

Commit 6c751ce

Browse files
committed
Merged config classes
1 parent 4dac80a commit 6c751ce

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

javascript/ql/lib/semmle/javascript/security/CorsPermissiveConfigurationCustomizations.qll

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ import javascript
1010
module CorsPermissiveConfiguration {
1111
private newtype TFlowState =
1212
TTaint() or
13-
TTrueOrNull() or
14-
TWildcard()
13+
TPermissive()
1514

16-
/** A flow state to asociate with a tracked value. */
15+
/** A flow state to associate with a tracked value. */
1716
class FlowState extends TFlowState {
1817
/** Gets a string representation of this flow state. */
1918
string toString() {
2019
this = TTaint() and result = "taint"
2120
or
22-
this = TTrueOrNull() and result = "true-or-null"
23-
or
24-
this = TWildcard() and result = "wildcard"
21+
this = TPermissive() and result = "permissive"
2522
}
2623
}
2724

@@ -30,11 +27,8 @@ module CorsPermissiveConfiguration {
3027
/** A tainted value. */
3128
FlowState taint() { result = TTaint() }
3229

33-
/** A `true` or `null` value. */
34-
FlowState trueOrNull() { result = TTrueOrNull() }
35-
36-
/** A `"*"` value. */
37-
FlowState wildcard() { result = TWildcard() }
30+
/** A permissive value (true, null, or "*"). */
31+
FlowState permissive() { result = TPermissive() }
3832
}
3933

4034
/**
@@ -59,14 +53,13 @@ module CorsPermissiveConfiguration {
5953
ActiveThreatModelSourceAsSource() { not this instanceof ClientSideRemoteFlowSource }
6054
}
6155

62-
/** An overly permissive value for `origin` (Apollo) */
63-
class TrueNullValue extends Source {
64-
TrueNullValue() { this.mayHaveBooleanValue(true) or this.asExpr() instanceof NullLiteral }
65-
}
66-
67-
/** An overly permissive value for `origin` (Express) */
68-
class WildcardValue extends Source {
69-
WildcardValue() { this.mayHaveStringValue("*") }
56+
/** An overly permissive value for `origin` configuration. */
57+
class PermissiveValue extends Source {
58+
PermissiveValue() {
59+
this.mayHaveBooleanValue(true) or
60+
this.asExpr() instanceof NullLiteral or
61+
this.mayHaveStringValue("*")
62+
}
7063
}
7164

7265
/**

javascript/ql/lib/semmle/javascript/security/CorsPermissiveConfigurationQuery.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ module CorsPermissiveConfigurationConfig implements DataFlow::StateConfigSig {
1919
class FlowState = CorsPermissiveConfiguration::FlowState;
2020

2121
predicate isSource(DataFlow::Node source, FlowState state) {
22-
source instanceof TrueNullValue and state = FlowState::trueOrNull()
23-
or
24-
source instanceof WildcardValue and state = FlowState::wildcard()
22+
source instanceof PermissiveValue and state = FlowState::permissive()
2523
or
2624
source instanceof RemoteFlowSource and state = FlowState::taint()
2725
}
2826

2927
predicate isSink(DataFlow::Node sink, FlowState state) {
3028
sink instanceof CorsOriginSink and
31-
state = [FlowState::taint(), FlowState::trueOrNull(), FlowState::wildcard()]
29+
state = [FlowState::taint(), FlowState::permissive()]
3230
}
3331

3432
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }

0 commit comments

Comments
 (0)