Struct MdbClient

Source
pub struct MdbClient {
    pub url: String,
    /* private fields */
}
Expand description

MalwareDB Client Configuration and connection

Fields§

§url: String

URL of MalwareDB, 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

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

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

Source

pub fn from_file(path: &PathBuf) -> Result<Self>

MDB Client loaded from a specified path

Source

pub fn load() -> Result<Self>

MDB Client from user’s home directory

Source

pub fn save(&self) -> Result<()>

Save MDB Client to the user’s home directory

Source

pub fn delete(&self) -> Result<()>

Delete the MalwareDB client config file

Source

pub async fn server_info(&self) -> Result<ServerInfo>

Get information about the server, unauthenticated

Source

pub async fn supported_types(&self) -> Result<SupportedFileTypes>

Get file types supported by the server, unauthenticated

Source

pub async fn whoami(&self) -> Result<GetUserInfoResponse>

Get information about the user

Source

pub async fn labels(&self) -> Result<Labels>

Get the sample labels known to the server

Source

pub async fn sources(&self) -> Result<Sources>

Get the sources available to the current user

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

Source

pub async fn retrieve(&self, hash: &str, cart: bool) -> Result<Vec<u8>>

Retrieve sample by hash, optionally in the CaRT format

Source

pub async fn report(&self, hash: &str) -> Result<Report>

Fetch a report for a sample

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.

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> 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,

Source§

impl<T> MaybeSendSync for T