Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2532,6 +2532,39 @@ schemas and the `paramify` CLI — not the internal code.

### Fixed

- **Disk, Key Vault, storage and SQL Managed Instance fetchers: an unread list
gives null counts, not 0.** When a list the run needs is refused (403),
throttled or times out, every total, count and percentage built from it is
null. Before, they read 0, which looked like "none found". Each run still
fails as `partial_failure`.
- `azure_disk_encryption_status` 0.3.0: when the disk list is not read, every
disk count and percentage is null (including `total_disks`).
- `azure_key_vault_configuration` 0.5.0: when the vault list is not read,
every count is null. When any vault's diagnostic settings are not read,
`vaults_with_diagnostic_settings`, `vaults_with_audit_logging`,
`vaults_without_audit_logging` and `audit_logging_percentage` are null too;
`vaults_audit_logging_unknown` still says how many.
- `azure_storage_encryption_status` 0.5.0: when the account list is not read,
every count is null (`total_storage_accounts` included). When any account's
container list is not read, the container counts and `in_scope_containers`
and `excluded_containers` are null; when any geo-redundant account's
replication status is not read, `geo_replication_live_accounts` and
`geo_failover_ready_accounts` are null. When any account's blob or file
service properties are not read, `blob_versioning_accounts`,
`container_soft_delete_accounts` (blob) and `share_soft_delete_accounts`
(file) are null; each account records `blob_properties_status` and
`file_service_properties_status` (collected, not_supported or failed).
- `azure_sql_managed_instance_encryption` 0.4.0: when the instance list is
not read, every count is null (`total_managed_instances` and
`in_scope_managed_instances` included). The key counts are null when any
instance's protector is not read, and the TDE counts when any instance's
database list is not read.
- `azure_sql_managed_instance_backups` 0.5.0: when the instance list is not
read, every instance, database and failover group count is null. The
database retention counts are null when any instance's database list is not
read, and `instances_in_failover_group` when any instance's failover group
membership is unknown.

- **`paramify upload` no longer sends an inventory direct when its channel has
no artifact request.** A Paramify inventory pipeline runs only on a file in an
approved batch, so a direct upload was stored and built nothing. The file now
Expand Down
11 changes: 8 additions & 3 deletions fetchers/azure/_shared/sql_managed_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ def _client():
return collector.guard("sql.SqlManagementClient (init)", _client)


def list_instances(client, collector: Collector, project: Callable) -> list[dict]:
"""Every instance, projected, with `resource_group`; one without a group is recorded and dropped."""
def list_instances(client, collector: Collector, project: Callable, unread=()) -> list[dict]:
"""Every instance, projected, with `resource_group`; one without a group is recorded and dropped.

A list that could not be read gives `unread` (an empty list by default; pass None to tell it from no instances).
"""
projected = collector.guard(
"sql.managed_instances.list",
lambda: [project(i) for i in client.managed_instances.list()],
default=[],
default=None,
)
if projected is None:
return list(unread) if unread is not None else None
instances = []
for instance in projected:
group = resource_group_from_id(instance.get("id"))
Expand Down
9 changes: 7 additions & 2 deletions fetchers/azure/disk_encryption_status/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,16 @@ def _cmk_coverage(disks: list[dict], prefix: str = "") -> dict:
}


