Skip to content

Commit

Permalink
coraza waf fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ansibleguy committed Dec 28, 2024
1 parent 604f8e7 commit cf04418
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ http-request set-var(txn.waf_app) str(app1) if { req.hdr(host) -i -m str ansible
http-request set-var(txn.waf_app) str(default) if !{ var(txn.waf_app) -m found }
filter spoe engine coraza config /etc/haproxy/waf-coraza-spoe.cfg
http-request send-spoe-group coraza coraza-req
```

### Result
Expand Down
5 changes: 3 additions & 2 deletions tasks/debian/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
mode: 0750

- name: "HAProxy WAF | Apps | {{ waf_app_name }} | Add rules {{ waf_app.ruleset_version }}"
ansible.builtin.command: |
cp -r {{ waf_app_rules_default_dir }}/rules/@owasp_crs {{ crs_dir }}
ansible.builtin.shell: |
cp -r {{ waf_app_rules_default_dir }}/rules/@owasp_crs {{ crs_dir }} &&
chown -R root:{{ WAF_HC.user }} {{ crs_dir }}
args:
creates: "{{ crs_dir }}"
vars:
Expand Down
5 changes: 4 additions & 1 deletion templates/etc/haproxy/waf-coraza-spoe.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ spoe-agent coraza-agent
{% else %}
messages coraza-req
{% endif %}
groups coraza-req
option var-prefix {{ WAF_CONFIG.spoa.var_prefix }}
option set-on-error error
timeout hello {{ WAF_CONFIG.spoa.timeout.hello }}
Expand All @@ -18,7 +19,9 @@ spoe-agent coraza-agent

spoe-message coraza-req
args app=var({{ WAF_HC.app_var }}) src-ip=src src-port=src_port dst-ip=dst dst-port=dst_port method=method path=path query=query version=req.ver headers=req.hdrs body=req.body
event on-backend-http-request

spoe-group coraza-req
messages coraza-req

{% if WAF_CONFIG.response_check | bool %}
spoe-message coraza-res
Expand Down

0 comments on commit cf04418

Please sign in to comment.