Saltstack Official FirewallD Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zones_spec.rb 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # frozen_string_literal: true
  2. control 'zones/public.xml configuration' do
  3. title 'should match desired lines'
  4. describe file('/etc/firewalld/zones/public.xml') do
  5. it { should be_file }
  6. it { should be_owned_by 'root' }
  7. it { should be_grouped_into 'root' }
  8. its('mode') { should cmp '0644' }
  9. its('content') do
  10. should include <<~ZONE_XML
  11. <zone>
  12. <short>Public</short>
  13. <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
  14. <service name="zabbixcustom" />
  15. <service name="http" />
  16. <service name="https" />
  17. <service name="ssh" />
  18. <service name="salt-minion" />
  19. <!-- zabbix-agent -->
  20. <port port="10050" protocol="tcp" />
  21. <!-- bacula-client -->
  22. <port port="9102" protocol="tcp" />
  23. <!-- vsftpd -->
  24. <port port="21" protocol="tcp" />
  25. <protocol value="igmp" />
  26. <!-- something -->
  27. <source-port port="2222" protocol="tcp" />
  28. <!-- something_else -->
  29. <source-port port="4444" protocol="tcp" />
  30. <rule family="ipv4">
  31. <source address="8.8.8.8/24" />
  32. <accept></accept>
  33. </rule>
  34. <rule family="ipv4">
  35. <source ipset="fail2ban-ssh" />
  36. <reject type="icmp-port-unreachable" />
  37. </rule>
  38. <rule>
  39. <service name="http" />
  40. <log prefix="http fw limit 3/m" level="warning">
  41. <limit value="3/m"/>
  42. </log>
  43. <accept> <limit value="3/m"/></accept>
  44. </rule>
  45. </zone>
  46. ZONE_XML
  47. end
  48. end
  49. end
  50. control 'zones/rich_public.xml configuration' do
  51. title 'should match desired lines'
  52. describe file('/etc/firewalld/zones/rich_public.xml') do
  53. it { should be_file }
  54. it { should be_owned_by 'root' }
  55. it { should be_grouped_into 'root' }
  56. its('mode') { should cmp '0644' }
  57. its('content') do
  58. should include <<~ZONE_XML
  59. <zone>
  60. <short>rich_public</short>
  61. <description>Example</description>
  62. <rule priority="15">
  63. <source ipset="other-ipset" />
  64. <service name="http" />
  65. <accept></accept>
  66. </rule>
  67. <rule>
  68. <source ipset="fail2ban-ssh" />
  69. <service name="ssh" />
  70. <accept></accept>
  71. </rule>
  72. <rule>
  73. <source ipset="other-ipset" />
  74. <service name="ssh" />
  75. <accept></accept>
  76. </rule>
  77. </zone>
  78. ZONE_XML
  79. end
  80. end
  81. end