Skip to content

Fix/11849 Disable Suricata log and syslog logging v2 (keep it in verbose mode) - #45

Closed
KEIAHNY wants to merge 1 commit into
mainfrom
11849-fix-syslog-suricata-log-v2
Closed

KEIAHNY wants to merge 1 commit into
mainfrom
11849-fix-syslog-suricata-log-v2

Conversation

@KEIAHNY

@KEIAHNY KEIAHNY commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

PR Type

Bug fix, Tests


Description

  • Disable Suricata file/syslog logging unless verbose mode

  • Add disable_loggging helper to yaml module

  • Add unit tests with Suricata config fixture


Diagram Walkthrough

flowchart LR
  main["main.rs"] -- "not verbose" --> disable["yaml::disable_loggging"]
  disable -- "set enabled: no" --> outputs["logging.outputs: file, syslog"]
  tests["tests/yaml_tests.rs"] -- "verify behavior" --> disable
Loading

File Walkthrough

Relevant files
Bug fix
main.rs
Disable logging when verbose mode is off                                 

src/main.rs

  • Call yaml::disable_loggging when verbose flag is off
  • Panic with error message if disabling logging fails
+7/-0     
Enhancement
yaml.rs
Add function to disable file and syslog outputs                   

src/yaml.rs

  • Add public disable_loggging function
  • Sets enabled: no for file and syslog logging outputs
  • Returns error when logging outputs section is missing
+22/-0   
Tests
yaml_tests.rs
Add unit tests for yaml logging functions                               

tests/yaml_tests.rs

  • Add tests for opening valid and missing YAML files
  • Add test verifying file/syslog disabled, console untouched
  • Add error-handling test for missing logging outputs section
+68/-0   
suricata.yaml
Add Suricata config fixture for tests                                       

tests/suricata.yaml

  • Add full Suricata 9.0 configuration file as test fixture
+2378/-0

@KEIAHNY KEIAHNY self-assigned this Oct 22, 2026
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

⚠️ Review coverage: The following files were not included in this review because of the token budget:

  • tests/suricata.yaml

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Replace panic with graceful exit

Using panic! for a configuration error in main is too aggressive and provides a poor
user experience. Replace it with a proper error message printed to stderr and exit
with a non-zero status code.

src/main.rs [57-61]

     if !args.verbose {
         if let Err(e) = yaml::disable_loggging(&mut suricata_string) {
-            panic!("{e}");
+            eprintln!("Error disabling logging: {e}");
+            std::process::exit(1);
         }
     }
Suggestion importance[1-10]: 5

__

Why: Replacing panic! with eprintln! and std::process::exit(1) provides a cleaner error message to the user, which is better practice for CLI applications.

Low
Fix typo in function name

The function name disable_loggging contains a typo (triple 'g'). It should be
renamed to disable_logging for correctness and maintainability.

src/yaml.rs [667]

-pub fn disable_loggging(suricata_string: &mut Value) -> Result<(), String> {
+pub fn disable_logging(suricata_string: &mut Value) -> Result<(), String> {
Suggestion importance[1-10]: 4

__

Why: The function name disable_loggging indeed contains a typo. Fixing it improves code quality and maintainability.

Low

⚠️ Suggestion coverage: Partial input coverage: 1 file(s) had patches clipped before analysis to fit the token budget: tests/suricata.yaml.

  • Author self-review: I have reviewed the PR code suggestions, and addressed the relevant ones.

@KEIAHNY

KEIAHNY commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator Author

Closing - applying changes.

@KEIAHNY KEIAHNY closed this Oct 23, 2026
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