Core Rule Set: Forgejo's ordinary requests pass by default (closes #342)
check / check (push) Waiting to run
check / check (push) Waiting to run
Forgejo 17.0.1's recorded requests are in testdata/forgejo-requests.txt, checked at the defaults. What Forgejo sends and gitea does not: - its flash cookie is named flash, which joins gitea_flash among the cookies left out; - its wiki search, whose q skips five rules in forgejo.conf, the fifteenth change. Gaps in gitea's fixes the recording showed: q on the name searches skips 932250 (ls -la), and the API's package search is one of them. User and organisation pages, any one-segment path, keep 932250. Model: opus-5-5
This commit is contained in:
1 parent
eba697af48
commit
6e867af2eb
9 files changed
+650
-37
No files matched your search
@@ -1,6 +1,6 @@
|
||||
// Package coreruleset runs the OWASP Core Rule Set 4.25.0, through Coraza, on the
|
||||
// method, the URL with its query and the headers of a request, and on its
|
||||
// body while SWW_WAF_BODY_LIMIT is set, with the fourteen changes sww
|
||||
// body while SWW_WAF_BODY_LIMIT is set, with the fifteen changes sww
|
||||
// makes to it and the exclusions in SWW_CORE_RULE_SET_EXCLUSIONS_FILE, as
|
||||
// "Attack detection" under "Settings" in SPEC.md describes them. It reads no
|
||||
// response.
|
||||
@@ -36,7 +36,7 @@ import (
|
||||
// giteaExclusions for the third, wordpressExclusions for the fourth,
|
||||
// drupalExclusions for the fifth, mediawikiExclusions for the sixth,
|
||||
// mastodonExclusions for the seventh, vaultwardenExclusions for the eighth,
|
||||
// and nextcloudExclusions for the ninth.
|
||||
// nextcloudExclusions for the ninth, and forgejoExclusions for the tenth.
|
||||
// Each rule sww adds has an id from 900000 to 900999, the ids the
|
||||
// Core Rule Set keeps for the rules that set it up, which
|
||||
// SWW_WAF_DISABLED_RULES and the exclusions file refuse, so that no
|
||||
@@ -102,7 +102,10 @@ SecRule ARGUMENTS_LIMIT_REACHED "@eq 1" "id:900300,phase:2,pass,\
|
||||
# So does the thirteenth.
|
||||
%s
|
||||
|
||||
# And the fourteenth.
|
||||
# So does the fourteenth.
|
||||
%s
|
||||
|
||||
# And the fifteenth.
|
||||
%s
|
||||
|
||||
# The sixth: only the rules for requests are loaded, and no response is
|
||||
@@ -239,11 +242,19 @@ var vaultwardenExclusions string
|
||||
//go:embed nextcloud.conf
|
||||
var nextcloudExclusions string
|
||||
|
||||
// forgejoExclusions are the fifteenth change: the fields of Forgejo's own
|
||||
// requests that skip the rules that refused them there, where Forgejo differs
|
||||
// from gitea, as Coraza directives.
|
||||
//
|
||||
//go:embed forgejo.conf
|
||||
var forgejoExclusions string
|
||||
|
||||
// cookiesNotRead are the cookies the Core Rule Set reads a request
|
||||
// without, the rest of the fifth change.
|
||||
// without, the rest of the fifth change. flash is Forgejo's name for
|
||||
// gitea_flash.
|
||||
//
|
||||
//nolint:gochecknoglobals // a constant cannot be a list
|
||||
var cookiesNotRead = []string{"gitea_flash", "redirect_to"}
|
||||
var cookiesNotRead = []string{"gitea_flash", "flash", "redirect_to"}
|
||||
|
||||
// Params are what New needs.
|
||||
type Params struct {
|
||||
@@ -352,7 +363,7 @@ type CoreRuleSet struct {
|
||||
bodyLimit int64
|
||||
}
|
||||
|
||||
// New returns the Core Rule Set with the fourteen changes, at params'
|
||||
// New returns the Core Rule Set with the fifteen changes, at params'
|
||||
// paranoia level, without the rules it switches off, reading request
|
||||
// bodies up to params' limit, and with params' exclusions file loaded
|
||||
// before the Core Rule Set's rules. An exclusions file is an error if it
|
||||
@@ -382,7 +393,7 @@ func New(params Params) (*CoreRuleSet, error) {
|
||||
text := fmt.Sprintf(directives, params.ParanoiaLevel, body, exclusions,
|
||||
giteaExclusions, wordpressExclusions, drupalExclusions,
|
||||
mediawikiExclusions, mastodonExclusions, vaultwardenExclusions,
|
||||
nextcloudExclusions)
|
||||
nextcloudExclusions, forgejoExclusions)
|
||||
|
||||
if len(params.DisabledRules) > 0 {
|
||||
ids := make([]string, len(params.DisabledRules))
|
||||
|
||||
Reference in new issue
Block a user