|
1 | 1 | import type { Faker } from '../..';
|
| 2 | +import { faker } from '../..'; |
2 | 3 | import { toDate } from '../../internal/toDate';
|
3 | 4 |
|
4 | 5 | /**
|
@@ -111,20 +112,32 @@ export class SecurityModule {
|
111 | 112 | score,
|
112 | 113 | vector: [
|
113 | 114 | 'CVSS:3.1',
|
114 |
| - `AV:${this.faker.helpers.arrayElement('NALP'.split(''))}`, |
115 |
| - `AC:${this.faker.helpers.arrayElement('LH'.split(''))}`, |
116 |
| - `PR:${this.faker.helpers.arrayElement('NLH'.split(''))}`, |
117 |
| - `UI:${this.faker.helpers.arrayElement('NR'.split(''))}`, |
118 |
| - `S:${this.faker.helpers.arrayElement('UC'.split(''))}`, |
119 |
| - `C:${this.faker.helpers.arrayElement('NLH'.split(''))}`, |
120 |
| - `I:${this.faker.helpers.arrayElement('NLH'.split(''))}`, |
121 |
| - `A:${this.faker.helpers.arrayElement('NLH'.split(''))}`, |
| 115 | + `AV:${randomCharFromString('NALP')}`, |
| 116 | + `AC:${randomCharFromString('LH')}`, |
| 117 | + `PR:${randomCharFromString('NLH')}`, |
| 118 | + `UI:${randomCharFromString('NR')}`, |
| 119 | + `S:${randomCharFromString('UC')}`, |
| 120 | + `C:${randomCharFromString('NLH')}`, |
| 121 | + `I:${randomCharFromString('NLH')}`, |
| 122 | + `A:${randomCharFromString('NLH')}`, |
122 | 123 | ].join('/'),
|
123 | 124 | rating: getRating(score),
|
124 | 125 | };
|
125 | 126 | }
|
126 | 127 | }
|
127 | 128 |
|
| 129 | +/** |
| 130 | + * Returns a random character from a string. |
| 131 | + * |
| 132 | + * @param string |
| 133 | + * |
| 134 | + * @example |
| 135 | + * randomCharFromString('abc'); // 'b' |
| 136 | + */ |
| 137 | +function randomCharFromString(string: string): string { |
| 138 | + return String(faker.helpers.arrayElement(string.split(''))); |
| 139 | +} |
| 140 | + |
128 | 141 | /**
|
129 | 142 | * Returns the textual representation of a score.
|
130 | 143 | *
|
|
0 commit comments