Skip to content
This repository was archived by the owner on Apr 13, 2026. It is now read-only.

Commit 10824f3

Browse files
committed
feat: enhance firewall rules generation with VLAN-specific limits
- Added functionality to limit the number of firewall rules generated per VLAN, allowing for more controlled configurations. - Updated the `generate_firewall_rules` function to accept an optional parameter for specifying the maximum number of rules per VLAN. - Enhanced tests to validate the new functionality, ensuring correct rule counts and priority assignments. - Updated documentation to reflect the new command options for generating firewall rules with VLAN limits. - All changes have been tested, and functionality is working as expected.
1 parent 90cbe79 commit 10824f3

13 files changed

Lines changed: 631 additions & 252 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ console = "0.16"
6565

6666
# Performance optimization dependencies
6767
rayon = { version = "1.8", optional = true } # Data parallelism
68-
tokio = { version = "1.0", features = ["full"] } # Async runtime
6968
bumpalo = "3.14" # Arena allocation
7069
lru = "0.16.0" # Template caching
7170
rustc-hash = "2.1.1" # Faster hashing

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,31 @@ cargo run --release -- xml --base-config config.xml --count 500 --output-dir loa
217217
# Test OPNsense performance with large configs
218218
```
219219

220+
### Firewall Rules Generation
221+
222+
```bash
223+
# Generate configurations with firewall rules (default complexity)
224+
cargo run --release -- generate --count 25 --format csv --output config.csv --include-firewall-rules
225+
226+
# Generate with specific firewall rule complexity
227+
cargo run --release -- generate --count 10 --format xml --base-config config.xml --include-firewall-rules --firewall-rule-complexity advanced
228+
229+
# Limit firewall rules per VLAN (useful for testing with smaller rule sets)
230+
cargo run --release -- generate --count 5 --format csv --output config.csv --include-firewall-rules --firewall-rules-per-vlan 2
231+
232+
# Generate XML with limited firewall rules per VLAN
233+
cargo run --release -- generate --count 10 --format xml --base-config config.xml --include-firewall-rules --firewall-rules-per-vlan 3 --firewall-rule-complexity intermediate
234+
```
235+
236+
**Firewall Rules Per VLAN**: The `--firewall-rules-per-vlan` flag allows you to control the number of firewall rules generated per VLAN. This is useful for:
237+
238+
- Testing with smaller, more manageable rule sets
239+
- Creating focused security scenarios
240+
- Reducing configuration complexity for specific use cases
241+
- Performance testing with controlled rule counts
242+
243+
When specified, this flag overrides the default rule count based on complexity level and ensures priorities are reassigned sequentially (1, 2, 3, ...) for each VLAN.
244+
220245
## Troubleshooting
221246

222247
### Common Issues

TESTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,13 @@ just coverage-html
177177
# CI-friendly coverage (ignores test failures)
178178
just coverage-ci
179179

180+
Note: CI runs (`just coverage-ci`) will never fail on coverage drops. To enforce an 80% threshold locally, use `just coverage`.
181+
180182
# Terminal coverage report
181183
just coverage-report
182184
```
183185

184-
The project enforces an **80% coverage threshold**. Coverage reports are generated using `cargo-llvm-cov`.
186+
The project enforces an **80% coverage threshold** locally via `just coverage`. CI runs (`just coverage-ci`) generate reports without threshold enforcement. Coverage reports are generated using `cargo-llvm-cov`.
185187

186188
### Linting and Formatting
187189

@@ -319,7 +321,7 @@ The CI pipeline automatically:
319321
1. **Validates Formatting**: `just rust-fmt-check`
320322
2. **Runs Linting**: `just rust-clippy` with strict warnings
321323
3. **Executes Tests**: `just rust-test` with all features
322-
4. **Generates Coverage**: `just coverage-ci` with 80% threshold
324+
4. **Generates Coverage**: `just coverage-ci` generates lcov report (no threshold enforcement)
323325
5. **Respects Environment**: Adapts output based on `TERM` variable
324326

325327
## Test Data and Fixtures

justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ coverage:
123123
coverage-ci:
124124
@echo "🔍 Running coverage for CI (generating lcov report)..."
125125
cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info --ignore-run-fail
126+
@echo "ℹ️ This CI step does not enforce coverage thresholds. Run \`just coverage\` locally to gate on 80%."
126127
@echo "✅ Coverage report generated!"
127128

128129
# Run coverage report in HTML format for local viewing

src/cli/commands/generate.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,14 @@ fn execute_csv_generation(args: &GenerateArgs) -> Result<()> {
180180

181181
// Generate firewall rules
182182
let firewall_pb = create_progress_bar(configs.len() as u64, "Generating firewall rules...");
183-
let firewall_rules =
184-
generate_firewall_rules(&configs, complexity, args.seed, Some(&firewall_pb))?;
183+
let firewall_rules = generate_firewall_rules(
184+
&configs,
185+
complexity,
186+
args.seed,
187+
Some(&firewall_pb),
188+
args.firewall_rules_per_vlan,
189+
)?;
190+
185191
firewall_pb.finish_with_message(format!(
186192
"✅ Generated {} firewall rules",
187193
firewall_rules.len()
@@ -250,7 +256,14 @@ fn execute_xml_generation(args: &GenerateArgs) -> Result<()> {
250256

251257
// Generate firewall rules
252258
let firewall_pb = create_progress_bar(configs.len() as u64, "Generating firewall rules...");
253-
let rules = generate_firewall_rules(&configs, complexity, args.seed, Some(&firewall_pb))?;
259+
let rules = generate_firewall_rules(
260+
&configs,
261+
complexity,
262+
args.seed,
263+
Some(&firewall_pb),
264+
args.firewall_rules_per_vlan,
265+
)?;
266+
254267
firewall_pb.finish_with_message(format!("✅ Generated {} firewall rules", rules.len()));
255268

256269
// Write firewall rules to CSV for reference

0 commit comments

Comments
 (0)