Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): better decrypt errors #11777

Merged
merged 1 commit into from Sep 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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