Skip to content

Fix logger NameError in load_rules and expand test coverage - #16

Merged
maclarel merged 1 commit into
mainfrom
add_test_coverage
Feb 23, 2026
Merged

Fix logger NameError in load_rules and expand test coverage#16
maclarel merged 1 commit into
mainfrom
add_test_coverage

Conversation

@maclarel

Copy link
Copy Markdown
Owner

Fix a NameError in load_rules where logger.critical was called but only the logging module was imported (no named logger defined). This would crash at runtime whenever load_rules was given a nonexistent directory.

Add 25 new unit tests covering previously untested code paths:

  • normalize_to_list utility function
  • load_config defaults (watch_rules, watch_interval) and YAML parse errors
  • load_rules with nonexistent directory and malformed YAML files
  • RuleValidator: header presence-only check, EOL Z-suffix format, EOL invalid format, EOL as datetime object (tz-aware and tz-naive), source_ip with no client_address, multiple CIDR OR logic
  • RuleFileMonitor: nonexistent directory, get_changed_rule_files directly, reload error handling preserving existing rules on duplicate URI conflict

Fix a NameError in load_rules where `logger.critical` was called but
only the `logging` module was imported (no named logger defined). This
would crash at runtime whenever load_rules was given a nonexistent
directory.

Add 25 new unit tests covering previously untested code paths:
- normalize_to_list utility function
- load_config defaults (watch_rules, watch_interval) and YAML parse errors
- load_rules with nonexistent directory and malformed YAML files
- RuleValidator: header presence-only check, EOL Z-suffix format, EOL
  invalid format, EOL as datetime object (tz-aware and tz-naive),
  source_ip with no client_address, multiple CIDR OR logic
- RuleFileMonitor: nonexistent directory, get_changed_rule_files directly,
  reload error handling preserving existing rules on duplicate URI conflict

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@maclarel maclarel self-assigned this Feb 23, 2026
@maclarel
maclarel merged commit f5b4eb7 into main Feb 23, 2026
3 checks passed
@maclarel
maclarel deleted the add_test_coverage branch February 23, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant