Commit Graph

59 Commits

Author SHA1 Message Date
Jamie Tanna 29a7b9c5f5 fix(util/http): allow blocking requests to internal hosts
To harden Renovate from being able to access internal hosts, we can add
a level of enforcement on all outgoing requests.

We can split this into two types of traffic:

- where the response becomes configuration (i.e. `extends`)
- where the response does not become configuration (i.e.
  `customDatasources`)

To harden this, we enforce on every outbound HTTP request:

- check the resolved URL before anything, including cache lookups, can
  proceed
  - catching IP-literal hosts in every spelling the WHATWG URL parser normalizes
  - blocking known Cloud metadata IPs, too
- a `dnsLookup` wrapper validates every address a hostname resolves to,
  on every new connection, which also defeats DNS rebinding
- a `beforeRedirect` hook re-runs the URL check on each redirect
  target, with the new host getting its own grant lookup rather than
  inheriting the original host's verdict

We default this enforcement to `warn`, to not break existing deployments
and instead give them visibility into required configuration before a
future major version (major+1) enables `block` by default.

We'll also remove allow in a future major version (major+2), to give
time for admins to migrate over.

When a request is blocked, this degrades like an unreachable registry,
so a Renovate run isn't aborted by a blocked request.

As part of this, we can also provide a worked example of the different
cases that do/do not need allowing via `hostRules`.

Requests through an admin-configured proxy resolve DNS at the proxy, so
`dnsLookup` never runs for them, so we can resolve the hostname locally
and validate every address before the request instead.

This doesn't catch everything, especially as the proxy may resolve the
name to a different result, and if we can't resolve the name - possible
in locked-down corporate environments - we fail open.

Child processes aren't currently able to route traffic through
Renovate's HTTP layer, so are unrestricted.

