in assets/lambda/code/download_defs/lambda.py [0:0]
def freshclam_update(download_path):
"""Points freshclam to the local database files. Downloads
the latest database files"""
conf = "/tmp/freshclam.conf"
# will already exist when Lambdas are running in same execution context
# or downloaded from the Virus Defs bucket
if not os.path.exists(conf):
with open(conf, "a") as f:
f.write("\nDNSDatabaseInfo current.cvd.clamav.net")
f.write("\nDatabaseMirror database.clamav.net")
f.write("\nReceiveTimeout 0")
f.write("\nCompressLocalDatabase true")
try:
command = [
"freshclam",
f"--config-file={conf}",
"--stdout",
"-u",
f"{pwd.getpwuid(os.getuid()).pw_name}",
f"--datadir={download_path}",
]
update_summary = subprocess.run(
command,
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
)
if update_summary.returncode != 0:
raise ClamAVException(
f"FreshClam exited with unexpected code: {update_summary.returncode}"
f"\nOutput: {update_summary.stdout}"
)
except subprocess.CalledProcessError as e:
report_failure(str(e.stderr))
except ClamAVException as e:
report_failure(e.message)
return