Skip to content

Feat/12394 v4 Prepare for release 1.1.0-dev (init command, CPU ranges, Suricata spec) - #34

Closed
KEIAHNY wants to merge 4 commits into
mainfrom
12394-feat-release-1.1.0-dev-v4
Closed

KEIAHNY wants to merge 4 commits into
mainfrom
12394-feat-release-1.1.0-dev-v4

Conversation

@KEIAHNY

@KEIAHNY KEIAHNY commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

PR Type

Enhancement, Documentation


Description

  • Add init command generating default configuration file

  • Support CPU range expansion in max_cpu_usage_vec

    • Validate CPUs against available system cores
    • Deduplicate CPUs via HashSet
  • Bump version to 1.1.0-dev, add num_cpus dependency

  • Update README with Suricata branch and init usage


Diagram Walkthrough

flowchart LR
  cli["CLI Args"] -- "init command" --> init["config_gen::init writes DEFAULT_CONFIG"]
  cli -- "max_cpu_usage_vec strings" --> parse["parse_cpu_list"]
  parse -- "expand ranges" --> expand["expand_cpu_range validates against num_cpus"]
  expand -- "deduplicate" --> cpus["Suriconf max_cpu_usage_vec"]
Loading

File Walkthrough

Relevant files
Enhancement
5 files
yaml.rs
Add CPU range parsing with validation and deduplication   
+77/-14 
argument.rs
Add Init command and change CPU vec to strings                     
+14/-2   
main.rs
Handle init command with early exit                                           
+10/-1   
config_gen.rs
New module generating default configuration file                 
+16/-0   
lib.rs
Register config_gen module and embed default config           
+4/-1     
Formatting
1 files
suricata.rs
Import io module for Result type shorthand                             
+2/-1     
Documentation
1 files
README.md
Update version, Suricata spec, and init documentation       
+14/-8   
Configuration changes
1 files
suriconf.yaml
Bump version and update default configuration values         
+4/-4     
Dependencies
1 files
Cargo.toml
Bump version to 1.1.0-dev, add num_cpus dependency             
+3/-2     
Additional files
4 files
ISSUES.md +0/-3     
suricata.yaml +0/-2347
suricata.yaml.in +0/-2339
suriconf.yaml.in +0/-6     

@KEIAHNY KEIAHNY self-assigned this Sep 28, 2026
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Misleading help text

The doc comment "Change directory for generated Suriconf configuration file" is attached to the new Init subcommand, but the subcommand neither changes a directory nor matches that description (it generates a config file at an output path). This text will appear in suriconf init --help as the subcommand description and misleads users. It should be something like "Generate a default Suriconf configuration file".

/// Change directory for generated Suriconf configuration file

Init {
Panic on init failure

init failures are handled with panic!("{e}") instead of a graceful error print and non-zero exit code. When the output file exists without --force, or the path is unwritable, the user gets a Rust panic message ("thread 'main' panicked at ...") rather than a clean error like other failure paths in main. Since config_gen::init already returns an io::Result, print the error and process::exit(1) instead.

if let Err(e) = init(output, *force) {
    panic!("{e}");
}
Behavior change for config-file CPUs

find_max_cpu_usage_vec now runs values from the YAML config file through insert_cpu/expand_cpu_range, which validates each CPU against num_cpus::get() on the machine running the tool. Previously, CPUs listed in suriconf.yaml were accepted as-is. Existing configurations that list CPU numbers greater than or equal to the local core count (e.g., a config written for a larger host, or a machine where num_cpus::get() reports fewer cores) will now panic at startup with "Unable to parse max cpu usage vector". If validating against the local machine is intended for CLI args only, the config-file path should skip that check.

pub fn find_max_cpu_usage_vec(&self, text: &Value) -> Result<Vec<u64>, String> {
    let seq = text
        .get("variables")
        .and_then(|c| c.get("max_cpu_usage_vec"))
        .and_then(|v| v.as_sequence())
        .ok_or_else(|| "Missing 'max_cpu_usage_vec' in Suriconf configuration".to_string())?;


    let mut cpus: Vec<u64> = Vec::new();
    let mut seen = HashSet::new();

    for item in seq {
        let s = match item {
            Value::Number(n) => n.to_string(),
            Value::String(s) => s.clone(),
            u => return Err(format!("Invalid CPU {:?}.", u))

        };

        insert_cpu(&s, &mut seen, &mut cpus)?;
    }
    Ok(cpus)        

@KEIAHNY

KEIAHNY commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator Author

Closing - applying changes.

@KEIAHNY KEIAHNY closed this Sep 28, 2026
@github-actions

Copy link
Copy Markdown

Failed to generate code suggestions for PR

@KEIAHNY
KEIAHNY deleted the 12394-feat-release-1.1.0-dev-v4 branch September 28, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant