Skip to content

Commit 0df537a

Browse files
authored
Merge pull request #301 from myii/ci/add-freebsd-vagrant-in-github-actions
ci: enable Vagrant-based testing using GitHub Actions
2 parents e7c2d20 + 5a6b203 commit 0df537a

File tree

13 files changed

+425
-16
lines changed

13 files changed

+425
-16
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
# vim: ft=yaml
3+
---
4+
name: 'Kitchen Vagrant (FreeBSD)'
5+
'on': ['push', 'pull_request']
6+
7+
env:
8+
KITCHEN_LOCAL_YAML: 'kitchen.vagrant.yml'
9+
10+
jobs:
11+
test:
12+
runs-on: 'macos-10.15'
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
instance:
17+
# - default-freebsd-122-latest-py3
18+
- freebsd-122-latest-py3
19+
# - default-freebsd-114-latest-py3
20+
- freebsd-114-latest-py3
21+
steps:
22+
- name: 'Check out code'
23+
uses: 'actions/checkout@v2'
24+
- name: 'Set up Bundler cache'
25+
uses: 'actions/cache@v1'
26+
with:
27+
path: 'vendor/bundle'
28+
key: "${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}"
29+
restore-keys: "${{ runner.os }}-gems-"
30+
- name: 'Run Bundler'
31+
run: |
32+
ruby --version
33+
bundle config path vendor/bundle
34+
bundle install --jobs 4 --retry 3
35+
- name: 'Run Test Kitchen'
36+
run: 'bundle exec kitchen verify ${{ matrix.instance }}'

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ gem 'kitchen-docker', git: 'https://gitlab.com/saltstack-formulas/infrastructure
1212
# rubocop:enable Layout/LineLength
1313
gem 'kitchen-inspec', '>= 2.2.1'
1414
gem 'kitchen-salt', '>= 0.6.3'
15+
16+
group :vagrant do
17+
gem 'kitchen-vagrant'
18+
end

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ GEM
292292
kitchen-salt (0.6.3)
293293
hashie (>= 3.5)
294294
test-kitchen (>= 1.4)
295+
kitchen-vagrant (1.7.0)
296+
test-kitchen (>= 1.4, < 3)
295297
libyajl2 (1.2.0)
296298
license-acceptance (1.0.19)
297299
pastel (~> 0.7)
@@ -525,6 +527,7 @@ DEPENDENCIES
525527
kitchen-docker!
526528
kitchen-inspec (>= 2.2.1)
527529
kitchen-salt (>= 0.6.3)
530+
kitchen-vagrant
528531

529532
BUNDLED WITH
530533
2.1.2

apache/files/FreeBSD/apache-2.4.config.jinja

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#
2+
# This file is managed by Salt! Do not edit by hand!
3+
#
4+
15
#
26
# This is the main Apache HTTP server configuration file. It contains the
37
# configuration directives that give the server its instructions.
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
{%- set apache = pillar.get('apache', {}) %}
2+
{%- set modsec = apache.get('mod_security', {}) %}
3+
{%- set sec_rule_engine = modsec.get('sec_rule_engine', 'DetectionOnly' ) -%}
4+
{%- set sec_request_body_access = modsec.get('sec_request_body_access', 'On' ) -%}
5+
{%- set sec_request_body_limit = modsec.get('sec_request_body_limit', 13107200 ) -%}
6+
{%- set sec_request_body_no_files_limit = modsec.get('sec_request_body_no_files_limit', 131072 ) -%}
7+
{%- set sec_request_body_in_memory_limit = modsec.get('sec_request_body_in_memory_limit', 131072 ) -%}
8+
{%- set sec_request_body_limit_action = modsec.get('sec_request_body_limit_action', 'Reject' ) -%}
9+
{%- set sec_pcre_match_limit = modsec.get('sec_pcre_match_limit', 1000 ) -%}
10+
{%- set sec_pcre_match_limit_recursion = modsec.get('sec_pcre_match_limit_recursion', 1000 ) -%}
11+
{%- set sec_debug_log_level = modsec.get('sec_debug_log_level', 0 ) -%}
12+
#
13+
# This file is managed by Salt! Do not edit by hand!
14+
# Modify the salt pillar that generates this file instead
15+
#
16+
# -- Rule engine initialization ----------------------------------------------
17+
18+
# Enable ModSecurity, attaching it to every transaction. Use detection
19+
# only to start with, because that minimises the chances of post-installation
20+
# disruption.
21+
#
22+
SecRuleEngine {{ sec_rule_engine }}
23+
24+
25+
# -- Request body handling ---------------------------------------------------
26+
27+
# Allow ModSecurity to access request bodies. If you don't, ModSecurity
28+
# won't be able to see any POST parameters, which opens a large security
29+
# hole for attackers to exploit.
30+
#
31+
SecRequestBodyAccess {{ sec_request_body_access }}
32+
33+
34+
# Enable XML request body parser.
35+
# Initiate XML Processor in case of xml content-type
36+
#
37+
SecRule REQUEST_HEADERS:Content-Type "(?:application(?:/soap\+|/)|text/)xml" \
38+
"id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
39+
40+
# Enable JSON request body parser.
41+
# Initiate JSON Processor in case of JSON content-type; change accordingly
42+
# if your application does not use 'application/json'
43+
#
44+
SecRule REQUEST_HEADERS:Content-Type "application/json" \
45+
"id:'200001',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON"
46+
47+
# Maximum request body size we will accept for buffering. If you support
48+
# file uploads then the value given on the first line has to be as large
49+
# as the largest file you are willing to accept. The second value refers
50+
# to the size of data, with files excluded. You want to keep that value as
51+
# low as practical.
52+
#
53+
SecRequestBodyLimit {{ sec_request_body_limit }}
54+
SecRequestBodyNoFilesLimit {{ sec_request_body_no_files_limit }}
55+
56+
# Store up to 128 KB of request body data in memory. When the multipart
57+
# parser reaches this limit, it will start using your hard disk for
58+
# storage. That is slow, but unavoidable.
59+
#
60+
SecRequestBodyInMemoryLimit {{ sec_request_body_in_memory_limit }}
61+
62+
# What do do if the request body size is above our configured limit.
63+
# Keep in mind that this setting will automatically be set to ProcessPartial
64+
# when SecRuleEngine is set to DetectionOnly mode in order to minimize
65+
# disruptions when initially deploying ModSecurity.
66+
#
67+
SecRequestBodyLimitAction {{ sec_request_body_limit_action }}
68+
69+
# Verify that we've correctly processed the request body.
70+
# As a rule of thumb, when failing to process a request body
71+
# you should reject the request (when deployed in blocking mode)
72+
# or log a high-severity alert (when deployed in detection-only mode).
73+
#
74+
SecRule REQBODY_ERROR "!@eq 0" \
75+
"id:'200002', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
76+
77+
# By default be strict with what we accept in the multipart/form-data
78+
# request body. If the rule below proves to be too strict for your
79+
# environment consider changing it to detection-only. You are encouraged
80+
# _not_ to remove it altogether.
81+
#
82+
SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
83+
"id:'200003',phase:2,t:none,log,deny,status:400, \
84+
msg:'Multipart request body failed strict validation: \
85+
PE %{REQBODY_PROCESSOR_ERROR}, \
86+
BQ %{MULTIPART_BOUNDARY_QUOTED}, \
87+
BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
88+
DB %{MULTIPART_DATA_BEFORE}, \
89+
DA %{MULTIPART_DATA_AFTER}, \
90+
HF %{MULTIPART_HEADER_FOLDING}, \
91+
LF %{MULTIPART_LF_LINE}, \
92+
SM %{MULTIPART_MISSING_SEMICOLON}, \
93+
IQ %{MULTIPART_INVALID_QUOTING}, \
94+
IP %{MULTIPART_INVALID_PART}, \
95+
IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
96+
FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
97+
98+
# Did we see anything that might be a boundary?
99+
#
100+
SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
101+
"id:'200004',phase:2,t:none,log,deny,msg:'Multipart parser detected a possible unmatched boundary.'"
102+
103+
# PCRE Tuning
104+
# We want to avoid a potential RegEx DoS condition
105+
#
106+
SecPcreMatchLimit {{ sec_pcre_match_limit }}
107+
SecPcreMatchLimitRecursion {{ sec_pcre_match_limit_recursion }}
108+
109+
# Some internal errors will set flags in TX and we will need to look for these.
110+
# All of these are prefixed with "MSC_". The following flags currently exist:
111+
#
112+
# MSC_PCRE_LIMITS_EXCEEDED: PCRE match limits were exceeded.
113+
#
114+
SecRule TX:/^MSC_/ "!@streq 0" \
115+
"id:'200005',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
116+
117+
118+
# -- Response body handling --------------------------------------------------
119+
120+
# Allow ModSecurity to access response bodies.
121+
# You should have this directive enabled in order to identify errors
122+
# and data leakage issues.
123+
#
124+
# Do keep in mind that enabling this directive does increases both
125+
# memory consumption and response latency.
126+
#
127+
SecResponseBodyAccess On
128+
129+
# Which response MIME types do you want to inspect? You should adjust the
130+
# configuration below to catch documents but avoid static files
131+
# (e.g., images and archives).
132+
#
133+
SecResponseBodyMimeType text/plain text/html text/xml
134+
135+
# Buffer response bodies of up to 512 KB in length.
136+
SecResponseBodyLimit 524288
137+
138+
# What happens when we encounter a response body larger than the configured
139+
# limit? By default, we process what we have and let the rest through.
140+
# That's somewhat less secure, but does not break any legitimate pages.
141+
#
142+
SecResponseBodyLimitAction ProcessPartial
143+
144+
145+
# -- Filesystem configuration ------------------------------------------------
146+
147+
# The location where ModSecurity stores temporary files (for example, when
148+
# it needs to handle a file upload that is larger than the configured limit).
149+
#
150+
# This default setting is chosen due to all systems have /tmp available however,
151+
# this is less than ideal. It is recommended that you specify a location that's private.
152+
#
153+
SecTmpDir /tmp/
154+
155+
# The location where ModSecurity will keep its persistent data. This default setting
156+
# is chosen due to all systems have /tmp available however, it
157+
# too should be updated to a place that other users can't access.
158+
#
159+
SecDataDir /tmp/
160+
161+
162+
# -- File uploads handling configuration -------------------------------------
163+
164+
# The location where ModSecurity stores intercepted uploaded files. This
165+
# location must be private to ModSecurity. You don't want other users on
166+
# the server to access the files, do you?
167+
#
168+
#SecUploadDir /opt/modsecurity/var/upload/
169+
170+
# By default, only keep the files that were determined to be unusual
171+
# in some way (by an external inspection script). For this to work you
172+
# will also need at least one file inspection rule.
173+
#
174+
#SecUploadKeepFiles RelevantOnly
175+
176+
# Uploaded files are by default created with permissions that do not allow
177+
# any other user to access them. You may need to relax that if you want to
178+
# interface ModSecurity to an external program (e.g., an anti-virus).
179+
#
180+
#SecUploadFileMode 0600
181+
182+
183+
# -- Debug log configuration -------------------------------------------------
184+
185+
# The default debug log configuration is to duplicate the error, warning
186+
# and notice messages from the error log.
187+
#
188+
#SecDebugLog /opt/modsecurity/var/log/debug.log
189+
SecDebugLogLevel {{ sec_debug_log_level }}
190+
191+
192+
# -- Audit log configuration -------------------------------------------------
193+
194+
# Log the transactions that are marked by a rule, as well as those that
195+
# trigger a server error (determined by a 5xx or 4xx, excluding 404,
196+
# level response status codes).
197+
#
198+
SecAuditEngine RelevantOnly
199+
SecAuditLogRelevantStatus "^(?:5|4(?!04))"
200+
201+
# Log everything we know about a transaction.
202+
SecAuditLogParts ABIJDEFHZ
203+
204+
# Use a single file for logging. This is much easier to look at, but
205+
# assumes that you will use the audit log only ocassionally.
206+
#
207+
SecAuditLogType Serial
208+
SecAuditLog /var/log/modsec_audit.log
209+
210+
# Specify the path for concurrent audit logging.
211+
#SecAuditLogStorageDir /opt/modsecurity/var/audit/
212+
213+
214+
# -- Miscellaneous -----------------------------------------------------------
215+
216+
# Use the most commonly used application/x-www-form-urlencoded parameter
217+
# separator. There's probably only one application somewhere that uses
218+
# something else so don't expect to change this value.
219+
#
220+
SecArgumentSeparator &
221+
222+
# Settle on version 0 (zero) cookies, as that is what most applications
223+
# use. Using an incorrect cookie version may open your installation to
224+
# evasion attacks (against the rules that examine named cookies).
225+
#
226+
SecCookieFormat 0
227+
228+
# Specify your Unicode Code Point.
229+
# This mapping is used by the t:urlDecodeUni transformation function
230+
# to properly map encoded data to your language. Properly setting
231+
# these directives helps to reduce false positives and negatives.
232+
#
233+
SecUnicodeMapFile unicode.mapping 20127
234+
235+
# Improve the quality of ModSecurity by sharing information about your
236+
# current ModSecurity version and dependencies versions.
237+
# The following information will be shared: ModSecurity version,
238+
# Web Server version, APR version, PCRE version, Lua version, Libxml2
239+
# version, Anonymous unique id for host.
240+
SecStatusEngine On
241+

apache/modsecurity.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ Suse:
2323
manage_config: false
2424
package: apache2-mod_security2
2525
config_file: /etc/apache2/conf.d/mod_security2.conf
26+
27+
FreeBSD:
28+
mod_security:
29+
crs_install: false
30+
manage_config: false
31+
package: ap24-mod_security
32+
config_file: /usr/local/etc/modsecurity/modsecurity.conf

apache/osfamilymap.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ FreeBSD:
202202
confext: ''
203203
default_site: default
204204
default_site_ssl: default-ssl
205+
moddir: /usr/local/etc/apache24/modules.d
205206
logdir: /var/log/
207+
logrotatedir: /usr/local/etc/logrotate.d/apache2
206208
wwwdir: /usr/local/www/apache24/
207209

208210
OpenBSD:

0 commit comments

Comments
 (0)