Skip to content

Commit

Permalink
fix(config): better decrypt errors (#11777)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Sep 16, 2021
1 parent 23b1c18 commit 1fe1eef
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions lib/config/decrypt.ts
Expand Up @@ -101,27 +101,37 @@ export async function tryDecrypt(
if (scopedRepository === repository) {
decryptedStr = value;
} else {
logger.warn(
logger.debug(
{ scopedRepository },
'Secret is scoped to a different repository'
);
const error = new Error('config-validation');
error.validationError = `Encrypted secret is scoped to a different repository: ${scopedRepository}.`;
throw error;
}
} else {
const scopedOrg = `${orgName}/`;
if (repository.startsWith(scopedOrg)) {
decryptedStr = value;
} else {
logger.warn(
logger.debug(
{ scopedOrg },
'Secret is scoped to a different org'
);
const error = new Error('config-validation');
error.validationError = `Encrypted secret is scoped to a different org" ${scopedOrg}.`;
throw error;
}
}
} else {
logger.warn('Missing scope from decrypted object');
const error = new Error('config-validation');
error.validationError = `Encrypted value in config is missing a scope.`;
throw error;
}
} else {
logger.warn('Decrypted object is missing a value');
const error = new Error('config-validation');
error.validationError = `Encrypted value in config is missing a value.`;
throw error;
}
} catch (err) {
logger.warn({ err }, 'Could not parse decrypted string');
Expand Down

0 comments on commit 1fe1eef

Please sign in to comment.