[Bug]: Cosmos DB private endpoint rule aborts rule evaluation ("Argument types do not match") and never recognises approved private endpoints
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 56/100
Rechercherichtung
Start by reading Get-MonkeyAzCosmosDBInfo.ps1, Get-MonkeyAzGenericPrivateEndpoint, Resolve-Filter.ps1, and the Cosmos DB rule azure-cosmosdb-lacks-private-endpoint.json. Reproduce the reported PowerShell 7.6.9 list behavior, then compare the rule's property path with the storage account rule. Done means evaluation completes and accounts with approved private endpoints pass without false findings; consider whether the shared filter affects other helpers.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
What happened?
Two problems with the rule "Ensure that Cosmos DB uses Private Endpoints where possible" (azure-cosmosdb-lacks-private-endpoint.json, path az_cosmosdb, whereObject = networking.privateEndpointConnections).
Problem 1: rule evaluation throws "Argument types do not match".
Get-MonkeyAzCosmosDBInfo.ps1 assigns the result of Get-MonkeyAzGenericPrivateEndpoint to networking.privateEndpointConnections. That function returns its list with Write-Output $allPrivateEndpoints -NoEnumerate, so the stored value is a List[Object] wrapped in a PSObject. The filter generated by Resolve-Filter.ps1 evaluates
@($_.networking.privateEndpointConnections).Where({$null -ne $_.id -and $_.privateLinkServiceConnectionState.status -eq 'Approved'})
On the PSObject-wrapped list, .Where() throws Argument types do not match. This happens for an empty list, for the placeholder entry (no private endpoint) and for real private endpoints. Out-MonkeyData writes the error with Write-Error; with $ErrorActionPreference = 'Stop' the whole scan stops.
Problem 2: approved private endpoints are never matched.
The rule checks privateLinkServiceConnectionState.status on the entry itself. Get-MonkeyAzGenericPrivateEndpoint stores the ARM data under properties (properties.privateLinkServiceConnectionState.status). With a workaround for problem 1, an account with an approved private endpoint still gets no match and, because of shouldExist: true, is reported as a finding (false positive).
How to reproduce it
Minimal repro for problem 1 (PowerShell 7.6.9):
function Get-Pe { $l = [System.Collections.Generic.List[System.Object]]::new(); [void]$l.Add([pscustomobject]@{ id = $null }); Write-Output $l -NoEnumerate }
$o = [pscustomobject]@{ networking = [pscustomobject]@{ privateEndpointConnections = $null } }
$o.networking.privateEndpointConnections = Get-Pe
@($o.networking.privateEndpointConnections).Where({ $null -ne $_.id }) # Argument types do not match
$o.networking.privateEndpointConnections = @(Get-Pe)
@($o.networking.privateEndpointConnections).Where({ $null -ne $_.id }) # works
With Monkey365: run Invoke-Monkey365 -Instance Azure against a subscription that contains a Cosmos DB account.
Expected behavior
The rule evaluates without error; accounts with an approved private endpoint pass.
Suggested fix
- Problem 1:
$cosmosDBObject.networking.privateEndpointConnections = @(Get-MonkeyAzGenericPrivateEndpoint @p)(this is the workaround we use). - Problem 2: use
properties.privateLinkServiceConnectionState.statusin the rule condition (the storage account rule already uses this path), or flatten the property in the helper.
From where are you running Monkey365?
- Resource: Docker container
- OS: Linux (Ubuntu 24.04)
- PowerShell Version: 7.6.9
- Monkey365 Version: 1.0.5 (PowerShell Gallery)
- Others: app-only authentication with access tokens
Additional context
In 1.0.0 this did not show up for us because Cosmos DB accounts without a diagnostic setting were dropped before evaluation (#196, fixed in 1.0.5). Other helpers also return lists with -NoEnumerate; any whereObject filter on such a property would fail the same way. A generic fix could be in Resolve-Filter.ps1 or in the helpers.
- Vorherrschende Sprache
- PowerShell
- Sterne
- 1.4k
- Forks
- 144
- Ø Merge
- 1 T. 21 Std.
- Gemergte PRs (30 T.)
- 1
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus silverhack/monkey365
-
bug status/needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
silverhack/monkey365#200 ·
-
bug status/needs-triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
silverhack/monkey365#199 ·
-
documentation enhancement help wanted impact-low priority-medium question
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 68/100
silverhack/monkey365#187 · 1 Kommentar ·
-
documentation enhancement epic priority-medium
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 30/100
silverhack/monkey365#184 ·
-
Expose domain-level context for SPF / DKIM / DMARC findings in Exchange OnlineEvtl. wieder frei @silverhack hat das vor 112 Tagen übernommen, und es ist kein Pull Request offen. Offenenhancement
silverhack/monkey365#167 · 3 Kommentare · 1 zugewiesene Person ·
Alle Issues in silverhack/monkey365
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
[BUG] OpenSearch domain endpoint includes a URI scheme and breaks standard Terraform consumersOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
floci-io/floci#7707 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
CRT transfer manager mutates the caller's ExtraArgs, so reusing the dict fails on the next uploadOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
boto/s3transfer#433 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
S3 input fails in Docker image: DuckDB can't find home directoryEvtl. vergeben @jnioche hat das heute übernommen. Offenbug docker reporting
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
DigitalPebble/spruce#315 ·
Maintainer antworten meist innerhalb von 1 Tag