diff options
author | Phil Ross <phil.ross@gmail.com> | 2019-10-25 18:47:43 +0100 |
---|---|---|
committer | Phil Ross <phil.ross@gmail.com> | 2019-10-25 18:47:43 +0100 |
commit | 3731797bf86bda905b6db44ada175fbed96b3d7a (patch) | |
tree | 589bbf472aa5fcb1fb3479c58f1c0667689f51ec | |
parent | 0d916d0c7a636fcd72d80f73193d8543a1e6dcd3 (diff) | |
download | rspamd-3731797bf86bda905b6db44ada175fbed96b3d7a.tar.gz rspamd-3731797bf86bda905b6db44ada175fbed96b3d7a.zip |
[Fix] Fix a failure calcuating URL reputation.
`url_reputation_filter` was attempting to lookup the token key returned
in the `get_token` callback in an integer-indexed table of requests.
Change to looking up the request by its index.
Commit 73d2cee changed from using `gen_url_queries` to
`lua_util.extract_specific_urls` in the assignment of `requests`.
The latter just returns a list of URLs. The former returns the TLD along
with the number of hits. The URL score calculation uses the number of
hits. Revert to using `gen_url_queries`.
-rw-r--r-- | src/plugins/lua/reputation.lua | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/plugins/lua/reputation.lua b/src/plugins/lua/reputation.lua index 6b43c7fb4..8b2b8c5a4 100644 --- a/src/plugins/lua/reputation.lua +++ b/src/plugins/lua/reputation.lua @@ -284,15 +284,15 @@ local function gen_url_queries(task, rule) end local function url_reputation_filter(task, rule) - local requests = lua_util.extract_specific_urls(task, rule.selector.config.max_urls) + local requests = gen_url_queries(task, rule) local results = {} local nchecked = 0 - local function tokens_cb(err, token, values) + local function indexed_tokens_cb(err, index, values) nchecked = nchecked + 1 if values then - results[token] = values + results[index] = values end if nchecked == #requests then @@ -319,8 +319,12 @@ local function url_reputation_filter(task, rule) end end - for _,u in ipairs(requests) do - rule.backend.get_token(task, rule, u:get_tld(), tokens_cb) + for i,req in ipairs(requests) do + local function tokens_cb(err, token, values) + indexed_tokens_cb(err, i, values) + end + + rule.backend.get_token(task, rule, req[1], tokens_cb) end end |