MalwareDBClient

Struct MalwareDBClient 

Source
pub struct MalwareDBClient { /* private fields */ }
Expand description

Malware DB client

Implementations§

Source§

impl MalwareDBClient

Source

pub fn new() -> PyResult<Self>

Load a configuration from a file if it can be found

§Errors

Returns an error if the configuration file can’t be found or isn’t valid.

Source

pub fn login( url: String, username: String, password: String, save: bool, cert_path: Option<PathBuf>, ) -> PyResult<Self>

Login with a username and password

§Errors

Returns an error if the server URL, username, or password were incorrect, or if a network issue occurred.

Source

pub fn connect( url: String, api_key: String, cert_path: Option<PathBuf>, ) -> PyResult<Self>

Connect if an API key is already known

§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 fn from_file(path: PathBuf) -> Result<Self>

Connect using a specific configuration file

§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 url(&self) -> String

Get the server’s URL

Source

pub fn get_file_bytes(&self, hash: &str) -> Result<Vec<u8>>

Get the bytes of a sample from the database

§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 fn submit_file( &self, contents: Vec<u8>, file_name: String, source_id: u32, ) -> Result<bool>

Submit a file to the database, which requires the file name and source ID. Returns true if stored.

§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.

Search by partial hash and/or partial file name, returning a list of hashes by specified hash type

§Errors
  • Invalid hash types will result in an error
  • 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
Source

pub fn get_sources(&self) -> Result<Vec<Source>>

Get sources available to 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 fn server_info(&self) -> Result<ServerInfo>

Get information about the server

§Errors

This may return an error if there’s a network problem or the server is down.

Source

pub fn get_supported_file_types(&self) -> Result<Vec<SupportedFileType>>

Get supported file types; Malware DB only accepts file types it knows about

§Errors

This may return an error if there’s a network problem or the server is down.

Source

pub fn whoami(&self) -> Result<UserInfo>

Get information about the user

§Errors

This may return an error if there’s a network problem or if the user is not logged in or not properly authorized to connect.

Source

pub fn labels(&self) -> Result<Vec<Label>>

Get labels

§Errors

This may return an error if there’s a network problem or if the user is not logged in or not properly authorized to connect.

Trait Implementations§

Source§

impl<'py> IntoPyObject<'py> for MalwareDBClient

Source§

type Target = MalwareDBClient

The Python output type
Source§

type Output = Bound<'py, <MalwareDBClient as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

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

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PyClass for MalwareDBClient

Source§

type Frozen = True

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for MalwareDBClient

Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

const RAW_DOC: &'static CStr = /// Malware DB client

Docstring for the class provided on the struct or enum. Read more
Source§

const DOC: &'static CStr

Fully rendered class doc, including the text_signature if a constructor is defined. Read more
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<MalwareDBClient>

This handles following two situations: Read more
Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

Source§

fn dict_offset() -> Option<isize>

Source§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature for MalwareDBClient

Source§

const TEXT_SIGNATURE: &'static str = "()"

Source§

impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder MalwareDBClient

Source§

type Holder = Option<PyClassGuard<'a, MalwareDBClient>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'holder mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyMethods<MalwareDBClient> for PyClassImplCollector<MalwareDBClient>

Source§

fn py_methods(self) -> &'static PyClassItems

Source§

impl PyTypeInfo for MalwareDBClient

Source§

const NAME: &'static str = "MalwareDBClient"

Class name.
Source§

const MODULE: Option<&'static str> = ::core::option::Option::None

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
Source§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
Source§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
Source§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl DerefToPyAny for MalwareDBClient

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<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
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> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

Source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
Source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

Source§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
Source§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> Ungil for T
where T: Send,