From: Eric Bollengier Date: Wed, 17 Apr 2024 07:39:31 +0000 (+0200) Subject: Enforce malware database download from Abuse.ch X-Git-Tag: Release-15.0.3~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ba1fa8410da1be0adf0322508044e31622a47a5;p=thirdparty%2Fbacula.git Enforce malware database download from Abuse.ch --- diff --git a/bacula/scripts/get_malware_abuse.ch b/bacula/scripts/get_malware_abuse.ch index 22d4536aa..0f310fe53 100755 --- a/bacula/scripts/get_malware_abuse.ch +++ b/bacula/scripts/get_malware_abuse.ch @@ -78,7 +78,7 @@ open(FP, "curl --silent $url $uncompress | $dir/md5tobase64.py|") or die "Unable while (my $l = ) { print FP2 $l; } -close(FP); +close(FP) or die "Unable to download $url database"; close(FP2); print "$dest\n"; diff --git a/bacula/scripts/md5tobase64.py b/bacula/scripts/md5tobase64.py index 893cb0fc8..7e376afca 100755 --- a/bacula/scripts/md5tobase64.py +++ b/bacula/scripts/md5tobase64.py @@ -18,6 +18,7 @@ parser.add_argument('--keep-padding', action='store_true', help="keep the '=' at args=parser.parse_args() def handle_file(input_file, remove_padding): + nb=0 for line in input_file: line=line.rstrip() if md5_re.match(line): @@ -27,13 +28,19 @@ def handle_file(input_file, remove_padding): if remove_padding: b64=b64.rstrip('=') print(b64) + nb = nb + 1 + return nb +nb=0 remove_padding=not args.keep_padding if args.file: for filename in args.file: input_file=open(filename) - handle_file(input_file, remove_padding) + nb += handle_file(input_file, remove_padding) else: # use stdin - handle_file(sys.stdin, remove_padding) + nb += handle_file(sys.stdin, remove_padding) + +# Raise an error if we have converted nothing +sys.exit(nb == 0)