Skip to content

Conversation

@airween
Copy link
Member

@airween airween commented Jan 23, 2026

what

This PR fixes a few cppcheck warnings:

  • src/engine/lua.h: added copy and = operator constructors
  • src/operators/pm.h: added copy and = operator constructors
  • src/operators/rx.h: added copy and = operator constructors
  • src/operators/rx_global.h: added copy and = operator constructors
  • src/request_body_processor/multipart.h: added copy and = operator constructors
  • src/utils/ip_tree.h: added copy and = operator constructors
  • src/variables/rule.h: change pointer declarations to const where it's possible

why

After a recently merged PR I got a notification about a failed test.

I downloaded the report and found these issues:

2026-01-22T18:05:30.2906400Z warning: src/operators/rx.h,47,warning,noCopyConstructor,Class 'Rx' does not have a copy constructor which is recommended since it has dynamic memory/resource management.
2026-01-22T18:05:30.3305610Z warning: src/operators/rx.h,47,warning,noOperatorEq,Class 'Rx' does not have a operator= which is recommended since it has dynamic memory/resource management.
2026-01-22T18:05:54.8985410Z warning: src/engine/lua.h,41,warning,noCopyConstructor,Class 'LuaScriptBlob' does not have a copy constructor which is recommended since it has dynamic memory/resource management.
2026-01-22T18:05:54.8988130Z warning: src/engine/lua.h,41,warning,noOperatorEq,Class 'LuaScriptBlob' does not have a operator= which is recommended since it has dynamic memory/resource management.
2026-01-22T18:14:35.7366650Z warning: src/operators/rx_global.h,47,warning,noCopyConstructor,Class 'RxGlobal' does not have a copy constructor which is recommended since it has dynamic memory/resource management.
2026-01-22T18:14:35.7374120Z warning: src/operators/rx_global.h,47,warning,noOperatorEq,Class 'RxGlobal' does not have a operator= which is recommended since it has dynamic memory/resource management.
2026-01-22T18:14:52.8542470Z warning: src/operators/pm.cc,101,warning,noCopyConstructor,Class 'Pm' does not have a copy constructor which is recommended since it has dynamic memory/resource management.
2026-01-22T18:14:52.8545010Z warning: src/operators/pm.cc,101,warning,noOperatorEq,Class 'Pm' does not have a operator= which is recommended since it has dynamic memory/resource management.
2026-01-22T18:18:03.0682420Z warning: src/variables/rule.h,43,style,constVariablePointer,Variable 'r' can be declared as pointer to const
2026-01-22T18:18:03.0685470Z warning: src/variables/rule.h,77,style,constVariablePointer,Variable 'r' can be declared as pointer to const
2026-01-22T18:18:38.7002810Z warning: src/request_body_processor/multipart.cc,170,warning,noCopyConstructor,Class 'Multipart' does not have a copy constructor which is recommended since it has dynamic memory/resource management.
2026-01-22T18:18:38.7004560Z warning: src/request_body_processor/multipart.cc,170,warning,noOperatorEq,Class 'Multipart' does not have a operator= which is recommended since it has dynamic memory/resource management.
2026-01-22T18:20:39.2194320Z warning: src/utils/ip_tree.cc,87,warning,noCopyConstructor,Class 'IpTree' does not have a copy constructor which is recommended since it has dynamic memory/resource management.
2026-01-22T18:20:39.2204500Z warning: src/utils/ip_tree.cc,87,warning,noOperatorEq,Class 'IpTree' does not have a operator= which is recommended since it has dynamic memory/resource management.

references

cppcheck new version (2.19.0) was released on 2025.12.21, see the release page. This new version was probably released into the GH workflow later than the mentioned PR was (2025.12.28).

@airween airween requested a review from fzipi January 23, 2026 12:49
@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses cppcheck 2.19.0 warnings by improving const-correctness and preventing unwanted object copying in classes with resource management.

Changes:

  • Added deleted copy constructors and assignment operators to six classes that manage dynamic resources
  • Made pointer parameters const in two functions that only read from rule objects

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/engine/lua.h Added deleted copy/assignment operators to LuaScriptBlob class which manages dynamic memory
src/operators/pm.h Added deleted copy/assignment operators to Pm class which manages ACMP resources
src/operators/rx.h Added deleted copy/assignment operators to Rx class which manages Regex resources
src/operators/rx_global.h Added deleted copy/assignment operators to RxGlobal class which manages Regex resources
src/request_body_processor/multipart.h Added deleted copy/assignment operators to Multipart class which manages resources
src/utils/ip_tree.h Added deleted copy/assignment operators to IpTree class which manages tree resources
src/variables/rule.h Made pointer parameters and local variables const in id() and severity() functions which only read from rules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@fzipi fzipi left a comment

Choose a reason for hiding this comment

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

LGTM!

@airween airween merged commit 64d43d4 into owasp-modsecurity:v3/master Jan 23, 2026
56 checks passed
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.

2 participants