harpo-native 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- harpo_native-1.4.0/.gitignore +1 -0
- harpo_native-1.4.0/Cargo.lock +293 -0
- harpo_native-1.4.0/Cargo.toml +29 -0
- harpo_native-1.4.0/PKG-INFO +6 -0
- harpo_native-1.4.0/benches/scanner.rs +35 -0
- harpo_native-1.4.0/pyproject.toml +16 -0
- harpo_native-1.4.0/src/candidates.rs +408 -0
- harpo_native-1.4.0/src/lib.rs +1238 -0
- harpo_native-1.4.0/src/main.rs +96 -0
- harpo_native-1.4.0/src/python.rs +41 -0
- harpo_native-1.4.0/tests/batch_protocol.rs +175 -0
- harpo_native-1.4.0/tests/scanner_contract.rs +167 -0
- harpo_native-1.4.0/tests/streaming.rs +84 -0
- harpo_native-1.4.0/tests/walker_contract.rs +207 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/target/
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "aho-corasick"
|
|
7
|
+
version = "1.1.5"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"memchr",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[package]]
|
|
15
|
+
name = "autocfg"
|
|
16
|
+
version = "1.5.1"
|
|
17
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
19
|
+
|
|
20
|
+
[[package]]
|
|
21
|
+
name = "cfg-if"
|
|
22
|
+
version = "1.0.5"
|
|
23
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
24
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
25
|
+
|
|
26
|
+
[[package]]
|
|
27
|
+
name = "harpocrates-rust-scanner"
|
|
28
|
+
version = "0.1.0"
|
|
29
|
+
dependencies = [
|
|
30
|
+
"pyo3",
|
|
31
|
+
"regex",
|
|
32
|
+
"serde",
|
|
33
|
+
"serde_json",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "heck"
|
|
38
|
+
version = "0.5.0"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
41
|
+
|
|
42
|
+
[[package]]
|
|
43
|
+
name = "indoc"
|
|
44
|
+
version = "2.0.8"
|
|
45
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
46
|
+
checksum = "a37b2691796cffeb8a8cd305ac66e65841559f147f4e63231d0eafa4db5384d1"
|
|
47
|
+
dependencies = [
|
|
48
|
+
"rustversion",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
[[package]]
|
|
52
|
+
name = "itoa"
|
|
53
|
+
version = "1.0.18"
|
|
54
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
55
|
+
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
|
56
|
+
|
|
57
|
+
[[package]]
|
|
58
|
+
name = "libc"
|
|
59
|
+
version = "0.2.191"
|
|
60
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
61
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
62
|
+
|
|
63
|
+
[[package]]
|
|
64
|
+
name = "memchr"
|
|
65
|
+
version = "2.8.3"
|
|
66
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
67
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
68
|
+
|
|
69
|
+
[[package]]
|
|
70
|
+
name = "memoffset"
|
|
71
|
+
version = "0.9.1"
|
|
72
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
73
|
+
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
74
|
+
dependencies = [
|
|
75
|
+
"autocfg",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
[[package]]
|
|
79
|
+
name = "once_cell"
|
|
80
|
+
version = "1.21.4"
|
|
81
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
82
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
83
|
+
|
|
84
|
+
[[package]]
|
|
85
|
+
name = "portable-atomic"
|
|
86
|
+
version = "1.15.0"
|
|
87
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
88
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
89
|
+
|
|
90
|
+
[[package]]
|
|
91
|
+
name = "proc-macro2"
|
|
92
|
+
version = "1.0.107"
|
|
93
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
94
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
95
|
+
dependencies = [
|
|
96
|
+
"unicode-ident",
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
[[package]]
|
|
100
|
+
name = "pyo3"
|
|
101
|
+
version = "0.23.5"
|
|
102
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
103
|
+
checksum = "7778bffd85cf38175ac1f545509665d0b9b92a198ca7941f131f85f7a4f9a872"
|
|
104
|
+
dependencies = [
|
|
105
|
+
"cfg-if",
|
|
106
|
+
"indoc",
|
|
107
|
+
"libc",
|
|
108
|
+
"memoffset",
|
|
109
|
+
"once_cell",
|
|
110
|
+
"portable-atomic",
|
|
111
|
+
"pyo3-build-config",
|
|
112
|
+
"pyo3-ffi",
|
|
113
|
+
"pyo3-macros",
|
|
114
|
+
"unindent",
|
|
115
|
+
]
|
|
116
|
+
|
|
117
|
+
[[package]]
|
|
118
|
+
name = "pyo3-build-config"
|
|
119
|
+
version = "0.23.5"
|
|
120
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
121
|
+
checksum = "94f6cbe86ef3bf18998d9df6e0f3fc1050a8c5efa409bf712e661a4366e010fb"
|
|
122
|
+
dependencies = [
|
|
123
|
+
"once_cell",
|
|
124
|
+
"target-lexicon",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
[[package]]
|
|
128
|
+
name = "pyo3-ffi"
|
|
129
|
+
version = "0.23.5"
|
|
130
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
131
|
+
checksum = "e9f1b4c431c0bb1c8fb0a338709859eed0d030ff6daa34368d3b152a63dfdd8d"
|
|
132
|
+
dependencies = [
|
|
133
|
+
"libc",
|
|
134
|
+
"pyo3-build-config",
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
[[package]]
|
|
138
|
+
name = "pyo3-macros"
|
|
139
|
+
version = "0.23.5"
|
|
140
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
141
|
+
checksum = "fbc2201328f63c4710f68abdf653c89d8dbc2858b88c5d88b0ff38a75288a9da"
|
|
142
|
+
dependencies = [
|
|
143
|
+
"proc-macro2",
|
|
144
|
+
"pyo3-macros-backend",
|
|
145
|
+
"quote",
|
|
146
|
+
"syn 2.0.119",
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
[[package]]
|
|
150
|
+
name = "pyo3-macros-backend"
|
|
151
|
+
version = "0.23.5"
|
|
152
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
153
|
+
checksum = "fca6726ad0f3da9c9de093d6f116a93c1a38e417ed73bf138472cf4064f72028"
|
|
154
|
+
dependencies = [
|
|
155
|
+
"heck",
|
|
156
|
+
"proc-macro2",
|
|
157
|
+
"pyo3-build-config",
|
|
158
|
+
"quote",
|
|
159
|
+
"syn 2.0.119",
|
|
160
|
+
]
|
|
161
|
+
|
|
162
|
+
[[package]]
|
|
163
|
+
name = "quote"
|
|
164
|
+
version = "1.0.47"
|
|
165
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
166
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
167
|
+
dependencies = [
|
|
168
|
+
"proc-macro2",
|
|
169
|
+
]
|
|
170
|
+
|
|
171
|
+
[[package]]
|
|
172
|
+
name = "regex"
|
|
173
|
+
version = "1.13.1"
|
|
174
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
175
|
+
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
|
|
176
|
+
dependencies = [
|
|
177
|
+
"aho-corasick",
|
|
178
|
+
"memchr",
|
|
179
|
+
"regex-automata",
|
|
180
|
+
"regex-syntax",
|
|
181
|
+
]
|
|
182
|
+
|
|
183
|
+
[[package]]
|
|
184
|
+
name = "regex-automata"
|
|
185
|
+
version = "0.4.18"
|
|
186
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
187
|
+
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
|
|
188
|
+
dependencies = [
|
|
189
|
+
"aho-corasick",
|
|
190
|
+
"memchr",
|
|
191
|
+
"regex-syntax",
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
[[package]]
|
|
195
|
+
name = "regex-syntax"
|
|
196
|
+
version = "0.8.11"
|
|
197
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
198
|
+
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
|
|
199
|
+
|
|
200
|
+
[[package]]
|
|
201
|
+
name = "rustversion"
|
|
202
|
+
version = "1.0.23"
|
|
203
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
204
|
+
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
|
|
205
|
+
|
|
206
|
+
[[package]]
|
|
207
|
+
name = "serde"
|
|
208
|
+
version = "1.0.229"
|
|
209
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
210
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
211
|
+
dependencies = [
|
|
212
|
+
"serde_core",
|
|
213
|
+
"serde_derive",
|
|
214
|
+
]
|
|
215
|
+
|
|
216
|
+
[[package]]
|
|
217
|
+
name = "serde_core"
|
|
218
|
+
version = "1.0.229"
|
|
219
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
220
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
221
|
+
dependencies = [
|
|
222
|
+
"serde_derive",
|
|
223
|
+
]
|
|
224
|
+
|
|
225
|
+
[[package]]
|
|
226
|
+
name = "serde_derive"
|
|
227
|
+
version = "1.0.229"
|
|
228
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
229
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
230
|
+
dependencies = [
|
|
231
|
+
"proc-macro2",
|
|
232
|
+
"quote",
|
|
233
|
+
"syn 3.0.3",
|
|
234
|
+
]
|
|
235
|
+
|
|
236
|
+
[[package]]
|
|
237
|
+
name = "serde_json"
|
|
238
|
+
version = "1.0.151"
|
|
239
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
240
|
+
checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
|
|
241
|
+
dependencies = [
|
|
242
|
+
"itoa",
|
|
243
|
+
"memchr",
|
|
244
|
+
"serde",
|
|
245
|
+
"serde_core",
|
|
246
|
+
"zmij",
|
|
247
|
+
]
|
|
248
|
+
|
|
249
|
+
[[package]]
|
|
250
|
+
name = "syn"
|
|
251
|
+
version = "2.0.119"
|
|
252
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
253
|
+
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
|
254
|
+
dependencies = [
|
|
255
|
+
"proc-macro2",
|
|
256
|
+
"quote",
|
|
257
|
+
"unicode-ident",
|
|
258
|
+
]
|
|
259
|
+
|
|
260
|
+
[[package]]
|
|
261
|
+
name = "syn"
|
|
262
|
+
version = "3.0.3"
|
|
263
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
264
|
+
checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3"
|
|
265
|
+
dependencies = [
|
|
266
|
+
"proc-macro2",
|
|
267
|
+
"quote",
|
|
268
|
+
"unicode-ident",
|
|
269
|
+
]
|
|
270
|
+
|
|
271
|
+
[[package]]
|
|
272
|
+
name = "target-lexicon"
|
|
273
|
+
version = "0.12.16"
|
|
274
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
275
|
+
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
|
276
|
+
|
|
277
|
+
[[package]]
|
|
278
|
+
name = "unicode-ident"
|
|
279
|
+
version = "1.0.24"
|
|
280
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
281
|
+
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
282
|
+
|
|
283
|
+
[[package]]
|
|
284
|
+
name = "unindent"
|
|
285
|
+
version = "0.2.4"
|
|
286
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
287
|
+
checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
|
|
288
|
+
|
|
289
|
+
[[package]]
|
|
290
|
+
name = "zmij"
|
|
291
|
+
version = "1.0.23"
|
|
292
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
293
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "harpocrates-rust-scanner"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2024"
|
|
5
|
+
description = "Native regex and entropy scanning engine for Harpocrates"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
|
|
8
|
+
[lib]
|
|
9
|
+
name = "harpocrates_rust_scanner"
|
|
10
|
+
path = "src/lib.rs"
|
|
11
|
+
# cdylib is the Python extension module (feature "python", built by maturin from core/pyproject.toml).
|
|
12
|
+
crate-type = ["cdylib", "rlib"]
|
|
13
|
+
|
|
14
|
+
[[bin]]
|
|
15
|
+
name = "harpocrates-rust-scanner"
|
|
16
|
+
path = "src/main.rs"
|
|
17
|
+
|
|
18
|
+
[[bench]]
|
|
19
|
+
name = "scanner"
|
|
20
|
+
harness = false
|
|
21
|
+
|
|
22
|
+
[features]
|
|
23
|
+
python = ["dep:pyo3"]
|
|
24
|
+
|
|
25
|
+
[dependencies]
|
|
26
|
+
pyo3 = { version = "0.23", features = ["abi3-py310"], optional = true }
|
|
27
|
+
regex = "1.11"
|
|
28
|
+
serde = { version = "1.0", features = ["derive"] }
|
|
29
|
+
serde_json = "1.0"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
use harpocrates_rust_scanner::{ScanOptions, scan_text};
|
|
2
|
+
use std::hint::black_box;
|
|
3
|
+
use std::time::Instant;
|
|
4
|
+
|
|
5
|
+
fn main() {
|
|
6
|
+
let mut fixture = String::new();
|
|
7
|
+
for index in 0..1_000 {
|
|
8
|
+
fixture.push_str(&format!(
|
|
9
|
+
"const value_{index} = \"ordinary-configuration-value-{index}\";\n"
|
|
10
|
+
));
|
|
11
|
+
}
|
|
12
|
+
fixture.push_str("api_secret = \"aB3dEfGhIjKlMnOpQrStUvWxYz012345\";\n");
|
|
13
|
+
|
|
14
|
+
let options = ScanOptions {
|
|
15
|
+
file: Some("benchmark.rs".to_owned()),
|
|
16
|
+
};
|
|
17
|
+
for _ in 0..20 {
|
|
18
|
+
black_box(scan_text(black_box(&fixture), black_box(&options)).expect("scan succeeds"));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let iterations = 500_u32;
|
|
22
|
+
let started = Instant::now();
|
|
23
|
+
for _ in 0..iterations {
|
|
24
|
+
black_box(scan_text(black_box(&fixture), black_box(&options)).expect("scan succeeds"));
|
|
25
|
+
}
|
|
26
|
+
let elapsed = started.elapsed();
|
|
27
|
+
let mean_ms = elapsed.as_secs_f64() * 1_000.0 / f64::from(iterations);
|
|
28
|
+
let throughput_mib_s =
|
|
29
|
+
fixture.len() as f64 * f64::from(iterations) / elapsed.as_secs_f64() / 1_048_576.0;
|
|
30
|
+
|
|
31
|
+
println!(
|
|
32
|
+
"{{\"iterations\":{iterations},\"fixture_bytes\":{},\"mean_ms\":{mean_ms:.6},\"throughput_mib_s\":{throughput_mib_s:.3}}}",
|
|
33
|
+
fixture.len()
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# The optional Python extension module `harpo_native`: the Rust detection rules, called in process.
|
|
2
|
+
# Install from a clone with `pip install ./core` or from PyPI with `pip install "harpo-scan[native]"`; Harpo uses it when it is present and its rules match.
|
|
3
|
+
[build-system]
|
|
4
|
+
requires = ["maturin>=1.7,<2"]
|
|
5
|
+
build-backend = "maturin"
|
|
6
|
+
|
|
7
|
+
[project]
|
|
8
|
+
name = "harpo-native"
|
|
9
|
+
version = "1.4.0"
|
|
10
|
+
description = "Harpo's regex and entropy rules in Rust, as an optional Python extension module"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
|
|
14
|
+
[tool.maturin]
|
|
15
|
+
features = ["python", "pyo3/extension-module"]
|
|
16
|
+
module-name = "harpo_native"
|