pub struct MalwareDBClient { /* private fields */ }
Expand description
Malware DB client
Implementations§
Source§impl MalwareDBClient
impl MalwareDBClient
Sourcepub fn new() -> PyResult<Self>
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.
Sourcepub fn login(
url: String,
username: String,
password: String,
save: bool,
cert_path: Option<PathBuf>,
) -> PyResult<Self>
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.
Sourcepub fn connect(
url: String,
api_key: String,
cert_path: Option<PathBuf>,
) -> PyResult<Self>
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.
Sourcepub fn from_file(path: PathBuf) -> Result<Self>
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.
Sourcepub fn get_file_bytes(&self, hash: &str) -> Result<Vec<u8>>
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.
Sourcepub fn submit_file(
&self,
contents: Vec<u8>,
file_name: String,
source_id: u32,
) -> Result<bool>
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.
Sourcepub fn partial_search(
&self,
hash: Option<String>,
hash_type: &str,
file_name: Option<String>,
limit: u32,
response_hash: &str,
) -> Result<Vec<String>>
pub fn partial_search( &self, hash: Option<String>, hash_type: &str, file_name: Option<String>, limit: u32, response_hash: &str, ) -> Result<Vec<String>>
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
Sourcepub fn get_sources(&self) -> Result<Vec<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.
Sourcepub fn server_info(&self) -> Result<ServerInfo>
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.
Sourcepub fn get_supported_file_types(&self) -> Result<Vec<SupportedFileType>>
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.
Trait Implementations§
Source§impl<'py> IntoPyObject<'py> for MalwareDBClient
impl<'py> IntoPyObject<'py> for MalwareDBClient
Source§type Target = MalwareDBClient
type Target = MalwareDBClient
Source§type Output = Bound<'py, <MalwareDBClient as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <MalwareDBClient as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for MalwareDBClient
impl PyClass for MalwareDBClient
Source§impl PyClassImpl for MalwareDBClient
impl PyClassImpl for MalwareDBClient
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// Malware DB client
const RAW_DOC: &'static CStr = /// Malware DB client
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature
if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<MalwareDBClient>
type ThreadChecker = SendablePyClass<MalwareDBClient>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for MalwareDBClient
impl PyClassNewTextSignature for MalwareDBClient
const TEXT_SIGNATURE: &'static str = "()"
Source§impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder MalwareDBClient
impl<'a, 'holder, 'py> PyFunctionArgument<'a, 'holder, 'py, false> for &'holder MalwareDBClient
Source§impl PyMethods<MalwareDBClient> for PyClassImplCollector<MalwareDBClient>
impl PyMethods<MalwareDBClient> for PyClassImplCollector<MalwareDBClient>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for MalwareDBClient
impl PyTypeInfo for MalwareDBClient
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
impl DerefToPyAny for MalwareDBClient
Auto Trait Implementations§
impl Freeze for MalwareDBClient
impl RefUnwindSafe for MalwareDBClient
impl Send for MalwareDBClient
impl Sync for MalwareDBClient
impl Unpin for MalwareDBClient
impl UnwindSafe for MalwareDBClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.