fix(azure): case-insensitive resource-ID parsing in panther_azureactivity_helpers - #2034
Conversation
…vity_helpers Azure Monitor Activity logs frequently deliver resourceId fully uppercased, e.g. "/SUBSCRIPTIONS/<id>/RESOURCEGROUPS/RG/PROVIDERS/MICROSOFT.STORAGE/ STORAGEACCOUNTS/ACCOUNT". The current implementation uses `parts.index(resource_type)` which is case-sensitive: for uppercase segment markers the function silently returns `<UNKNOWN>` for storageAccounts, resourceGroups, vaults, runbooks, and every other resource_type it looks up. This breaks downstream alert context enrichment, lookup-based suppression, and dedup keys for any detection that relies on this helper. Fix: iterate parts once comparing each segment's `.lower()` against `resource_type.lower()`. The returned name is still the original (unlowered) value at parts[idx+1], so downstream correlation against authoritative resource names continues to match. Contract-compatible: same signature, same default behavior, same return type. Mixed-case resourceIds (the common case) continue to work unchanged; previously- broken uppercased resourceIds now extract correctly.
|
|
PR SummaryLow Risk Overview The helper now scans segments using lowercase comparisons (instead of Reviewed by Cursor Bugbot for commit 5cab932. Bugbot is set up for automated code reviews on this repo. Configure here. |
arielkr256
left a comment
There was a problem hiding this comment.
Nice catch, thank you!
48eb7cc
|
@wired33 could you please sign the CLA? #2034 (comment) |
Upstream PR: fix(azure): case-insensitive resource-ID parsing in panther_azureactivity_helpers
Target repo:
panther-labs/panther-analysisBase branch:
developFeature branch:
fix-azure-helper-case-sensitivityLocal commit:
5cab9323(inpanther-work/panther-analysis/)File changed:
global_helpers/panther_azureactivity_helpers.pyLines: +13 / -9 (1 file)
Operator action to submit:
PR Title
PR Body
Summary
extract_resource_name_from_id()inglobal_helpers/panther_azureactivity_helpers.pyusesparts.index(resource_type)to locate a named segment in an Azure resourceId path.list.index()is case-sensitive, but Azure Monitor Activity logs frequently deliverresourceIdfully uppercased. For those events the helper silently returns thedefault(<UNKNOWN>) for every resource type it looks up —storageAccounts,resourceGroups,vaults,runbooks, and any other caller.This breaks downstream enrichment (alert context, dedup keys, lookup-based suppression) on any detection that uses this helper against real-world uppercased resourceIds.
Evidence
Observed in production Azure Monitor Activity logs during our 2026-04-20 weekly detection review. Representative resourceId delivered by Azure:
Current behavior:
Expected behavior:
Fix
Compare each path segment's
.lower()againstresource_type.lower()instead of relying onlist.index(). The returned name is still the original (unmodified) value atparts[idx + 1], so downstream correlation against authoritative resource names continues to match the caller's expectations for case.Contract compatibility
resource_id(the fix is in the marker comparison, not the return).Test plan
pipenv run panther_analysis_tool test --path global_helpers/— existing global-helper tests still pass.extract_resource_name_from_id— all now benefit without code change.Downstream impact (reason we found it)
In our fork, we'd patched this helper locally and several Azure.MonitorActivity detections were consuming the patched version. Upstreaming this means we can eventually drop the fork of the helper itself. We still carry downstream-specific customizations of a few detection rules that will remain in our fork; this PR is just for the helper.
Related
split("/resourceGroups/")(not using this helper). Fixed locally in our repo — may file a separate upstream PR if the detection is upstream-hosted.