Commit Graph

68 Commits

Author SHA1 Message Date
Jamie Tanna acb46bc706 fix(config): surface blocked hosts more clearly when resolving config
With the new hardening on blocking internal hosts with outbound HTTP
calls, we should build on top of this to ensure that the UX is better
when a preset is blocked.

We can do this by making sure that when `HOST_BLOCKED`, we report a more
targeted config validation error.

We can also make sure to pass around our `internalGrants`, similar to
how we currently allow an admin's `headers` are handled.

Co-authored-by: Claude Fable 5 <jamie.tanna+claude-code@mend.io>
Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
2026-09-10 14:52:01 +01:00
Jamie Tanna 4732da7d2b fix(util/host-rules): apply the admin's headers over a repository's
As part of changes we've recently made to the merging of
`hostRules[].headers`, it highlighted that a repository - or a preset
it extends - could lead to a header an admin has configured for one host
to be sent to another.

This happened due to the way we additively merged i.e.
`Object.assign({}, ...matchedHeaders)`.

This doesn't require the repository to know a credential is being
set (for a specific host), or to act maliciously - any header of their
own for that host is enough to bring the administrator's masked one
back, with nothing logged or failing to show it happened.

To fix this, we can:

- apply admin headers last, as they are "trusted"
- stop repositories from being able to unset an admin-set header
- retain the existing logic for the "most specific rule" being used
- make sure that `trusted` isn't a field that could be injected by a
  repository, and make sure we explicitly only set it where we know
  we're using self-hosted administrator config
- make `filterAllowedHeaders` drop `headers` if every header name was
  denied, so `{}` isn't returned and used to suppress headers when
  merged

Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
2026-09-03 08:01:41 +01:00
Jamie Tanna c98f4f71c8 fix(util/host-rules): enforce allowedHeaders within add()
We previously enforced `allowedHeaders` by making sure that each
`hostRules.add()` call had `filterAllowedHeaders`.

This isn't super future proofed, and although we could add a linting
rule, we should instead enforce this by making sure that
`hostRules.add()` applies the filtering.

This also catches cases like host rules from `.npmrc` which wasn't
currently being filtered - albeit there was no means to bypass
`allowedHeaders`.

Moving `filterAllowedHeaders` into `lib/util` removes a dependency from
the global bootstrap and `config-validator` importing from
`lib/workers/repository/init/`.

While doing so, we can also make sure that:

- we log only one WARN for global `hostRules` being invalid, rather than
  once per `repositories[]`
- `renovate-config-validator` validates a global config file's
  `hostRules` against that file's own `allowedHeaders`, like a real run
  would after parsing it

Co-authored-by: Claude Fable 5 <jamie.tanna+claude-code@mend.io>
2026-09-03 08:01:41 +01:00
Jamie Tanna 2382888bc7 fix(workers/repository): validate resolved presets
As a further level of defence-in-depth for fixes on top of `allowedEnv`
and `allowedHeaders` enforcement, we can also make sure that we're
performing full config validation for the resolved configuration.

This allows us to report any configuration errors/warnings when we
include the full resolved configuration, without necessarily blocking
the full Renovate run, unless using `configValidationError`.

Co-authored-by: Claude Opus 4.8 <jamie.tanna+claude-code@mend.io>
Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
2026-09-03 08:01:41 +01:00
Jamie Tanna 223e6efd4e fix(config): enforce allowedHeaders when applying headers
As an additional defence-in-depth, we can make sure that when applying
the `headers` configuration (from repo config, or presets) we
re-validate it.

We allow any admin-supplied configuration regardless, and then any
user-supplied settings are re-filtered according to `allowedHeaders`.

Due to the existing way that header merging incorrectly merges the repo
(or preset) `headers` over the admin config, we don't currently handle
this explicitly, unlike `filterAllowedEnv`.

If a user-supplied setting is filtered, we log a WARN message to inform
the user - and the admin - that this is ignored.

At this point, we don't try and explain which preset(s) this may have
come from, only that there is an issue.

Co-authored-by: Claude Opus 4.8 <jamie.tanna+claude-code@mend.io>
Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
2026-09-03 08:01:41 +01:00
Jamie Tanna 6b2b607080 fix(config): enforce allowedEnv when applying env vars
As an additional defence-in-depth, we can make sure that when applying
the `env` configuration (from repo config, or presets) we re-validate
it.

We allow any admin-supplied configuration regardless, and then any
user-supplied settings are re-filtered according to `allowedEnv`.

If a user-supplied setting is filtered, we log a WARN message to inform
the user - and the admin - that this is ignored.

At this point, we don't try and explain which preset(s) this may have
come from, only that there is an issue.