def summarize(disks: list[dict]) -> dict:
def summarize(disks: list[dict] | None) -> dict:
"""CMK coverage is the headline, computed three ways: all / attached / unattached.

`None` means the disk list was not read: every count and percentage is then null, not 0.

Managed disks are encrypted at rest unconditionally, so a generic "encrypted"
percentage would be a constant 100 and prove nothing.
"""
if disks is None:
return {k: None for k in summarize([])}
attached = [d for d in disks if d["attached"]]
unattached = [d for d in disks if not d["attached"]]
return {
Expand Down Expand Up @@ -318,6 +322,7 @@ def main() -> int:
if not listed:
exclusions.mark_unread()
exclusions.warn_unmatched(logger)
summary = summarize(disks)
disks = disks or []

evidence = build_payload(
Expand All @@ -330,7 +335,7 @@ def main() -> int:
"excluded": excluded,
},
summary={
**summarize(disks),
**summary,
"provider_registration_status": registration,
**exclusions.summary(excluded, KINDS, {"disks": len(disks) if listed else None}),
},
Expand Down
12 changes: 6 additions & 6 deletions fetchers/azure/disk_encryption_status/fetcher.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: azure_disk_encryption_status
version: 0.2.1
version: 0.3.0
description: >-
Shows which key encrypts each managed disk at rest, whether Azure Disk Encryption is on, whether the disk is attached, and how exposed its export path is.
category: azure
Expand Down Expand Up @@ -84,12 +84,12 @@ evidence_set:
- in_scope_disks — Number of disks read and in scope; null when the disk list could not be read; 0 means there are none or the patterns took out every disk, which a check can catch by requiring more than 0

Which disks exist?
- total_disks — Number of in-scope managed disks, attached or not; reads 0, not null, when the disk list could not be read, so read it together with in_scope_disks
- attached_total_disks — Number of disks attached to a virtual machine (the disk names an owner or a shared-disk owner list)
- unattached_total_disks — Number of disks attached to no virtual machine; they still hold the data of the machine they were detached from
- total_disks — Number of in-scope managed disks, attached or not; null when the disk list could not be read, as is every count and percentage below
- attached_total_disks — Number of disks attached to a virtual machine (the disk names an owner or a shared-disk owner list); null when the disk list could not be read
- unattached_total_disks — Number of disks attached to no virtual machine; they still hold the data of the machine they were detached from; null when the disk list could not be read
- provider_registration_status — Whether the Compute provider (Microsoft.Compute) is registered on the subscription: registered, not_registered or unknown
- os_disks — Number of disks that report an operating system type
- data_disks — Number of disks that report no operating system type
- os_disks — Number of disks that report an operating system type; null when the disk list could not be read
- data_disks — Number of disks that report no operating system type; null when the disk list could not be read

Which key encrypts the disks at rest?
- customer_managed_key_disks — Number of disks encrypted with a customer-managed key (an encryption type other than the platform key, held in a disk encryption set). Managed disks are always encrypted at rest, so this is what varies
Expand Down
26 changes: 23 additions & 3 deletions fetchers/azure/key_vault_configuration/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,27 @@ def with_audit_logging(vault: dict, settings) -> dict:
}


def summarize(vaults: list[dict]) -> dict:
"""RBAC adoption and recoverability are the headlines."""
AUDIT_COUNTS = (
"vaults_with_diagnostic_settings", "vaults_with_audit_logging", "vaults_without_audit_logging",
"audit_logging_percentage",
)


def summarize(vaults: list[dict] | None) -> dict:
"""RBAC adoption and recoverability are the headlines.

`None` means the vault list was not read: every count is null, not 0. The counts built from
diagnostic settings are null too while any vault's settings could not be read.
"""
if vaults is None:
return {k: None for k in summarize([])}
counts = _summarize(vaults)
if any(v.get("audit_logging_enabled") is None for v in vaults):
counts.update({k: None for k in AUDIT_COUNTS})
return counts


def _summarize(vaults: list[dict]) -> dict:
total = len(vaults)
rbac = sum(1 for v in vaults if v["rbac_authorization_enabled"])
recoverable = sum(1 for v in vaults if v["recoverable"])
Expand Down Expand Up @@ -537,6 +556,7 @@ def main() -> int:

exclusions.record_invalid(collector)
listed = vaults is not None
summary = summarize(vaults)
vaults = vaults or []
if not listed:
exclusions.mark_unread()
Expand All @@ -552,7 +572,7 @@ def main() -> int:
"excluded": excluded,
},
summary={
**summarize(vaults),
**summary,
"provider_registration_status": registration,
**exclusions.summary(excluded, ("key_vault",), {"key_vaults": len(vaults) if listed else None}),
},
Expand Down
18 changes: 9 additions & 9 deletions fetchers/azure/key_vault_configuration/fetcher.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: azure_key_vault_configuration
version: 0.4.1
version: 0.5.0
description: >-
Shows how each key vault grants access, whether deleted vaults and secrets can be recovered, how it's exposed to the network, and whether its audit events are logged.
category: azure
Expand Down Expand Up @@ -86,20 +86,20 @@ evidence_set:
- in_scope_key_vaults — Number of key vaults read and in scope; null when the key vault list could not be read; 0 means there are none or the patterns took out every vault, which a check can catch by requiring more than 0

