Skip to content

Commit

Permalink
[FEATURE] In JSON report: print info about matched pattern in a separ…
Browse files Browse the repository at this point in the history
…ate chunk
  • Loading branch information
hasherezade committed Feb 18, 2024
1 parent 85362e5 commit ce63d66
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions scanners/workingset_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ namespace pesieve {
outs << ",\n";
OUT_PADDED(outs, level, "\"has_shellcode\" : ");
outs << std::dec << has_shellcode;
if (all_matched_count) {
outs << ",\n";
OUT_PADDED(outs, level, "\"patterns_matched\" : ");
outs << std::dec << all_matched_count;
}
if (custom_matched.size()) {
outs << ",\n";
OUT_PADDED(outs, level, "\"custom_matched\" : ");
outs << std::dec << custom_matched.size();
}
if (!is_executable) {
outs << ",\n";
OUT_PADDED(outs, level, "\"is_executable\" : ");
Expand All @@ -88,6 +78,7 @@ namespace pesieve {
OUT_PADDED(outs, level, "\"mapped_name\" : ");
outs << "\"" << pesieve::util::escape_path_separators(mapped_name) << "\"";
}
patternsToJSON(outs, level, jdetails);
#ifdef CALC_PAGE_STATS
if (stats.isFilled()) {
outs << ",\n";
Expand Down Expand Up @@ -129,6 +120,26 @@ namespace pesieve {
}
return "unknown";
}
///---

const void patternsToJSON(std::stringstream& outs, size_t level, const pesieve::t_json_level& jdetails)
{
if (!all_matched_count) {
return;
}
outs << ",\n";
OUT_PADDED(outs, level, "\"patterns\" : {\n");
const size_t level2 = level + 1;
OUT_PADDED(outs, level2, "\"total_matched\" : ");
outs << std::dec << all_matched_count;
if (custom_matched.size()) {
outs << ",\n";
OUT_PADDED(outs, level2, "\"custom_matched\" : ");
outs << std::dec << custom_matched.size();
}
outs << "\n";
OUT_PADDED(outs, level, "}");
}
};


Expand Down

0 comments on commit ce63d66

Please sign in to comment.