Co-authored-by: Claude Opus 4.8 <jamie.tanna+claude-code@mend.io>
Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
2026-09-03 08:01:41 +01:00
Sebastian Poxhofer 9717259ffc refactor(oxlint): enable no-else-return and unicorn/no-lonely-if (#44553)
Enable no-else-return (with allowElseIf: false) and unicorn/no-lonely-if
as errors in .oxlintrc.json and fix all 131 pre-existing violations
(91 no-else-return, 40 unicorn/no-lonely-if) across 98 files.

The no-else-return violations were fixed with the oxlint autofix
(iterated to a fixpoint, plus two else-if chains that required
--fix-dangerously) followed by Prettier formatting. One comment dropped
by the autofix in lib/modules/manager/pub/artifacts.ts was restored
manually. The unicorn/no-lonely-if violations were merged by hand,
preserving comments and coverage-ignore hints.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 12:11:21 +00:00
Jamie Tanna 032a5cb289 feat(presets): log the resolved configuration (without internal presets) (#39314)
As noted in #15827, it would be useful to log the "shallow"
configuration for a given repository - that is, the resolved
configuration, but without any Renovate internal presets being included.

This will be very useful for debugging, as it shows the final resulting
configuration, but without the - often very - verbose internal presets.

In the case that only this log line is shared, we can make sure to
reference the version of the Renovate CLI in the log line.

This requires building on top of changes in
6a4fa3f245 to be able to return a `merged`
and `unmerged` list of presets, and uses helpers from
c8f42e86b4, and
66b84dd12b to process the internal presets
accordingly.

Since we first worked on this, we've worked on improvements to caching
which should provide a require no additional performance overhead
performing this resolution twice.

This can also lead to being able to understand more clearly how Renovate
configuration is being used[0], as we have the final resolved configuration.

We want to make sure we don't try and merge or visit any internal
presets if we're not going to merge them, so we can avoid verbose
`config` or `visitedPresets` results.

[0]: https://www.jvt.me/posts/2024/04/14/renovate-config-sql/
2026-05-11 10:46:55 +00:00
Felipe Santos b24b88bfd8 fix(config): resolve repository entry presets in correct order (#41477)
* fix(config): resolve repository entry presets in correct order

* refactor: extract `applyHostRules` and `applyNpmrc` to functions

* Reuse applyHostRules in inherited.ts

* Fix test failure

* Improve resolvedRepoEntry log

* Coerce everything

* Fix another test coverage issue
2026-04-20 21:50:32 +00:00
RahulGautamSingh 36f9d4a185 refactor: move requireConfig to InheritConfig (#41385)
* refactor: move requireConfig to InheritConfig

* fix test

* update test

* refactor
2026-04-14 11:53:53 +00:00
Felipe Santos e7f55d7e42 refactor: extract applyHostRules and applyNpmrc to functions (#41528)
* refactor: extract `applyHostRules` and `applyNpmrc` to functions

* Reuse applyHostRules in inherited.ts

* Restore original log message for npmrc

* Simplify applyNpmrc log context handling

* Remove redundant config word

* Apply Jamie's suggestion

* Restore log messages again

* Revert "Restore log messages again"

This reverts commit 7a67c5d3a4.

* chore: re-add log line

---------

Co-authored-by: Jamie Tanna <jamie.tanna@mend.io>
2026-03-31 18:03:44 +00:00
RahulGautamSingh d1fa243a08 refactor: move onboardingConfigFileName to InheritConfig (#41383)
* refactor: move onboardingConfigFilenName to InheritConfig

* fix test

* fix type

* update fn
2026-02-26 20:29:53 +00:00
Sergei Zharinov 930cf6633c refactor: Rewrite imports with .ts extensions (#40700)
fix: Additional vi.mock path corrections and prettier formatting
2026-01-26 22:48:17 +00:00
Jamie Tanna 6a4fa3f245 refactor(presets): return merged presets from resolveConfigPresets (#40422)
As part of future changes, we want to log the shallow configuration (the
full resolved configuration, but without any internal Renovate
configuration presets), where we'll want to note which presets have not
been merged in.

Before that, we can start with an initial refactor to indicate which
have been merged, and return them.
2026-01-14 16:52:16 +00:00
RahulGautamSingh 76f911041a refactor: use named exports (#39196)
* use named exports

* fix test

* add missing imnport

* fix prettier
2025-11-10 12:00:35 +00:00
RahulGautamSingh a86b32ea0f feat: configurable repo config filenames (#36644)
* feat: configurable repo config filenames

* docs: configFileNames

* fix tests

* update tests

* fix coverage

* Apply Suggestions

* refactor: remove platform-based filename filtering

* docs

* refactor

* docs: add note for config-validator use

* feat: add inherited config support

* fix: build

* fix lint

* fix test
2025-10-20 06:19:01 +00:00
Gabriel-Ladzaretti 9adf6b7e94 fix(static-config): attempt migration before aborting (#37456) 2025-08-13 05:52:17 +00:00
Gabriel-Ladzaretti 3b72c7b6fe feat: replace env based static repo config with file based support (#37115)
Co-authored-by: Nabeel Saabna <48175656+nabeelsaabna@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2025-08-07 09:56:31 +00:00
RahulGautamSingh 5adb95593f feat(config): variables (#35350) 2025-07-06 07:24:33 +00:00
RahulGautamSingh 6ca2520d66 refactor: deduplicate common function (#36641) 2025-06-22 14:36:09 +00:00
Nabeel Saabna c2d3401afe fix: static repo config order and merge extends (#36179) 2025-05-27 05:03:11 +00:00
RahulGautamSingh b06ef83e9a refactor(workers): enhance some fns (#35941) 2025-05-17 11:09:39 +00:00
RahulGautamSingh 49fa1be464 feat(util): getEnv (#35161)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-05-06 18:37:28 +00:00
RahulGautamSingh 80b7cdf1e0 refactor(util): move user env to util folder (#35103) 2025-04-02 10:27:27 +00:00
renovate[bot] 94c073ab6b chore(deps): update linters (main) (#34869)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: secustor <sebastian@poxhofer.at>
2025-03-23 17:57:04 +00:00
Gabriel-Ladzaretti 718e19717b fix: append the static repo config to the repo config (#34313) 2025-02-21 13:10:22 +00:00
RahulGautamSingh 2194c226b4 fix(config): set npmToken in npmrc when not in encrypted (#31815) 2024-11-08 08:15:53 +00:00
renovate[bot] eb8c08079e chore(deps): update typescript-eslint monorepo to v8 (major) (#30750)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-08-14 10:33:02 +00:00
Rhys Arkins 654c447e6e feat: mode=silent (#28396) 2024-05-06 11:40:54 +00:00
Rhys Arkins cda68de084 refactor: config file parsing (#27863) 2024-03-12 07:37:59 +00:00
Rhys Arkins 0cab01b14e fix(config): log warning if package.json used (#26893) 2024-01-29 11:32:36 +00:00
Rhys Arkins 535c7ae1a1 refactor: fetch raw config from within config migration (#26891) 2024-01-28 13:36:06 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
RahulGautamSingh 4231b1ae09 feat: predictible json/json5 handling (#24612)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-11-06 10:30:11 +00:00
RahulGautamSingh 32340dbc47 feat(config): validate reconfigure branch (#24699)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-11-03 13:31:49 +00:00
Philip bece5a1c50 refactor(errors): massaging validation messages before we assign it (#25452)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-10-31 13:46:55 +00:00
Rhys Arkins 36e2b328bb chore: update types reference 2023-08-15 11:31:15 +02:00
Rhys Arkins 4bee881f6c refactor: less config logging (#23308) 2023-07-12 05:18:52 +00:00
RahulGautamSingh fa6e5df805 feat(onboarding): skip processing onboarding branch (#22490)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-06-21 10:55:57 +00:00
Rhys Arkins 9276a54069 refactor(scm): use scm for getFileList, checkoutBranch (#22006) 2023-05-07 04:12:15 +00:00
RahulGautamSingh bccf0997fb refactor: delete cached configFilename (#20746) 2023-03-07 10:09:04 +00:00
Sergei Zharinov b2d18d1110 feat(http): maxRequestsPerSecond (#18325) 2022-10-25 11:03:19 +00:00
Philip 03aea02302 fix(presets): support ignorePresets in global config (#18026) 2022-10-13 12:21:00 +03:00
Michael Kriese 8ad1947e4a fix(http): clear queues after hostrules change (#17563) 2022-09-01 09:36:04 +02:00
Gabriel-Ladzaretti 1b8fd393dc refactor(repo/init): return additional raw config from detectRepoFileConfig (#17021)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2022-08-19 00:08:13 +03:00
Gabriel-Ladzaretti 1c429f6037 refactor(repository/merge): extract unnecessarily nested function from detectConfigFile (#17066)
extract unnecessary nested function from `detectConfigFile`

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-08-09 16:43:58 +00:00
Michael Kriese e5c6f38d75 refactor: enable strict checks (#16168)
* refactor:  enable strict checks

* chore: revert changes

* chore: fix tsconfig
2022-06-21 13:00:21 +02:00
Michael Kriese 0a582d31c7 refactor: fix nullable types (#16156)
* refactor: fix nullable types

* chore: revert changes

* chore: fix lint comments

* chore: revert changes
2022-06-20 16:15:40 +00:00
Brad Jorsch ef41262f17 fix: resolve repoConfig.packageRules.extends with repo config (#14978) 2022-06-13 14:19:44 +00:00
Maron 0cf2ab4823 feat: refactor requireConfig option (#15594) 2022-05-18 10:21:51 +00:00