mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-05-12 22:10:25 +00:00
fix: secret name-prefix regex (#12213)
Fixes: #12212 Sorry for this bug, I introduced it by not testing !10682 better. Now the `forbiddenPrefixPattern`-regex is compliant to the docu: ``` It cannot start with FORGEJO_, GITEA_, GITHUB_, or a number. ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12213 Reviewed-by: Andreas Ahlenstorf <aahlenst@noreply.codeberg.org> Co-authored-by: zokki <zokki.softwareschmiede@gmail.com> Co-committed-by: zokki <zokki.softwareschmiede@gmail.com>
This commit is contained in:
parent
529b14291d
commit
4001ab027a
2 changed files with 7 additions and 1 deletions
|
|
@ -20,7 +20,7 @@ import (
|
|||
|
||||
var (
|
||||
namePattern = regexp.MustCompile("(?i)^[A-Z_][A-Z0-9_]*$")
|
||||
forbiddenPrefixPattern = regexp.MustCompile("(?i)^FORGEJO_|GITEA_|GITHUB_")
|
||||
forbiddenPrefixPattern = regexp.MustCompile("(?i)^(FORGEJO_|GITEA_|GITHUB_|[0-9])")
|
||||
|
||||
ErrInvalidName = util.NewInvalidArgumentErrorf("invalid secret name")
|
||||
)
|
||||
|
|
|
|||
|
|
@ -257,12 +257,18 @@ func TestSecretValidateName(t *testing.T) {
|
|||
valid bool
|
||||
}{
|
||||
{"FORGEJO_", false},
|
||||
{"PRE_FORGEJO_", true},
|
||||
{"PRE_FORGEJO_SUF", true},
|
||||
{"FORGEJO_123", false},
|
||||
{"FORGEJO_ABC", false},
|
||||
{"GITEA_", false},
|
||||
{"PRE_GITEA_", true},
|
||||
{"PRE_GITEA_SUF", true},
|
||||
{"GITEA_123", false},
|
||||
{"GITEA_ABC", false},
|
||||
{"GITHUB_", false},
|
||||
{"PRE_GITHUB_", true},
|
||||
{"PRE_GITHUB_SUF", true},
|
||||
{"GITHUB_123", false},
|
||||
{"GITHUB_ABC", false},
|
||||
{"123_TEST", false},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue