feat: updated by reptile feedback

This commit is contained in:
=
2025-08-07 20:55:41 +05:30
parent adb3185042
commit 676ebaf3c2
7 changed files with 57 additions and 48 deletions
@@ -183,7 +183,12 @@ export const AwsElastiCacheDatabaseProvider = (): TDynamicProviderFns => {
} catch (err) { } catch (err) {
const sanitizedErrorMessage = sanitizeString({ const sanitizedErrorMessage = sanitizeString({
unsanitizedString: (err as Error)?.message, unsanitizedString: (err as Error)?.message,
tokens: [providerInputs.accessKeyId, providerInputs.secretAccessKey, providerInputs.clusterName] tokens: [
providerInputs.accessKeyId,
providerInputs.secretAccessKey,
providerInputs.clusterName,
providerInputs.region
]
}); });
throw new BadRequestError({ throw new BadRequestError({
message: `Failed to connect with provider: ${sanitizedErrorMessage}` message: `Failed to connect with provider: ${sanitizedErrorMessage}`
@@ -180,6 +180,7 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
awsTags.push(...additionalTags); awsTags.push(...additionalTags);
} }
try {
const createUserRes = await client.send( const createUserRes = await client.send(
new CreateUserCommand({ new CreateUserCommand({
Path: awsPath, Path: awsPath,
@@ -206,7 +207,9 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
.split(",") .split(",")
.filter(Boolean) .filter(Boolean)
.map((policyArn) => .map((policyArn) =>
client.send(new AttachUserPolicyCommand({ UserName: createUserRes?.User?.UserName, PolicyArn: policyArn })) client.send(
new AttachUserPolicyCommand({ UserName: createUserRes?.User?.UserName, PolicyArn: policyArn })
)
) )
); );
} }
@@ -220,7 +223,6 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
); );
} }
try {
const createAccessKeyRes = await client.send( const createAccessKeyRes = await client.send(
new CreateAccessKeyCommand({ new CreateAccessKeyCommand({
UserName: createUserRes.User.UserName UserName: createUserRes.User.UserName
@@ -114,12 +114,12 @@ export const AzureEntraIDProvider = (): TDynamicProviderFns & {
}; };
const revoke = async (inputs: unknown, entityId: string) => { const revoke = async (inputs: unknown, entityId: string) => {
const providerInputs = await validateProviderInputs(inputs);
try { try {
// Creates a new password // Creates a new password
await create({ inputs }); await create({ inputs });
return { entityId }; return { entityId };
} catch (err) { } catch (err) {
const providerInputs = await validateProviderInputs(inputs);
const sanitizedErrorMessage = sanitizeString({ const sanitizedErrorMessage = sanitizeString({
unsanitizedString: (err as Error)?.message, unsanitizedString: (err as Error)?.message,
tokens: [providerInputs.clientSecret, providerInputs.applicationId, entityId] tokens: [providerInputs.clientSecret, providerInputs.applicationId, entityId]
@@ -66,11 +66,7 @@ export const ElasticSearchProvider = (): TDynamicProviderFns => {
const connection = await $getClient(providerInputs); const connection = await $getClient(providerInputs);
try { try {
const infoResponse = await connection const infoResponse = await connection.info().then(() => true);
.info()
.then(() => true)
.catch(() => false);
return infoResponse; return infoResponse;
} catch (err) { } catch (err) {
const tokens = []; const tokens = [];
@@ -216,7 +216,8 @@ export const LdapProvider = (): TDynamicProviderFns => {
if (providerInputs.credentialType === LdapCredentialType.Static) { if (providerInputs.credentialType === LdapCredentialType.Static) {
const dnRegex = new RE2("^dn:\\s*(.+)", "m"); const dnRegex = new RE2("^dn:\\s*(.+)", "m");
const dnMatch = dnRegex.exec(providerInputs.rotationLdif); const dnMatch = dnRegex.exec(providerInputs.rotationLdif);
const username = dnMatch?.[1] || ""; const username = dnMatch?.[1];
if (!username) throw new BadRequestError({ message: "Username not found from Ldif" });
const password = generatePassword(); const password = generatePassword();
if (dnMatch) { if (dnMatch) {
@@ -123,7 +123,12 @@ export const RedisDatabaseProvider = (): TDynamicProviderFns => {
if (connection) await connection.quit(); if (connection) await connection.quit();
const sanitizedErrorMessage = sanitizeString({ const sanitizedErrorMessage = sanitizeString({
unsanitizedString: (err as Error)?.message, unsanitizedString: (err as Error)?.message,
tokens: [providerInputs.password || "", providerInputs.username, providerInputs.host] tokens: [
providerInputs.password || "",
providerInputs.username,
providerInputs.host,
String(providerInputs.port)
]
}); });
throw new BadRequestError({ throw new BadRequestError({
message: `Failed to connect with provider: ${sanitizedErrorMessage}` message: `Failed to connect with provider: ${sanitizedErrorMessage}`
@@ -155,7 +155,7 @@ export const SnowflakeProvider = (): TDynamicProviderFns => {
sqlText: revokeStatement, sqlText: revokeStatement,
complete(err) { complete(err) {
if (err) { if (err) {
return reject(); return reject(err);
} }
return resolve(true); return resolve(true);