Skip to content

Commit b0a55c2

Browse files
committed
feat: expose all classes in python module
1 parent c32cf5f commit b0a55c2

File tree

6 files changed

+20
-7
lines changed

6 files changed

+20
-7
lines changed

boreal-py/src/lib.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use pyo3::{create_exception, ffi, intern};
1111
use ::boreal::compiler;
1212

1313
// TODO: all clone impls should be efficient...
14-
// TODO: should all pyclasses have names and be exposed in the module?
1514
// TODO: check GIL handling in all functions (especially match)
1615

1716
mod rule;
@@ -31,6 +30,20 @@ fn boreal(m: &Bound<'_, PyModule>) -> PyResult<()> {
3130
m.add("ScanError", m.py().get_type::<scanner::ScanError>())?;
3231
m.add("TimeoutError", m.py().get_type::<scanner::TimeoutError>())?;
3332

33+
m.add("Rule", m.py().get_type::<rule::Rule>())?;
34+
m.add("Match", m.py().get_type::<rule_match::Match>())?;
35+
m.add("Scanner", m.py().get_type::<scanner::Scanner>())?;
36+
m.add("RulesIter", m.py().get_type::<scanner::RulesIter>())?;
37+
m.add(
38+
"StringMatchInstance",
39+
m.py()
40+
.get_type::<string_match_instance::StringMatchInstance>(),
41+
)?;
42+
m.add(
43+
"StringMatches",
44+
m.py().get_type::<string_matches::StringMatches>(),
45+
)?;
46+
3447
Ok(())
3548
}
3649

boreal-py/src/rule.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use ::boreal::scanner;
55
use ::boreal::{Metadata, MetadataValue};
66

77
/// A matching rule
8-
#[pyclass(frozen)]
8+
#[pyclass(frozen, module = "boreal")]
99
pub struct Rule {
1010
/// Name of the rule
1111
#[pyo3(get)]

boreal-py/src/rule_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::rule::convert_metadata;
1010
use crate::string_matches::StringMatches;
1111

1212
/// A matching rule
13-
#[pyclass(frozen)]
13+
#[pyclass(frozen, module = "boreal")]
1414
pub struct Match {
1515
/// Name of the matching rule
1616
#[pyo3(get)]

boreal-py/src/scanner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::rule_match::Match;
1414
create_exception!(boreal, ScanError, PyException, "error when scanning");
1515
create_exception!(boreal, TimeoutError, PyException, "scan timed out");
1616

17-
#[pyclass(frozen)]
17+
#[pyclass(frozen, module = "boreal")]
1818
pub struct Scanner {
1919
scanner: scanner::Scanner,
2020

@@ -151,7 +151,7 @@ impl Scanner {
151151
}
152152
}
153153

154-
#[pyclass]
154+
#[pyclass(module = "boreal")]
155155
pub struct RulesIter {
156156
rules_iter: std::vec::IntoIter<crate::rule::Rule>,
157157
}

boreal-py/src/string_match_instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use pyo3::prelude::*;
55
use ::boreal::scanner;
66

77
/// Match instance of a YARA string
8-
#[pyclass(frozen)]
8+
#[pyclass(frozen, module = "boreal")]
99
#[derive(Clone)]
1010
pub struct StringMatchInstance {
1111
/// Offset of the match.

boreal-py/src/string_matches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use ::boreal::scanner;
77
use crate::string_match_instance::StringMatchInstance;
88

99
/// List of match instances of a YARA string
10-
#[pyclass(frozen)]
10+
#[pyclass(frozen, module = "boreal")]
1111
#[derive(Clone)]
1212
pub struct StringMatches {
1313
/// Name of the matching string.

0 commit comments

Comments
 (0)