Skip to content

Commit 3ef022b

Browse files
LefsFlare0xBAADF00D
LefsFlare
authored andcommitted
Fixes possible vulnerabilities with keyword hijacking (#20)
- Added public entries to reserved keywords list - Rename variables - Derped comment
1 parent 3dedc02 commit 3ef022b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

models/user.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,12 @@ func NewGhostUser() *User {
505505
}
506506

507507
var (
508-
reversedUsernames = []string{"debug", "raw", "install", "api", "avatar", "user", "org", "help", "stars", "issues", "pulls", "commits", "repo", "template", "admin", "new", ".", ".."}
509-
reversedUserPatterns = []string{"*.keys"}
508+
reservedUsernames = []string{"assets", "css", "img", "js", "less", "plugins", "debug", "raw", "install", "api", "avatar", "user", "org", "help", "stars", "issues", "pulls", "commits", "repo", "template", "admin", "new", ".", ".."}
509+
reservedUserPatterns = []string{"*.keys"}
510510
)
511511

512512
// isUsableName checks if name is reserved or pattern of name is not allowed
513-
// based on given reversed names and patterns.
513+
// based on given reserved names and patterns.
514514
// Names are exact match, patterns can be prefix or suffix match with placeholder '*'.
515515
func isUsableName(names, patterns []string, name string) error {
516516
name = strings.TrimSpace(strings.ToLower(name))
@@ -535,7 +535,7 @@ func isUsableName(names, patterns []string, name string) error {
535535
}
536536

537537
func IsUsableUsername(name string) error {
538-
return isUsableName(reversedUsernames, reversedUserPatterns, name)
538+
return isUsableName(reservedUsernames, reservedUserPatterns, name)
539539
}
540540

541541
// CreateUser creates record of a new user.

0 commit comments

Comments
 (0)