Skip to content

feat(apache::vhost): refactor ModSecurity configuration handling - #2627

Merged
span786 merged 1 commit into
puppetlabs:mainfrom
bovy89:main
Oct 26, 2026
Merged

span786 merged 1 commit into
puppetlabs:mainfrom
bovy89:main

Conversation

@bovy89

@bovy89 bovy89 commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add modsec_rule_engine parameter (Enum['On', 'Off', 'DetectionOnly'], default undef) to explicitly control the SecRuleEngine directive while preserving the global setting when unset
  • Deprecate modsec_disable_vhost boolean in favor of modsec_rule_engine (retain backward compatibility via deprecation warning)
  • Security fragment template remains conditionally 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

Additional Context

Add any additional context about the problem here.

  • Root cause and the steps to reproduce. (If applicable)
  • Thought process behind the implementation.

Related Issues (if any)

Mention any related issues or pull requests.

Checklist

  • 🟢 Spec tests.
  • 🟢 Acceptance tests.
  • Manually verified. (For example puppet apply)

@bovy89
bovy89 requested review from a team, bastelfreak, ekohl and smortex as code owners March 24, 2026 10:57
@bovy89
bovy89 force-pushed the main branch 3 times, most recently from 6f8403c to 96668e7 Compare March 24, 2026 12:53
@bovy89
bovy89 force-pushed the main branch 7 times, most recently from 3fa7900 to 994e4af Compare April 3, 2026 22:20
@amitkarsale

Copy link
Copy Markdown
Contributor

@bovy89 can you rebase your changes please

@bovy89

bovy89 commented May 5, 2026

Copy link
Copy Markdown
Contributor Author

@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

@jst-cyr

jst-cyr commented Oct 6, 2026

Copy link
Copy Markdown
Member

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.

@jst-cyr

jst-cyr commented Oct 6, 2026

Copy link
Copy Markdown
Member

Running CI tests for this PR here: #2654

@jst-cyr

jst-cyr commented Oct 7, 2026

Copy link
Copy Markdown
Member

Acceptance Test Results: https://github.com/puppetlabs/puppetlabs-apache/actions/runs/37528270417?pr=2654

Full green across the board. Looks good from testing perspective!

@jst-cyr jst-cyr closed this Oct 7, 2026
@jst-cyr jst-cyr reopened this Oct 7, 2026
@jst-cyr

jst-cyr commented Oct 7, 2026

Copy link
Copy Markdown
Member

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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_engine and 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.

Comment thread manifests/vhost.pp Resolved
Comment thread manifests/vhost.pp Resolved
Comment thread manifests/vhost.pp
'modsec_outbound_anomaly_threshold' => $modsec_outbound_anomaly_threshold,
'modsec_allowed_methods' => $modsec_allowed_methods,
}
if $modsec_enabled {
Comment on lines +13 to +14
SecRuleEngine <%= $_modsec_rule_engine %>
<% if $_modsec_rule_engine != 'Off' { -%>
@span786

span786 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

@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.

@bovy89

bovy89 commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

@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

@span786
span786 requested a balanced review from Copilot October 26, 2026 17:00
- 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Static review found no blocking issues in the focused parameter and template changes; tests were not executed.

2 open issues
2 resolved since last review

Review effort: Balanced

@span786
span786 merged commit 9b812f5 into puppetlabs:main Oct 26, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants