Fix parsing of SecComponentSignature, SecServerSignature and SecWebAppId#3558
Fix parsing of SecComponentSignature, SecServerSignature and SecWebAppId#3558meirdev wants to merge 1 commit into
Conversation
|
|
Quality Gate failed on auto-generated code |
|
I generated the file using flex -V./configure --enable-parser-generation |
There was a problem hiding this comment.
Pull request overview
This PR fixes SecLang directive argument extraction for SecComponentSignature, SecServerSignature, and SecWebAppId so their values are parsed consistently (notably for quoted values), addressing the parsing issue reported in ModSecurity-nginx#365.
Changes:
- Update SecLang scanner rules to extract directive arguments via
find_separator(yytext)and sanitize them withparserSanitizer(...)(instead of usingstrchr(...)+2for some directives). - Add a regression test validating that
SecComponentSignatureis emitted correctly in the JSON audit logcomponentsarray.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/test-cases/regression/auditlog.json | Adds a regression test ensuring SecComponentSignature is serialized correctly in JSON audit logs. |
| src/parser/seclang-scanner.ll | Updates lexer rules for SecComponentSignature, SecServerSignature, and SecWebAppId to use separator finding + sanitization for argument parsing. |
| src/parser/seclang-scanner.cc | Regenerated scanner output reflecting the .ll changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {CONFIG_COMPONENT_SIG}[ \t]+["]{FREE_TEXT}["] { return p::make_CONFIG_COMPONENT_SIG(parserSanitizer(find_separator(yytext)), *driver.loc.back()); } | ||
| {CONFIG_SEC_SERVER_SIG}[ \t]+["]{FREE_TEXT}["] { return p::make_CONFIG_SEC_SERVER_SIG(parserSanitizer(find_separator(yytext)), *driver.loc.back()); } | ||
| {CONFIG_SEC_WEB_APP_ID}[ \t]+["]{FREE_TEXT}["] { return p::make_CONFIG_SEC_WEB_APP_ID(parserSanitizer(find_separator(yytext)), *driver.loc.back()); } |
There was a problem hiding this comment.
@airween - That's a good comment from Copilot.
I used the same pattern as the other directives (CONFIG_DIR_AUDIT_LOG, CONFIG_DIR_AUDIT_STS, CONFIG_DIR_AUDIT_DIR, ...). Do you want me to change the find_separator function?
| "SecAuditLogFileMode 0600", | ||
| "SecAuditLog /tmp/audit_component_signature.log", | ||
| "SecAuditLogType Serial" | ||
| ] |

Fix: owasp-modsecurity/ModSecurity-nginx#365