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.

167 lines
4.0KB

  1. # frozen_string_literal: true
  2. control 'firewalld `map.jinja` YAML dump' do
  3. title 'should contain the lines'
  4. yaml_dump = "---\n"
  5. yaml_dump += <<~YAML_DUMP.chomp
  6. AutomaticHelpers: system
  7. FirewallBackend: nftables
  8. FlushAllOnReload: 'yes'
  9. IndividualCalls: 'no'
  10. LogDenied: 'off'
  11. RFC3964_IPv4: 'yes'
  12. backend:
  13. manage: true
  14. pkg: nftables
  15. config: /etc/firewalld.conf
  16. default_zone: public
  17. direct:
  18. chain:
  19. MYCHAIN:
  20. ipv: ipv4
  21. table: raw
  22. rule:
  23. INTERNETACCESS:
  24. ipv: ipv4
  25. table: filter
  26. chain: FORWARD
  27. priority: '0'
  28. args: -i iintern -o iextern -s 192.168.1.0/24 -m conntrack --ctstate NEW,RELATED,ESTABLISHED
  29. -j ACCEPT
  30. passthrough:
  31. MYPASSTHROUGH:
  32. ipv: ipv4
  33. args: -t raw -A MYCHAIN -j DROP
  34. enabled: true
  35. ipset:
  36. manage: true
  37. pkg: ipset
  38. ipsets:
  39. fail2ban-ssh:
  40. short: fail2ban-ssh
  41. description: fail2ban-ssh ipset
  42. type: hash:ip
  43. options:
  44. maxelem:
  45. - 65536
  46. timeout:
  47. - 300
  48. hashsize:
  49. - 1024
  50. entries:
  51. - 10.0.0.1
  52. fail2ban-ssh-ipv6:
  53. short: fail2ban-ssh-ipv6
  54. description: fail2ban-ssh-ipv6 ipset
  55. type: hash:ip
  56. options:
  57. family:
  58. - inet6
  59. maxelem:
  60. - 65536
  61. timeout:
  62. - 300
  63. hashsize:
  64. - 1024
  65. entries:
  66. - 2a01::1
  67. package: firewalld
  68. service: firewalld
  69. services:
  70. sshcustom:
  71. short: sshcustom
  72. description: SSH on port 3232 and 5252. Secure Shell (SSH) is a protocol for logging
  73. into and executing commands on remote machines. It provides secure encrypted
  74. communications. If you plan on accessing your machine remotely via SSH over
  75. a firewalled interface, enable this option. You need the openssh-server package
  76. installed for this option to be useful.
  77. ports:
  78. tcp:
  79. - 3232
  80. - 5252
  81. modules:
  82. - some_module_to_load
  83. protocols:
  84. - igmp
  85. source_ports:
  86. tcp:
  87. - 21
  88. destinations:
  89. ipv4:
  90. - 224.0.0.251
  91. - 224.0.0.252
  92. ipv6:
  93. - ff02::fb
  94. - ff02::fc
  95. zabbixcustom:
  96. short: Zabbixcustom
  97. description: zabbix custom rule
  98. ports:
  99. tcp:
  100. - '10051'
  101. salt-minion:
  102. short: salt-minion
  103. description: salt-minion
  104. ports:
  105. tcp:
  106. - '8000'
  107. zones:
  108. public:
  109. short: Public
  110. description: For use in public areas. You do not trust the other computers on
  111. networks to not harm your computer. Only selected incoming connections are accepted.
  112. services:
  113. - http
  114. - https
  115. - ssh
  116. - salt-minion
  117. other_services:
  118. - zabbixcustom
  119. protocols:
  120. - igmp
  121. rich_rules:
  122. - family: ipv4
  123. source:
  124. address: 8.8.8.8/24
  125. accept: true
  126. - family: ipv4
  127. ipset:
  128. name: fail2ban-ssh
  129. reject:
  130. type: icmp-port-unreachable
  131. ports:
  132. - comment: zabbix-agent
  133. port: 10050
  134. protocol: tcp
  135. - comment: bacula-client
  136. port: 9102
  137. protocol: tcp
  138. - comment: vsftpd
  139. port: 21
  140. protocol: tcp
  141. source_ports:
  142. - comment: something
  143. port: 2222
  144. protocol: tcp
  145. - comment: something_else
  146. port: 4444
  147. protocol: tcp
  148. rich_public:
  149. short: rich_public
  150. description: Example
  151. rich_rules:
  152. ssh-csg:
  153. accept: true
  154. ipsets:
  155. - fail2ban-ssh
  156. - other-ipset
  157. services:
  158. - ssh
  159. YAML_DUMP
  160. describe file('/tmp/salt_yaml_dump.yaml') do
  161. its('content') { should include yaml_dump }
  162. end
  163. end