File tree 1 file changed +4
-7
lines changed
1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { field, logger } from "@coder/logger";
2
2
import { ServerMessage , SharedProcessActiveMessage } from "@coder/protocol/src/proto" ;
3
3
import { Command , flags } from "@oclif/command" ;
4
4
import { fork , ForkOptions , ChildProcess } from "child_process" ;
5
+ import { randomFillSync } from "crypto" ;
5
6
import * as fs from "fs" ;
6
7
import * as os from "os" ;
7
8
import * as path from "path" ;
@@ -136,13 +137,9 @@ export class Entry extends Command {
136
137
let password = flags [ "password" ] ;
137
138
if ( ! password ) {
138
139
// Generate a random password
139
- const passwordLength = 12 ;
140
- const possible = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ;
141
- const chars = [ ] ;
142
- for ( let i = 0 ; i < passwordLength ; i ++ ) {
143
- chars . push ( possible [ Math . floor ( Math . random ( ) * possible . length ) ] ) ;
144
- }
145
- password = chars . join ( "" ) ;
140
+ const buffer = Buffer . alloc ( 12 ) ;
141
+ randomFillSync ( buffer ) ;
142
+ password = buffer . toString ( "hex" ) ;
146
143
}
147
144
148
145
const hasCustomHttps = certData && certKeyData ;
You can’t perform that action at this time.
0 commit comments