Skip to content

Commit 8a48ca9

Browse files
Potential fix for code scanning alert no. 521: Insecure randomness
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 2a6a399 commit 8a48ca9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/utils/S3Setup.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const AWS = require('aws-sdk');
33
const { promisify } = require('util');
44
const { Logger } = require('werelogs');
55
const admincredentials = require('vaultclient/tests/utils/admincredentials.json');
6+
const crypto = require('crypto');
67

78
const log = new Logger('S3Setup');
89

@@ -18,7 +19,8 @@ const region = 'us-east-1';
1819
async function createTestAccount(vaultClient) {
1920
const iamEndpoint = new AWS.Endpoint(`http://${iamHost}:${iamPort}`);
2021
const s3Endpoint = new AWS.Endpoint(`http://${s3Host}:${s3Port}`);
21-
const accountName = `test-account-${Math.random().toString(36).substring(2, 8)}`;
22+
const randomSuffix = crypto.randomBytes(4).toString('hex').substring(0, 6);
23+
const accountName = `test-account-${randomSuffix}`;
2224
const accountEmail = `${accountName}@example.com`;
2325
const bucketName = accountName;
2426
const iamUser = `${accountName}-user`;

0 commit comments

Comments
 (0)