fixed how to detect obscured key (#524)

* fixed how to detect obscured key

* wip

* wip
This commit is contained in:
Hoan Luu Huu
2025-12-12 20:56:55 +07:00
committed by GitHub
parent 15f2d92f71
commit 1aa28e8ba0

View File

@@ -50,18 +50,15 @@ function isObscureKey(bucketCredentials) {
service_key = '',
connection_string = ''
} = bucketCredentials || {};
let pattern;
// Pattern matches: 4-6 any characters followed by one or more X's
const pattern = /^.{4,6}X+$/;
switch (vendor) {
case 'aws_s3':
case 's3_compatible':
pattern = /^([A-Za-z0-9]{4,6}X+$)/;
return pattern.test(secret_access_key);
case 'azure':
pattern = /^([A-Za-z0-9:]{4,6}X+$)/;
return pattern.test(connection_string);
case 'google': {
pattern = /^([A-Za-z0-9]{4,6}X+$)/;
let {private_key} = JSON.parse(service_key);
const key_header = '-----BEGIN PRIVATE KEY-----\n';
private_key = private_key.slice(key_header.length, private_key.length);