Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
285 changes: 285 additions & 0 deletions store/random_names.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
package store

var adjectives = []string{
"able",
"alert",
"basic",
"bold",
"bouncy",
"breezy",
"brief",
"bright",
"brisk",
"calm",
"chill",
"clean",
"clear",
"clever",
"cool",
"crisp",
"curious",
"eager",
"early",
"even",
"fair",
"fast",
"fine",
"firm",
"flat",
"fresh",
"gentle",
"glossy",
"good",
"grand",
"great",
"green",
"happy",
"hearty",
"high",
"honest",
"hot",
"just",
"keen",
"kind",
"large",
"light",
"long",
"lucky",
"major",
"merry",
"modern",
"neat",
"new",
"nice",
"nifty",
"open",
"peppy",
"perky",
"plain",
"prime",
"proud",
"pure",
"quick",
"quiet",
"rapid",
"rare",
"ready",
"rich",
"right",
"round",
"safe",
"sharp",
"short",
"shy",
"simple",
"slim",
"smart",
"smooth",
"snappy",
"snug",
"soft",
"solid",
"sound",
"spunky",
"square",
"stable",
"steep",
"still",
"straight",
"strong",
"sunny",
"sure",
"sweet",
"tall",
"thick",
"tidy",
"tight",
"tiny",
"vivid",
"warm",
"wide",
"wild",
"wise",
"young",
"zesty",
}

var nouns = []string{
"aura",
"badge",
"band",
"bar",
"base",
"beacon",
"beam",
"bell",
"berry",
"bloom",
"bluff",
"bolt",
"branch",
"brick",
"bridge",
"brook",
"brush",
"bud",
"bulb",
"burst",
"button",
"cabin",
"camp",
"carve",
"catch",
"chalk",
"chime",
"cliff",
"cloud",
"coil",
"cradle",
"craft",
"crest",
"curve",
"dash",
"dawn",
"dome",
"drop",
"dust",
"edge",
"ember",
"field",
"fire",
"flake",
"flash",
"flick",
"flock",
"fog",
"forge",
"frame",
"gem",
"glade",
"grain",
"groove",
"grove",
"guard",
"gust",
"halo",
"harbor",
"haze",
"hill",
"hollow",
"hook",
"ice",
"isle",
"knot",
"lake",
"leaf",
"lever",
"light",
"maze",
"meadow",
"mist",
"moon",
"moss",
"nest",
"note",
"ocean",
"orb",
"pack",
"peak",
"pebble",
"peg",
"petal",
"pine",
"plate",
"plume",
"pond",
"pool",
"quest",
"reef",
"ridge",
"ring",
"rise",
"river",
"rock",
"roll",
"rope",
"sail",
"scale",
"seal",
"shade",
"shard",
"ship",
"shore",
"skid",
"sky",
"slate",
"snow",
"song",
"spike",
"spool",
"spore",
"spring",
"spur",
"stack",
"star",
"stem",
"stone",
"storm",
"strap",
"stripe",
"sun",
"surf",
"swirl",
"tail",
"tide",
"tile",
"trail",
"tree",
"trunk",
"tube",
"vale",
"veil",
"vent",
"vessel",
"wave",
"whirl",
"wind",
"wing",
"wood",
"yard",
"zone",
}

var themes = []string{
"balance",
"bliss",
"breeze",
"calm",
"cascade",
"cheer",
"dream",
"drift",
"echo",
"flow",
"flutter",
"gleam",
"glimmer",
"glow",
"harmony",
"hope",
"hum",
"joy",
"journey",
"lightness",
"melody",
"mirth",
"peace",
"radiance",
"rhythm",
"ripple",
"serenity",
"shine",
"sparkle",
"vibe",
"whisper",
}
9 changes: 6 additions & 3 deletions store/util.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package store

import (
"math/rand/v2"
"os"
"regexp"
"strings"

"github.com/docker/docker/pkg/namesgenerator"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -39,8 +39,11 @@ func ValidateName(s string) (string, error) {

func GenerateName(txn *Txn) (string, error) {
var name string
for i := range 6 {
name = namesgenerator.GetRandomName(i)
for range 6 {
name = adjectives[rand.IntN(len(adjectives))] + "_" +
nouns[rand.IntN(len(nouns))] + "_" +
themes[rand.IntN(len(themes))] // #nosec G404 -- ignore "Use of weak random number generator"
Comment on lines +42 to +45
Copy link

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the global rand package without seeding or initialization may cause issues in concurrent environments. Consider using a local rand.Rand instance or ensuring proper initialization.

Suggested change
for range 6 {
name = adjectives[rand.IntN(len(adjectives))] + "_" +
nouns[rand.IntN(len(nouns))] + "_" +
themes[rand.IntN(len(themes))] // #nosec G404 -- ignore "Use of weak random number generator"
// Create a local rand.Rand instance seeded from crypto/rand
var seed int64
b := make([]byte, 8)
if _, err := rand.Read(b); err != nil {
return "", errors.Wrap(err, "failed to seed random generator")
}
seed = int64(binary.LittleEndian.Uint64(b))
r := rand.New(rand.NewSource(seed))
for range 6 {
name = adjectives[r.IntN(len(adjectives))] + "_" +
nouns[r.IntN(len(nouns))] + "_" +
themes[r.IntN(len(themes))] // #nosec G404 -- ignore "Use of weak random number generator"

Copilot uses AI. Check for mistakes.

if _, err := txn.NodeGroupByName(name); err != nil {
if !os.IsNotExist(errors.Cause(err)) {
return "", err
Expand Down
Loading