renovate 40.0.0-next.16 → 40.0.0-next.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/config/decrypt.d.ts +3 -1
  2. package/dist/config/decrypt.js +54 -11
  3. package/dist/config/decrypt.js.map +1 -1
  4. package/dist/config/options/index.js +1 -1
  5. package/dist/config/options/index.js.map +1 -1
  6. package/dist/config/presets/gitlab/index.js +1 -1
  7. package/dist/config/presets/gitlab/index.js.map +1 -1
  8. package/dist/config/presets/http/index.js +1 -1
  9. package/dist/config/presets/http/index.js.map +1 -1
  10. package/dist/config/presets/internal/custom-managers.js +3 -4
  11. package/dist/config/presets/internal/custom-managers.js.map +1 -1
  12. package/dist/data/monorepo.json +2 -1
  13. package/dist/instrumentation/utils.js +1 -1
  14. package/dist/instrumentation/utils.js.map +1 -1
  15. package/dist/modules/datasource/artifactory/index.js +1 -1
  16. package/dist/modules/datasource/artifactory/index.js.map +1 -1
  17. package/dist/modules/datasource/azure-pipelines-tasks/index.js +11 -1
  18. package/dist/modules/datasource/azure-pipelines-tasks/index.js.map +1 -1
  19. package/dist/modules/datasource/azure-pipelines-tasks/schema.d.ts +16 -0
  20. package/dist/modules/datasource/azure-pipelines-tasks/schema.js +2 -0
  21. package/dist/modules/datasource/azure-pipelines-tasks/schema.js.map +1 -1
  22. package/dist/modules/datasource/crate/index.js +1 -1
  23. package/dist/modules/datasource/crate/index.js.map +1 -1
  24. package/dist/modules/datasource/custom/formats/html.js +1 -1
  25. package/dist/modules/datasource/custom/formats/html.js.map +1 -1
  26. package/dist/modules/datasource/custom/formats/yaml.js +1 -1
  27. package/dist/modules/datasource/custom/formats/yaml.js.map +1 -1
  28. package/dist/modules/datasource/deb/index.js +1 -1
  29. package/dist/modules/datasource/deb/index.js.map +1 -1
  30. package/dist/modules/datasource/docker/common.js +1 -1
  31. package/dist/modules/datasource/docker/common.js.map +1 -1
  32. package/dist/modules/datasource/docker/index.js +1 -1
  33. package/dist/modules/datasource/docker/index.js.map +1 -1
  34. package/dist/modules/datasource/github-release-attachments/index.js +2 -2
  35. package/dist/modules/datasource/github-release-attachments/index.js.map +1 -1
  36. package/dist/modules/datasource/go/base.js +1 -1
  37. package/dist/modules/datasource/go/base.js.map +1 -1
  38. package/dist/modules/datasource/go/releases-goproxy.js +1 -1
  39. package/dist/modules/datasource/go/releases-goproxy.js.map +1 -1
  40. package/dist/modules/datasource/golang-version/index.js +1 -1
  41. package/dist/modules/datasource/golang-version/index.js.map +1 -1
  42. package/dist/modules/datasource/hexpm-bob/index.js +1 -1
  43. package/dist/modules/datasource/hexpm-bob/index.js.map +1 -1
  44. package/dist/modules/datasource/maven/util.js +1 -1
  45. package/dist/modules/datasource/maven/util.js.map +1 -1
  46. package/dist/modules/datasource/nuget/v2.js +1 -1
  47. package/dist/modules/datasource/nuget/v2.js.map +1 -1
  48. package/dist/modules/datasource/nuget/v3.js +1 -1
  49. package/dist/modules/datasource/nuget/v3.js.map +1 -1
  50. package/dist/modules/datasource/pod/index.js +1 -1
  51. package/dist/modules/datasource/pod/index.js.map +1 -1
  52. package/dist/modules/datasource/pypi/index.js +1 -1
  53. package/dist/modules/datasource/pypi/index.js.map +1 -1
  54. package/dist/modules/datasource/ruby-version/index.js +1 -1
  55. package/dist/modules/datasource/ruby-version/index.js.map +1 -1
  56. package/dist/modules/datasource/rubygems/index.js +1 -1
  57. package/dist/modules/datasource/rubygems/index.js.map +1 -1
  58. package/dist/modules/datasource/rubygems/versions-endpoint-cache.js +2 -2
  59. package/dist/modules/datasource/rubygems/versions-endpoint-cache.js.map +1 -1
  60. package/dist/modules/datasource/terraform-provider/index.js +1 -1
  61. package/dist/modules/datasource/terraform-provider/index.js.map +1 -1
  62. package/dist/modules/manager/batect-wrapper/artifacts.js +1 -1
  63. package/dist/modules/manager/batect-wrapper/artifacts.js.map +1 -1
  64. package/dist/modules/manager/bazel/rules/git.js +7 -1
  65. package/dist/modules/manager/bazel/rules/git.js.map +1 -1
  66. package/dist/modules/manager/composer/utils.js +9 -6
  67. package/dist/modules/manager/composer/utils.js.map +1 -1
  68. package/dist/modules/manager/devbox/artifacts.d.ts +1 -1
  69. package/dist/modules/manager/devbox/artifacts.js +29 -11
  70. package/dist/modules/manager/devbox/artifacts.js.map +1 -1
  71. package/dist/modules/manager/fingerprint.generated.js +6 -6
  72. package/dist/modules/manager/fingerprint.generated.js.map +1 -1
  73. package/dist/modules/manager/gradle-wrapper/artifacts.js +1 -1
  74. package/dist/modules/manager/gradle-wrapper/artifacts.js.map +1 -1
  75. package/dist/modules/manager/maven/extract.js +3 -1
  76. package/dist/modules/manager/maven/extract.js.map +1 -1
  77. package/dist/modules/manager/pep621/utils.js +1 -2
  78. package/dist/modules/manager/pep621/utils.js.map +1 -1
  79. package/dist/modules/manager/poetry/artifacts.js +3 -4
  80. package/dist/modules/manager/poetry/artifacts.js.map +1 -1
  81. package/dist/modules/manager/poetry/extract.js +2 -2
  82. package/dist/modules/manager/poetry/extract.js.map +1 -1
  83. package/dist/modules/manager/terraform/lockfile/hash.d.ts +1 -1
  84. package/dist/modules/platform/bitbucket/index.js +1 -1
  85. package/dist/modules/platform/bitbucket/index.js.map +1 -1
  86. package/dist/modules/platform/gerrit/client.js +1 -1
  87. package/dist/modules/platform/gerrit/client.js.map +1 -1
  88. package/dist/modules/platform/github/common.d.ts +2 -0
  89. package/dist/modules/platform/github/common.js +16 -0
  90. package/dist/modules/platform/github/common.js.map +1 -1
  91. package/dist/modules/platform/github/index.d.ts +1 -1
  92. package/dist/modules/platform/github/index.js +6 -4
  93. package/dist/modules/platform/github/index.js.map +1 -1
  94. package/dist/modules/versioning/composer/index.js +10 -0
  95. package/dist/modules/versioning/composer/index.js.map +1 -1
  96. package/dist/modules/versioning/npm/index.js +2 -1
  97. package/dist/modules/versioning/npm/index.js.map +1 -1
  98. package/dist/modules/versioning/types.d.ts +4 -0
  99. package/dist/modules/versioning/types.js.map +1 -1
  100. package/dist/util/exec/containerbase.js +1 -1
  101. package/dist/util/exec/containerbase.js.map +1 -1
  102. package/dist/util/http/auth.js +0 -1
  103. package/dist/util/http/auth.js.map +1 -1
  104. package/dist/util/http/bitbucket-server.d.ts +5 -4
  105. package/dist/util/http/bitbucket-server.js +17 -20
  106. package/dist/util/http/bitbucket-server.js.map +1 -1
  107. package/dist/util/http/bitbucket.d.ts +6 -5
  108. package/dist/util/http/bitbucket.js +30 -31
  109. package/dist/util/http/bitbucket.js.map +1 -1
  110. package/dist/util/http/cache/abstract-http-cache-provider.js +1 -1
  111. package/dist/util/http/cache/abstract-http-cache-provider.js.map +1 -1
  112. package/dist/util/http/errors.d.ts +2 -0
  113. package/dist/util/http/errors.js +8 -0
  114. package/dist/util/http/errors.js.map +1 -0
  115. package/dist/util/http/gerrit.d.ts +6 -4
  116. package/dist/util/http/gerrit.js +11 -12
  117. package/dist/util/http/gerrit.js.map +1 -1
  118. package/dist/util/http/gitea.d.ts +5 -4
  119. package/dist/util/http/gitea.js +12 -13
  120. package/dist/util/http/gitea.js.map +1 -1
  121. package/dist/util/http/github.d.ts +14 -8
  122. package/dist/util/http/github.js +64 -60
  123. package/dist/util/http/github.js.map +1 -1
  124. package/dist/util/http/gitlab.d.ts +7 -5
  125. package/dist/util/http/gitlab.js +56 -46
  126. package/dist/util/http/gitlab.js.map +1 -1
  127. package/dist/util/http/got.d.ts +9 -0
  128. package/dist/util/http/got.js +54 -0
  129. package/dist/util/http/got.js.map +1 -0
  130. package/dist/util/http/host-rules.d.ts +2 -1
  131. package/dist/util/http/host-rules.js.map +1 -1
  132. package/dist/util/http/http.d.ts +93 -0
  133. package/dist/util/http/http.js +339 -0
  134. package/dist/util/http/http.js.map +1 -0
  135. package/dist/util/http/index.d.ts +6 -74
  136. package/dist/util/http/index.js +5 -359
  137. package/dist/util/http/index.js.map +1 -1
  138. package/dist/util/http/types.d.ts +9 -16
  139. package/dist/util/http/types.js.map +1 -1
  140. package/dist/util/toml.d.ts +1 -0
  141. package/dist/util/toml.js +6 -0
  142. package/dist/util/toml.js.map +1 -1
  143. package/dist/util/url.js +3 -8
  144. package/dist/util/url.js.map +1 -1
  145. package/dist/workers/global/config/parse/env.js +3 -2
  146. package/dist/workers/global/config/parse/env.js.map +1 -1
  147. package/dist/workers/global/config/parse/file.js +18 -8
  148. package/dist/workers/global/config/parse/file.js.map +1 -1
  149. package/dist/workers/global/config/parse/host-rules-from-env.js +6 -2
  150. package/dist/workers/global/config/parse/host-rules-from-env.js.map +1 -1
  151. package/dist/workers/repository/update/pr/changelog/bitbucket/index.js +1 -1
  152. package/dist/workers/repository/update/pr/changelog/bitbucket/index.js.map +1 -1
  153. package/dist/workers/repository/update/pr/changelog/gitlab/index.js +1 -1
  154. package/dist/workers/repository/update/pr/changelog/gitlab/index.js.map +1 -1
  155. package/package.json +30 -30
