Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow_rdp_from_internet and allows_ssh_from_internet fails on NSGs that have multiple source addresses #169

Closed
skelleyton opened this issue Apr 3, 2019 · 2 comments

Comments

@skelleyton
Copy link
Contributor

skelleyton commented Apr 3, 2019

🎛 Description

Choose one: is this a 🐛 bug report or 🙋 feature request? Bug Report

When testing allow_rdp_from_internet or allow_ssh_from_internet against NSGs that contain multiple source addresses, the test will fail and return the error "no member 'sourceAddressPrefix' in struct".

🌍 InSpec and Platform Version

Inspec Version 3.6.6
macOS 10.14.3

🤔 Replication Case

Create an NSG in Azure that contains source IP restriction for RDP with multiple IP addresses.
Run test allow_rdp_from_internet against NSG.

💁 Possible Solutions

I was able to resolve the issue by editing the source_open? method in azurerm_network_security_group.rb with the following code.

def source_open?(properties)
    properties_hash = properties.to_h
    if properties_hash.include?(:sourceAddressPrefix)
      return properties['sourceAddressPrefix'] =~ %r{\*|0\.0\.0\.0|<nw>\/0|\/0|Internet|any}
    end
    if properties_hash.include?(:sourceAddressPrefixes)
      return properties['sourceAddressPrefixes'].include?('0.0.0.0')
    end
  end
@rmoles
Copy link
Contributor

rmoles commented Jan 28, 2020

Hi, @skelleyton I just want to confirm that the above PR resolved your issue before closing.

@skelleyton
Copy link
Contributor Author

Hi @rmoles, I can confirm that fixed this issue. I will go ahead and close it. Thanks.

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

No branches or pull requests

2 participants