Skip to content

Azure monitoring fetchers: an unread list gives null counts, not 0 or false - #368

Open
Controgon wants to merge 9 commits into
mainfrom
fde-1201
Open

Controgon wants to merge 9 commits into
mainfrom
fde-1201

Conversation

@Controgon

@Controgon Controgon commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes FDE-1201
Part of FDE-1190

Summary

Four Azure monitoring fetchers read 0 or false for every count and verdict built from a list that was refused or failed. They now give null, the same rule as the policy compliance, managed identity and data services fixes. The run still exits 1 as partial_failure.

  • azure_activity_log_alerts 0.4.0: an unread alert rule list nulls every alert count, both coverage maps and the coverage verdicts (the two operation totals stay 12 and 4). An unread processing rule list makes suppressed and reaches_human null per alert and nulls alerts_suppressed, alerts_possibly_suppressed, alerts_reaching_human, the change coverage fields and monitored_operation_coverage_reaching_human. Before: 0 and false, and alerts read as not suppressed. alert_routing.route() takes rules=None for an unread list.
  • azure_diagnostic_settings 0.2.0: unread settings null activity_log_exported, the counts, the coverage map and the required-category verdicts. Before: activity_log_exported false.
  • azure_resource_diagnostic_settings 0.5.0: an unread Resource Graph inventory nulls the resource, coverage, destination and ingestion counts and verdicts, plus in_scope_resources and excluded_resources. Before: 0.
  • azure_log_analytics_workspaces 0.4.0: an unread workspace list nulls every count, in_scope_workspaces and excluded_workspaces. A workspace whose tables or data exports are unread nulls total_tables, min_table_total_retention_in_days and the data export counts. sentinel_onboarded is null while any workspace's solutions are unread and none is known to have Sentinel (before: false).

A list that was read and is empty still counts 0 and false. The plain-text instructions say which fields are null and when. Changelog entry added under Unreleased > Fixed.

Tests

tests/test_azure_monitoring_null_counts.py (new): per fetcher, runs main() with the list refused (and the sub-lists refused for workspaces) and asserts every field built from it is null, plus a read-and-empty case that still counts 0/false. Added a refused processing-rule test, a fixed-totals test and a read-and-empty workspace test. With the fetcher.py files reverted to main, the refused-list tests fail and the read-case guards pass; the processing-rule test also fails against the first commit of this branch.

Ran under nice: the new file, the existing tests for these fetchers (text, verdicts, exclusions), the contract tests and the status lib tests: 1233 passed. No full suite (CI runs it).

Validator check

No validator on main reads these evidence sets. On added-validators, each validator that reads a changed field was checked against a null value:

  • Verdict unchanged (fails before and after, no match or partial_failure true): azure_activity_log_alerts_cover_operations_routed, azure_activity_log_required_categories_exported (its regex captures null and the rules want true), azure_diag_all_resources_ingesting_recently, azure_diag_inventory_fully_assessed, azure_diag_log_analytics_coverage_complete, azure_diag_logs_only_to_approved_workspaces.
  • Not affected (read per-record fields that did not change): the other azure_diag_*, log_analytics_* and azure_activity_log_required_categories_to_log_analytics validators.
  • One verdict changes: azure_diag_no_resource_missing_log_setting reads resources_emitting_logs_without_setting as \d+. On an unread inventory it passed on 0; it now has no match and fails its presence rule. That pass was false (the run's collection validator fails anyway). It is not edited here; it is the user's call whether it goes back for review.

The processing-rule nulls (alerts_suppressed, alerts_possibly_suppressed, change_operation*) were checked against azure_activity_log_alerts_cover_operations_routed with an ECMAScript evaluation of its regex on a refused-processing-rule run: no match before (partial_failure true) and no match after (null, even with partial_failure forced false). Verdict unchanged.

Changed after review

  • route() in _shared/alert_routing.py: with the processing rule list unread (rules is None), an enabled alert whose own action groups give False for routes_to_enabled_receiver or routes_to_person now gets null, because a processing rule may add a group. A True stays. reaches_human follows, so the alert lands in alerts_routing_unknown and alerts_reaching_human_unknown. Disabled alerts stay false.
  • processing_rule_matches and suppressed_by_processing_rules are null, not [], when the list was not read. A list that was read and is empty still gives [] and false.
  • The summary needed no other change: the new nulls feed the existing unknown counts. Field text for those two counts mentions the unread-list case.
  • Tests: unit tests for route() (enabled, no own group, rules unread / read-empty / known own group / disabled) and an end-to-end run with an alert that has no action group and a refused processing rule list.
  • alert_routing.py is byte-identical to the one in the azure_alert_rules PR (azure_alert_rules: suppression fields and processing rule counts are null when processing rules weren't read #370).

🤖 Generated with Claude Code

Controgon and others added 4 commits November 13, 2026 14:52
… read

Four Azure monitoring fetchers (activity_log_alerts, diagnostic_settings,
resource_diagnostic_settings, log_analytics_workspaces) read 0 or false for
every count and verdict built from a list that was refused or failed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
An unread alert processing rule list no longer reads as no suppression.
The operation totals stay numbers when the alert list is unread, the
resource inventory read flag is explicit, and a read-and-empty workspace
test is added.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@bruceweygandt bruceweygandt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main change is correct in all four fetchers. An unread alert list,
diagnostic setting list, Resource Graph inventory or workspace list now gives
null counts, maps and verdicts, not 0 or false. A list that was read and is
empty still gives 0 and false. The fixed totals stay. The version bumps
(activity_log_alerts 0.4.0, diagnostic_settings 0.2.0,
log_analytics_workspaces 0.4.0, resource_diagnostic_settings 0.5.0), the
CHANGELOG entry and the field text match the code. It merges cleanly with main,
and the tests pass. One gap remains, in the shared routing code.

1. fetchers/azure/_shared/alert_routing.py:227-228 and :238 (should fix)

Problem: A processing rule can add an action group to an alert. When the
processing rule list was not read, route() still decides routing from the
alert's own action groups only. An alert with no own action group, or with no
own deliverable one, gets routes_to_enabled_receiver: false, and line 238
makes reaches_human false, not null. I checked this: with_routing(alert, {}, None) for an enabled alert with no action group gives
routes_to_enabled_receiver: false and reaches_human: false.

Why this is a problem: The alert record says "does not reach a person" when
this is not known. The PR text says an unread processing rule list makes
reaches_human null per alert; that is true only for alerts with a deliverable
own group. In the summary (activity_log_alerts/fetcher.py:327-332), the alert
is in neither alerts_routing_to_enabled_receiver nor alerts_routing_unknown,
and it is not in alerts_reaching_human_unknown. These three fields are not in
SUPPRESSION_FIELDS (line 268), so they read as known counts.

Fix: In route(), when rules is None and the alert is enabled, change a
False from _tri to None for routes and to_person. A True can stay,
because a known own group already delivers. Then reaches_human becomes null
too, and the unknown counts include the alert. Also return None, not [], for
processing_rule_matches and suppressed_by_processing_rules. Add a test with
an enabled alert that has no own action group. #370 has the same route()
change, so make the fix in both PRs.

Controgon and others added 4 commits November 17, 2026 12:57
…ert without its own group unknown

With the processing rule list unread, an enabled alert with no deliverable
own action group read false for routes_to_enabled_receiver, routes_to_person
and reaches_human, and was missing from the unknown counts. A False from the
own groups is now null, a True stays, and processing_rule_matches and
suppressed_by_processing_rules are null, not [].

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants