v3: "General failure, action: 0x..." prints a pointer instead of the action name
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 src/rules_exceptions.cc 和 src/rule_with_actions.cc 中提到的三个输出位置入手,然后运行 test/regression_tests 中的复现用例。Issue 指出了指针格式化方式和预期的操作名称;更新受影响的消息,并验证它们输出的是 chain 这样的名称,而不是地址。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
When SecRuleUpdateActionById is given an action that can't be updated (a configuration-time action such as chain, id, phase, rev, ver, maturity or accuracy), libModSecurity v3 prints a memory address instead of the action's name:
General failure, action: 0x932c545b8 has not expected to be used with UpdateActionByID.
This was reported before in #2625 and closed as completed in 2021, but the code that prints it hasn't changed.
To Reproduce
SecRule REQUEST_HEADERS:User-Agent "@rx ^curl" "id:10,phase:2,pass,log,chain"
SecRule REQUEST_HEADERS:Accept "@rx \*/\*" "t:none"
SecRuleUpdateActionById 10 "pass,chain"
Seen with test/regression_tests on v3/master (84b59962).
Expected behavior
The message should name the action, e.g. General failure, action: chain has not expected to be used with UpdateActionByID.
Cause
Action::m_name is a std::shared_ptr<std::string>, so std::cout << a->m_name prints the pointer. Writing *a->m_name instead fixes it. The same mistake appears three times:
src/rules_exceptions.cc:40(the "has not expected to be used with UpdateActionByID" message)src/rules_exceptions.cc:51("has an unknown type")src/rule_with_actions.cc:127("has an unknown type")
Related
All three messages are written straight to std::cout rather than returned through the existing error out-parameter. A connector therefore never sees them in its error log, and the configuration still loads with the action silently dropped. Fixing the pointer is the minimal change. Reporting the problem through error, as a warning or as a load failure, needs a decision, because it would change behavior for configurations shared with v2 that repeat chain in an update. v2 requires repeating chain there; see the "Updating chained rules" note in owasp-modsecurity/documentation#2.
- 主要语言
- C++
- 星标
- 9.8k
- 派生
- 1.8k
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
owasp-modsecurity/ModSecurity 的其他 Issue
-
v2: t:utf8toUnicode drops the last hex digit of code points above U+FFFF (regression since 2.9.9)未关闭
难度 2/5 1-3 小时 新手友好度 78/100
owasp-modsecurity/ModSecurity#3684 ·
维护者通常 1 天内回复
-
2.x bug Platform - IIS pr available windows
难度 1/5 1 小时以内 新手友好度 90/100
owasp-modsecurity/ModSecurity#3623 · 2 条评论 ·
维护者通常 1 天内回复
-
2.x bug Platform - IIS pr available windows
难度 2/5 1-3 小时 新手友好度 82/100
owasp-modsecurity/ModSecurity#3621 · 2 条评论 ·
维护者通常 1 天内回复
-
2.x bug Platform - IIS pr available windows
难度 2/5 1-3 小时 新手友好度 84/100
owasp-modsecurity/ModSecurity#3619 · 2 条评论 ·
维护者通常 1 天内回复
-
2.x bug Platform - IIS pr available windows
难度 2/5 1-3 小时 新手友好度 76/100
owasp-modsecurity/ModSecurity#3612 · 2 条评论 ·
维护者通常 1 天内回复
查看 owasp-modsecurity/ModSecurity 的全部 Issue
相似的 Issue
-
Status: Needs confirmation Status: Needs triage
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
boykopovar/AnyPS5#12124 ·
维护者通常 1 天内回复
-
bug-unconfirmed
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
A-combat P-low S-ready-to-start task
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复