Co-authored-by: Claude Fable 5 <jamie.tanna+claude-code@mend.io>
Co-authored-by: Claude Opus 5 <jamie.tanna+claude-code@mend.io>
Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-09-10 14:52:01 +01:00
Sergei Zharinov 3e15fc29ed fix(datasource): isolate release lookups by registry configuration (#45738)
* fix(datasource): include default and additional registries in cache key

* fix(datasource): avoid mutating cached releases when merging registries
2026-09-07 13:07:50 +00:00
Sebastian Poxhofer 97327c3d28 refactor(linters): add prefer-coerce-array rule (#45492)
* refactor(linters): add prefer-coerce-array rule

Refs #45217

`x ?? []` and `coerceArray(x)` say the same thing, but only the second
one is searchable and consistent. The rule flags a `??` whose default is
a bare `[]` literal; a non-empty default or an asserted `([] as Foo[])`
still passes.

Applying it across `lib/` surfaced three spots the helper cannot cover,
which keep `?? []` with a disable comment or a narrower fix:

- `package-files.ts` destructures a tuple, which `coerceArray()` widens
- `generate.spec.ts` defaults `matchAll()`, an iterator rather than an array
- `mise/upgradeable-tooling.ts` declares a `Record` return, so its
  `?? []` fallback was wrong to begin with and becomes `coerceObject()`

* refactor(platform/github): hoist the GHE version header lookup

`Object.entries(...).find()` returns a tuple, and defaulting it with
`?? []` only to destructure the second element reads as an array
default when it is not one. Name the found entry instead, which drops
the `?? []` rather than routing a tuple through `coerceArray()`.
2026-08-28 09:27:58 +00:00
RahulGautamSingh 37444eff27 fix(datasource): keep merged releases when a registry is rate-limited (#45299)
* fix(datasource): keep merged releases when a registry is rate-limited

* apply suggestions
2026-08-18 09:21:54 +00: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
Sebastian Poxhofer 58771bb183 refactor(linters): enabled oxlints func-style (#44691)
* refactor(oxlint): enable func-style

Enable the built-in func-style rule as ["warn", "declaration"] so that
named functions are written as function declarations instead of arrow or
function expressions assigned to variables, matching the convention in
docs/development/best-practices.md (Functions section). Inline arrow
callbacks are unaffected; prefer-arrow-callback continues to cover the
callback direction.

Severity is "warn" instead of "error" as a fallback: a repo-wide run
found 196 pre-existing violations (70 in spec files, 126 in production
code), exceeding the 80-violation fix threshold for this change, so no
violations were fixed here. Follow-up work can convert the offenders
(largest clusters: lib/modules/versioning/ruby, lib/util/cache/package,
lib/modules/versioning/maven, lib/modules/versioning/gradle) and then
raise the rule to "error". Note oxlint 1.72 also supports an
allowTypeAnnotation option if typed consts should remain arrows.

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

* ci(linter): enforce func-style at error

* refactor(func-style): convert const-arrow functions to declarations in with-cache spec and ruby versioning

* refactor(func-style): convert const-arrow functions to declarations in maven/gradle modules

* refactor(func-style): convert const-arrow functions to declarations in remaining versioning modules

* refactor(func-style): convert const-arrow functions to declarations in platform modules

Discriminated-union closures (ensureCommentRemoval byTopic/byContent
helpers in github, gitlab, bitbucket, bitbucket-server) needed the
narrowed field passed explicitly as a parameter, since function
declarations are hoisted and lose the outer if-narrowing that inline
arrow-function closures previously relied on.

* refactor(func-style): convert const-arrow functions to declarations across util/manager/datasource modules

One case (logger/renovate-logger.ts logOnceFn) is kept as an arrow
function with a documented oxlint-disable: it is stored on
this.logger.once[level] and relies on lexically-bound this, which a
hoisted function declaration would not preserve.

* refactor(func-style): convert remaining const-arrow test helpers to declarations

get-updated.spec.ts: hoisted expectPipCompilePackageAndLockFile to
module scope (it only closes over the module-level pipCompile mock)
and added a documented oxlint-disable for vitest/expect-expect on its
caller test, since oxlint's expect-expect check does not trace
assertions through an externally-defined helper function.

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-19 11:14:22 +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
Mike Ryan f635ae29c4 chore(instrumentation): add timing statistics for getReleases (#42523)
* feat: timing statistics for getReleases

Adds collection and reporting of timing statistics for
`datasource.getReleases()` calls. Each call records the datasource, registryUrl,
packageName, and duration. The intent is to visibility into where
renovate is retrieving release information and how long that might take.

The report consists of a nested data-structure that provides increasing
detail as we descend datasource, registryUrl, and packageName.

The full report  is logged at trace level
`getReleases statistics with packages`.

A summary report including only datasources and registryUrls is logged
at debug level `getReleases statistics summary`.

* add GetReleasesSpanProcessor

- Re-instrument getReleases calls using open telemetry.
- Adds GetReleasesSpanProcessor, which can adapt
  `getReleases` spans to GetReleasesStats.

* fixup instrumentation tests

* pr feedback

* pr feedback: naming

* pr feedback: comments
2026-04-14 17:36:37 +00:00
Sergei Zharinov 9d857c1f68 refactor(lint): Organize imports with biome (#40966) 2026-02-06 13:40:01 +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
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
Sergei Zharinov 05d42780ad fix(cache): Make TTL overrides work for all namespaces (#36903)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2025-07-16 11:40:48 +00:00
Sergei Zharinov 3601bd02e5 fix: Force centralized datasource cache via cachePrivatePackages (#36990) 2025-07-15 06:13:59 +00:00
Sergei Zharinov 916044e8a8 feat: Implement cacheTtlOverride for datasource index cache (#36842) 2025-07-10 06:40:41 +00:00
Sergei Zharinov a6891591b1 fix(datasource): Force central cache via cachePrivatePackages (#36925) 2025-07-09 11:59:15 +00:00
Sergei Zharinov 24f51381bc feat(cache): Clean datasource memory cache after fetch (#35713) 2025-05-06 11:28:04 +00:00
renovate[bot] 86408be681 build(deps): update dependency @sindresorhus/is to v7 (main) (#35682)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2025-05-02 09:43:35 +00:00
Rhys Arkins 70fb88459b feat(datasource/maven)!: use latest and release values as tags (#35515)
Adds support for `latest` and `release` tags in Maven datasource. This means that Renovate will no longer upgrade past the `latest` version in Maven unless `respectLatest` is explicitly configured to `false`.

BREAKING CHANGE: Renovate will now enforce `latest` version for Maven upgrades
2025-04-30 10:51:58 +02:00
Trim21 fb3f86f5df feat: allow manager to set registryStrategy for a package (#35080) 2025-03-31 11:55:59 +00:00
RahulGautamSingh 0d23707604 refactor(logger): remove templating from WARN log messages (#33488) 2025-01-14 13:03:05 +00:00
Sergei Zharinov 1056d1af8e refactor(datasource): Simplify merge registry logic (#31430) 2024-09-18 05:54:47 +00:00
Sergei Zharinov 7229d962f7 feat: Stats for datasource cache (#30623) 2024-08-11 08:07:16 +00:00
renovate[bot] be0bd3d63e build(deps): update dependency prettier to v3.3.3 (#30272)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-07-20 16:51:43 +00:00
Sergei Zharinov 4aca7294b4 feat: Support cachePrivatePackages option for datasource index level (#30120) 2024-07-12 18:56:25 +00:00
Rhys Arkins d5f3d6fcea fix(datasource/docker): better reuse of lookupName for getDigest (#27724) 2024-03-05 15:02:51 +01:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Rhys Arkins 42b3a7c046 feat: versionCompatibility (#24717) 2023-10-02 09:55:01 +00:00
Michael Kriese a9dc0625cf fix: better branch code coverage (#24270) 2023-09-06 11:26:22 +00:00
Sergei Zharinov 17bf7d7ed9 refactor: Reuse datasource filtering (#23716) 2023-08-07 20:02:57 +00:00
Sergei Zharinov 8c0013f1fc fix(util/result): Types for wrapNullable (#23713) 2023-08-04 15:00:11 +00:00
Sergei Zharinov f2f6c17227 refactor(datasource): Extract getRawPkgReleases from getPkgReleases (#23712) 2023-08-04 13:39:12 +00:00
Sergei Zharinov 45328c57b6 refactor: Extract datasource result filters to separate file (#23587) 2023-07-28 08:09:41 +00:00
Sebastian Poxhofer f26d21fcc3 feat(datasource): implement custom datasource (#23147) 2023-07-10 18:22:35 +00:00
Sergei Zharinov 8f39f500cb refactor: Don't restrict error type for Result<T, E> (#23265) 2023-07-10 09:41:38 +00:00
Sergei Zharinov 76cacd5953 refactor: Extract ReleaseResult filtering functions (#23253) 2023-07-09 05:41:16 +00:00
Sergei Zharinov 8af5ca0a47 refactor: Rename getPkgReleasesWithResult to getPkgReleasesSafe (#23211) 2023-07-06 12:00:45 +00:00
Sebastian Poxhofer 8ccb0eaae2 feat(datasource)!: default to the central default versioning (#23020)
BREAKING CHANGE: semver-coerced is now the default versioning
2023-07-04 19:21:52 +02:00
Rhys Arkins ad0479a11b feat(npm): support constraintsFiltering=strict (#22447)
Closes #4826

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
2023-07-04 19:21:52 +02:00
Sergei Zharinov e27424c833 refactor(datasource): Use Result utility class for lookups (#23067) 2023-06-30 17:46:51 +00:00
Rhys Arkins 930fc9fa6f refactor: don't throw errors from datasource package releases lookup (#23058) 2023-06-30 12:29:26 +00:00
Sergei Zharinov ef6f0c7ffa feat: Use klona library for deep clone (#22979) 2023-06-26 17:21:29 +00:00
Sergei Zharinov 228c6bfa32 refactor: Extract uniq utility function (#22968) 2023-06-25 17:15:00 +00:00
Adam Setch 787d623282 refactor: add export to getDatasourceFor function (#22872) 2023-06-19 10:16:33 +00:00
Lctrs 2e25de1211 feat(datasource): support range constraints filtering (#20842)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2023-03-15 06:12:08 +00:00
Rhys Arkins b17bcf2789 refactor(datasource): use packageName and not depName for datasource lookups (#20474) 2023-03-10 09:34:40 +01:00
RahulGautamSingh dcd298a625 feat(config)!: add new option constraintsFiltering (#19992)
Adds new option `constraintsFiltering`.

Closes #19979

BREAKING CHANGE: PyPI releases will no longer be filtered by default based on `constraints.python` compatibility. To retain existing functionality, set
`constraintsFiltering=strict`.
2023-03-10 09:24:44 +01:00
Henrik Poulsen d5ece8bf45 fix(datasource): add warning when unable to find datasource (#20805)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2023-03-08 11:25:00 +00:00
Gabriel-Ladzaretti 66159ac549 feat(repo/lookup): log registry urls used at the lookup phase (#19332) 2022-12-12 10:23:03 +02:00
renovate[bot] d941ef31c5 chore(deps): update dependency type-fest to v3 (#18429)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
2022-10-20 17:34:35 +00:00
t-kulmburg e14f09d75b feat(replacement): datasource changes (#17881)
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-09-27 13:19:18 +00:00