pub struct MdbClient {
pub url: String,
/* private fields */
}blocking only.Expand description
Blocking Malware DB Client Configuration and connection which requires the blocking feature
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 login(
url: String,
username: String,
password: String,
save: bool,
cert_path: Option<PathBuf>,
) -> Result<Self>
pub fn login( url: String, username: String, password: String, save: bool, cert_path: Option<PathBuf>, ) -> Result<Self>
Sourcepub fn reset_key(&self) -> Result<()>
pub 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.
§Panics
This method panics if called from within an async runtime.
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 fn server_info(&self) -> Result<ServerInfo>
pub 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 fn supported_types(&self) -> Result<SupportedFileTypes>
pub 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 fn whoami(&self) -> Result<GetUserInfoResponse>
pub 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 fn labels(&self) -> Result<Labels>
pub 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 fn sources(&self) -> Result<Sources>
pub 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 fn submit(
&self,
contents: impl AsRef<[u8]>,
file_name: String,
source_id: u32,
) -> Result<bool>
pub fn submit( &self, contents: impl AsRef<[u8]>, file_name: String, source_id: u32, ) -> Result<bool>
Submit one file to Malware DB: 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 fn submit_as_cbor(
&self,
contents: impl AsRef<[u8]>,
file_name: String,
source_id: u32,
) -> Result<bool>
pub fn submit_as_cbor( &self, contents: impl AsRef<[u8]>, file_name: String, source_id: u32, ) -> Result<bool>
Submit one file to Malware DB: 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 fn partial_search(
&self,
partial_hash: Option<(PartialHashSearchType, String)>,
name: Option<String>,
response: PartialHashSearchType,
limit: u32,
) -> Result<SearchResponse>
pub 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 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 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 fn next_page_search(
&self,
response: &SearchResponse,
) -> Result<SearchResponse>
pub 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 fn retrieve(&self, hash: &str, cart: bool) -> Result<Vec<u8>>
pub 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 fn report(&self, hash: &str) -> Result<Report>
pub 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 fn similar(&self, contents: &[u8]) -> Result<SimilarSamplesResponse>
pub 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.