Skip to content

Commit

Permalink
use seeded random for uuidv4
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallmain committed Mar 6, 2020
1 parent 5f38e3a commit aa77f8d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions x-pack/plugins/endpoint/common/generate_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export class EndpointDocGenerator {

constructor(seed = Math.random().toString()) {
this.random = seedrandom(seed);
this.hostId = uuid.v4();
this.agentId = uuid.v4();
this.hostId = this.seededUUIDv4();
this.agentId = this.seededUUIDv4();
this.hostname = this.randomHostname();
this.lastDHCPLeaseAt = new Date().getTime();
this.ip = this.randomArray(3, () => this.randomIP());
Expand Down Expand Up @@ -138,7 +138,7 @@ export class EndpointDocGenerator {
action: this.randomChoice(FILE_OPERATIONS),
kind: 'alert',
category: 'malware',
id: uuid.v4(),
id: this.seededUUIDv4(),
dataset: 'endpoint',
module: 'endpoint',
type: 'creation',
Expand Down Expand Up @@ -258,7 +258,7 @@ export class EndpointDocGenerator {
category: options.eventCategory ? options.eventCategory : 'process',
kind: 'event',
type: options.eventType ? options.eventType : 'creation',
id: uuid.v4(),
id: this.seededUUIDv4(),
},
host: {
id: this.hostId,
Expand Down Expand Up @@ -427,4 +427,8 @@ export class EndpointDocGenerator {
private randomHostname(): string {
return `Host-${this.randomString(10)}`;
}

private seededUUIDv4(): string {
return uuid.v4({ random: [...this.randomNGenerator(255, 16)] });
}
}

0 comments on commit aa77f8d

Please sign in to comment.