@@ -1,3 +1,5 @@
1
1
  import type { RenovateConfig } from './types';
2
2
  export declare function tryDecrypt(privateKey: string, encryptedStr: string, repository: string, keyName: string): Promise<string | null>;
3
- export declare function decryptConfig(config: RenovateConfig, repository: string): Promise<RenovateConfig>;
3
+ export declare function validateDecryptedValue(decryptedObjStr: string, repository: string): string | null;
4
+ export declare function decryptConfig(config: RenovateConfig, repository: string, existingPath?: string): Promise<RenovateConfig>;
5
+ export declare function getAzureCollection(): string | undefined;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tryDecrypt = tryDecrypt;
4
+ exports.validateDecryptedValue = validateDecryptedValue;
4
5
  exports.decryptConfig = decryptConfig;
6
+ exports.getAzureCollection = getAzureCollection;
5
7
  const tslib_1 = require("tslib");
6
8
  const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
7
9
  const error_messages_1 = require("../constants/error-messages");
@@ -59,6 +61,14 @@ function validateDecryptedValue(decryptedObjStr, repository) {
59
61
  error.validationError = `Encrypted value in config is missing a scope.`;
60
62
  throw error;
61
63
  }
64
+ const repositories = [repository.toUpperCase()];
65
+ const azureCollection = getAzureCollection();
66
+ if (is_1.default.nonEmptyString(azureCollection)) {
67
+ // used for full 'org/project/repo' matching
68
+ repositories.push(`${azureCollection}/${repository}`.toUpperCase());
69
+ // used for org prefix matching without repo
70
+ repositories.push(`${azureCollection}/*/`.toUpperCase());
71
+ }
62
72
  const orgPrefixes = org
