-
Notifications
You must be signed in to change notification settings - Fork 732
Added V3.1/dev contributing #879
Conversation
|
So @jnazarioFastly brought it up, but i think common variable naming is as follows. When used as part of a collection in the variable section it is capitalized (i.e SecRule TX:hello). However when used as an action it is lowercased. setvar:tx.hello=test. Thoughts? |
|
Dev Branch Please replace
with It is very likely we overlook this when we switch the dev branch and the additional clarification will avoid mistakes. |
|
Collections Unfortunately, Apache and ModSecurity leave the choice in our hands, so there is some ambiguity. Also, I do not know if libModSecurity 3.0 will change anything in this regard. Maybe @zimmerle / @victorhora want to chime in. In the ModSecurity Handbook, we propose The current usage in CRS and @jnazarioFastly / @csanders are close to this proposal, but the action / setvar syntax writes the collection in lowercase. This is perfectly sound. And it has the advantage of making more of the action text lowercase. However, Personally, I have no strong feelings either way, but please consider the anchor idea. It is something people overlook very often. |
|
ID Numbering Scheme I am proposing the following text for the numbering scheme. It is very extensive, but we better get this right and describe it in detail or we'll have to do a lot of cleanup. The CRS project used the numerical id rule namespace from 900,000 to 999,999 for the CRS rules as well as 9,000,000 to 9,999,999 for default CRS rule exclusion packages. Rules applying to the incoming request use the id range 900,000 to 949,999. The rules are grouped by vulnerability class they address (SQLi, RCE, etc.) or functionality (initialization). These groups occupy blocks of thousands (e.g. SQLi: 942,000 - 942,999). The individual rule files for the vulnerability classes are organized by the paranoia level of the rules. PL 1 is first, then PL 2 etc. The block from 9XX000 - 9XX099 is reserved for use by CRS helper functionality. There are no blocking or filtering rules in this block. Among the rules serving a CRS helper functionality are rules that skip rules depending on the paranoia level. These rules always use the following reserved rule ids: 9XX011-9XX018 with very few exceptions. The blocking or filter rules start with 9XX100 with a step width of 10. E.g. 9XX100, 9XX110, 9XX120 etc. The rule id does not correspond directly with the paranoia level of a rule. Given the size of a rule group and the organization by lower PL rules first, PL2 and above tend to have rule IDs with higher numbers. Within a rule file / block, there are sometimes smaller groups of rules that belong to together. They are closely linked and very often represent copies of the original rules with a stricter limit (alternatively, they can represent the same rule addressing a different target in a second rule where this was necessary). These are stricter siblings of the base rule. Stricter siblings usually share the first five digits of the rule ID and raise the rule ID by one. E.g. Base rule at 9XX160, stricter sibling at 9XX161. Stricter siblings often have a different paranoia level. This means that the base rule and the stricter sibling do not reside next to one another in the rule file. Instead they are ordered in their appropriate paranoia level and can be linked via the first digits of the rule id. It is a good practice to introduce stricter siblings together with the base rule in the comments of the base rule and to reference the base rule with the keyword stricter sibling in the comments of the stricter sibling. E.g. "... This is |
|
Good write up on the rules, looks right to me. I didn't realize we stuck so closely to the 9XX011-9XX018 rule. There is probably something to add about in the event we run out of rule ID's in the step width of 10. Interesting.feedback on the variables. i'm don't feel strongly one way or the other, my previous post only relates to the fact that almost always the entire action is lowercase. It also gives you a reminder to use the dot syntax instead of the colon syntax. |
|
We tried to stick very closely, with only four exceptions (-> 912019, 950020, 950021, 950022) we accepted in order to avoid rule collisions with CRS2. One of the goals of the renumbering in CRS3 was to allow parallel installations with CRS2. With the PL helper rules I made sure we did not spoil that. You do have a point with the reminder: |
|
I've updated the text with the paranoia levels and rule id numbering. The last thing mentioned which is in the FIXME (and discussed here) is the variable naming conventions. |
|
I think we settled on @fzipi: could you replace the dev branch description with my proposal above, please. I think this got overlooked. Your PL description had me chuckle. It's a funny text. Maybe we should tune it down a bit though and I also think a discussion is due with regards to your characterisation of the various PLs. @csanders-git / @lifeforms : Could you please review that part of the PR as well? |
|
@dune73 The PL description was the one that @spartantri made on PR #887, it aren't my words. It was funny indeed. We should change it though, I agree. I will replace the tx description while we give another look at the PL description. |
|
I see. :) However, #887 covers something completely different, I think. |
|
Oh, It's in one of the issues. That's why I did not find it myself. Thanks for helping me out. Yes, It's a funny text, but let's tune it down a bit. Nothing wrong with a joke or too, but this is overdoing it. Besides, we only have PL1-PL4 as of this writing. |
CONTRIBUTING.md
Outdated
|
|
||
| * Variable names are lowercase using chars from `[a-z0-9_]` | ||
| * To somewhat reflect the fact that the syntax for variable usage is different when you define it (using setvar) and when you use it, we propose the following visual distinction: | ||
| * Capital letters for collection, colon as separator, variable name. E.g: `SecRule TX:foo_bar_variable` |
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.
In your description, setvar is first, then in the example, SecRule is first. Please align it.
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.
Done.
| ## Rules compliance with each Paranoia Level (PL) | ||
|
|
||
| Rules in the CRS are organized in Paranoia Levels, which are described below. | ||
| Rules in the CRS are organized in Paranoia Levels, which allows you to choose the desired level of rule checks. |
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.
Please add a reference to the crs-setup.conf where PLs are introduced and explained. Here we only give some rules of thumb.
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.
Done.
|
Travis is failing from white spacing in comment lines. I don't know if this is the expected behavior.
What do you think? |
|
I think we concluded that we do not want trailing whitespaces no matter where. An exception would be unit tests that need trailing whitespace as part of their payload, but everywhere else, the whitespace should go. |
|
Good. Yes, indeed. But I was somewhat reluctant to add "rules" changes in this PR, to keep clearly separated. Now I corrected this to pass travis, but I think maybe this could be handled in a new PR until this one gets merged. |
|
Nice progress here :) |
…urity-crs into v3.1/dev-contributing
|
@csanders-git wrote in the summary that @lifeforms would be assigned, but then it's actually me according to this PR. I think it is time to merge and then update as we see fit. Thank you for the PR @fzipi, it's a most welcome contribution (file). |
@dune73 commented:
This is a good start, but we'll need to talk about this some time as per your suggestion.
I'd like to merge this to v3.1/dev first. Then we can talk about backporting, but personally I do not see much sense in this.
Adding a remark with regards to doing PRs against the v3.1/dev file would also be worthwhile.
Your indentation example does not really adhere to the proposed style. At least not on my screen, please check.
We need a description of the tagging system we use. Given we think about overhauling this, a FIXME might do for the time being.
This is what springs to me right now. Not necessarily exhaustive list, though. Thank you for your initiative; really makes sense.
and @Spartani:
a sample rule template ready to copy paste would be nice :)
there are no naming conventions for vars and markers and rule id numbering
First of all, I'm doing this PR against v3.1/dev. I tried to add all your comments, and proposed some standards for vars and markes (which I'll be adding to the rule cleanup issue later).
wrt vars and markers, below are all the definitions summarized:
So the text for naming markers is somewhat similar to what we have now. I'm assuming there is no impact on renaming markers, also.
Below are the vars and its usage:
I don't know if there is a clear naming there, maybe we can say:
%{rule.id}-TAGNAME-%{matched_var_name}