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): encrypted field validation #33382

Merged
merged 15 commits into from
Jan 6, 2025
12 changes: 12 additions & 0 deletions lib/config/decrypt.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('config/decrypt', () => {
beforeEach(() => {
config = {};
GlobalConfig.reset();
delete process.env.MEND_HOSTED;
delete process.env.RENOVATE_X_ENCRYPTED_STRICT;
});

Expand All @@ -34,8 +35,19 @@ describe('config/decrypt', () => {

it('throws exception if encrypted found but no privateKey', async () => {
config.encrypted = { a: '1' };

process.env.RENOVATE_X_ENCRYPTED_STRICT = 'true';
await expect(decryptConfig(config, repository)).rejects.toThrow(
'config-validation',
);
});

// coverage
it('throws exception if encrypted found but no privateKey- Mend Hosted', async () => {
config.encrypted = { a: '1' };

process.env.MEND_HOSTED = 'true';
process.env.RENOVATE_X_ENCRYPTED_STRICT = 'true';
await expect(decryptConfig(config, repository)).rejects.toThrow(
'config-validation',
);
Expand Down
6 changes: 6 additions & 0 deletions lib/config/decrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ export async function decryptConfig(
error.validationSource = 'config';
error.validationError = 'Encrypted config unsupported';
error.validationMessage = `This config contains an encrypted object at location \`$.${key}\` but no privateKey is configured. To support encrypted config, the Renovate administrator must configure a \`privateKey\` in Global Configuration.`;
if (process.env.MEND_HOSTED === 'true') {
error.validationMessage = `Mend-hosted Renovate Apps no longer support the use of encrypted secrets in Renovate file config (e.g. renovate.json).
Please migrate all secrets to the Developer Portal using the web UI available at https://developer.mend.io/

Refer to migration documents here: https://docs.renovatebot.com/mend-hosted/migrating-secrets/`;
}
throw error;
} else {
logger.error('Found encrypted data but no privateKey');
Expand Down
Loading