pub struct MdbClient {
pub url: String,
/* private fields */
}Expand description
Asynchronous Malware DB Client Configuration and connection
Fields§
§url: StringURL of the Malware DB server, including http and port number, ending without a slash
Implementations§
Source§impl MdbClient
impl MdbClient
Sourcepub fn new(
url: String,
api_key: String,
cert_path: Option<PathBuf>,
) -> Result<Self>
pub fn new( url: String, api_key: String, cert_path: Option<PathBuf>, ) -> Result<Self>
MDB Client from components, doesn’t test connectivity
§Errors
Returns an error if a list of certificates was passed and any were not in the expected DER or PEM format or could not be parsed.
Sourcepub async fn login(
url: String,
username: String,
password: String,
save: bool,
cert_path: Option<PathBuf>,
) -> Result<Self>
pub async fn login( url: String, username: String, password: String, save: bool, cert_path: Option<PathBuf>, ) -> Result<Self>
Login to a server, optionally save the configuration file, and return a client object
§Errors
Returns an error if the server URL, username, or password were incorrect, or if a network issue occurred.
Sourcepub async fn reset_key(&self) -> Result<()>
pub async fn reset_key(&self) -> Result<()>
Reset one’s own API key to effectively logout & disable all clients who are using the key
§Errors
Returns an error if there was a network issue or the user wasn’t properly logged in.
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Malware DB Client configuration loaded from a specified path
§Errors
Returns an error if the configuration file cannot be read, possibly because it doesn’t exist or due to a permission error or a parsing error.
Sourcepub fn load() -> Result<Self>
pub fn load() -> Result<Self>
Malware DB Client configuration from user’s home directory
On macOS, it will attempt to load this information in the Keychain, which isn’t required.
§Errors
Returns an error if the configuration file cannot be read, possibly because it doesn’t exist or due to a permission error or a parsing error.
Sourcepub fn save(&self) -> Result<()>
pub fn save(&self) -> Result<()>
Save Malware DB Client configuration to the user’s home directory.
On macOS, it will attempt to save this information in the Keychain, which isn’t required.
§Errors
Returns an error if there was a problem saving the configuration file.
Sourcepub fn delete(&self) -> Result<()>
pub fn delete(&self) -> Result<()>
Delete the Malware DB client configuration file
§Errors
Returns an error if there isn’t a configuration file to delete, or if it cannot be deleted, possibly due to a permissions error.
Sourcepub async fn server_info(&self) -> Result<ServerInfo>
pub async fn server_info(&self) -> Result<ServerInfo>
Get information about the server, unauthenticated
§Errors
This may return an error if there’s a network situation.
Sourcepub async fn supported_types(&self) -> Result<SupportedFileTypes>
pub async fn supported_types(&self) -> Result<SupportedFileTypes>
Get file types supported by the server, unauthenticated
§Errors
This may return an error if there’s a network situation.
Sourcepub async fn whoami(&self) -> Result<GetUserInfoResponse>
pub async fn whoami(&self) -> Result<GetUserInfoResponse>
Get information about the user
§Errors
This may return an error if there’s a network situation or if the user is not logged in or not properly authorized to connect.
Sourcepub async fn labels(&self) -> Result<Labels>
pub async fn labels(&self) -> Result<Labels>
Get the sample labels known to the server
§Errors
This may return an error if there’s a network situation or if the user is not logged in or not properly authorized to connect.
Sourcepub async fn sources(&self) -> Result<Sources>
pub async fn sources(&self) -> Result<Sources>
Get the sources available to the current user
§Errors
This may return an error if there’s a network situation or if the user is not logged in or not properly authorized to connect.
Sourcepub async fn submit(
&self,
contents: impl AsRef<[u8]>,
file_name: impl AsRef<str>,
source_id: u32,
) -> Result<bool>
pub async fn submit( &self, contents: impl AsRef<[u8]>, file_name: impl AsRef<str>, source_id: u32, ) -> Result<bool>
Submit one file to MalwareDB: provide the contents, file name, and source ID
§Errors
This may return an error if there’s a network situation or if the user is not logged in or not properly authorized to connect.
Sourcepub async fn submit_as_cbor(
&self,
contents: impl AsRef<[u8]>,
file_name: impl AsRef<str>,
source_id: u32,
) -> Result<bool>
pub async fn submit_as_cbor( &self, contents: impl AsRef<[u8]>, file_name: impl AsRef<str>, source_id: u32, ) -> Result<bool>
Submit one file to MalwareDB as a Cbor object: provide the contents, file name, and source ID
Experimental! May be removed at any point.
§Errors
This may return an error if there’s a network situation or if the user is not logged in or not properly authorized to connect.
Sourcepub async fn partial_search(
&self,
partial_hash: Option<(PartialHashSearchType, String)>,
name: Option<String>,
response: PartialHashSearchType,
limit: u32,
) -> Result<SearchResponse>
pub async fn partial_search( &self, partial_hash: Option<(PartialHashSearchType, String)>, name: Option<String>, response: PartialHashSearchType, limit: u32, ) -> Result<SearchResponse>
Search for a file based on partial hash and/or partial file name, returns a list of hashes
§Errors
- This may return an error if there’s a network situation or if the user is not logged in or the request isn’t valid
Sourcepub async fn partial_search_labels_type(
&self,
partial_hash: Option<(PartialHashSearchType, String)>,
name: Option<String>,
response: PartialHashSearchType,
labels: Option<Vec<String>>,
file_type: Option<String>,
magic: Option<String>,
limit: u32,
) -> Result<SearchResponse>
pub async fn partial_search_labels_type( &self, partial_hash: Option<(PartialHashSearchType, String)>, name: Option<String>, response: PartialHashSearchType, labels: Option<Vec<String>>, file_type: Option<String>, magic: Option<String>, limit: u32, ) -> Result<SearchResponse>
Search for a file based on partial hash and/or partial file name, labels, file type; returns a list of hashes
§Errors
- This may return an error if there’s a network situation or if the user is not logged in or the request isn’t valid
Sourcepub async fn next_page_search(
&self,
response: &SearchResponse,
) -> Result<SearchResponse>
pub async fn next_page_search( &self, response: &SearchResponse, ) -> Result<SearchResponse>
Return the next page from the search result
§Errors
Returns an error if there is a network problem, or pagination not available
Sourcepub async fn retrieve(&self, hash: &str, cart: bool) -> Result<Vec<u8>>
pub async fn retrieve(&self, hash: &str, cart: bool) -> Result<Vec<u8>>
Retrieve sample by hash, optionally in the CaRT format
§Errors
This may return an error if there’s a network situation or if the user is not logged in or not properly authorized to connect.
Sourcepub async fn report(&self, hash: &str) -> Result<Report>
pub async fn report(&self, hash: &str) -> Result<Report>
Fetch a report for a sample
§Errors
This may return an error if there’s a network situation or if the user is not logged in or not properly authorized to connect.
Sourcepub async fn similar(&self, contents: &[u8]) -> Result<SimilarSamplesResponse>
pub async fn similar(&self, contents: &[u8]) -> Result<SimilarSamplesResponse>
Find similar samples in MalwareDB based on the contents of a given file.
This does not submit the sample to MalwareDB.
§Errors
This may return an error if there’s a network situation or if the user is not logged in or not properly authorized to connect.