Skip to main content

Crate vaas

Crate vaas 

Source
Expand description

§Verdict-as-a-Service SDK

vaas is a client SDK for the Verdict-as-a-Service (VaaS) platform by the GDATA CyberSecurity AG. It provides an API to check a hash sum of a file or a file for malicious content.

§Intended For

The vaas SDK is intended for developers who want to integrate Verdict-as-a-Service into their product. For example to check all files uploaded by user on a website or plugin into an e-mail client, to check all attachments of an e-mail for malicious content.

§More information

Please see the main project information on GitHub for more information on VaaS, licensing, and credentials.

§Examples

Check a file hash for malicious content:

use vaas::{error::VResult, CancellationToken, Vaas, VaasVerdict, Sha256};
use vaas::authentication::ClientCredentials;
use vaas::options::ForSha256Options;
use std::convert::TryFrom;
use std::time::Duration;

#[tokio::main]
async fn main() -> VResult<()> {
    let ct = CancellationToken::new();
    // Create VaaS instance
    let authenticator = ClientCredentials::try_new("client_id".to_string(), "client_secret".to_string())?;
    let vaas = Vaas::builder(authenticator).build()?;

    // Create the SHA256 we want to check.
    let sha256 = Sha256::try_from("698CDA840A0B344639F0C5DBD5C629A847A27448A9A179CB6B7A648BC1186F23")?;

    // Perform the lookup
    let verdict = vaas.for_sha256(&sha256, ForSha256Options::default(), &ct).await?;

    // Prints "Clean", "Malicious" or "Unknown"
    println!("{}", verdict.verdict);
    Ok(())
}

Check a file for malicious content:

use vaas::{error::VResult, CancellationToken, Vaas, VaasVerdict};
use vaas::authentication::ClientCredentials;
use vaas::options::ForFileOptions;
use std::convert::TryFrom;
use std::time::Duration;

#[tokio::main]
async fn main() -> VResult<()> {
    let ct = CancellationToken::new();
    // Create VaaS instance
    let authenticator = ClientCredentials::try_new("client_id".to_string(), "client_secret".to_string())?;
    let vaas = Vaas::builder(authenticator).build()?;

    // Create file we want to check.
    let file = std::path::Path::new("myfile");

    // Perform the lookup
    let verdict = vaas.for_file(&file, ForFileOptions::default(), &ct).await?;

    // Prints "Clean", "Pup" or "Malicious"
    println!("{}", verdict.verdict);
    Ok(())
}

Check a file behind a URL for malicious content:

use vaas::{error::VResult, CancellationToken, Vaas, VaasVerdict};
use vaas::authentication::ClientCredentials;
use vaas::options::ForUrlOptions;
use reqwest::Url;
use std::convert::TryFrom;
use std::time::Duration;

#[tokio::main]
async fn main() -> VResult<()> {
    let ct = CancellationToken::new();
    // Create VaaS instance
    let authenticator = ClientCredentials::try_new("client_id".to_string(), "client_secret".to_string())?;
    let vaas = Vaas::builder(authenticator).build()?;

    let url = Url::parse("https://mytesturl.test").unwrap();

    // Perform the lookup
    let verdict = vaas.for_url(&url, ForUrlOptions::default(), &ct).await?;

    // Prints "Clean", "Pup" or "Malicious"
    println!("{}", verdict.verdict);
    Ok(())
}

Re-exports§

pub use crate::vaas::Vaas;
pub use builder::Builder;
pub use sha256::Sha256;
pub use vaas_verdict::VaasVerdict;

Modules§

authentication
Authentication
builder
The Builder struct create a new Vaas instance with the expected default values and allows the custom configuration.
error
The Error type is returned by the vaas API everywhere, where an error can occur.
message
Contains messages (requests and responses) between the client and the server endpoints.
options
Contains configuration options to customize the behavior of VaaS scanning
sha256
Implements a SHA256 structure that guarantees that a given hash string is in the correct format.
vaas
The Vaas module provides all needed functions to check a hash or file for malicious content.
vaas_verdict
VaaS Verdict

Structs§

Bytes
A cheaply cloneable and sliceable chunk of contiguous memory.
CancellationToken
A token which can be used to signal a cancellation request to one or more tasks.