Skip to content

fix: make configured resp CT lowercase - #3648

Merged
fzipi merged 1 commit into
owasp-modsecurity:v3/masterfrom
airween:v3/responsebodytypefix
Sep 30, 2026
Merged

fzipi merged 1 commit into
owasp-modsecurity:v3/masterfrom
airween:v3/responsebodytypefix

Conversation

@airween

@airween airween commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

what

Make configured SecResponseBodyMimeType types lowercase.

why

Without this, if the admin puts the CT with not lowercase, the engine will skip the response body check.

references

Summary by CodeRabbit

  • Bug Fixes
    • MIME types configured for response-body inspection are now matched regardless of letter casing, improving reliability when server headers and rule settings use different capitalization.

@airween
airween requested review from fzipi and a balanced review from Copilot September 30, 2026 16:01
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: aee69d28-c151-4f76-9462-77aafc9b51fb

📥 Commits

Reviewing files that changed from the base of the PR and between 1925753 and c70a4a7.

📒 Files selected for processing (3)
  • src/parser/seclang-parser.cc
  • src/parser/seclang-parser.yy
  • test/test-cases/regression/variable-RESPONSE_BODY.json

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The parser now lowercases configured MIME types before adding them to the response-body inspection set. A regression case checks mixed-case MIME types and expects HTTP 403 when the response body contains denystring.

Changes

Response MIME type matching

Layer / File(s) Summary
Normalize configured response MIME types
src/parser/seclang-parser.yy, test/test-cases/regression/variable-RESPONSE_BODY.json
The parser lowercases configured MIME types before adding them to the inspection set. The regression case checks mixed-case response and configuration values. It expects HTTP 403 when the body contains denystring.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to c70a4

Mixed-case configured MIME types now match normalized response headers, allowing response-body inspection to run as intended. The change is ready to merge; the regression test was not run as part of this review.

Architecture Summary

Architecture risk: 🔵 Low · up to c70a4

The change affects 2 systems.

Changed systems: src, test

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.
  • observed — test (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/parser/seclang-parser.yy: The response-body MIME-type configuration now lowercases each token before inserting it into the inspection set; previously, it inserted tokens with their original casing.
  • observed — Modified behavior in test/test-cases/regression/variable-RESPONSE_BODY.json: Adds a regression case with mixed-case response Content-Type and mixed-case MIME types in SecResponseBodyMimeType; it expects HTTP 403 when the response body contains denystring.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes the main change: lowercasing configured response content types. Its abbreviations are concise and relevant to the change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation consistently normalizes configuration values and includes focused regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Normalizes configured response MIME types so mixed-case values cannot bypass response-body inspection.

Changes:

  • Lowercases SecResponseBodyMimeType values during parsing.
  • Updates generated parser output.
  • Adds mixed-case regression coverage.
File Description
src/​parser/​seclang-parser.yy Normalizes configured MIME types.
src/​parser/​seclang-parser.cc Updates pregenerated parser code.
test/​test-cases/​regression/​variable-RESPONSE_BODY.json Tests mixed-case configuration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sonarqubecloud

Copy link
Copy Markdown

@fzipi fzipi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@fzipi
fzipi merged commit 8554250 into owasp-modsecurity:v3/master Sep 30, 2026
99 checks passed
@airween airween mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants