File tree Expand file tree Collapse file tree 3 files changed +51
-3
lines changed
cpp/ql/test/query-tests/Security/CWE/CWE-611 Expand file tree Collapse file tree 3 files changed +51
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
// ---
6
6
7
- class SecurityManager ;
8
- class InputSource ;
7
+
8
+
9
9
10
10
class AbstractDOMParser {
11
11
public:
Original file line number Diff line number Diff line change 1
- // library functions for rule CWE-611
1
+ // library/common functions for rule CWE-611
2
2
3
+ class SecurityManager ;
4
+ class InputSource ;
Original file line number Diff line number Diff line change
1
+ // test cases for rule CWE-611
2
+
3
+ #include " tests.h"
4
+
5
+ // ---
6
+
7
+ class SAXParser
8
+ {
9
+ public:
10
+ SAXParser ();
11
+
12
+ void setDisableDefaultEntityResolution (bool ); // default is false
13
+ void setSecurityManager (SecurityManager *const manager);
14
+ void parse (const InputSource &data);
15
+ };
16
+
17
+ // ---
18
+
19
+ void test2_1 (InputSource &data) {
20
+ SAXParser *p = new SAXParser ();
21
+
22
+ p->parse (data); // BAD (parser not correctly configured) [NOT DETECTED]
23
+ }
24
+
25
+ void test2_2 (InputSource &data) {
26
+ SAXParser *p = new SAXParser ();
27
+
28
+ p->setDisableDefaultEntityResolution (true );
29
+ p->parse (data); // GOOD
30
+ }
31
+
32
+ void test2_3 (InputSource &data) {
33
+ SAXParser *p = new SAXParser ();
34
+ bool v = false ;
35
+
36
+ p->setDisableDefaultEntityResolution (v);
37
+ p->parse (data); // BAD (parser not correctly configured) [NOT DETECTED]
38
+ }
39
+
40
+ void test2_4 (InputSource &data) {
41
+ SAXParser *p = new SAXParser ();
42
+ bool v = true ;
43
+
44
+ p->setDisableDefaultEntityResolution (v);
45
+ p->parse (data); // GOOD
46
+ }
You can’t perform that action at this time.
0 commit comments