clamav is throwing error while upgrading lambda runtimeversion to 3.11

237 views Asked by At
def current_library_search_path()
    ld_verbose = check_output(["ld", "--verbose"]).decode("utf-8")
    rd_ld = re.compile("SEARCH_DIR\(\"([A-z0-9/-]*)\"\)")
    return rd_ld.findall(ld_verbose)
[ERROR] FileNotFoundError: [Errno 2] No such file or directory: 'ld'
Traceback (most recent call last):
  File "/var/task/update.py", line 43, in lambda_handler
    clamav.update_defs_from_freshclam(AV_DEFINITION_PATH, CLAMAVLIB_PATH)
  File "/var/task/clamav.py", line 100, in update_defs_from_freshclam
    fc_env["LD_LIBRARY_PATH"] = "%s:%s" % (":".join(current_library_search_path()), CLAMAVLIB_PATH)

The code works fine with Lambda runtime 3.7 as of now but not with runtimes 3.8/3.9/3.10/3.11 Since as EOL is approaching, we need to upgrade it to 3.11 (recommended by AWS).

Has anyone recently faced this issue, and what is the fix done.

We are using below code - https://github.com/bluesentry/bucket-antivirus-function

1

There are 1 answers

0
Nazmul On

My approach has been to avoid using the ld part entirely, and it has proven effective for me.

I've replaced this:

fc_env["LD_LIBRARY_PATH"] = "%s:%s" % (":".join(current_library_search_path()), CLAMAVLIB_PATH)

With:

fc_env["LD_LIBRARY_PATH"] = "%s:%s" % (fc_env["LD_LIBRARY_PATH"], CLAMAVLIB_PATH)