use serde::Deserialize;
use serde_json::Value;
pub mod url;
pub mod domain;
pub mod ip;
pub mod file;
pub mod comment;
#[derive(Debug, Deserialize)]
pub struct CommentGetResponse {
pub meta: Meta,
pub data: Vec<Comment>,
pub links: ScanLink,
}
#[derive(Debug, Deserialize)]
pub struct CommentPutResponse {
pub data: Comment,
}
#[derive(Debug, Deserialize)]
pub struct Meta {
pub count: u32,
}
#[derive(Debug, Deserialize)]
pub struct Comment {
pub attributes: CommentAttributes,
#[serde(rename = "type")]
pub vtype: String,
pub id: String,
pub links: ScanLink,
}
#[derive(Debug, Deserialize)]
pub struct CommentAttributes {
pub date: u32,
pub text: String,
pub votes: CommentVote,
pub html: String,
pub tags: Option<Vec<String>>,
}
#[derive(Debug, Deserialize)]
pub struct CommentVote {
pub positive: u32,
pub abuse: u32,
pub negative: u32,
}
#[derive(Debug, Deserialize)]
pub struct DomainReportResponse {
pub data: DomainReportData,
}
#[derive(Debug, Deserialize)]
pub struct DomainReportData {
pub attributes: DomainAttributes,
#[serde(rename = "type")]
pub vtype: String,
pub id: String,
pub links: ScanLink,
}
#[derive(Debug, Deserialize)]
pub struct DomainAttributes {
pub last_dns_records: Option<Value>,
pub jarm: Option<String>,
pub whois: Option<String>,
pub last_https_certificate_date: Option<Value>,
pub tags: Option<Vec<Value>>,
pub popularity_ranks: Option<Value>,
pub last_analysis_date: Option<u32>,
pub last_dns_records_date: Option<u32>,
pub last_analysis_stats: Option<LastAnalysisStats>,
pub whois_date: Option<u32>,
pub reputation: Option<Value>,
pub registrar: Option<String>,
pub last_analysis_results: Option<Value>,
pub tld: Option<String>,
pub last_modification_date: Option<u32>,
pub last_https_certificate: Option<Value>,
pub categories: Option<Value>,
pub total_votes: Option<TotalVotes>,
}
#[derive(Debug, Deserialize)]
pub struct PopularityRanks {
pub majestic: Option<Rank>,
pub statvoo: Option<Rank>,
pub alexa: Option<Rank>,
pub cisco_umbrella: Option<Rank>,
pub quantcast: Option<Rank>,
}
#[derive(Debug, Deserialize)]
pub struct Rank {
pub timestamp: u32,
pub rank: u32,
}
#[derive(Debug, Deserialize)]
pub struct LastAnalysisStats {
pub harmless: u32,
pub malicious: u32,
pub suspicious: u32,
pub undetected: u32,
pub timeout: u32,
}
#[derive(Debug, Deserialize)]
pub struct TotalVotes {
pub harmless: u32,
pub malicious: u32,
}
#[derive(Debug, Deserialize)]
pub struct IpReportResponse {
pub data: IpReportData,
}
#[derive(Debug, Deserialize)]
pub struct IpReportData {
pub attributes: IpAttributes,
#[serde(rename = "type")]
pub vtype: String,
pub id: String,
pub links: ScanLink,
}
#[derive(Debug, Deserialize)]
pub struct IpAttributes {
pub whois: Option<Value>,
pub tags: Option<Vec<Value>>,
pub last_analysis_date: Option<u32>,
pub last_analysis_stats: Option<LastAnalysisStats>,
pub whois_date: Option<u32>,
pub last_analysis_results: Option<Value>,
pub reputation: Option<u32>,
pub last_modification_date: Option<u32>,
pub total_votes: Option<TotalVotes>,
}
#[derive(Debug, Deserialize)]
pub struct UrlScanResponse {
pub data: UrlScanData,
}
#[derive(Debug, Deserialize)]
pub struct UrlScanData {
#[serde(rename = "type")]
pub vtype: String,
pub id: String,
pub links: ScanLink,
}
#[derive(Debug, Deserialize)]
pub struct ScanLink {
#[serde(rename = "self")]
pub vself: String,
}
#[derive(Debug, Deserialize)]
pub struct FileScanResponse {
pub data: FileScanResponseData,
}
#[derive(Debug, Deserialize)]
pub struct FileRescanResponse {
pub data: FileScanResponseData,
}
#[derive(Debug, Deserialize)]
pub struct FileScanResponseData {
#[serde(rename = "type")]
pub vtype: String,
pub id: String,
pub links: ScanLink,
}
#[derive(Copy, Debug, Clone)]
pub enum VtType {
File,
Url,
Domain,
Ip,
}
#[derive(Copy, Clone)]
pub struct VtClient<'a> {
api_key: &'a str,
endpoint: &'a str,
}
impl<'a> VtClient<'a> {
pub fn new(api_key: &'a str) -> Self {
VtClient {
api_key,
endpoint: "https://www.virustotal.com/api/v3",
}
}
}