Repository navigation
feat(apache::vhost): refactor ModSecurity configuration handling - #2627
Conversation
6f8403c to
96668e7
Compare
3fa7900 to
994e4af
Compare
|
@bovy89 can you rebase your changes please |
@amitkarsale the build is failing but it is not an error related to the changes I've made |
|
Hi @bovy89 , the build was likely failing due to issues running tests against forks. I'm going to kick off some acceptance tests against a branch (after having rebased this again) just so we can get some acceptance test feedback on this PR. |
|
Running CI tests for this PR here: #2654 |
|
Acceptance Test Results: https://github.com/puppetlabs/puppetlabs-apache/actions/runs/37528270417?pr=2654 Full green across the board. Looks good from testing perspective! |
|
My apologies for the accidental closing... was trying to close off the branched PR, not this one. Reopened again so we can continue with review. |
There was a problem hiding this comment.
🟡 Changes recommended
The default mapping can override globally disabled or detection-only ModSecurity configurations, and the new behavior lacks tests.
4 open findings
What changed in this PR
Adds explicit per-vhost ModSecurity engine control while preserving the legacy disable parameter.
Changes:
- Adds
modsec_rule_engineand typed EPP parameters. - Suppresses non-engine directives when disabled.
- Restricts the global engine setting to supported values.
| File | Description |
|---|---|
manifests/vhost.pp |
Adds per-vhost engine selection and legacy mapping. |
templates/vhost/_security.epp |
Renders and conditionally guards ModSecurity directives. |
manifests/mod/security.pp |
Strengthens engine parameter typing. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| 'modsec_outbound_anomaly_threshold' => $modsec_outbound_anomaly_threshold, | ||
| 'modsec_allowed_methods' => $modsec_allowed_methods, | ||
| } | ||
| if $modsec_enabled { |
| SecRuleEngine <%= $_modsec_rule_engine %> | ||
| <% if $_modsec_rule_engine != 'Off' { -%> |
|
@bovy89 Could you please take a look at the Copilot review comments? If possible, please address all of them, or at least prioritize the high-impact comments before we proceed. |
done |
- Add modsec_rule_engine parameter (Enum['On','Off','DetectionOnly'], default 'On') to explicitly control SecRuleEngine directive - Deprecate modsec_disable_vhost boolean in favor of modsec_rule_engine (retain backward compatibility via deprecation warning) - Security fragment template is now always included (as before) - Add EPP signature with explicit type enforcement to _security.epp - Guard all non-engine directives in _security.epp behind modsec_rule_engine != 'Off' to prevent inert configuration noise when ModSecurity is disabled


Summary
modsec_rule_engineparameter (Enum['On', 'Off', 'DetectionOnly'], defaultundef) to explicitly control theSecRuleEnginedirective while preserving the global setting when unsetmodsec_disable_vhostboolean in favor ofmodsec_rule_engine(retain backward compatibility via deprecation warning)_security.epp_security.eppbehindmodsec_rule_engine != 'Off'to prevent inert configuration noise when ModSecurity is disabledAdditional Context
Add any additional context about the problem here.
Related Issues (if any)
Mention any related issues or pull requests.
Checklist
puppet apply)