Skip to content

Commit

Permalink
msg-filters: added filter for too-many event in csdiff
Browse files Browse the repository at this point in the history
Resolves: issues.redhat.com/browse/OSH-496

Added filter and test for error[too-many] findings in csdiff in order to apply the filter deterministically even if the location and the number of occurrences vary
  • Loading branch information
jperezdealgaba committed Jun 12, 2024
1 parent be1def4 commit 55f3ae2
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/msg-filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ MsgFilter::MsgFilter():
d(new Private)
{
d->addMsgFilter("", "[0-9][0-9]* out of [0-9][0-9]* times");
// abstrct out the occurences and specified rate limit
d->addMsgFilter("", "[0-9]+ (occurrences of warning\\[.*\\] exceeded the specified limit) [0-9]+", "NNNN \\1 NNNN");
d->addMsgFilter("UNUSED_VALUE",
"\\(instance [0-9]+\\)");
d->addMsgFilter("STRING_OVERFLOW",
Expand Down
1 change: 1 addition & 0 deletions tests/csdiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@ test_csdiff(diff-misc 22-kernel-zstream-path)
test_csdiff(diff-misc 23-cov-parser-key-event)
test_csdiff(diff-misc 24-shellcheck-line-content)
test_csdiff(diff-misc 25-llvm-17-path-filter)
test_csdiff(diff-misc 26-too-many-events-filter)

add_subdirectory(filter-file)
7 changes: 7 additions & 0 deletions tests/csdiff/diff-misc/26-too-many-events-filter-add-z.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Error: SNYK_CODE_WARNING (CWE-89):
sqlite-src-3260000/tool/speedtest8.c:219:11: error[cpp/Sqli]: Unsanitized input from a file flows into sqlite3_prepare_v2, where it is used in an SQL query. This may result in an SQL injection vulnerability.
# 217| nStmt++;
# 218| nByte += n;
# 219|-> prepareAndRun(db, &zSql[i], bQuiet);
# 220| }
# 221| zSql[j] = ';';
7 changes: 7 additions & 0 deletions tests/csdiff/diff-misc/26-too-many-events-filter-add.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Error: SNYK_CODE_WARNING (CWE-89):
sqlite-src-3260000/tool/speedtest8.c:219:11: error[cpp/Sqli]: Unsanitized input from a file flows into sqlite3_prepare_v2, where it is used in an SQL query. This may result in an SQL injection vulnerability.
# 217| nStmt++;
# 218| nByte += n;
# 219|-> prepareAndRun(db, &zSql[i], bQuiet);
# 220| }
# 221| zSql[j] = ';';
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions tests/csdiff/diff-misc/26-too-many-events-filter-new.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Error: SNYK_CODE_WARNING (CWE-190):
<unknown>: error[too-many]: 1573 occurrences of warning[cpp/IntegerOverflow] exceeded the specified limit 1024
sqlite-src-3260000/tsrc/testfile3.c:1304:5: note: 573 occurrences of warning[cpp/IntegerOverflow] were discarded because of this

Error: SNYK_CODE_WARNING (CWE-89):
sqlite-src-3260000/tool/speedtest8.c:219:11: error[cpp/Sqli]: Unsanitized input from a file flows into sqlite3_prepare_v2, where it is used in an SQL query. This may result in an SQL injection vulnerability.
# 217| nStmt++;
# 218| nByte += n;
# 219|-> prepareAndRun(db, &zSql[i], bQuiet);
# 220| }
# 221| zSql[j] = ';';
3 changes: 3 additions & 0 deletions tests/csdiff/diff-misc/26-too-many-events-filter-old.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Error: SNYK_CODE_WARNING (CWE-190):
<unknown>: error[too-many]: 1573 occurrences of warning[cpp/IntegerOverflow] exceeded the specified limit 1024
sqlite-src-3260000/tsrc/fts3.c:1304:5: note: 573 occurrences of warning[cpp/IntegerOverflow] were discarded because of this

0 comments on commit 55f3ae2

Please sign in to comment.