Which vaults were checked?
- total_key_vaults — Number of in-scope key vaults; every count and percentage below covers only these; reads 0, not null, when the key vault list could not be read, so read it together with in_scope_key_vaults
- total_key_vaults — Number of in-scope key vaults; every count and percentage below covers only these; null when the key vault list could not be read, as is every count and percentage below
- provider_registration_status — Whether Microsoft.KeyVault is registered on the subscription: registered, not_registered or unknown

How is access to the vaults granted?
- rbac_authorization_vaults — Number of vaults that use Azure RBAC role assignments for access to keys, secrets and certificates (the role assignments aren't in this evidence)
- access_policy_vaults — Number of vaults that use the older vault access policies instead of Azure RBAC
- rbac_authorization_percentage — Percentage of vaults that use Azure RBAC = rbac_authorization_vaults / total_key_vaults × 100 (a whole number, rounded down; reads 0 when total_key_vaults is 0)
- total_access_policies — Number of access policy entries across all vaults, each giving a user, group or app permissions on a vault's keys, secrets, certificates or storage accounts; 0 when the key vault list could not be read
- rbac_authorization_percentage — Percentage of vaults that use Azure RBAC = rbac_authorization_vaults / total_key_vaults × 100 (a whole number, rounded down; reads 0 when total_key_vaults is 0, null when the key vault list could not be read)
- total_access_policies — Number of access policy entries across all vaults, each giving a user, group or app permissions on a vault's keys, secrets, certificates or storage accounts; null when the key vault list could not be read

Can a deleted vault or secret be recovered?
- soft_delete_vaults — Number of vaults with soft delete on, so deleted vaults, keys and secrets are kept for the retention period and can be restored; a vault that doesn't report the setting counts as off
- purge_protection_vaults — Number of vaults with purge protection on, so nobody can permanently delete the vault or its contents before the retention period ends
- recoverable_vaults — Number of recoverable vaults: both soft delete and purge protection on
- recoverable_percentage — Percentage of vaults that are recoverable = recoverable_vaults / total_key_vaults × 100 (a whole number, rounded down; reads 0 when total_key_vaults is 0)
- recoverable_percentage — Percentage of vaults that are recoverable = recoverable_vaults / total_key_vaults × 100 (a whole number, rounded down; reads 0 when total_key_vaults is 0, null when the key vault list could not be read)

Is network access restricted?
- public_network_access_disabled_vaults — Number of vaults with public network access disabled, reachable only through private endpoints; a vault that doesn't report the setting counts as enabled
Expand All @@ -110,8 +110,8 @@ evidence_set:
- premium_sku_vaults — Number of vaults on the Premium tier, which can hold keys in hardware security modules (HSMs); whether each key is HSM-backed isn't checked

Is every operation on keys and secrets logged?
- vaults_with_diagnostic_settings — Number of vaults with at least one diagnostic setting, whatever it exports
- vaults_with_audit_logging — Number of vaults with audit logging: a diagnostic setting that exports the AuditEvent category (directly, or through the audit or allLogs group) to a storage account, Log Analytics workspace, event hub or partner solution; AuditEvent records every read or change of a key, secret or certificate
- vaults_without_audit_logging — Number of vaults whose diagnostic settings were read and include no audit logging
- vaults_with_diagnostic_settings — Number of vaults with at least one diagnostic setting, whatever it exports; null when any vault's diagnostic settings couldn't be read
- vaults_with_audit_logging — Number of vaults with audit logging: a diagnostic setting that exports the AuditEvent category (directly, or through the audit or allLogs group) to a storage account, Log Analytics workspace, event hub or partner solution; AuditEvent records every read or change of a key, secret or certificate; null when any vault's diagnostic settings couldn't be read
- vaults_without_audit_logging — Number of vaults whose diagnostic settings were read and include no audit logging; null when any vault's diagnostic settings couldn't be read
- vaults_audit_logging_unknown — Number of vaults whose diagnostic settings couldn't be read
- audit_logging_percentage — Percentage of vaults with audit logging = vaults_with_audit_logging / total_key_vaults × 100 (a whole number, rounded down; reads 0 when total_key_vaults is 0); vaults whose settings couldn't be read count in the total but not as logged
- audit_logging_percentage — Percentage of vaults with audit logging = vaults_with_audit_logging / total_key_vaults × 100 (a whole number, rounded down; reads 0 when total_key_vaults is 0, null when the key vault list could not be read); null when any vault's diagnostic settings couldn't be read
Loading
Loading