[pmg-devel] [RFC pmg-api 0/3] add support for custom checks
Stoiko Ivanov
s.ivanov at proxmox.com
Wed Mar 13 21:39:40 CET 2019
Closes #1988.
As seen every now and then in the forum and the pmg-devel mailinglists, quite
a few users want to be able to customize the way PMG does its spam/virus
detection.
Given that some of the requests cannot be fulfilled in general due to licensing
reasons (e.g. uploads to virus total might be ok for smaller scale setups, and
for private use, but not for all our userbase), or performance reasons
(non-daemonized AV scanners), this patchset tries to provide a stable 'API'
for users to attach their custom scanning tools to PMG.
I tried to keep the interface simple and thus the input to the custom_check (via
cli-args) is:
* the queue-file (the mail in rfc822 format)
and its result can be:
* OK
* VIRUS (with optional virus-description for logging)
* SCORE (a postive or negative number to be added to SpamAssassins result)
Additionally I added an api-version (inspired by PVE's custom storage
plugins), so that we have the option of changing the interface w/o breaking
already deployed custom_checks.
I would be grateful for a sensibility check of the concept and any hints to
caveats/pitfalls I did not think about!
For testing (and hopefully documentation) purposes I wrote a tiny /bin/sh script
which follows the API and returns random results (OK, VIRUS, SCORE, or runs into
a timeout):
```
#!/bin/sh
echo "called with $*" 1>&2
if [ "$#" -ne 2 ]; then
echo "usage: $0 APIVERSION QUEUEFILENAME" 1>&2
exit 1
fi
apiver="$1"
shift
if [ "$apiver" != "v1" ]; then
echo "wrong APIVERSION: $apiver" 1>&2
exit 2
fi
queue_file="$1"
echo "v1"
choice=$(shuf -i 0-3 -n1)
case "$choice" in
0)
echo OK
;;
1)
echo SCORE: 4
;;
2)
echo VIRUS: Random Virus
;;
3) #timeout-test
for i in $(seq 1 7); do
echo "custom checking mail: $queue_file - minute $i" 1>&2
sleep 60
done
;;
esac
exit 0
```
Stoiko Ivanov (3):
add custom_check handling
integrate custom_check
add debug dumper
PMG/Config.pm | 12 ++++++++
PMG/RuleDB/Spam.pm | 11 +++++++
PMG/Utils.pm | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++
bin/pmg-smtp-filter | 26 ++++++++++-------
4 files changed, 123 insertions(+), 10 deletions(-)
--
2.11.0
More information about the pmg-devel
mailing list