This allow us to avoid entropy usage in non-crypto critical places.
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
| ... | ... |
@@ -24,7 +24,7 @@ func createContainerPlatformSpecificSettings(container *Container, config *runco |
| 24 | 24 |
case 2: |
| 25 | 25 |
name, destination = parts[0], filepath.Clean(parts[1]) |
| 26 | 26 |
default: |
| 27 |
- name = stringid.GenerateRandomID() |
|
| 27 |
+ name = stringid.GenerateNonCryptoID() |
|
| 28 | 28 |
destination = filepath.Clean(parts[0]) |
| 29 | 29 |
} |
| 30 | 30 |
// Skip volumes for which we already have something mounted on that |
| ... | ... |
@@ -350,7 +350,7 @@ func (daemon *Daemon) mergeAndVerifyConfig(config *runconfig.Config, img *image. |
| 350 | 350 |
func (daemon *Daemon) generateIdAndName(name string) (string, string, error) {
|
| 351 | 351 |
var ( |
| 352 | 352 |
err error |
| 353 |
- id = stringid.GenerateRandomID() |
|
| 353 |
+ id = stringid.GenerateNonCryptoID() |
|
| 354 | 354 |
) |
| 355 | 355 |
|
| 356 | 356 |
if name == "" {
|
| ... | ... |
@@ -135,7 +135,7 @@ func TestLoadWithVolume(t *testing.T) {
|
| 135 | 135 |
t.Fatal(err) |
| 136 | 136 |
} |
| 137 | 137 |
|
| 138 |
- hostVolumeId := stringid.GenerateRandomID() |
|
| 138 |
+ hostVolumeId := stringid.GenerateNonCryptoID() |
|
| 139 | 139 |
vfsPath := filepath.Join(tmp, "vfs", "dir", hostVolumeId) |
| 140 | 140 |
volumePath := filepath.Join(tmp, "volumes", hostVolumeId) |
| 141 | 141 |
|
| ... | ... |
@@ -419,7 +419,7 @@ func TestRemoveLocalVolumesFollowingSymlinks(t *testing.T) {
|
| 419 | 419 |
t.Fatal(err) |
| 420 | 420 |
} |
| 421 | 421 |
|
| 422 |
- hostVolumeId := stringid.GenerateRandomID() |
|
| 422 |
+ hostVolumeId := stringid.GenerateNonCryptoID() |
|
| 423 | 423 |
vfsPath := filepath.Join(tmp, "vfs", "dir", hostVolumeId) |
| 424 | 424 |
volumePath := filepath.Join(tmp, "volumes", hostVolumeId) |
| 425 | 425 |
|
| ... | ... |
@@ -155,7 +155,7 @@ func (d *Daemon) ContainerExecCreate(config *runconfig.ExecConfig) (string, erro |
| 155 | 155 |
} |
| 156 | 156 |
|
| 157 | 157 |
execConfig := &execConfig{
|
| 158 |
- ID: stringid.GenerateRandomID(), |
|
| 158 |
+ ID: stringid.GenerateNonCryptoID(), |
|
| 159 | 159 |
OpenStdin: config.AttachStdin, |
| 160 | 160 |
OpenStdout: config.AttachStdout, |
| 161 | 161 |
OpenStderr: config.AttachStderr, |
| ... | ... |
@@ -19,7 +19,7 @@ func (d *driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessCo |
| 19 | 19 |
inListen, outListen, errListen *npipe.PipeListener |
| 20 | 20 |
term execdriver.Terminal |
| 21 | 21 |
err error |
| 22 |
- randomID string = stringid.GenerateRandomID() |
|
| 22 |
+ randomID string = stringid.GenerateNonCryptoID() |
|
| 23 | 23 |
serverPipeFormat, clientPipeFormat string |
| 24 | 24 |
pid uint32 |
| 25 | 25 |
exitCode int32 |
| ... | ... |
@@ -314,7 +314,7 @@ func (graph *Graph) TempLayerArchive(id string, sf *streamformatter.StreamFormat |
| 314 | 314 |
|
| 315 | 315 |
// mktemp creates a temporary sub-directory inside the graph's filesystem. |
| 316 | 316 |
func (graph *Graph) mktemp(id string) (string, error) {
|
| 317 |
- dir := filepath.Join(graph.root, "_tmp", stringid.GenerateRandomID()) |
|
| 317 |
+ dir := filepath.Join(graph.root, "_tmp", stringid.GenerateNonCryptoID()) |
|
| 318 | 318 |
if err := system.MkdirAll(dir, 0700); err != nil {
|
| 319 | 319 |
return "", err |
| 320 | 320 |
} |
| ... | ... |
@@ -68,7 +68,7 @@ func TestInterruptedRegister(t *testing.T) {
|
| 68 | 68 |
defer nukeGraph(graph) |
| 69 | 69 |
badArchive, w := io.Pipe() // Use a pipe reader as a fake archive which never yields data |
| 70 | 70 |
image := &image.Image{
|
| 71 |
- ID: stringid.GenerateRandomID(), |
|
| 71 |
+ ID: stringid.GenerateNonCryptoID(), |
|
| 72 | 72 |
Comment: "testing", |
| 73 | 73 |
Created: time.Now(), |
| 74 | 74 |
} |
| ... | ... |
@@ -126,7 +126,7 @@ func TestRegister(t *testing.T) {
|
| 126 | 126 |
t.Fatal(err) |
| 127 | 127 |
} |
| 128 | 128 |
image := &image.Image{
|
| 129 |
- ID: stringid.GenerateRandomID(), |
|
| 129 |
+ ID: stringid.GenerateNonCryptoID(), |
|
| 130 | 130 |
Comment: "testing", |
| 131 | 131 |
Created: time.Now(), |
| 132 | 132 |
} |
| ... | ... |
@@ -229,19 +229,19 @@ func TestByParent(t *testing.T) {
|
| 229 | 229 |
graph, _ := tempGraph(t) |
| 230 | 230 |
defer nukeGraph(graph) |
| 231 | 231 |
parentImage := &image.Image{
|
| 232 |
- ID: stringid.GenerateRandomID(), |
|
| 232 |
+ ID: stringid.GenerateNonCryptoID(), |
|
| 233 | 233 |
Comment: "parent", |
| 234 | 234 |
Created: time.Now(), |
| 235 | 235 |
Parent: "", |
| 236 | 236 |
} |
| 237 | 237 |
childImage1 := &image.Image{
|
| 238 |
- ID: stringid.GenerateRandomID(), |
|
| 238 |
+ ID: stringid.GenerateNonCryptoID(), |
|
| 239 | 239 |
Comment: "child1", |
| 240 | 240 |
Created: time.Now(), |
| 241 | 241 |
Parent: parentImage.ID, |
| 242 | 242 |
} |
| 243 | 243 |
childImage2 := &image.Image{
|
| 244 |
- ID: stringid.GenerateRandomID(), |
|
| 244 |
+ ID: stringid.GenerateNonCryptoID(), |
|
| 245 | 245 |
Comment: "child2", |
| 246 | 246 |
Created: time.Now(), |
| 247 | 247 |
Parent: parentImage.ID, |
| ... | ... |
@@ -14,7 +14,7 @@ func (s *DockerSuite) TestRenameStoppedContainer(c *check.C) {
|
| 14 | 14 |
dockerCmd(c, "wait", cleanedContainerID) |
| 15 | 15 |
|
| 16 | 16 |
name, err := inspectField(cleanedContainerID, "Name") |
| 17 |
- newName := "new_name" + stringid.GenerateRandomID() |
|
| 17 |
+ newName := "new_name" + stringid.GenerateNonCryptoID() |
|
| 18 | 18 |
dockerCmd(c, "rename", "first_name", newName) |
| 19 | 19 |
|
| 20 | 20 |
name, err = inspectField(cleanedContainerID, "Name") |
| ... | ... |
@@ -30,7 +30,7 @@ func (s *DockerSuite) TestRenameStoppedContainer(c *check.C) {
|
| 30 | 30 |
func (s *DockerSuite) TestRenameRunningContainer(c *check.C) {
|
| 31 | 31 |
out, _ := dockerCmd(c, "run", "--name", "first_name", "-d", "busybox", "sh") |
| 32 | 32 |
|
| 33 |
- newName := "new_name" + stringid.GenerateRandomID() |
|
| 33 |
+ newName := "new_name" + stringid.GenerateNonCryptoID() |
|
| 34 | 34 |
cleanedContainerID := strings.TrimSpace(out) |
| 35 | 35 |
dockerCmd(c, "rename", "first_name", newName) |
| 36 | 36 |
|
| ... | ... |
@@ -46,7 +46,7 @@ func (s *DockerSuite) TestRenameRunningContainer(c *check.C) {
|
| 46 | 46 |
func (s *DockerSuite) TestRenameCheckNames(c *check.C) {
|
| 47 | 47 |
dockerCmd(c, "run", "--name", "first_name", "-d", "busybox", "sh") |
| 48 | 48 |
|
| 49 |
- newName := "new_name" + stringid.GenerateRandomID() |
|
| 49 |
+ newName := "new_name" + stringid.GenerateNonCryptoID() |
|
| 50 | 50 |
dockerCmd(c, "rename", "first_name", newName) |
| 51 | 51 |
|
| 52 | 52 |
name, err := inspectField(newName, "Name") |
| ... | ... |
@@ -134,7 +134,7 @@ func assertIndexGet(t *testing.T, index *TruncIndex, input, expectedResult strin |
| 134 | 134 |
func BenchmarkTruncIndexAdd100(b *testing.B) {
|
| 135 | 135 |
var testSet []string |
| 136 | 136 |
for i := 0; i < 100; i++ {
|
| 137 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 137 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 138 | 138 |
} |
| 139 | 139 |
b.ResetTimer() |
| 140 | 140 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -150,7 +150,7 @@ func BenchmarkTruncIndexAdd100(b *testing.B) {
|
| 150 | 150 |
func BenchmarkTruncIndexAdd250(b *testing.B) {
|
| 151 | 151 |
var testSet []string |
| 152 | 152 |
for i := 0; i < 250; i++ {
|
| 153 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 153 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 154 | 154 |
} |
| 155 | 155 |
b.ResetTimer() |
| 156 | 156 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -166,7 +166,7 @@ func BenchmarkTruncIndexAdd250(b *testing.B) {
|
| 166 | 166 |
func BenchmarkTruncIndexAdd500(b *testing.B) {
|
| 167 | 167 |
var testSet []string |
| 168 | 168 |
for i := 0; i < 500; i++ {
|
| 169 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 169 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 170 | 170 |
} |
| 171 | 171 |
b.ResetTimer() |
| 172 | 172 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -183,7 +183,7 @@ func BenchmarkTruncIndexGet100(b *testing.B) {
|
| 183 | 183 |
var testSet []string |
| 184 | 184 |
var testKeys []string |
| 185 | 185 |
for i := 0; i < 100; i++ {
|
| 186 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 186 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 187 | 187 |
} |
| 188 | 188 |
index := NewTruncIndex([]string{})
|
| 189 | 189 |
for _, id := range testSet {
|
| ... | ... |
@@ -207,7 +207,7 @@ func BenchmarkTruncIndexGet250(b *testing.B) {
|
| 207 | 207 |
var testSet []string |
| 208 | 208 |
var testKeys []string |
| 209 | 209 |
for i := 0; i < 250; i++ {
|
| 210 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 210 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 211 | 211 |
} |
| 212 | 212 |
index := NewTruncIndex([]string{})
|
| 213 | 213 |
for _, id := range testSet {
|
| ... | ... |
@@ -231,7 +231,7 @@ func BenchmarkTruncIndexGet500(b *testing.B) {
|
| 231 | 231 |
var testSet []string |
| 232 | 232 |
var testKeys []string |
| 233 | 233 |
for i := 0; i < 500; i++ {
|
| 234 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 234 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 235 | 235 |
} |
| 236 | 236 |
index := NewTruncIndex([]string{})
|
| 237 | 237 |
for _, id := range testSet {
|
| ... | ... |
@@ -254,7 +254,7 @@ func BenchmarkTruncIndexGet500(b *testing.B) {
|
| 254 | 254 |
func BenchmarkTruncIndexDelete100(b *testing.B) {
|
| 255 | 255 |
var testSet []string |
| 256 | 256 |
for i := 0; i < 100; i++ {
|
| 257 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 257 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 258 | 258 |
} |
| 259 | 259 |
b.ResetTimer() |
| 260 | 260 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -277,7 +277,7 @@ func BenchmarkTruncIndexDelete100(b *testing.B) {
|
| 277 | 277 |
func BenchmarkTruncIndexDelete250(b *testing.B) {
|
| 278 | 278 |
var testSet []string |
| 279 | 279 |
for i := 0; i < 250; i++ {
|
| 280 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 280 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 281 | 281 |
} |
| 282 | 282 |
b.ResetTimer() |
| 283 | 283 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -300,7 +300,7 @@ func BenchmarkTruncIndexDelete250(b *testing.B) {
|
| 300 | 300 |
func BenchmarkTruncIndexDelete500(b *testing.B) {
|
| 301 | 301 |
var testSet []string |
| 302 | 302 |
for i := 0; i < 500; i++ {
|
| 303 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 303 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 304 | 304 |
} |
| 305 | 305 |
b.ResetTimer() |
| 306 | 306 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -323,7 +323,7 @@ func BenchmarkTruncIndexDelete500(b *testing.B) {
|
| 323 | 323 |
func BenchmarkTruncIndexNew100(b *testing.B) {
|
| 324 | 324 |
var testSet []string |
| 325 | 325 |
for i := 0; i < 100; i++ {
|
| 326 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 326 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 327 | 327 |
} |
| 328 | 328 |
b.ResetTimer() |
| 329 | 329 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -334,7 +334,7 @@ func BenchmarkTruncIndexNew100(b *testing.B) {
|
| 334 | 334 |
func BenchmarkTruncIndexNew250(b *testing.B) {
|
| 335 | 335 |
var testSet []string |
| 336 | 336 |
for i := 0; i < 250; i++ {
|
| 337 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 337 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 338 | 338 |
} |
| 339 | 339 |
b.ResetTimer() |
| 340 | 340 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -345,7 +345,7 @@ func BenchmarkTruncIndexNew250(b *testing.B) {
|
| 345 | 345 |
func BenchmarkTruncIndexNew500(b *testing.B) {
|
| 346 | 346 |
var testSet []string |
| 347 | 347 |
for i := 0; i < 500; i++ {
|
| 348 |
- testSet = append(testSet, stringid.GenerateRandomID()) |
|
| 348 |
+ testSet = append(testSet, stringid.GenerateNonCryptoID()) |
|
| 349 | 349 |
} |
| 350 | 350 |
b.ResetTimer() |
| 351 | 351 |
for i := 0; i < b.N; i++ {
|
| ... | ... |
@@ -357,7 +357,7 @@ func BenchmarkTruncIndexAddGet100(b *testing.B) {
|
| 357 | 357 |
var testSet []string |
| 358 | 358 |
var testKeys []string |
| 359 | 359 |
for i := 0; i < 500; i++ {
|
| 360 |
- id := stringid.GenerateRandomID() |
|
| 360 |
+ id := stringid.GenerateNonCryptoID() |
|
| 361 | 361 |
testSet = append(testSet, id) |
| 362 | 362 |
l := rand.Intn(12) + 12 |
| 363 | 363 |
testKeys = append(testKeys, id[:l]) |
| ... | ... |
@@ -382,7 +382,7 @@ func BenchmarkTruncIndexAddGet250(b *testing.B) {
|
| 382 | 382 |
var testSet []string |
| 383 | 383 |
var testKeys []string |
| 384 | 384 |
for i := 0; i < 500; i++ {
|
| 385 |
- id := stringid.GenerateRandomID() |
|
| 385 |
+ id := stringid.GenerateNonCryptoID() |
|
| 386 | 386 |
testSet = append(testSet, id) |
| 387 | 387 |
l := rand.Intn(12) + 12 |
| 388 | 388 |
testKeys = append(testKeys, id[:l]) |
| ... | ... |
@@ -407,7 +407,7 @@ func BenchmarkTruncIndexAddGet500(b *testing.B) {
|
| 407 | 407 |
var testSet []string |
| 408 | 408 |
var testKeys []string |
| 409 | 409 |
for i := 0; i < 500; i++ {
|
| 410 |
- id := stringid.GenerateRandomID() |
|
| 410 |
+ id := stringid.GenerateNonCryptoID() |
|
| 411 | 411 |
testSet = append(testSet, id) |
| 412 | 412 |
l := rand.Intn(12) + 12 |
| 413 | 413 |
testKeys = append(testKeys, id[:l]) |
| ... | ... |
@@ -127,7 +127,7 @@ var globalTestID string |
| 127 | 127 |
// new directory. |
| 128 | 128 |
func TestDirectory(templateDir string) (dir string, err error) {
|
| 129 | 129 |
if globalTestID == "" {
|
| 130 |
- globalTestID = stringid.GenerateRandomID()[:4] |
|
| 130 |
+ globalTestID = stringid.GenerateNonCryptoID()[:4] |
|
| 131 | 131 |
} |
| 132 | 132 |
prefix := fmt.Sprintf("docker-test%s-%s-", globalTestID, GetCallerName(2))
|
| 133 | 133 |
if prefix == "" {
|