Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibClamAV Error: cl_load(): No such file or directory: /var/lib/clamav #5

Open
glenadamson1984 opened this issue Oct 16, 2020 · 3 comments

Comments

@glenadamson1984
Copy link

I notice when a layer is installed the folder structure is /opt/ then whatever files are in the layer so in this case clamscan is in /opt/bin/clamscan.

However when i run the virus scan via an aws lambda is throws and error not with reading the file that could potentially be infected but by being unable to find its own directory in /var/lib/clamav - can you offer any guidance.

I would very much appreciate it.

@Maxwell2022
Copy link
Contributor

how do you run it in you node application?

@m-schrepel
Copy link

This appears to happen when you run the command with child_process.exec, but not childProcess.spawn

// doesn't work

    fs.writeFileSync('/tmp/bs.txt', 'hello world!', { encoding: 'utf8' })
    const file = fs.readFileSync('/tmp/bs.txt', 'utf8')
    console.log('file contents', file)

    const scan = execSync('clamscan /tmp/bs.txt')
    console.log('scan status', scan.status);
    console.log(scan.stdout.toString());

produces:

{
  "errorType": "Error",
  "errorMessage": "Command failed: clamscan /tmp/bs.txt\nLibClamAV Error: cl_load(): No such file or directory: /var/clamav\nERROR: Can't get file status\n",
  "trace": [
    "Error: Command failed: clamscan /tmp/bs.txt",
    "LibClamAV Error: cl_load(): No such file or directory: /var/clamav",
    "ERROR: Can't get file status",
    "",
    "    at checkExecSyncError (child_process.js:616:11)",
    "    at execSync (child_process.js:652:15)",
    "    at Runtime.exports.handler (/var/task/index.js:10:18)",
    "    at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)"
  ]
}

// works kinda

    const spawnSync = require('child_process').spawnSync;

    fs.writeFileSync('/tmp/bs.txt', "hello world!", { encoding: 'utf8' })
    const file = fs.readFileSync('/tmp/bs.txt', 'utf8')
    console.log('file contents:', file)

    const scan = spawnSync('clamscan', ['', '/tmp/bs.txt'], {
        stdio: 'pipe',
        stderr: 'pipe'
    });
    console.log('scan status', scan.status);
    console.log(scan.stdout.toString());

produces:

Function Logs
START RequestId: 6a8d44a4-1113-4c1a-8e58-c4ddb9853cc9 Version: $LATEST
2021-02-04T03:06:03.457Z	6a8d44a4-1113-4c1a-8e58-c4ddb9853cc9	INFO	file contents: hello world!
2021-02-04T03:06:04.598Z	6a8d44a4-1113-4c1a-8e58-c4ddb9853cc9	INFO	scan status 2
2021-02-04T03:06:04.617Z	6a8d44a4-1113-4c1a-8e58-c4ddb9853cc9	INFO	
----------- SCAN SUMMARY -----------
Known viruses: 0
Engine version: 0.102.4
Scanned directories: 0
Scanned files: 0
Infected files: 0
Data scanned: 0.00 MB
Data read: 0.00 MB (ratio 0.00:1)
Time: 0.380 sec (0 m 0 s)

@tktwong
Copy link

tktwong commented Apr 8, 2022

Hi all,
Implement the same approach as m-schrepel but still got "No such file or directory"
//My codes
const scanStatus: SpawnSyncReturns<Buffer> = spawnSync('clamscan', ['--database=/opt/var/lib/clamav',/tmp/${record.s3.object.key}], { stdio: 'pipe', encoding: 'buffer', }); console.log('scanStatus', scanStatus); console.log('stdout', scanStatus.stdout.toString()); console.log('stderr', scanStatus.stderr.toString()); scanStatus.output.forEach(item => console.log(item && item.toString()));

//scanStatus
37772a93-7eb3-4de5-aae4-979e26d2232f INFO scanStatus { status: 2, signal: null, output: [ null, <Buffer 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 53 43 41 4e 20 53 55 4d 4d 41 52 59 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 4b 6e 6f 77 6e 20 76 69 72 75 73 65 ... 233 more bytes>, <Buffer 4c 69 62 43 6c 61 6d 41 56 20 45 72 72 6f 72 3a 20 63 6c 5f 6c 6f 61 64 28 29 3a 20 4e 6f 20 73 75 63 68 20 66 69 6c 65 20 6f 72 20 64 69 72 65 63 74 ... 54 more bytes> ], pid: 24, stdout: <Buffer 0a 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 20 53 43 41 4e 20 53 55 4d 4d 41 52 59 20 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 0a 4b 6e 6f 77 6e 20 76 69 72 75 73 65 ... 233 more bytes>, stderr: <Buffer 4c 69 62 43 6c 61 6d 41 56 20 45 72 72 6f 72 3a 20 63 6c 5f 6c 6f 61 64 28 29 3a 20 4e 6f 20 73 75 63 68 20 66 69 6c 65 20 6f 72 20 64 69 72 65 63 74 ... 54 more bytes> }

//stdout
37772a93-7eb3-4de5-aae4-979e26d2232f INFO stdout ----------- SCAN SUMMARY -----------Known viruses: 0Engine version: 0.103.5Scanned directories: 0Scanned files: 0Infected files: 0Data scanned: 0.00 MBData read: 0.00 MB (ratio 0.00:1)Time: 0.021 sec (0 m 0 s)Start Date: 2022:04:08 08:42:12End Date: 2022:04:08 08:42:12 | 2022-04-08T08:42:12.612Z 37772a93-7eb3-4de5-aae4-979e26d2232f INFO stdout ----------- SCAN SUMMARY ----------- Known viruses: 0 Engine version: 0.103.5 Scanned directories: 0 Scanned files: 0 Infected files: 0 Data scanned: 0.00 MB Data read: 0.00 MB (ratio 0.00:1) Time: 0.021 sec (0 m 0 s) Start Date: 2022:04:08 08:42:12 End Date: 2022:04:08 08:42:12

//stderr
37772a93-7eb3-4de5-aae4-979e26d2232f INFO stderr LibClamAV Error: cl_load(): No such file or directory: /opt/var/lib/clamav ERROR: Can't get file status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants