Skip to content
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

msg-filter: abstract out numbers from error[too-many] findings #188

Merged
merged 1 commit into from
Jun 14, 2024
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
5 changes: 5 additions & 0 deletions src/lib/msg-filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ MsgFilter::MsgFilter():
d(new Private)
{
d->addMsgFilter("", "[0-9][0-9]* out of [0-9][0-9]* times");

// abstract out the number of occurrences and rate limit in error[too-many] findings
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.
15 changes: 15 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,15 @@
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-190):
<unknown>: error[memleak]: 1573 occurrences of warning[cpp/memleak] 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] = ';';
7 changes: 7 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,7 @@
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

Error: SNYK_CODE_WARNING (CWE-190):
<unknown>: error[memleak]: 15173 occurrences of warning[cpp/memleak] exceeded the specified limit 102123
sqlite-src-3260000/tsrc/testfile3.c:1304:5: note: 573 occurrences of warning[cpp/IntegerOverflow] were discarded because of this