Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
output: sarif-results
upload: never

- name: Filter external results and SVDConv source suppressions
- name: Filter external results and approved source suppressions
run: |
set -euo pipefail
mkdir sarif-results-filtered
Expand All @@ -84,6 +84,16 @@ jobs:
and any(.suppressions[]?;
.kind == "inSource" and ((.status // "accepted") == "accepted")
);
def is_xmlreader_trivial_switch_suppression:
.ruleId == "cpp/trivial-switch"
and (
(.locations[0].physicalLocation.artifactLocation.uri // "")
| gsub("\\\\"; "/")
| test("^(\\./)?libs/xmlreader/src/XML_Reader\\.cpp$")
)
and any(.suppressions[]?;
.kind == "inSource" and ((.status // "accepted") == "accepted")
);
.runs |= map(
.results |= map(
select(
Expand All @@ -92,6 +102,7 @@ jobs:
| not
)
| select(is_svdconv_unused_suppression | not)
| select(is_xmlreader_trivial_switch_suppression | not)
)
)
' "$sarif_file" > "sarif-results-filtered/$(basename "$sarif_file")"
Expand Down
5 changes: 5 additions & 0 deletions libs/xmlreader/src/XML_Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,13 @@ UTFCode XML_Reader::CheckUTF(const string& text)
const char* str = text.c_str();

UTFCode utfDetected = UTFCode::UTF_NULL;
// Keep the byte-decoding switch structure extensible for additional BOM variants.
switch (*str++) {
case (char)0xEF: {
// codeql[cpp/trivial-switch]
switch (*str++) {
case (char)0xBB: {
// codeql[cpp/trivial-switch]
switch (*str++) {
case (char)0xBF: {
utfDetected = UTFCode::UTF8;
Expand All @@ -418,6 +421,7 @@ UTFCode XML_Reader::CheckUTF(const string& text)
} break;

case (char)0xFE: {
// codeql[cpp/trivial-switch]
switch (*str++) {
case (char)0xFF: {
utfDetected = UTFCode::UTF16_BE;
Expand All @@ -428,6 +432,7 @@ UTFCode XML_Reader::CheckUTF(const string& text)
} break;

case (char)0xFF: {
// codeql[cpp/trivial-switch]
switch (*str++) {
case (char)0xFE: {
utfDetected = UTFCode::UTF16_LE;
Expand Down
Loading