aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2018-01-31 00:56:57 +0200
committerAndrew Lewis <nerf@judo.za.org>2018-02-12 13:14:56 +0200
commit724a0b6e7cfdf9652e3f04bebad58a8ec617b174 (patch)
treea9fcd5391eb013eae0e431b67ca507ea4718decd /lualib
parent5d4e163d94b22142ec80d42985d9b8cb3950946f (diff)
downloadrspamd-724a0b6e7cfdf9652e3f04bebad58a8ec617b174.tar.gz
rspamd-724a0b6e7cfdf9652e3f04bebad58a8ec617b174.zip
[Minor] Small fixes for rspamadm corpus_test
Diffstat (limited to 'lualib')
-rw-r--r--lualib/rspamadm/corpus_test.lua19
1 files changed, 13 insertions, 6 deletions
diff --git a/lualib/rspamadm/corpus_test.lua b/lualib/rspamadm/corpus_test.lua
index fa296a0b4..eb93d586c 100644
--- a/lualib/rspamadm/corpus_test.lua
+++ b/lualib/rspamadm/corpus_test.lua
@@ -1,3 +1,4 @@
+local rspamd_logger = require "rspamd_logger"
local ucl = require "ucl"
local lua_util = require "lua_util"
@@ -41,13 +42,17 @@ local function encoded_json_to_log(result)
local is_good, err = parser:parse_string(result)
if not is_good then
- print(err)
- os.exit()
+ io.stderr:write(rspamd_logger.slog("Parser error: %1\n", err))
+ return nil
end
result = parser:get_object()
filtered_result.score = result.score
+ if not result.action then
+ io.stderr:write(rspamd_logger.slog("Bad JSON: %1\n", result))
+ return nil
+ end
local action = result.action:gsub("%s+", "_")
filtered_result.action = action
@@ -72,8 +77,10 @@ local function scan_results_to_logs(results, actual_email_type)
for _, result in pairs(results) do
result = encoded_json_to_log(result)
- result['type'] = actual_email_type
- table.insert(logs, result)
+ if result then
+ result['type'] = actual_email_type
+ table.insert(logs, result)
+ end
end
return logs
@@ -106,7 +113,7 @@ return function (_, res)
if spam_directory then
io.write("Scanning spam corpus...\n")
- local spam_results = scan_email(connections, spam_directory)
+ local spam_results = scan_email(connections, spam_directory, res.timeout)
spam_results = scan_results_to_logs(spam_results, SPAM)
no_of_spam = #spam_results
@@ -124,4 +131,4 @@ return function (_, res)
io.write(string.format("No of ham: %d\n", no_of_ham))
io.write(string.format("No of spam: %d\n", no_of_spam))
-end \ No newline at end of file
+end