Skip to content

Commit

Permalink
feat: handle alerts file
Browse files Browse the repository at this point in the history
  • Loading branch information
swarit-pandey committed Aug 23, 2024
1 parent 161a1b9 commit da54306
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {

const NETWORK_EVENTS_PREFIX = "knoxctl_scan_network_events_md_";
const PROCESS_TREE_PREFIX = "knoxctl_scan_process_tree_";
const ALERTS_PREFIX = "knoxctl_scan_processed_alerts_";

function stopKnoxctlScan(): void {
const pidFile = getPidFilePath();
Expand Down Expand Up @@ -79,13 +80,14 @@ function processResultFile(
outputDir: string,
prefix: string,
title: string,
emoji: string,
): void {
const file = getLatestFile(outputDir, prefix);
if (file) {
const filePath = path.join(outputDir, file);
log(`Processing ${title} file: ${filePath}`);
const content = fs.readFileSync(filePath, ENCODING);
addToSummary(`## ${title}\n\n${content}`);
addToSummary(`## ${emoji} ${title}\n\n${content}`);
} else {
log(
`No ${title.toLowerCase()} file found with prefix ${prefix} in ${outputDir}`,
Expand All @@ -111,8 +113,9 @@ function processResults(): void {

addToSummary("# 📊 Runtime Security Report Generated by AccuKnox\n\n");

processResultFile(outputDir, NETWORK_EVENTS_PREFIX, "🌐 Network Events");
processResultFile(outputDir, PROCESS_TREE_PREFIX, "🖥️ Process Tree");
processResultFile(outputDir, NETWORK_EVENTS_PREFIX, "Network Events", "🌐");
processResultFile(outputDir, PROCESS_TREE_PREFIX, "Process Tree", "🖥️");
processResultFile(outputDir, ALERTS_PREFIX, "Alerts Summary", "🚨");

if (!IS_GITHUB_ACTIONS) {
log(
Expand Down

0 comments on commit da54306

Please sign in to comment.