Skip to content

Commit 27b6b99

Browse files
committed
C++: Correct and improve some comments and naming.
1 parent 2ad81e6 commit 27b6b99

File tree

2 files changed

+13
-9
lines changed
  • cpp/ql
    • src/Security/CWE/CWE-611
    • test/query-tests/Security/CWE/CWE-611

2 files changed

+13
-9
lines changed

cpp/ql/src/Security/CWE/CWE-611/XXE.ql

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ class XercesDOMParserFlowState extends XXEFlowState {
8181
}
8282

8383
/**
84-
* The qualifier of a call to `AbstractDOMParser.setDisableDefaultEntityResolution`.
84+
* Flow state transformer for a call to
85+
* `AbstractDOMParser.setDisableDefaultEntityResolution`. Transforms the flow
86+
* state through the qualifier according to the setting in the parameter.
8587
*/
8688
class DisableDefaultEntityResolutionTranformer extends XXEFlowStateTranformer {
8789
Expr newValue;
@@ -111,7 +113,9 @@ class DisableDefaultEntityResolutionTranformer extends XXEFlowStateTranformer {
111113
}
112114

113115
/**
114-
* The qualifier of a call to `AbstractDOMParser.setDisableDefaultEntityResolution`.
116+
* Flow state transformer for a call to
117+
* `AbstractDOMParser.setCreateEntityReferenceNodes`. Transforms the flow
118+
* state through the qualifier according to the setting in the parameter.
115119
*/
116120
class CreateEntityReferenceNodesTranformer extends XXEFlowStateTranformer {
117121
Expr newValue;
@@ -151,13 +155,13 @@ class ParseFunction extends Function {
151155
}
152156

153157
/**
154-
* Configuration for tracking Xerces library XML objects and their states.
158+
* Configuration for tracking XML objects and their states.
155159
*/
156-
class XercesXXEConfiguration extends DataFlow::Configuration {
157-
XercesXXEConfiguration() { this = "XercesXXEConfiguration" }
160+
class XXEConfiguration extends DataFlow::Configuration {
161+
XXEConfiguration() { this = "XXEConfiguration" }
158162

159163
override predicate isSource(DataFlow::Node node, string flowstate) {
160-
// source is the write on `this` of a call to the XercesDOMParser
164+
// source is the write on `this` of a call to the `XercesDOMParser`
161165
// constructor.
162166
exists(CallInstruction call |
163167
call.getStaticCallTarget() = any(XercesDOMParserClass c).getAConstructor() and
@@ -192,7 +196,7 @@ class XercesXXEConfiguration extends DataFlow::Configuration {
192196
}
193197
}
194198

195-
from XercesXXEConfiguration conf, DataFlow::PathNode source, DataFlow::PathNode sink
199+
from XXEConfiguration conf, DataFlow::PathNode source, DataFlow::PathNode sink
196200
where conf.hasFlowPath(source, sink)
197201
select sink, source, sink,
198202
"This $@ is not configured to prevent an External Entity Expansion (XXE) attack.", source,

cpp/ql/test/query-tests/Security/CWE/CWE-611/tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class AbstractDOMParser {
1111
public:
1212
AbstractDOMParser();
1313

14-
void setDisableDefaultEntityResolution(bool); // default is false (bad)
15-
void setCreateEntityReferenceNodes(bool); // default is true (good)
14+
void setDisableDefaultEntityResolution(bool); // default is false
15+
void setCreateEntityReferenceNodes(bool); // default is true
1616
void setSecurityManager(SecurityManager *const manager);
1717
void parse(const InputSource &data);
1818
};

0 commit comments

Comments
 (0)