windows_firewall resource
Use the windows_firewall Chef InSpec audit resource to test if a firewall profile is correctly configured on a Windows system.
Availability
Install
This resource is distributed with Chef InSpec and is automatically available for use.Syntax
A windows_firewall resource block specifies which profile to validate:
describe windows_firewall('name') do
  it { should be_enabled }
end
where:
('name')must specify the name of a firewall profile, such as'Public','Private'or'Domain'be_enabledis a valid matcher for this resource
Examples
The following example shows how to use this Chef InSpec audit resource.
Test if the firewall has the appropriate amount of rules and default Accept
describe windows_firewall('Public') do
  it { should be_enabled }
  it { should have_default_inbound_allowed }
  its('num_rules') { should eq 219 }
end
Properties
The resource compiles the following list of firewall profile properties:
descriptiondefault_inbound_actiondefault_outbound_actionallow_inbound_rulesallow_local_firewall_rulesallow_local_ipsec_rulesallow_user_appsallow_user_portsallow_unicast_response_to_multicastnotify_on_listenenable_stealth_mode_for_ipseclog_max_size_kilobyteslog_allowedlog_blockedlog_ignorednum_rules
Each of these properties can be used in two distinct ways:
its('default_inbound_action') { should cmp 'Allow' }
or with a matcher:
it { should have_default_inbound_action 'Allow' }
Shortcuts are defined for:
have_default_inbound_allow?have_default_outbound_allow?
Matchers
For a full list of available matchers, see our Universal Matchers page.This resource has the following special matchers.
be_enabled
The be_enabled matcher tests if the Profile is enabled:
it { should be_enabled }