You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feat/12394 v4 Prepare for release 1.1.0-dev (init command, CPU ranges, Suricata spec) - #34
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 fileInit{
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.
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.
pubfn 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())?;letmut cpus:Vec<u64> = Vec::new();letmut seen = HashSet::new();for item in seq {let s = match item {Value::Number(n) => n.to_string(),Value::String(s) => s.clone(),
u => returnErr(format!("Invalid CPU {:?}.", u))};insert_cpu(&s,&mut seen,&mut cpus)?;}Ok(cpus)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Documentation
Description
Add
initcommand generating default configuration fileSupport CPU range expansion in
max_cpu_usage_vecHashSetBump version to 1.1.0-dev, add
num_cpusdependencyUpdate README with Suricata branch and init usage
Diagram Walkthrough
File Walkthrough
5 files
Add CPU range parsing with validation and deduplicationAdd Init command and change CPU vec to stringsHandle init command with early exitNew module generating default configuration fileRegister config_gen module and embed default config1 files
Import io module for Result type shorthand1 files
Update version, Suricata spec, and init documentation1 files
Bump version and update default configuration values1 files
Bump version to 1.1.0-dev, add num_cpus dependency4 files