Azure / Azure-Network-Security

Resources for improving Customer Experience with Azure Network Security

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dangling DNS Finder fails with latest version of Az

lawrencewilson opened this issue · comments

Describe the bug
The Azure Dangling DNS Finder does not work with Az.ResourceGraph version 0.10.0

Reproduce
Steps to reproduce the behavior:

  1. issue Install-module -name Az and ensure you've pulled the latest version (5.9.0)
  2. Issue Get-Command "Search-AzGraph", ensure you have version 0.10.0
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Search-AzGraph                                 0.10.0    Az.ResourceGraph
  1. Run the Get-DanglingDnsRecords
  2. See error
InvalidOperation: You cannot call a method on a null-valued expression. 
At C:\Octopus\Tentacle\Work\20210504200347-1591704-260\scripts\dns-management\Get-DanglingDnsRecords.ps1:338 char:13 
+             $key = $psitem.$keyName.trim(" ").tolower() 

Expected behavior
The tool works and is able to retrieve Az-Resources as usual.

Screenshots
If applicable, add screenshots/images to help explain your problem.

Environment- if applicable

  • What version of CLI was used [Az –version] 5.9.0

Desktop (please complete the following information if applicable):

  • OS: Windows 10
  • Browser Firefox
  • Version [e.g. 22]

Logs- if applicable

  • If logs are available, please provide relevant snippets

Additional context
It looks like there is a change in Search-AzGraph (version 0.10.0) where the data returned is now encapsulated in data.
For example:
instead of

$key = $psitem.$keyName.trim(" ").tolower() 

It would need to be:

$key = $psitem.data.$keyName.trim(" ").tolower() 

My work-around was to:

Option 1. Ensure a previous version of Az.ResourceGraph is used.

Option 2. Update the Dangling dns finder to account for this change.

https://github.com/Azure/Azure-Network-Security/blob/master/Cross%20Product/DNS%20-%20Find%20Dangling%20DNS%20Records/AzDanglingDomain/Export/Get-DanglingDnsRecords.ps1#L308

to look like this:
return ($(Search-AzGraph -Query $query @params)).data

Looks like there is already a fix for this incoming. I will close this issue

Reference:
#40