From 17a2760f8bbbed2a1b3d9bf5a3cf91240e504400 Mon Sep 17 00:00:00 2001 From: Sefinek Date: Thu, 10 Apr 2025 02:05:41 +0200 Subject: [PATCH] Fixes --- index.js | 18 +++++++----------- scripts | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index dcf1fe7..0d5e4d1 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,7 @@ const reportToAbuseIPDb = async (logData, categories, comment) => { log(0, `Reported ${logData.srcIp} [${logData.dpt}/${logData.proto}]; ID: ${logData.id}; Categories: ${categories}; Abuse: ${res.data.abuseConfidenceScore}%`); return true; } catch (err) { - log(2, `Failed to report ${logData.srcIp} [${logData.dpt}/${logData.proto}]; ID: ${logData.id}; ${err.message}\n${JSON.stringify(err.response.data?.errors || err.response.data)}`); + log(2, `Failed to report ${logData.srcIp} [${logData.dpt}/${logData.proto}]; ID: ${logData.id}; ${err.message}\n${JSON.stringify(err.response.data?.errors || err.response.data)}`, 0); return false; } }; @@ -40,7 +40,7 @@ const toNumber = (str, regex) => { }; const processLogLine = async (line, test = false) => { - if (!line.includes('[UFW BLOCK]')) return log(0, `Ignoring invalid line: ${line}`); + if (!line.includes('[UFW BLOCK]')) return log(1, `Ignoring invalid line: ${line}`, 1); const logData = { date: parseTimestamp(line), // Log timestamp @@ -65,21 +65,17 @@ const processLogLine = async (line, test = false) => { }; const { srcIp, proto, dpt } = logData; - if (!srcIp) { - return log(2, `Missing SRC in the log line: ${line}`); - } + if (!srcIp) return log(2, `Missing SRC in the log line: ${line}`, 1); const ips = getServerIPs(); - if (!Array.isArray(ips)) { - return log(2, 'For some reason, \'ips\' is not an array'); - } + if (!Array.isArray(ips)) return log(2, 'For some reason, \'ips\' is not an array', 1); if (ips.includes(srcIp)) { - return log(0, `Ignoring own IP address! PROTO=${proto?.toLowerCase()} SRC=${srcIp} DPT=${dpt} ID=${logData.id}`); + return log(0, `Ignoring own IP address! PROTO=${proto?.toLowerCase()} SRC=${srcIp} DPT=${dpt} ID=${logData.id}`, 1); } if (isLocalIP(srcIp)) { - return log(0, `Ignoring local IP address! PROTO=${proto?.toLowerCase()} SRC=${srcIp} DPT=${dpt} ID=${logData.id}`); + return log(0, `Ignoring local IP address! PROTO=${proto?.toLowerCase()} SRC=${srcIp} DPT=${dpt} ID=${logData.id}`, 1); } // Report MUST NOT be of an attack where the source address is likely spoofed i.e. SYN floods and UDP floods. @@ -142,7 +138,7 @@ const processLogLine = async (line, test = false) => { const stats = fs.statSync(path); if (stats.size < fileOffset) { fileOffset = 0; - log(1, 'The file has been truncated, and the offset has been reset'); + log(1, 'The file has been truncated, and the offset has been reset', 1); } fs.createReadStream(path, { start: fileOffset, encoding: 'utf8' }).on('data', chunk => { diff --git a/scripts b/scripts index 4582f3c..46096e9 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit 4582f3ce9de4f852ba17bdbe516e319ec6d75686 +Subproject commit 46096e9790bd5a6544a0a1f1c3ab63d3882bd0d5