Skip to content

Commit 08293d0

Browse files
committed
CPP: Simplify.
1 parent 98b9afd commit 08293d0

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

cpp/ql/src/Likely Bugs/Protocols/boostorg/TlsSettingsMisconfiguration.ql

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,29 @@ class ExistsAnyFlowConfig extends DataFlow::Configuration {
1414
ExistsAnyFlowConfig() { this = "ExistsAnyFlowConfig" }
1515

1616
override predicate isSource(DataFlow::Node source) {
17-
source.asExpr() instanceof ConstructorCall
17+
exists(BoostorgAsio::SslContextClass c |
18+
c.getAContructorCall() = source.asExpr()
19+
)
1820
}
1921

2022
override predicate isSink(DataFlow::Node sink) { any() }
2123
}
2224

2325
bindingset[flag]
2426
predicate isOptionSet(ConstructorCall cc, int flag, FunctionCall fcSetOptions) {
25-
exists(BoostorgAsio::SslContextClass c, ExistsAnyFlowConfig anyFlowConfig
26-
|
27-
c.getAContructorCall() = cc and
28-
exists(VariableAccess contextSetOptions |
29-
anyFlowConfig.hasFlow(DataFlow::exprNode(cc), DataFlow::exprNode(contextSetOptions)) and
30-
exists(BoostorgAsio::SslSetOptionsFunction f | f.getACallToThisFunction() = fcSetOptions |
31-
contextSetOptions = fcSetOptions.getQualifier() and
32-
forall(
33-
Expr optionArgument, BoostorgAsio::SslOptionConfig optionArgConfig,
34-
Expr optionArgumentSource
35-
|
36-
optionArgument = fcSetOptions.getArgument(0) and
37-
optionArgConfig
38-
.hasFlow(DataFlow::exprNode(optionArgumentSource), DataFlow::exprNode(optionArgument))
39-
|
40-
optionArgument.getValue().toInt().bitShiftRight(16).bitAnd(flag) = flag
41-
)
27+
exists(ExistsAnyFlowConfig anyFlowConfig, VariableAccess contextSetOptions |
28+
anyFlowConfig.hasFlow(DataFlow::exprNode(cc), DataFlow::exprNode(contextSetOptions)) and
29+
exists(BoostorgAsio::SslSetOptionsFunction f | f.getACallToThisFunction() = fcSetOptions |
30+
contextSetOptions = fcSetOptions.getQualifier() and
31+
forall(
32+
Expr optionArgument, BoostorgAsio::SslOptionConfig optionArgConfig,
33+
Expr optionArgumentSource
34+
|
35+
optionArgument = fcSetOptions.getArgument(0) and
36+
optionArgConfig
37+
.hasFlow(DataFlow::exprNode(optionArgumentSource), DataFlow::exprNode(optionArgument))
38+
|
39+
optionArgument.getValue().toInt().bitShiftRight(16).bitAnd(flag) = flag
4240
)
4341
)
4442
)
@@ -54,7 +52,7 @@ predicate isOptionNotSet(ConstructorCall cc, int flag) {
5452
from
5553
BoostorgAsio::SslContextCallTlsProtocolConfig configConstructor,
5654
Expr protocolSource, Expr protocolSink,
57-
BoostorgAsio::SslContextClass c, ConstructorCall cc, Expr e, string msg
55+
ConstructorCall cc, Expr e, string msg
5856
where
5957
configConstructor.hasFlow(DataFlow::exprNode(protocolSource), DataFlow::exprNode(protocolSink)) and
6058
cc.getArgument(0) = protocolSink and

0 commit comments

Comments
 (0)