Struct MdbClient

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for MdbClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MdbClient

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Drop for MdbClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Serialize for MdbClient

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Zeroize for MdbClient

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,