snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
This commit is contained in:
56
selfservice/strategy/code/strategy_recovery_nonrfc_test.go
Normal file
56
selfservice/strategy/code/strategy_recovery_nonrfc_test.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright © 2026 Ory Corp
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package code
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ory/x/decoderx"
|
||||
)
|
||||
|
||||
// decodeRecoverySubmission drives the production decode path used by
|
||||
// (*Strategy).decodeRecovery.
|
||||
func decodeRecoverySubmission(t *testing.T, email string) error {
|
||||
t.Helper()
|
||||
|
||||
compiler, err := decoderx.HTTPRawJSONSchemaCompiler(recoveryMethodSchema)
|
||||
require.NoError(t, err)
|
||||
|
||||
form := url.Values{"email": {email}, "method": {"code"}}
|
||||
req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode()))
|
||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
|
||||
var body struct {
|
||||
Email string `json:"email"`
|
||||
}
|
||||
return decoderx.Decode(req, &body, compiler,
|
||||
decoderx.HTTPDecoderUseQueryAndBody(),
|
||||
decoderx.HTTPKeepRequestBody(true),
|
||||
decoderx.HTTPDecoderAllowedMethods("POST"),
|
||||
decoderx.HTTPDecoderSetValidatePayloads(true),
|
||||
decoderx.HTTPDecoderJSONFollowsFormFormat(),
|
||||
)
|
||||
}
|
||||
|
||||
// TestCodeRecoverySubmissionAcceptsNonRFCEmail verifies the `email_loose`
|
||||
// recovery submission schema accepts schema-approved non-RFC carrier addresses
|
||||
// while still rejecting injection-unsafe input at decode.
|
||||
func TestCodeRecoverySubmissionAcceptsNonRFCEmail(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
require.NoError(t, decodeRecoverySubmission(t, "user@example.org"))
|
||||
require.NoError(t, decodeRecoverySubmission(t, "foo.@docomo.ne.jp"))
|
||||
|
||||
for _, evil := range []string{"foo@ory.sh\r\nBcc: evil@x", "foo<bar>@ory.sh", "foo@ory.sh,evil@x"} {
|
||||
t.Run("rejected="+evil, func(t *testing.T) {
|
||||
require.Error(t, decodeRecoverySubmission(t, evil))
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user