1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! Loads the scan's rule sets onto the in-house forbidden-regex engine.
//!
//! Stage two of the engine swap (#384) routes rule loading through the stage-one frx
//! compiler instead of the resharp/`regex` pipeline. Two sources feed a scan:
//!
//! - the resolved runtime rules file (the `forbidden-strings.local.txt` precedence
//! chain), compiled from text at startup via `compile_from_text`; and
//! - the builtin baseline, embedded as a precompiled serialized `RegexSet` and
//! rebuilt via `load_precompiled` (never recompiled), active only under
//! `--builtin-rules`.
//!
//! A scan runs each set in order and attributes findings by rule id. The two sets
//! carry independent 0-based id spaces, so the builtin's ids are offset past the
//! runtime set's rule count: the runtime rules keep ids `0..user_len` and the
//! builtin takes `user_len..`, mirroring the old "user rules first, baseline
//! appended" ordering the `--builtin-rules` contract documents.
/// Imports the CLI-boundary error channel and its construction macro.
use ;
/// Imports the engine's compiled-ruleset type held by each loaded set.
use RegexSet;
/// Imports the std filesystem module used to read the runtime rules file.
use fs;
/// Imports the stage-one frx construction paths (from text and from precompiled bytes).
use crate::;
/// One compiled rule set plus the rule-id offset applied to its findings.
///
/// `base` is added to every rule id the set reports, giving each source a disjoint id
/// range in the combined `rule=N` output.
/// The ordered rule sets a scan runs, each contributing offset rule ids.
///
/// Built by [`load`]; consumed by the scan path, which runs every set against each
/// file's lines. Holding the sets in one value keeps the scan loop source-agnostic.
/// Reads a value out of a `LoadedRules` for the scan path.
/// Loads the runtime rules file and, under the flag, the precompiled builtin baseline.
///
/// Reads the resolved `rules_path`, compiles it from text, and (when `builtin_rules`)
/// appends the embedded baseline rebuilt from `precompiled`. A missing implicit
/// default file is tolerated only under `--builtin-rules` (the baseline alone scans);
/// an explicitly named missing file, or any other read failure, errors. Every error
/// is redacted: an I/O error names only the path, and a compile error carries only an
/// opaque rule index plus the engine's static reason, never rule text.
/// Registers the loader precedence and offset tests (sidecar, lint-exempt).