-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Add support for SAXParser to the CWE-611 XXE query. #8948
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4e2344c
C++: Add test cases for SAXParser.
geoffw0 2ccd5a5
C++: Add support for SAXParser in the query.
geoffw0 79d1ffc
C++: Change note.
geoffw0 33d499c
C++: Address review comments.
geoffw0 215453e
Update cpp/ql/src/Security/CWE/CWE-611/XXE.ql
geoffw0 7fb1069
C++: Use GVN on the values passed into set* functions.
geoffw0 034c4fa
Merge branch 'main' into xxe3
geoffw0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
cpp/ql/src/change-notes/2022-04-28-external-entity-expansion.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* The "XML external entity expansion" (`cpp/external-entity-expansion`) query has been extended to support a broader selection of XML libraries and interfaces. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
|
||
// --- | ||
|
||
class SecurityManager; | ||
class InputSource; | ||
|
||
|
||
|
||
class AbstractDOMParser { | ||
public: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
// library functions for rule CWE-611 | ||
// library/common functions for rule CWE-611 | ||
|
||
class SecurityManager; | ||
class InputSource; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// test cases for rule CWE-611 | ||
|
||
#include "tests.h" | ||
|
||
// --- | ||
|
||
class SAXParser | ||
{ | ||
public: | ||
SAXParser(); | ||
|
||
void setDisableDefaultEntityResolution(bool); // default is false | ||
void setSecurityManager(SecurityManager *const manager); | ||
void parse(const InputSource &data); | ||
}; | ||
|
||
// --- | ||
|
||
void test2_1(InputSource &data) { | ||
SAXParser *p = new SAXParser(); | ||
|
||
p->parse(data); // BAD (parser not correctly configured) | ||
} | ||
|
||
void test2_2(InputSource &data) { | ||
SAXParser *p = new SAXParser(); | ||
|
||
p->setDisableDefaultEntityResolution(true); | ||
p->parse(data); // GOOD | ||
} | ||
|
||
void test2_3(InputSource &data) { | ||
SAXParser *p = new SAXParser(); | ||
bool v = false; | ||
|
||
p->setDisableDefaultEntityResolution(v); | ||
p->parse(data); // BAD (parser not correctly configured) | ||
} | ||
|
||
void test2_4(InputSource &data) { | ||
SAXParser *p = new SAXParser(); | ||
bool v = true; | ||
|
||
p->setDisableDefaultEntityResolution(v); | ||
p->parse(data); // GOOD | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Acronyms should be PascalCase/camelCase.