-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: regex key support for ctl:ruleRemoveTargetById and ctl:ruleRemoveTargetByTag #3526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3/master
Are you sure you want to change the base?
Changes from all commits
bc95a9b
c34ec48
637ad9c
8bdbda6
8e7cf44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * ModSecurity, http://www.modsecurity.org/ | ||
| * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) | ||
| * | ||
| * You may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * If any of the files related to licensing are missing or if you have any | ||
| * other questions related to licensing please contact Trustwave Holdings, Inc. | ||
| * directly using the email address security@modsecurity.org. | ||
| * | ||
| */ | ||
|
|
||
| #ifndef HEADERS_MODSECURITY_RULE_REMOVE_TARGET_ENTRY_H_ | ||
| #define HEADERS_MODSECURITY_RULE_REMOVE_TARGET_ENTRY_H_ | ||
|
|
||
| #include <memory> | ||
| #include <string> | ||
|
|
||
| namespace modsecurity { | ||
|
|
||
| namespace Utils { | ||
| class Regex; | ||
| } | ||
|
|
||
| /** | ||
| * Shared target-matching logic for ctl:ruleRemoveTarget{ById,ByTag}. | ||
| * Supports literal target (e.g. ARGS:pwd) or regex (e.g. ARGS:/^json\.\d+\.JobDescription$/). | ||
| * Regex is compiled at config load time. | ||
| */ | ||
| struct RuleRemoveTargetSpec { | ||
| std::string literal; | ||
| std::shared_ptr<Utils::Regex> regex; | ||
|
|
||
| bool matchesKeyWithCollection(const std::string &key, | ||
| const std::string &keyWithCollection) const; | ||
| bool matchesFullName(const std::string &fullName) const; | ||
| }; | ||
|
|
||
|
|
||
| struct RuleRemoveTargetByIdEntry { | ||
| int id; | ||
| RuleRemoveTargetSpec target; | ||
| }; | ||
|
|
||
|
|
||
| struct RuleRemoveTargetByTagEntry { | ||
| std::string tag; | ||
| RuleRemoveTargetSpec target; | ||
| }; | ||
|
|
||
| } // namespace modsecurity | ||
|
|
||
| #endif // HEADERS_MODSECURITY_RULE_REMOVE_TARGET_ENTRY_H_ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,9 @@ typedef struct Rules_t RulesSet; | |
| #include "modsecurity/variable_origin.h" | ||
| #include "modsecurity/anchored_set_variable_translation_proxy.h" | ||
| #include "modsecurity/audit_log.h" | ||
| #ifdef __cplusplus | ||
| #include "modsecurity/rule_remove_target_entry.h" | ||
| #endif | ||
|
|
||
|
|
||
| #ifndef NO_LOGS | ||
|
|
@@ -520,12 +523,12 @@ class Transaction : public TransactionAnchoredVariables, public TransactionSecMa | |
| /** | ||
| * | ||
| */ | ||
| std::list< std::pair<std::string, std::string> > m_ruleRemoveTargetByTag; | ||
| std::list<RuleRemoveTargetByTagEntry> m_ruleRemoveTargetByTag; | ||
|
|
||
| /** | ||
| * | ||
| */ | ||
| std::list< std::pair<int, std::string> > m_ruleRemoveTargetById; | ||
| std::list<RuleRemoveTargetByIdEntry> m_ruleRemoveTargetById; | ||
|
|
||
|
Comment on lines
+526
to
532
|
||
| /** | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transaction.hnow includesmodsecurity/rule_remove_target_entry.h, but that header is not currently listed inpkginclude_HEADERS(src/Makefile.am). That meansmake installwon’t ship it, and external users including<modsecurity/transaction.h>will fail to compile. Add the new header to the installed headers list (and avoid depending onsrc/*headers from installed headers).