1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
//! # 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.
//!
//! ## Contact
//!
//! For questions and support please contact us at [OEM at GDATA](mailto:oem@gdata.de)!
//!
//! # Examples
//!
//! Check a file hash for malicious content:
//! ```rust,no_run
//! use vaas::{error::VResult, CancellationToken, Vaas, VaasVerdict, Sha256};
//! use vaas::auth::authenticators::ClientCredentials;
//! use std::convert::TryFrom;
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> VResult<()> {
//! // Cancel the request after 10 seconds if no response is received.
//! let ct = CancellationToken::from_seconds(10);
//!
//! //Authenticate and create VaaS instance
//! let authenticator = ClientCredentials::new("client_id".to_string(), "client_secret".to_string());
//! let vaas = Vaas::builder(authenticator).build()?.connect().await?;
//!
//! // Create the SHA256 we want to check.
//! let sha256 = Sha256::try_from("698CDA840A0B344639F0C5DBD5C629A847A27448A9A179CB6B7A648BC1186F23")?;
//!
//! let verdict = vaas.for_sha256(&sha256, &ct).await?;
//!
//! // Prints "Clean", "Malicious" or "Unknown"
//! println!("{}", verdict.verdict);
//! Ok(())
//! }
//! ```
//!
//! Check a file for malicious content:
//! ```rust,no_run
//! use vaas::{error::VResult, CancellationToken, Vaas, VaasVerdict};
//! use vaas::auth::authenticators::ClientCredentials;
//! use std::convert::TryFrom;
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> VResult<()> {
//! // Cancel the request after 10 seconds if no response is received.
//! let ct = CancellationToken::from_seconds(10);
//!
//! //Authenticate and create VaaS instance
//! let authenticator = ClientCredentials::new("client_id".to_string(), "client_secret".to_string());
//! let vaas = Vaas::builder(authenticator).build()?.connect().await?;
//!
//! // Create file we want to check.
//! let file = std::path::PathBuf::from("myfile");
//!
//! let verdict = vaas.for_file(&file, &ct).await?;
//!
//! // Prints "Clean", "Pup" or "Malicious"
//! println!("{}", verdict.verdict);
//! Ok(())
//! }
//! ```
//!
//! Check a file behind a URL for malicious content:
//! ```rust,no_run
//! use vaas::{error::VResult, CancellationToken, Vaas, VaasVerdict};
//! use vaas::auth::authenticators::ClientCredentials;
//! use reqwest::Url;
//! use std::convert::TryFrom;
//! use std::time::Duration;
//!
//! #[tokio::main]
//! async fn main() -> VResult<()> {
//! // Cancel the request after 10 seconds if no response is received.
//! let ct = CancellationToken::from_seconds(10);
//!
//! //Authenticate and create VaaS instance
//! let authenticator = ClientCredentials::new("client_id".to_string(), "client_secret".to_string());
//! let vaas = Vaas::builder(authenticator).build()?.connect().await?;
//!
//! let url = Url::parse("https://mytesturl.test").unwrap();
//! let verdict = vaas.for_url(&url, &ct).await?;
//!
//! // Prints "Clean", "Pup" or "Malicious"
//! println!("{}", verdict.verdict);
//! Ok(())
//! }
//! ```
//!
#![warn(missing_docs)]
pub mod auth;
pub mod builder;
pub mod cancellation;
pub mod connection;
pub mod error;
pub mod message;
mod options;
pub mod sha256;
pub mod vaas;
pub mod vaas_verdict;
pub use crate::vaas::Vaas;
pub use builder::Builder;
pub use cancellation::CancellationToken;
pub use connection::Connection;
pub use sha256::Sha256;
pub use vaas_verdict::VaasVerdict;