63
73
  .split(',')
64
74
  .map((o) => o.trim())
@@ -66,8 +76,10 @@ function validateDecryptedValue(decryptedObjStr, repository) {
66
76
  .map((o) => (0, url_1.ensureTrailingSlash)(o));
67
77
  if (is_1.default.nonEmptyString(repo)) {
68
78
  const scopedRepos = orgPrefixes.map((orgPrefix) => `${orgPrefix}${repo}`.toUpperCase());
69
- if (scopedRepos.some((r) => r === repository.toUpperCase())) {
70
- return value;
79
+ for (const rp of repositories) {
80
+ if (scopedRepos.some((r) => r === rp)) {
81
+ return value;
82
+ }
71
83
  }
72
84
  logger_1.logger.debug({ scopedRepos }, 'Secret is scoped to a different repository');
73
85
  const error = new Error('config-validation');
@@ -76,8 +88,13 @@ function validateDecryptedValue(decryptedObjStr, repository) {
76
88
  throw error;
77
89
  }
78
90
  // no scoped repos, only org
79
- if (orgPrefixes.some((orgPrefix) => repository.toUpperCase().startsWith(orgPrefix))) {
80
- return value;
91
+ const azcol = azureCollection === undefined
92
+ ? undefined
93
+ : (0, url_1.ensureTrailingSlash)(azureCollection).toUpperCase();
94
+ for (const rp of repositories) {
95
+ if (orgPrefixes.some((orgPrefix) => rp.startsWith(orgPrefix) && orgPrefix !== azcol)) {
96
+ return value;
97
+ }
81
98
  }
82
99
  logger_1.logger.debug({ orgPrefixes }, 'Secret is scoped to a different org');
83
100
  const error = new Error('config-validation');
@@ -90,21 +107,22 @@ function validateDecryptedValue(decryptedObjStr, repository) {
90
107
  }
91
108
  return null;
92
109
  }
93
- async function decryptConfig(config, repository) {
110
+ async function decryptConfig(config, repository, existingPath = '$') {
94
111
  logger_1.logger.trace({ config }, 'decryptConfig()');
95
112
  const decryptedConfig = { ...config };
96
113
  const privateKey = global_1.GlobalConfig.get('privateKey');
97
114
  const privateKeyOld = global_1.GlobalConfig.get('privateKeyOld');
98
115
  for (const [key, val] of Object.entries(config)) {
99
116
  if (key === 'encrypted' && is_1.default.object(val)) {
100
- logger_1.logger.debug({ config: val }, 'Found encrypted config');
117
+ const path = `${existingPath}.${key}`;
118
+ logger_1.logger.debug({ config: val }, `Found encrypted config in ${path}`);
101
119
  const encryptedWarning = global_1.GlobalConfig.get('encryptedWarning');
102
120
  if (is_1.default.string(encryptedWarning)) {
103
121
  logger_1.logger.once.warn(encryptedWarning);
104
122
  }
105
123
  if (privateKey) {
106
124
  for (const [eKey, eVal] of Object.entries(val)) {
107
- logger_1.logger.debug('Trying to decrypt ' + eKey);
125
+ logger_1.logger.debug(`Trying to decrypt ${eKey} in ${path}`);
108
126
  let decryptedStr = await tryDecrypt(privateKey, eVal, repository, eKey);
109
127
  if (privateKeyOld && !is_1.default.nonEmptyString(decryptedStr)) {
110
128
  logger_1.logger.debug(`Trying to decrypt with old private key`);
@@ -115,7 +133,7 @@ async function decryptConfig(config, repository) {
115
133
  error.validationError = `Failed to decrypt field ${eKey}. Please re-encrypt and try again.`;
116
134
  throw error;
117
135
  }
118
- logger_1.logger.debug(`Decrypted ${eKey}`);
136
+ logger_1.logger.debug(`Decrypted ${eKey} in ${path}`);
119
137
  if (eKey === 'npmToken') {
120
138
  const token = decryptedStr.replace((0, regex_1.regEx)(/\n$/), '');
121
139
  decryptedConfig[eKey] = token;
@@ -149,9 +167,10 @@ Refer to migration documents here: https://docs.renovatebot.com/mend-hosted/migr
149
167
  }
150
168
  else if (is_1.default.array(val)) {
151
169
  decryptedConfig[key] = [];
152
- for (const item of val) {
170
+ for (const [index, item] of val.entries()) {
153
171
  if (is_1.default.object(item) && !is_1.default.array(item)) {
154
- decryptedConfig[key].push(await decryptConfig(item, repository));
172
+ const path = `${existingPath}.${key}[${index}]`;
173
+ decryptedConfig[key].push(await decryptConfig(item, repository, path));
155
174
  }
156
175
  else {
157
176
  decryptedConfig[key].push(item);
@@ -159,11 +178,35 @@ Refer to migration documents here: https://docs.renovatebot.com/mend-hosted/migr
159
178
  }
160
179
  }
161
180
  else if (is_1.default.object(val) && key !== 'content') {
162
- decryptedConfig[key] = await decryptConfig(val, repository);
181
+ const path = `${existingPath}.${key}`;
182
+ decryptedConfig[key] = await decryptConfig(val, repository, path);
163
183
  }
164
184
  }
165
185
  delete decryptedConfig.encrypted;
166
186
  logger_1.logger.trace({ config: decryptedConfig }, 'decryptedConfig');
167
187
  return decryptedConfig;
168
188
  }
189
+ function getAzureCollection() {
190
+ const platform = global_1.GlobalConfig.get('platform');
191
+ if (platform !== 'azure') {
192
+ return undefined;
193
+ }
194
+ const endpoint = global_1.GlobalConfig.get('endpoint');
195
+ const endpointUrl = (0, url_1.parseUrl)(endpoint);
196
+ if (endpointUrl === null) {
197
+ // should not happen
198
+ logger_1.logger.warn({ endpoint }, 'Unable to parse endpoint for token decryption');
199
+ return undefined;
200
+ }
201
+ const azureCollection = (0, url_1.trimSlashes)(endpointUrl.pathname);
202
+ if (!is_1.default.nonEmptyString(azureCollection)) {
203
+ logger_1.logger.debug({ endpoint }, 'Unable to find azure collection name from URL');
204
+ return undefined;
205
+ }
206
+ if (azureCollection.startsWith('tfs/')) {
207
+ // Azure DevOps Server
208
+ return azureCollection.substring(4);
209
+ }
210
+ return azureCollection;
211
+ }
169
212
  //# sourceMappingURL=decrypt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decrypt.js","sourceRoot":"","sources":["../../lib/config/decrypt.ts"],"names":[],"mappings":";;AAgBA,gCAmCC;AAsED,sCAyFC;;AAlND,kEAAkC;AAClC,gEAAgE;AAChE,sCAAmC;AACnC,yCAAsC;AACtC,+CAA0D;AAC1D,qCAAkD;AAClD,2CAAkD;AAClD,6CAG0B;AAC1B,+CAAsD;AACtD,qCAAwC;AACxC,qCAA2C;AAGpC,KAAK,UAAU,UAAU,CAC9B,UAAkB,EAClB,YAAoB,EACpB,UAAk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AAC;YAC1B,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;gBACvB,IAAI,YAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;oBACtC,eAAe,CAAC,GAAG,CAAsB,CAAC,IAAI,CAC7C,MAAM,aAAa,CAAC,IAAsB,EAAE,UAAU,CAAC,CACxD,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACL,eAAe,CAAC,GAAG,CAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,YAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YAC/C,eAAe,CAAC,GAAG,CAAC,GAAG,MAAM,aAAa,CACxC,GAAqB,EACrB,UAAU,CACX,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,eAAe,CAAC,SAAS,CAAC;IACjC,eAAM,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,EAAE,iBAAiB,CAAC,CAAC;IAC7D,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { CONFIG_VALIDATION } from '../constants/error-messages';\nimport { logger } from '../logger';\nimport { regEx } from '../util/regex';\nimport { addSecretForSanitizing } from '../util/sanitize';\nimport { ensureTrailingSlash } from '../util/url';\nimport { tryDecryptKbPgp } from './decrypt/kbpgp';\nimport {\n tryDecryptPublicKeyDefault,\n tryDecryptPublicKeyPKCS1,\n} from './decrypt/legacy';\nimport { tryDecryptOpenPgp } from './decrypt/openpgp';\nimport { GlobalConfig } from './global';\nimport { DecryptedObject } from './schema';\nimport type { RenovateConfig } from './types';\n\nexport async function tryDecrypt(\n privateKey: string,\n encryptedStr: string,\n repository: string,\n keyName: string,\n): Promise<string | null> {\n let decryptedStr: string | null = null;\n if (privateKey?.startsWith('-----BEGIN PGP PRIVATE KEY BLOCK-----')) {\n const decryptedObjStr =\n process.env.RENOVATE_X_USE_OPENPGP === 'true'\n ? await tryDecryptOpenPgp(privateKey, encryptedStr)\n : await tryDecryptKbPgp(privateKey, encryptedStr);\n if (decryptedObjStr) {\n decryptedStr = validateDecryptedValue(decryptedObjStr, repository);\n }\n } else {\n decryptedStr = tryDecryptPublicKeyDefault(privateKey, encryptedStr);\n if (is.string(decryptedStr)) {\n logger.warn(\n { keyName },\n 'Encrypted value is using deprecated default padding, please change to using PGP encryption.',\n );\n } else {\n decryptedStr = tryDecryptPublicKeyPKCS1(privateKey, encryptedStr);\n /* v8 ignore start: not testable */\n if (is.string(decryptedStr)) {\n logger.warn(\n { keyName },\n 'Encrypted value is using deprecated PKCS1 padding, please change to using PGP encryption.',\n );\n }\n /* v8 ignore stop */\n }\n }\n return decryptedStr;\n}\n\nfunction validateDecryptedValue(\n decryptedObjStr: string,\n repository: string,\n): string | null {\n try {\n const decryptedObj = DecryptedObject.safeParse(decryptedObjStr);\n if (!decryptedObj.success) {\n const error = new Error('config-validation');\n error.validationError = `Could not parse decrypted config.`;\n throw error;\n }\n\n const { o: org, r: repo, v: value } = decryptedObj.data;\n\n if (!is.nonEmptyString(value)) {\n const error = new Error('config-validation');\n error.validationError = `Encrypted value in config is missing a value.`;\n throw error;\n }\n\n if (!is.nonEmptyString(org)) {\n const error = new Error('config-validation');\n error.validationError = `Encrypted value in config is missing a scope.`;\n throw error;\n }\n\n const orgPrefixes = org\n .split(',')\n .map((o) => o.trim())\n .map((o) => o.toUpperCase())\n .map((o) => ensureTrailingSlash(o));\n\n if (is.nonEmptyString(repo)) {\n const scopedRepos = orgPrefixes.map((orgPrefix) =>\n `${orgPrefix}${repo}`.toUpperCase(),\n );\n if (scopedRepos.some((r) => r === repository.toUpperCase())) {\n return value;\n }\n logger.debug(\n { scopedRepos },\n 'Secret is scoped to a different repository',\n );\n const error = new Error('config-validation');\n const scopeString = scopedRepos.join(',');\n error.validationError = `Encrypted secret is scoped to a different repository: \"${scopeString}\".`;\n throw error;\n }\n\n // no scoped repos, only org\n if (\n orgPrefixes.some((orgPrefix) =>\n repository.toUpperCase().startsWith(orgPrefix),\n )\n ) {\n return value;\n }\n logger.debug({ orgPrefixes }, 'Secret is scoped to a different org');\n const error = new Error('config-validation');\n const scopeString = orgPrefixes.join(',');\n error.validationError = `Encrypted secret is scoped to a different org: \"${scopeString}\".`;\n throw error;\n } catch (err) {\n logger.warn({ err }, 'Could not parse decrypted string');\n }\n return null;\n}\n\nexport async function decryptConfig(\n config: RenovateConfig,\n repository: string,\n): Promise<RenovateConfig> {\n logger.trace({ config }, 'decryptConfig()');\n const decryptedConfig = { ...config };\n const privateKey = GlobalConfig.get('privateKey');\n const privateKeyOld = GlobalConfig.get('privateKeyOld');\n for (const [key, val] of Object.entries(config)) {\n if (key === 'encrypted' && is.object(val)) {\n logger.debug({ config: val }, 'Found encrypted config');\n\n const encryptedWarning = GlobalConfig.get('encryptedWarning');\n if (is.string(encryptedWarning)) {\n logger.once.warn(encryptedWarning);\n }\n\n if (privateKey) {\n for (const [eKey, eVal] of Object.entries(val)) {\n logger.debug('Trying to decrypt ' + eKey);\n let decryptedStr = await tryDecrypt(\n privateKey,\n eVal,\n repository,\n eKey,\n );\n if (privateKeyOld && !is.nonEmptyString(decryptedStr)) {\n logger.debug(`Trying to decrypt with old private key`);\n decryptedStr = await tryDecrypt(\n privateKeyOld,\n eVal,\n repository,\n eKey,\n );\n }\n if (!is.nonEmptyString(decryptedStr)) {\n const error = new Error('config-validation');\n error.validationError = `Failed to decrypt field ${eKey}. Please re-encrypt and try again.`;\n throw error;\n }\n logger.debug(`Decrypted ${eKey}`);\n if (eKey === 'npmToken') {\n const token = decryptedStr.replace(regEx(/\\n$/), '');\n decryptedConfig[eKey] = token;\n addSecretForSanitizing(token);\n } else {\n decryptedConfig[eKey] = decryptedStr;\n addSecretForSanitizing(decryptedStr);\n }\n }\n } else {\n if (process.env.RENOVATE_X_ENCRYPTED_STRICT === 'true') {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = 'config';\n error.validationError = 'Encrypted config unsupported';\n 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.`;\n if (process.env.MEND_HOSTED === 'true') {\n error.validationMessage = `Mend-hosted Renovate Apps no longer support the use of encrypted secrets in Renovate file config (e.g. renovate.json).\nPlease migrate all secrets to the Developer Portal using the web UI available at https://developer.mend.io/\n\nRefer to migration documents here: https://docs.renovatebot.com/mend-hosted/migrating-secrets/`;\n }\n throw error;\n } else {\n logger.error('Found encrypted data but no privateKey');\n }\n }\n delete decryptedConfig.encrypted;\n } else if (is.array(val)) {\n decryptedConfig[key] = [];\n for (const item of val) {\n if (is.object(item) && !is.array(item)) {\n (decryptedConfig[key] as RenovateConfig[]).push(\n await decryptConfig(item as RenovateConfig, repository),\n );\n } else {\n (decryptedConfig[key] as unknown[]).push(item);\n }\n }\n } else if (is.object(val) && key !== 'content') {\n decryptedConfig[key] = await decryptConfig(\n val as RenovateConfig,\n repository,\n );\n }\n }\n delete decryptedConfig.encrypted;\n logger.trace({ config: decryptedConfig }, 'decryptedConfig');\n return decryptedConfig;\n}\n"]}
1
+ {"version":3,"file":"decrypt.js","sourceRoot":"","sources":["../../lib/config/decrypt.ts"],"names":[],"mappings":";;AAgBA,gCAmCC;AAED,wDAqFC;AAED,sCA8FC;AAED,gDAyBC;;AArQD,kEAAkC;AAClC,gEAAgE;AAChE,sCAAmC;AACnC,yCAAsC;AACtC,+CAA0D;AAC1D,qCAAyE;AACzE,2CAAkD;AAClD,6CAG0B;AAC1B,+CAAsD;AACtD,qCAAwC;AACxC,qCAA2C;AAGpC,KAAK,UAAU,UAAU,CAC9B,UAAkB,EAClB,YAAoB,EACpB,UAAkB,EAClB,OAAe;IAEf,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,UAAU,EAAE,UAAU,CAAC,uCA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C;IACtC,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC","sourcesContent":["import is from '@sindresorhus/is';\nimport { CONFIG_VALIDATION } from '../constants/error-messages';\nimport { logger } from '../logger';\nimport { regEx } from '../util/regex';\nimport { addSecretForSanitizing } from '../util/sanitize';\nimport { ensureTrailingSlash, parseUrl, trimSlashes } from '../util/url';\nimport { tryDecryptKbPgp } from './decrypt/kbpgp';\nimport {\n tryDecryptPublicKeyDefault,\n tryDecryptPublicKeyPKCS1,\n} from './decrypt/legacy';\nimport { tryDecryptOpenPgp } from './decrypt/openpgp';\nimport { GlobalConfig } from './global';\nimport { DecryptedObject } from './schema';\nimport type { RenovateConfig } from './types';\n\nexport async function tryDecrypt(\n privateKey: string,\n encryptedStr: string,\n repository: string,\n keyName: string,\n): Promise<string | null> {\n let decryptedStr: string | null = null;\n if (privateKey?.startsWith('-----BEGIN PGP PRIVATE KEY BLOCK-----')) {\n const decryptedObjStr =\n process.env.RENOVATE_X_USE_OPENPGP === 'true'\n ? await tryDecryptOpenPgp(privateKey, encryptedStr)\n : await tryDecryptKbPgp(privateKey, encryptedStr);\n if (decryptedObjStr) {\n decryptedStr = validateDecryptedValue(decryptedObjStr, repository);\n }\n } else {\n decryptedStr = tryDecryptPublicKeyDefault(privateKey, encryptedStr);\n if (is.string(decryptedStr)) {\n logger.warn(\n { keyName },\n 'Encrypted value is using deprecated default padding, please change to using PGP encryption.',\n );\n } else {\n decryptedStr = tryDecryptPublicKeyPKCS1(privateKey, encryptedStr);\n /* v8 ignore start: not testable */\n if (is.string(decryptedStr)) {\n logger.warn(\n { keyName },\n 'Encrypted value is using deprecated PKCS1 padding, please change to using PGP encryption.',\n );\n }\n /* v8 ignore stop */\n }\n }\n return decryptedStr;\n}\n\nexport function validateDecryptedValue(\n decryptedObjStr: string,\n repository: string,\n): string | null {\n try {\n const decryptedObj = DecryptedObject.safeParse(decryptedObjStr);\n if (!decryptedObj.success) {\n const error = new Error('config-validation');\n error.validationError = `Could not parse decrypted config.`;\n throw error;\n }\n\n const { o: org, r: repo, v: value } = decryptedObj.data;\n\n if (!is.nonEmptyString(value)) {\n const error = new Error('config-validation');\n error.validationError = `Encrypted value in config is missing a value.`;\n throw error;\n }\n\n if (!is.nonEmptyString(org)) {\n const error = new Error('config-validation');\n error.validationError = `Encrypted value in config is missing a scope.`;\n throw error;\n }\n\n const repositories = [repository.toUpperCase()];\n\n const azureCollection = getAzureCollection();\n if (is.nonEmptyString(azureCollection)) {\n // used for full 'org/project/repo' matching\n repositories.push(`${azureCollection}/${repository}`.toUpperCase());\n // used for org prefix matching without repo\n repositories.push(`${azureCollection}/*/`.toUpperCase());\n }\n\n const orgPrefixes = org\n .split(',')\n .map((o) => o.trim())\n .map((o) => o.toUpperCase())\n .map((o) => ensureTrailingSlash(o));\n\n if (is.nonEmptyString(repo)) {\n const scopedRepos = orgPrefixes.map((orgPrefix) =>\n `${orgPrefix}${repo}`.toUpperCase(),\n );\n for (const rp of repositories) {\n if (scopedRepos.some((r) => r === rp)) {\n return value;\n }\n }\n\n logger.debug(\n { scopedRepos },\n 'Secret is scoped to a different repository',\n );\n const error = new Error('config-validation');\n const scopeString = scopedRepos.join(',');\n error.validationError = `Encrypted secret is scoped to a different repository: \"${scopeString}\".`;\n throw error;\n }\n\n // no scoped repos, only org\n const azcol =\n azureCollection === undefined\n ? undefined\n : ensureTrailingSlash(azureCollection).toUpperCase();\n for (const rp of repositories) {\n if (\n orgPrefixes.some(\n (orgPrefix) => rp.startsWith(orgPrefix) && orgPrefix !== azcol,\n )\n ) {\n return value;\n }\n }\n logger.debug({ orgPrefixes }, 'Secret is scoped to a different org');\n const error = new Error('config-validation');\n const scopeString = orgPrefixes.join(',');\n error.validationError = `Encrypted secret is scoped to a different org: \"${scopeString}\".`;\n throw error;\n } catch (err) {\n logger.warn({ err }, 'Could not parse decrypted string');\n }\n return null;\n}\n\nexport async function decryptConfig(\n config: RenovateConfig,\n repository: string,\n existingPath = '$',\n): Promise<RenovateConfig> {\n logger.trace({ config }, 'decryptConfig()');\n const decryptedConfig = { ...config };\n const privateKey = GlobalConfig.get('privateKey');\n const privateKeyOld = GlobalConfig.get('privateKeyOld');\n for (const [key, val] of Object.entries(config)) {\n if (key === 'encrypted' && is.object(val)) {\n const path = `${existingPath}.${key}`;\n logger.debug({ config: val }, `Found encrypted config in ${path}`);\n\n const encryptedWarning = GlobalConfig.get('encryptedWarning');\n if (is.string(encryptedWarning)) {\n logger.once.warn(encryptedWarning);\n }\n\n if (privateKey) {\n for (const [eKey, eVal] of Object.entries(val)) {\n logger.debug(`Trying to decrypt ${eKey} in ${path}`);\n let decryptedStr = await tryDecrypt(\n privateKey,\n eVal,\n repository,\n eKey,\n );\n if (privateKeyOld && !is.nonEmptyString(decryptedStr)) {\n logger.debug(`Trying to decrypt with old private key`);\n decryptedStr = await tryDecrypt(\n privateKeyOld,\n eVal,\n repository,\n eKey,\n );\n }\n if (!is.nonEmptyString(decryptedStr)) {\n const error = new Error('config-validation');\n error.validationError = `Failed to decrypt field ${eKey}. Please re-encrypt and try again.`;\n throw error;\n }\n logger.debug(`Decrypted ${eKey} in ${path}`);\n if (eKey === 'npmToken') {\n const token = decryptedStr.replace(regEx(/\\n$/), '');\n decryptedConfig[eKey] = token;\n addSecretForSanitizing(token);\n } else {\n decryptedConfig[eKey] = decryptedStr;\n addSecretForSanitizing(decryptedStr);\n }\n }\n } else {\n if (process.env.RENOVATE_X_ENCRYPTED_STRICT === 'true') {\n const error = new Error(CONFIG_VALIDATION);\n error.validationSource = 'config';\n error.validationError = 'Encrypted config unsupported';\n 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.`;\n if (process.env.MEND_HOSTED === 'true') {\n error.validationMessage = `Mend-hosted Renovate Apps no longer support the use of encrypted secrets in Renovate file config (e.g. renovate.json).\nPlease migrate all secrets to the Developer Portal using the web UI available at https://developer.mend.io/\n\nRefer to migration documents here: https://docs.renovatebot.com/mend-hosted/migrating-secrets/`;\n }\n throw error;\n } else {\n logger.error('Found encrypted data but no privateKey');\n }\n }\n delete decryptedConfig.encrypted;\n } else if (is.array(val)) {\n decryptedConfig[key] = [];\n for (const [index, item] of val.entries()) {\n if (is.object(item) && !is.array(item)) {\n const path = `${existingPath}.${key}[${index}]`;\n (decryptedConfig[key] as RenovateConfig[]).push(\n await decryptConfig(item as RenovateConfig, repository, path),\n );\n } else {\n (decryptedConfig[key] as unknown[]).push(item);\n }\n }\n } else if (is.object(val) && key !== 'content') {\n const path = `${existingPath}.${key}`;\n decryptedConfig[key] = await decryptConfig(\n val as RenovateConfig,\n repository,\n path,\n );\n }\n }\n delete decryptedConfig.encrypted;\n logger.trace({ config: decryptedConfig }, 'decryptedConfig');\n return decryptedConfig;\n}\n\nexport function getAzureCollection(): string | undefined {\n const platform = GlobalConfig.get('platform');\n if (platform !== 'azure') {\n return undefined;\n }\n\n const endpoint = GlobalConfig.get('endpoint');\n const endpointUrl = parseUrl(endpoint);\n if (endpointUrl === null) {\n // should not happen\n logger.warn({ endpoint }, 'Unable to parse endpoint for token decryption');\n return undefined;\n }\n\n const azureCollection = trimSlashes(endpointUrl.pathname);\n if (!is.nonEmptyString(azureCollection)) {\n logger.debug({ endpoint }, 'Unable to find azure collection name from URL');\n return undefined;\n }\n\n if (azureCollection.startsWith('tfs/')) {\n // Azure DevOps Server\n return azureCollection.substring(4);\n }\n return azureCollection;\n}\n"]}
@@ -1874,7 +1874,7 @@ const options = [
1874
1874
  type: 'string',
1875
1875
  allowedValues: ['auto', 'fast-forward', 'merge-commit', 'rebase', 'squash'],
1876
1876
  default: 'auto',
1877
- supportedPlatforms: ['azure', 'bitbucket', 'gitea'],
1877
+ supportedPlatforms: ['azure', 'bitbucket', 'gitea', 'github'],
1878
1878
  },
1879
1879
  {
1880
1880
  name: 'automergeComment',