You are not logged in. Click here to log in.

codebeamer Application Lifecycle Management (ALM)

Search In Project

Search inClear

Tags:  not added yet

Content Virus Scanner

Out-of-the-box, the content virus scanning implementation or the antivirus software is not shipped with Codebeamer. Using File Upload Listener, you can implement an integrated virus scan programming interface.

Example Implementation: ClamAVFileUploadListener

The following example demonstrates how to use the FileUploadListener API to scan uploaded files for viruses with ClamAV antivirus.


Requirement

ClamAV virus scanner must be installed on the server where Codebeamer runs. See Installing ClamAV for detailed instructions.


Implementation Guidelines

Refer to Add virus scanner FileUploadListener on GitHub for a full implementation example. As a reference, see the following Java interface:


package com.intland.customization;

import java.nio.file.Path;

import org.springframework.stereotype.Component;

import com.intland.codebeamer.event.FileUploadEventData;
import com.intland.codebeamer.event.FileUploadListener;
import com.intland.codebeamer.event.util.VetoException;

import xyz.capybara.clamav.ClamavClient;
import xyz.capybara.clamav.ClamavException;
import xyz.capybara.clamav.commands.scan.result.ScanResult;

@Component
public class ClamavFileUploadListener implements FileUploadListener {

    private final ClamavClient clamavClient;

    public ClamavFileUploadListener() {
        this.clamavClient = new ClamavClient("127.0.0.1");
    }

    @Override
    public void fileUploaded(FileUploadEventData event) throws VetoException {
        try {
            Path filePath = event.getSource().toPath();
            ScanResult scanResult = clamavClient.scan(filePath);
            if (scanResult instanceof ScanResult.VirusFound virusFound) {
                throw new VetoException("Virus found during scan: " + virusFound.getFoundViruses());
            }
        } catch (ClamavException ex) {
            throw new VetoException(ex);
        }
    }
}