Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6940109

Browse files
committed
Merge branch '558-clone-name-restriction' into 'master'
fix: prohibit the use of slashes in clone identifiers (#558) Closes #558 See merge request postgres-ai/database-lab!835
2 parents db43822 + e47d380 commit 6940109

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

‎engine/internal/srv/server.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (s *Server) Reload(cfg srvCfg.Config) {
187187

188188
// InitHandlers initializes handler functions of the HTTP server.
189189
func (s *Server) InitHandlers() {
190-
r := mux.NewRouter().StrictSlash(true)
190+
r := mux.NewRouter().StrictSlash(true).UseEncodedPath()
191191

192192
authMW := mw.NewAuth(s.Config.VerificationToken, s.Platform)
193193

‎engine/internal/validator/validator.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package validator
77

88
import (
99
"fmt"
10+
"strings"
1011

1112
"github.com/pkg/errors"
1213
passwordvalidator "github.com/wagslane/go-password-validator"
@@ -34,6 +35,10 @@ func (v Service) ValidateCloneRequest(cloneRequest *types.CloneCreateRequest) er
3435
return errors.New("missing DB password")
3536
}
3637

38+
if cloneRequest.ID != "" && strings.Contains(cloneRequest.ID, "/") {
39+
return errors.New("Clone ID cannot contain slash ('/'). Please choose another ID")
40+
}
41+
3742
if err := passwordvalidator.Validate(cloneRequest.DB.Password, minEntropyBits); err != nil {
3843
return fmt.Errorf("password validation: %w", err)
3944
}

‎engine/internal/validator/validator_test.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ func TestValidationCloneRequestErrors(t *testing.T) {
5555
createRequest: types.CloneCreateRequest{DB: &types.DatabaseRequest{Password: "password"}},
5656
error: "missing DB username",
5757
},
58+
{
59+
createRequest: types.CloneCreateRequest{
60+
DB: &types.DatabaseRequest{Username: "user", Password: "password"},
61+
ID: "test/ID",
62+
},
63+
error: "Clone ID cannot contain slash ('/'). Please choose another ID",
64+
},
5865
}
5966

6067
for _, tc := range testCases {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /