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
Suricata will fail to start if the user-configured log directory does not already exist on disk. Create the directory (including parents) before passing it via -l, and handle errors explicitly rather than silently continuing.
pub fn set_log_dir(suriconf: &Suriconf, vec_of_sur_cmd: &mut Vec<String>) {
+ if let Err(e) = std::fs::create_dir_all(&suriconf.log_dir) {+ panic!("Failed to create log dir {}: {e}", suriconf.log_dir.display());+ }
vec_of_sur_cmd.push("-l".to_string());
vec_of_sur_cmd.push(suriconf.log_dir.display().to_string());
}
Suggestion importance[1-10]: 4
__
Why: Suricata does fail when the log directory does not exist, so creating it via std::fs::create_dir_all before appending the -l flag is a valid robustness improvement. However, the PR does not show whether the log directory is already guaranteed to exist elsewhere (e.g., when parsing suriconf.log_dir), and the suggested panic! error handling mirrors existing code style but limits the quality of the improvement.
Low
General
Guard against empty log directory
If suriconf.log_dir is empty or unconfigured, pushing -l with an empty string will make Suricata fail or fall back to unexpected behavior. Skip adding the -l flags in that case so the default log directory is respected.
Why: Guarding against an empty suriconf.log_dir is a plausible defensive check to avoid passing an empty -l argument to Suricata. It is speculative though, since the PR does not show how log_dir is constructed, and it may already be validated or defaulted in the configuration code.
Low
Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.
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
Bug fix
Description
Add
set_log_dirto pass configured log directoryInvoke
set_log_dirwhen building Suricata commandDiagram Walkthrough
File Walkthrough
suricata.rs
Pass user-configured log directory to Suricata commandsrc/suricata.rs
set_log_dirfunction that appends the-lflag andsuriconf.log_dirpath to the Suricata command argumentsset_log_dirinexecute_suricataduring command construction,before
get_capture_mode