Commit Graph

104 Commits

Author SHA1 Message Date
RahulGautamSingh 9cecb86eca feat(config): add experimental exitCodeForErrors option (#45752)
* feat(config): add experimental exitCodeForErrors option

* feat(config): give unknown-error its own exit code

* docs: restore exit codes 1 and 2 to the table
2026-09-10 11:07:26 +00: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 432bb00cd2 fix(workers/global): enforce allowedHeaders for the admin's own hostRules
For some time, admin configuration for `hostRules[].headers` was
enforced through `allowedHeaders`, but no validation feedback was given
to administrators, as it was silently ignored when `applyHostRule` runs.

To provide visibility to administrators who were setting headers that
were silently being ignored, we can instead provide validation at the
time we set our global host rules.

In a future change, we'll align the behaviour of `allowedHeaders` and
`allowedEnv` to make it so admin-controlled `hostRules` aren't bound by
the `allowedHeaders` flag.

We can also make it clear in the documentation that this is the
behaviour.

Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
2026-09-03 08:01:41 +01:00
Sebastian Poxhofer 16ef1715e9 refactor(linters): add rules for @sindresorhus/is helpers (#45229)
* feat(lint): add renovate/prefer-is-helpers and renovate/prefer-is-object rules

Flag ad-hoc type checks that have @sindresorhus/is equivalents:
- .filter(Boolean) -> .filter(isTruthy)
- typeof x === 'string' -> isString(x)
- x === null || x === undefined -> isNullOrUndefined(x) (and negation)

The typeof x === 'object' shape lives in a separate suggestion-only rule
(renovate/prefer-is-object, kept at warn) because isObject()/isPlainObject()
are not drop-in equivalents: null, arrays and functions behave differently.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: fix renovate/prefer-is-helpers violations

Replace ad-hoc type checks with @sindresorhus/is helpers across lib/:
- 13x .filter(Boolean) -> .filter(isTruthy)
- 36x typeof x ==/!== 'string' -> isString(x) / !isString(x)
- 6x x === null || x === undefined -> isNullOrUndefined(x) (and negation)

Promote renovate/prefer-is-helpers to error now that the codebase is clean.
renovate/prefer-is-object stays at warn: its 15 remaining sites guard
parsed YAML/JSON or unknown values where isObject()/isPlainObject() are
not provably equivalent (null/array/function semantics).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor: enforce renovate/prefer-is-object at error level

Resolve the 15 remaining warnings and raise the rule from warn to error:

- Migrate 10 sites to isObject() where the guarded value provably cannot
  be a function (parsed YAML/JSON, typed exec command arguments, or
  test-controlled fixtures): helm-values, woodpecker, bun, pre-commit
  managers, exec utils, file package cache, and the github http spec.
  In the bun manager this also fixes a latent crash where a null
  `workspaces` value would throw on the `in` operator.
- Keep 5 sites as reasoned oxlint-disable comments where excluding
  functions is load-bearing: the byte-exact fingerprint canonicalizer
  (2), the circularity walker, the zod result guard, and the generic
  hasKey helper.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-13 14:22:03 +00:00
Jamie Tanna 244bfe15a7 fix(workers/global): sanitise COREPACK_NPM_{TOKEN,PASSWORD} in logs (#45116)
As we weren't previously doing so.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-08-06 14:04:31 +00:00
Jamie Tanna 0e6429b13e refactor(types): document localDir isn't a globalOnly option (#44635)
* refactor(types): document `localDir` isn't a `globalOnly` option

To make sure that it's clear when reviewing `GlobalConfig`, as well as
working with our types, we can move the `localDir` definition into a
separate type.

* fixup! refactor(types): document `localDir` isn't a `globalOnly` option

* fixup! refactor(types): document `localDir` isn't a `globalOnly` option

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

* fixup! refactor(types): document `localDir` isn't a `globalOnly` option

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

* fixup! refactor(types): document `localDir` isn't a `globalOnly` option

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>

---------

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-07-20 08:07:17 +00:00
Felipe Santos 523bf29be8 fix: not applying global options in object entries in repositories array (#43295)
* fix: not applying global options in object entries in `repositories` array

* Use isNonEmptyObject

* Add test for per-repo override

* Use AllConfig instead
2026-06-19 14:55:52 +00:00
Jamie Tanna ff6761ed23 fix(config/global): return default values for GlobalConfig.get (#42113)
* fix(config/global): return default values for `GlobalConfig.get`

As noted in #39949, it can be awkward working with in `GlobalConfig.get`, where
we would previously need to specify the default value when calling `.get`,
which could lead to drift with the defaults for a given config option.

To reduce this risk, we can rely on a given `default` for a configuration
option, providing that as a default.

Because this now definitely returns a value that matches the config option, it
now allows us to remove `!` assertions.

* fixup! fix(config/global): return default values for `GlobalConfig.get`

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

* fixup! fix(config/global): return default values for `GlobalConfig.get`

* test(presets): remove impossible test

As it's now not possible to set a value as `undefined` (as
`GlobalConfig` will then use the default), this test no longer validates
anything.

* test(workers/repository): add mock

Now `platform` defaults to `github`, we need to mock out the call to
fetch config.

Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>

* test: coverage

* test: coverage

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
2026-05-15 17:10:38 +00:00
renovate[bot] 766db6fc6f build(deps): update dependency upath to v3 (main) (#43121)
* build(deps): update dependency upath to v3

| datasource | package | from  | to    |
| ---------- | ------- | ----- | ----- |
| npm        | upath   | 2.0.1 | 3.0.7 |

* chore: fix types

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2026-05-06 12:09:33 +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
Michael Kriese 50d8f010b4 fix: log renovate version on startup (#41346) 2026-02-20 09:13:05 +00:00
Felipe Santos 530d2efc3c fix(config): presets in repositories array are merged in wrong order (#40898)
* fix(config): presets in repositories array are merged in wrong order

* Simplify test to a single match
2026-02-19 17:55:04 +00:00
Sergei Zharinov 2b0e80b884 feat!: Switch to ESM modules (#40756) 2026-01-29 14:21:41 +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 1fc78a0326 fix(instrumentation): use Semantic Conventions for repository span (#39609)
As part of ongoing work to improve OpenTelemetry instrumentation of
Renovate in #38609, we can improve our repository instrumentation by
using Semantic Convention attributes for the platform, repo and owner.
2025-11-28 13:31:48 +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 5adb95593f feat(config): variables (#35350) 2025-07-06 07:24:33 +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
Claude Muller 22fc1acb26 fix(config): merge globalExtends before default config (#35521)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2025-05-05 09:46:24 +00:00
Michael Kriese a910126752 fix(worker): init user agent early (#35364) 2025-04-14 12:16:52 +00:00
RahulGautamSingh f2acf6a9a2 refactor(logger): remove templating from FATAL logs (#33490) 2025-01-10 11:15:01 +00:00
Gabriel-Ladzaretti 0a60dc1d53 feat: apply ignorePresets when resolving the globalExtends array (#32845) 2024-12-02 14:31:50 +00:00
Michael Kriese 42b448b0e5 feat(logger): prefix log env settings with RENOVATE_ (#32499)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-11-13 17:58:19 +00:00
Michael Kriese 09824b1bef build!: require node v20 (#30291) 2024-07-25 15:28:16 +02:00
Rhys Arkins e3175a3557 fix(config)!: globalExtends merge order (#28145)
Previously, config from globalExtends was incorrectly merged _after_ other global config. This meant for example that packageRules in a config.js could not override packageRules from within globalExtends, because they were applied after. Now, globalExtends content will be merged first, and remaining global config merged second.

Fixes #28131

BREAKING CHANGE: order of globalExtends resolution is changed so that it is applied first and remaining global config takes precedence.
2024-07-25 15:28:16 +02:00
RahulGautamSingh 03f5c5cb98 feat: remove RENOVATE_X_IGNORE_NODE_WARN (#29835) 2024-06-25 12:00:44 +00:00
Michael Kriese 842f205c20 fix(worker/global): apply allowedHeaders again (#29281) 2024-05-27 13:58:30 +00:00
RahulGautamSingh c441c84151 fix: set allowedHeaders to GlobalConfig before initPlatform is invoked (#28228) 2024-04-04 20:29:36 +00:00
Rhys Arkins dffa7b5f06 fix(config): RENOVATE_X_EAGER_GLOBAL_EXTENDS (#28144) 2024-03-26 16:53:10 +00:00
Sebastian Poxhofer 370927fa3b feat(instrumentation/report): add problems to reports (#28042)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2024-03-20 16:44:19 +00:00
Rhys Arkins e500e5048d feat(config): expose topLevelOrg, templateOrg to templates (#27997) 2024-03-18 19:42:30 +00:00
Sebastian Poxhofer 481aa216b2 feat(instrumentation/reporting): add report option (#26087)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-03-17 09:22:42 +00:00
Sergei Zharinov c30a4b0b54 feat(logger): Log level remapping (#26951)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-02-16 20:06:11 +00:00
Rhys Arkins 030c65788d chore(logs): mention debug logging on exit if info level set (#27350) 2024-02-16 16:43:22 +00:00
Sergei Zharinov b06af6600b refactor(regex): Inverse dependency on logger util (#26997) 2024-02-01 18:45:55 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Rhys Arkins 36e2b328bb chore: update types reference 2023-08-15 11:31:15 +02:00
Rhys Arkins 93052ec917 feat: platform=local (#22010)
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
2023-05-10 04:30:12 +00:00
Rhys Arkins ceaa005ac1 feat: deprecate Node.js 16 for Renovate runtime (#20088)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-01-30 08:24:12 +00:00
Michael Kriese 39b23d64fe feat: better sanitize (#19646) 2023-01-03 12:29:07 +00:00
RahulGautamSingh af3b2038f8 refactor: replace enums with union/object (#18903) 2022-11-14 20:55:38 +02:00
Sergei Zharinov b2d18d1110 feat(http): maxRequestsPerSecond (#18325) 2022-10-25 11:03:19 +00:00
Sebastian Poxhofer b53c581e5c feat(telemetry): add OpenTelemetry tracing MVC (#15731) 2022-10-23 06:48:35 +02:00
Michael Kriese 8ad1947e4a fix(http): clear queues after hostrules change (#17563) 2022-09-01 09:36:04 +02:00
Michael Kriese 8270d5512d refactor: fix lint issues (#16779)
* refactor: fix lint issues

* Update lib/renovate.ts

* chore: revert toplevel await for ts
2022-07-26 08:32:12 +00:00
renovate[bot] 0ed7072a1f chore(deps): update dependency type-fest to v2.16.0 (#16473)
* chore(deps): update dependency type-fest to v2.16.0

* chore: fix type issues

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-07-15 10:09:50 +00:00
Sergei Zharinov bfc393ef00 refactor(fs): Don't proxy writeFile function (#16310)
* refactor(fs): Don't proxy `writeFile` function

* Fix

* Update lib/workers/global/index.spec.ts

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-06-29 06:23:36 +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
Sergei Zharinov 0cf4f48842 refactor: Strict null checks for all files except tests (#16071)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-06-20 11:47:07 +02:00