Skip to content

Commit

Permalink
fix: add login component username validation
Browse files Browse the repository at this point in the history
Signed-off-by: Czékus Máté <[email protected]>
  • Loading branch information
Shikachuu committed Jul 5, 2024
1 parent 866a176 commit 74e46ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/nerdctl/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"errors"
"io"
"net/url"

Check failure on line 22 in cmd/nerdctl/login.go

View workflow job for this annotation

GitHub Actions / lint

"net/url" imported and not used (typecheck)

Check failure on line 22 in cmd/nerdctl/login.go

View workflow job for this annotation

GitHub Actions / cross (1.22.x)

"net/url" imported and not used

Check failure on line 22 in cmd/nerdctl/login.go

View workflow job for this annotation

GitHub Actions / test-integration-docker-compatibility

"net/url" imported and not used

Check failure on line 22 in cmd/nerdctl/login.go

View workflow job for this annotation

GitHub Actions / test-integration-docker-compatibility

"net/url" imported and not used

Check failure on line 22 in cmd/nerdctl/login.go

View workflow job for this annotation

GitHub Actions / test-integration-windows

"net/url" imported and not used
"strings"

"github.com/containerd/log"
Expand Down Expand Up @@ -82,6 +83,11 @@ func processLoginOptions(cmd *cobra.Command) (types.LoginCommandOptions, error)
password = strings.TrimSuffix(string(contents), "\n")
password = strings.TrimSuffix(password, "\r")
}

if strings.Contains(username, ":") {
return types.LoginCommandOptions{}, errors.New("username cannot contain colons")
}

return types.LoginCommandOptions{
GOptions: globalOptions,
Username: username,
Expand Down

0 comments on commit 74e46ef

Please sign in to comment.