Skip to content

Commit

Permalink
msg-filter: abstract out notes about builtin models
Browse files Browse the repository at this point in the history
... so that semantically equal findings are matched with each other

Resolves: https://issues.redhat.com/browse/OSH-700
Closes: #189
  • Loading branch information
kdudka committed Jun 24, 2024
1 parent 3c764eb commit 25965d4
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 180 deletions.
10 changes: 6 additions & 4 deletions src/lib/msg-filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ MsgFilter::MsgFilter():
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",
"You might overrun the [0-9][0-9]* byte");
// whether a builtin model was used or not is insignificant for matching the finding
d->addMsgFilter("", " \\[Note: The source code implementation of the function has been overridden by a builtin model.\\]$");

d->addMsgFilter("UNUSED_VALUE", "\\(instance [0-9]+\\)");
d->addMsgFilter("STRING_OVERFLOW", "You might overrun the [0-9][0-9]* byte");

// ignore changes in parameters -> it is still the same UNUSED_VALUE
d->addMsgFilter("UNUSED_VALUE",
"returned by \"([^\\(]+)\\(.*\\)\"",
Expand Down
1 change: 1 addition & 0 deletions tests/csdiff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@ 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)
test_csdiff(diff-misc 27-cov-builtin-model)

add_subdirectory(filter-file)
Empty file.
Empty file.
Empty file.
Empty file.
23 changes: 23 additions & 0 deletions tests/csdiff/diff-misc/27-cov-builtin-model-new.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Error: FORWARD_NULL (CWE-476):
kernel-999/arch/x86/boot/compressed/kaslr.c:266:2: path: Condition "!args", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:271:2: path: Condition "!tmp_cmdline", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:3: path: Falling through to end of if statement.
kernel-999/arch/x86/boot/compressed/kaslr.c:305:2: path: Jumping back to the beginning of the loop.
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: var_compare_op: Comparing "val" to null implies that "val" might be null.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "strcmp(param, "--") == 0", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "1", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "strstr(param, "hugepages")", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:291:10: path: Condition "!strcmp(param, "mem")", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:292:4: alias_transfer: Assigning: "p" = "val".
kernel-999/arch/x86/boot/compressed/kaslr.c:294:4: var_deref_model: Passing null pointer "p" to "strcmp", which dereferences it. [Note: The source code implementation of the function has been overridden by a builtin model.]
# 292| char *p = val;
# 293|
# 294|-> if (!strcmp(p, "nopentium"))
# 295| continue;
# 296| mem_size = memparse(p, &p);
23 changes: 23 additions & 0 deletions tests/csdiff/diff-misc/27-cov-builtin-model-old.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Error: FORWARD_NULL (CWE-476):
kernel-999/arch/x86/boot/compressed/kaslr.c:266:2: path: Condition "!args", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:271:2: path: Condition "!tmp_cmdline", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:3: path: Falling through to end of if statement.
kernel-999/arch/x86/boot/compressed/kaslr.c:305:2: path: Jumping back to the beginning of the loop.
kernel-999/arch/x86/boot/compressed/kaslr.c:281:2: path: Condition "*args", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "!val", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: var_compare_op: Comparing "val" to null implies that "val" might be null.
kernel-999/arch/x86/boot/compressed/kaslr.c:284:3: path: Condition "strcmp(param, "--") == 0", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:287:3: path: Condition "!strcmp(param, "memmap")", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "1", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:289:10: path: Condition "strstr(param, "hugepages")", taking false branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:291:10: path: Condition "!strcmp(param, "mem")", taking true branch.
kernel-999/arch/x86/boot/compressed/kaslr.c:292:4: alias_transfer: Assigning: "p" = "val".
kernel-999/arch/x86/boot/compressed/kaslr.c:294:4: var_deref_model: Passing null pointer "p" to "strcmp", which dereferences it.
# 292| char *p = val;
# 293|
# 294|-> if (!strcmp(p, "nopentium"))
# 295| continue;
# 296| mem_size = memparse(p, &p);
Loading

0 comments on commit 25965d4

Please sign in to comment.