Skip to content

Commit

Permalink
Added support for Cyren AV
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklax committed Dec 13, 2021
1 parent 07d9e17 commit 8228fc6
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following options are available in the **options** array.

**Returns**

* An `array` with keys `spam` (score), `vod` (virus score), `refid` and `rules` on success (etc.)
* An `array` with keys `spam` (score), `vod` (virus score), `virus` (list of viruses), `refid` and `rules` on success (etc.)
* An `array` with key `error` on errors

### cyren_ip(senderip, [options])
Expand Down
57 changes: 57 additions & 0 deletions cyren.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ void cyren_as(HalonHSLContext* hhc, HalonHSLArguments* args, HalonHSLValue* ret)

HalonMTA_hsl_value_set(ret, HALONMTA_HSL_TYPE_ARRAY, nullptr, 0);
auto ss = std::stringstream(data);
HalonHSLValue *virus = nullptr;
double virusl = 0;
for (std::string line; std::getline(ss, line, '\n');)
{
line.erase(line.find_last_not_of(" \n\r\t") + 1);
Expand Down Expand Up @@ -301,6 +303,61 @@ void cyren_as(HalonHSLContext* hhc, HalonHSLArguments* args, HalonHSLValue* ret)
HalonMTA_hsl_value_set(v, HALONMTA_HSL_TYPE_NUMBER, &malicious_category, 0);
continue;
}
if (key == "x-ctch-av-threatscount")
{
HalonMTA_hsl_value_array_add(ret, &k, &v);
HalonMTA_hsl_value_set(k, HALONMTA_HSL_TYPE_STRING, "virus", 0);
HalonMTA_hsl_value_set(v, HALONMTA_HSL_TYPE_ARRAY, nullptr, 0);
}
if (key == "x-ctch-av-scanresult")
{
if (value == "Infected")
{
auto viruslist = HalonMTA_hsl_value_array_find(ret, "virus");
if (viruslist)
{
HalonMTA_hsl_value_array_add(viruslist, &k, &virus);
HalonMTA_hsl_value_set(k, HALONMTA_HSL_TYPE_NUMBER, &virusl, 0);
HalonMTA_hsl_value_set(virus, HALONMTA_HSL_TYPE_ARRAY, nullptr, 0);
++virusl;
}
}
else
{
virus = nullptr;
}
continue;
}
if (key == "x-ctch-av-detectiontype")
{
if (virus)
{
HalonMTA_hsl_value_array_add(virus, &k, &v);
HalonMTA_hsl_value_set(k, HALONMTA_HSL_TYPE_STRING, "type", 0);
HalonMTA_hsl_value_set(v, HALONMTA_HSL_TYPE_STRING, value.c_str(), value.size());
}
continue;
}
if (key == "x-ctch-av-detectionaccuracy")
{
if (virus)
{
HalonMTA_hsl_value_array_add(virus, &k, &v);
HalonMTA_hsl_value_set(k, HALONMTA_HSL_TYPE_STRING, "accuracy", 0);
HalonMTA_hsl_value_set(v, HALONMTA_HSL_TYPE_STRING, value.c_str(), value.size());
}
continue;
}
if (key == "x-ctch-av-detectionname")
{
if (virus)
{
HalonMTA_hsl_value_array_add(virus, &k, &v);
HalonMTA_hsl_value_set(k, HALONMTA_HSL_TYPE_STRING, "name", 0);
HalonMTA_hsl_value_set(v, HALONMTA_HSL_TYPE_STRING, value.c_str(), value.size());
}
continue;
}
}
}

Expand Down

0 comments on commit 8228fc6

Please sign in to comment.