v3: "General failure, action: 0x..." prints a pointer instead of the action name
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start with the three output sites named in src/rules_exceptions.cc and src/rule_with_actions.cc, then run the test/regression_tests reproduction. The issue identifies the pointer formatting and the intended action name; update the affected messages and verify they print names such as chain instead of addresses.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.8k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 16
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from owasp-modsecurity/ModSecurity
-
v2: t:utf8toUnicode drops the last hex digit of code points above U+FFFF (regression since 2.9.9)Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
owasp-modsecurity/ModSecurity#3684 ·
Maintainers usually reply within 1 day
-
2.x bug Platform - IIS pr available windows
Difficulty 1/5 Under an hour Newbie friendliness 90/100
owasp-modsecurity/ModSecurity#3623 · 2 comments ·
Maintainers usually reply within 1 day
-
2.x bug Platform - IIS pr available windows
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
owasp-modsecurity/ModSecurity#3621 · 2 comments ·
Maintainers usually reply within 1 day
-
2.x bug Platform - IIS pr available windows
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
owasp-modsecurity/ModSecurity#3619 · 2 comments ·
Maintainers usually reply within 1 day
-
2.x bug Platform - IIS pr available windows
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
owasp-modsecurity/ModSecurity#3612 · 2 comments ·
Maintainers usually reply within 1 day
All issues in owasp-modsecurity/ModSecurity
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NVIDIA-Omniverse/PhysX#590 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/rocketmq-clients#1469 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 9 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
compiler-explorer/compiler-explorer#9402 ·
Maintainers usually reply within 1 day
-
自定义颜色添加为常用颜色Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
mg-chao/snow-apps#2227 · 2 comments ·
Maintainers usually reply within 1 day