pub struct MdbClient {
pub url: String,
/* private fields */
}
Expand description
MalwareDB
Client Configuration and connection
Fields§
§url: String
URL of the MalwareDB
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 config 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: &PathBuf) -> Result<Self>
pub fn from_file(path: &PathBuf) -> Result<Self>
MDB Client 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>
MDB Client from user’s home directory
§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 MDB Client to the user’s home directory
§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 MalwareDB
client config 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: &str,
source_id: u32,
) -> Result<bool>
pub async fn submit( &self, contents: impl AsRef<[u8]>, file_name: &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 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.