All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kanishka.virustotalv2.VirustotalPublicV2 Maven / Gradle / Ivy

The newest version!
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kanishka.virustotalv2;

import com.kanishka.virustotal.dto.DomainReport;
import com.kanishka.virustotal.dto.FileScanReport;
import com.kanishka.virustotal.dto.GeneralResponse;
import com.kanishka.virustotal.dto.IPAddressReport;
import com.kanishka.virustotal.dto.ScanInfo;
import com.kanishka.virustotal.exception.InvalidArgumentsException;
import com.kanishka.virustotal.exception.QuotaExceededException;
import com.kanishka.virustotal.exception.UnauthorizedAccessException;

import java.io.File;
import java.io.IOException;

/**
 * @author [email protected]
 */
public interface VirustotalPublicV2 {

    String URI_VT2_FILE_SCAN = "https://www.virustotal.com/vtapi/v2/file/scan";
    String URI_VT2_RESCAN = "https://www.virustotal.com/vtapi/v2/file/rescan";
    String URI_VT2_FILE_SCAN_REPORT = "https://www.virustotal.com/vtapi/v2/file/report";
    String URI_VT2_URL_SCAN = "https://www.virustotal.com/vtapi/v2/url/scan";
    String URI_VT2_URL_SCAN_REPORT = "http://www.virustotal.com/vtapi/v2/url/report";
    String URI_VT2_IP_REPORT = "http://www.virustotal.com/vtapi/v2/ip-address/report";
    String URI_VT2_DOMAIN_REPORT = "http://www.virustotal.com/vtapi/v2/domain/report";
    String URI_VT2_PUT_COMMENT = "https://www.virustotal.com/vtapi/v2/comments/put";
    String VT2_URL_SEPARATOR = "\n";
    int VT2_MAX_ALLOWED_URLS_PER_REQUEST = 4;

    /**
     * Scan a given single file
     *
     * @param fileToScan the file object to be scanned
     * @return scan information
     * @throws IOException                 If the request fails due to io issues
     * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation
     * @throws QuotaExceededException      If the api request rate limit is exceeded
     */
    ScanInfo scanFile(final File fileToScan) throws IOException, UnauthorizedAccessException, QuotaExceededException;

    /**
     * The call allows you to rescan files in VirusTotal's file store without having to resubmit them, thus saving bandwidth.
     * 
* The VirusTotal public API allows you to rescan files that you or other users already sent in the past and, hence, * are already present in our file store. Before requesting a rescan we encourage you to retrieve the latest report * on the files, if it is recent enough you might want to save time and bandwidth by making use of it. * * @param resources a set of md5/sha1/sha256 hashes.this allows you to perform a batch request with one * single call. Note that the file must already be present in our file * store. * @return The {@link ScanInfo} object describing the scan * @throws IOException If the request fails due to io issues * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation * @throws QuotaExceededException If the api request rate limit is exceeded * @throws InvalidArgumentsException If one of the specified resources cannot be found */ ScanInfo[] reScanFiles(final String[] resources) throws IOException, UnauthorizedAccessException, InvalidArgumentsException, QuotaExceededException; /** * Returns the detailed most reason scan report for a given resource * * @param resource a md5/sha1/sha256 hash will retrieve the most recent * report on a given sample. You may also specify a scan_id * (sha256-timestamp as returned by the file upload API) to access a * specific report. * @return The specified report * @throws IOException If the request fails due to io issues * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation * @throws QuotaExceededException If the api request rate limit is exceeded */ FileScanReport getScanReport(final String resource) throws IOException, UnauthorizedAccessException, QuotaExceededException; /** * Returns the detailed most reason scan reports for given set of resources * * @param resources You can also specify an array of resources (up to 4 items with the standard request rate), * this allows you to perform a batch request with one single call. * @return The specified reports * @throws IOException If the request fails due to io issues * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation * @throws QuotaExceededException If the api request rate limit is exceeded * @throws InvalidArgumentsException If one of the specified resources cannot be found */ FileScanReport[] getScanReports(final String[] resources) throws IOException, UnauthorizedAccessException, QuotaExceededException, InvalidArgumentsException; /** * URLs can also be submitted for scanning. Once again, before performing your submission we encourage you to retrieve * the latest report on the URL, if it is recent enough you might want to save time and bandwidth by making use of it. * * @param urls set of urls to be scanned * @return The {@link ScanInfo} object describing the scan * @throws IOException If the request fails due to io issues * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation * @throws QuotaExceededException If the api request rate limit is exceeded * @throws InvalidArgumentsException If one of the specified urls is invalid */ ScanInfo[] scanUrls(final String[] urls) throws IOException, UnauthorizedAccessException, QuotaExceededException, InvalidArgumentsException; /** * Returns the detailed scan report for given set of urls * * @param url set of urls * @param scan true if url s must be scanned before generating the report * @return The specified report * @throws IOException If the request fails due to io issues * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation * @throws QuotaExceededException If the api request rate limit is exceeded * @throws InvalidArgumentsException If one of the specified resources cannot be found */ FileScanReport[] getUrlScanReport(final String[] url, boolean scan) throws IOException, UnauthorizedAccessException, QuotaExceededException, InvalidArgumentsException; /** * Returns detailed report for a given IP * * @param ipAddress a valid IPv4 address in dotted quad notation, for the time being only IPv4 addresses are supported. * @return The specified report * @throws IOException If the request fails due to io issues * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation * @throws QuotaExceededException If the api request rate limit is exceeded * @throws InvalidArgumentsException If the specified ipAddress is invalid */ IPAddressReport getIPAddressReport(final String ipAddress) throws InvalidArgumentsException, QuotaExceededException, UnauthorizedAccessException, IOException; /** * Returns a detailed report for a given domain * * @param domain domain name * @return The specified report * @throws IOException If the request fails due to io issues * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation * @throws QuotaExceededException If the api request rate limit is exceeded * @throws InvalidArgumentsException If the specified domain is invalid */ DomainReport getDomainReport(final String domain) throws InvalidArgumentsException, UnauthorizedAccessException, QuotaExceededException, IOException; /** * @param resource either a md5/sha1/sha256 hash of the file you want to review or the URL itself that you want to comment on. * @param comment the actual review, you can tag it using the "#" twitter-like syntax (e.g. #disinfection #zbot) * and reference users using the "@" syntax (e.g. @VirusTotalTeam). * @return The API response * @throws IOException If the request fails due to io issues * @throws UnauthorizedAccessException If the specified api key does not allow access to this operation * @throws QuotaExceededException If the api request rate limit is exceeded * @throws InvalidArgumentsException If the specified resource cannot be found */ GeneralResponse makeAComment(final String resource, final String comment) throws IOException, UnauthorizedAccessException, InvalidArgumentsException, QuotaExceededException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy