Skip to content

Commit 67e9510

Browse files
authored
Support multiple policy files for both NAP WAF & NAP DoS (#146)
1 parent 3254e9e commit 67e9510

19 files changed

+103
-60
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.7.0 (Unreleased)
4+
5+
BREAKING CHANGES:
6+
7+
Refactor how `nginx_app_protect_*_policy_file*` variables work. You can now specify a list of both `security` and `log` policies for both NGINX App Protect WAF and NGINX App Protect DoS.
8+
39
## 0.6.2 (October 25, 2021)
410

511
ENHANCEMENTS:

defaults/main.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ nginx_app_protect_timeout: 180
9292
# Creates basic configuration files and enables NGINX App Protect WAF on the target host
9393
nginx_app_protect_configure: false
9494

95-
# Copy local NGINX App Protect WAF security policy to host
95+
# Copy local NGINX App Protect security policy to host
9696
nginx_app_protect_security_policy_file_enable: false
97-
nginx_app_protect_security_policy_file_src: files/config/security-policy.json
98-
nginx_app_protect_security_policy_file_dest: /etc/app_protect/conf/security-policy.json
97+
nginx_app_protect_security_policy_file:
98+
- src: files/config/security-policy.json
99+
dest: /etc/app_protect/conf/security-policy.json
99100

100-
# Copy local NGINX App Protect WAF log policy to host
101+
# Copy local NGINX App Protect log policy to host
101102
nginx_app_protect_log_policy_file_enable: false
102-
nginx_app_protect_log_policy_file_src: files/config/log-policy.json
103-
nginx_app_protect_log_policy_file_dest: /etc/app_protect/conf/log-policy.json
103+
nginx_app_protect_log_policy_file:
104+
- src: files/config/log-policy.json
105+
dest: /etc/app_protect/conf/log-policy.json

molecule/default/converge.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,11 @@
1313
nginx_app_protect_install_signatures: true
1414
nginx_app_protect_install_threat_campaigns: true
1515
nginx_app_protect_configure: true
16-
nginx_app_protect_conf_template_enable: false
16+
nginx_app_protect_security_policy_file_enable: true
17+
nginx_app_protect_security_policy_file:
18+
- src: files/test-security-policy.json
19+
dest: /etc/app_protect/conf/test-security-policy.json
20+
nginx_app_protect_log_policy_file_enable: true
21+
nginx_app_protect_log_policy_file:
22+
- src: files/test-log-profile.json
23+
dest: /etc/app_protect/conf/test-log-profile.json
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"filter": {
3+
"request_type": "all"
4+
},
5+
"content": {
6+
"format": "splunk",
7+
"max_request_size": "any",
8+
"max_message_size": "10k"
9+
}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"policy" : {
3+
"name": "app_protect_default_policy",
4+
"template": {
5+
"name": "POLICY_TEMPLATE_NGINX_BASE"
6+
}
7+
}
8+
}

molecule/default/verify.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,21 @@
4343
register: service
4444
failed_when: (service is changed) or (service is failed)
4545
when: ansible_os_family != "Alpine"
46+
47+
- name: Store the statistics of /etc/app_protect/conf/test-security-policy.json in the 'security_policy' variable
48+
stat:
49+
path: /etc/app_protect/conf/test-security-policy.json
50+
register: security_policy
51+
52+
- name: Ensure /etc/app_protect/conf/test-security-policy.json exists
53+
assert:
54+
that: security_policy.stat.exists | bool
55+
56+
- name: Store the statistics of /etc/app_protect/conf/test-log-profile.json in the 'log_profile' variable
57+
stat:
58+
path: /etc/app_protect/conf/test-log-profile.json
59+
register: log_profile
60+
61+
- name: Ensure /etc/app_protect/conf/test-security-profile.json exists
62+
assert:
63+
that: log_profile.stat.exists | bool

molecule/dos/molecule.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
---
2-
dependency:
3-
name: galaxy
4-
options:
5-
role-file: molecule/dos/requirements.yml
62
driver:
73
name: docker
84
lint: |
@@ -41,6 +37,5 @@ platforms:
4137
provisioner:
4238
name: ansible
4339
playbooks:
44-
prepare: prepare.yml
4540
converge: converge.yml
4641
verify: verify.yml

molecule/dos/prepare.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,3 @@
1616
dest: ../../files/license/nginx-repo.key
1717
force: false
1818
mode: 0444
19-
20-
- name: Install NGINX Plus R24 to avoid dependency issues
21-
hosts: all
22-
tasks:
23-
- name: Set repo if Debian
24-
set_fact:
25-
version: "=24-2~{{ ansible_distribution_release }}"
26-
when: ansible_os_family == "Debian"
27-
- name: Set repo if Red Hat
28-
set_fact:
29-
version: "-24-2.{{ (ansible_distribution =='Amazon') | ternary('amzn2', ('el' + ansible_distribution_major_version | string)) }}.ngx"
30-
when: ansible_os_family == "RedHat"
31-
- name: Install NGINX Plus R24 to avoid dependency issues
32-
include_role:
33-
name: nginxinc.nginx
34-
vars:
35-
nginx_type: plus
36-
nginx_version: "{{ version }}"
37-
nginx_license:
38-
certificate: ../../files/license/nginx-repo.crt
39-
key: ../../files/license/nginx-repo.key

molecule/dos/requirements.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
- name: Copy NGINX App Protect security policy files
3+
block:
4+
- name: Ensure NGINX App Protect security policy directories exist
5+
file:
6+
path: "{{ item.dest | default('/etc/app_protect/conf') | dirname }}"
7+
state: directory
8+
mode: 0755
9+
loop: "{{ nginx_app_protect_security_policy_file }}"
10+
11+
- name: Copy NGINX App Protect security policy files
12+
copy:
13+
src: "{{ item.src }}"
14+
dest: "{{ item.dest | default('/etc/app_protect/conf') }}"
15+
backup: true
16+
mode: 0644
17+
loop: "{{ nginx_app_protect_security_policy_file }}"
18+
when: nginx_app_protect_security_policy_file_enable | bool
19+
20+
- name: Copy NGINX App Protect log policy files
21+
block:
22+
- name: Ensure NGINX App Protect log policy directories exist
23+
file:
24+
path: "{{ item.dest | default('/etc/app_protect/conf') | dirname }}"
25+
state: directory
26+
mode: 0755
27+
loop: "{{ nginx_app_protect_log_policy_file }}"
28+
29+
- name: Copy NGINX App Protect log policy files
30+
copy:
31+
src: "{{ item.src }}"
32+
dest: "{{ item.dest | default('/etc/app_protect/conf') }}"
33+
backup: true
34+
mode: 0644
35+
loop: "{{ nginx_app_protect_log_policy_file }}"
36+
when: nginx_app_protect_log_policy_file_enable | bool

0 commit comments

Comments
 (0)