Skip to content

Antivirus

Purpose

Provides antivirus methods.

Methods

Binding name: p6.antivirus


scan (inputstream)

Since 6.9.2

Execute an antivirus scan on an inputstream and returns if the file is clean.

Syntax

boolean p6.antivirus.scan(Inpustream stream)

Warning

To perform the antivirus scan, the stream will be read.

If you need to consume the stream after the scan, you will need to:

  • reset the stream (using reset()) is markSupported() is true on the steam.
  • or read the stream from the source again.
Example
new File("p6file:/opt/p6core.data/path/to/file.pdf").newInputStream().withCloseable { stream ->
    if (p6.antivirus.scan(stream)) {
      println "File delete or quarantine automatically depending on config"
    }
}

scan (file)

Since 6.9.2

Read the content of the file, execute the scan and returns if the file is clean.

Syntax

boolean p6.antivirus.scan(String uri)
Example
if (p6.antivirus.scan("p6file:/opt/p6core.data/path/to/file.pdf")) {
  println "File delete or quarantine automatically depending on config"
}

Antivirus

By default, there is no antivirus installed on the instance. You can configure one according to the antivirus configuration.

Warning

If antivirus.engine=none all the scanned files are considered clean.

If a file is detected as corrupted, according to antivirus.action the file will be:

Delete mode (default)

Corrupted files are deleted. No recovery possible.

Quarantine mode

Corrupted files are moved to ${P6_DATA}/resources/quarantine with a unique name.

A report file will be created having the same name and suffixed by -metadata.txt.

Report example

Original file: /opt/p6.data/resources/path/to/currupted.file
Scan date: 2023-04-19T15:30:31.524340Z
Report: Virus XXX detected
Ignore mode

Corrupted files are just mentioned in the log. No action will be done.

Warning

This mode is not recommended and should be used on purpose.