Commit Graph

56 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
renovate[bot] 2561284dc4 build(deps): update dependency got to v15 (main) (#43120)
* build(deps): update dependency got to v15

| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | got     | 14.6.6 | 15.0.5 |

* chore: adapt code to breaking changes

* test: fix test

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: secustor <sebastian@poxhofer.at>
Co-authored-by: Michael Kriese <michael.kriese@mend.io>
2026-09-09 09:01:11 +00:00
Felipe Santos 392105b7c6 chore(oxlint): enable unicorn plugin and prefer-node-protocol (#43283)
chore(oxlint): enable unicorn plugin and prefer-node-protocol
2026-05-29 06:55:58 +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
Sergei Zharinov b8809cedb5 fix(http): fallback to github hostType for GHE platform endpoint (#42287)
* fix(http): fallback to github hostType for GHE platform endpoint

When running against GitHub Enterprise Server, datasources not listed
in GITHUB_API_USING_HOST_TYPES (e.g. github-digest) fail to authenticate
because the existing fallback only covers api.github.com URLs.

This adds a host-matching fallback: when the active platform is github
and the request URL targets the same host as the configured endpoint,
credentials from the github hostType rule are applied.

* Refactor

* Fix
2026-03-31 17:07:43 +00:00
renovate[bot] 00aeb9d8dc build(deps): update dependency got to v12 (main) (#41284)
* build(deps): update dependency got to v12

| datasource | package | from   | to     |
| ---------- | ------- | ------ | ------ |
| npm        | got     | 11.8.6 | 12.6.1 |

* fix: migration

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2026-02-18 16:08:12 +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
Cyrille a8ee6648c0 fix(forgejo): support fallback for all forgejo-* host types (#39968)
* fix: support fallback for forgejo-* host types

* Sort imports

* Reorganize code to lexicographical order
2025-12-16 20:28:24 +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
Jamie Tanna f84305d7bf feat(hostRules): auto-wire a hostRule for api.github.com (#38733)
feat(hostRules): automagically use host rules for any `api.github.com` lookups

As noted in #38732, the Typst datasource performs API calls to the
GitHub APIs, but as we do not have explicit datasource mapping for the
API calls (via `GITHUB_API_USING_HOST_TYPES`), we end up sending
unauthenticated API calls, which then can result in rate limits.

We had previously attempted to fix this in #30490, for a different
datasource, and there are likely other datasources impacted.

To simplify this, we can auto-wire any `https://api.github.com/` API
calls with the `hostType: github` hostRule, when matching against the
hostname from the `url`.

This also adds a note to deprecate the usage of
`GITHUB_API_USING_HOST_TYPES`, unless it's explicitly needed.

Closes #38953.
2025-11-04 17:10:58 +00:00
Johannes Feichtner 68a66a05a9 feat(bitbucket-server): add support for changelogs (#34569) 2025-04-09 09:45:32 +00:00
Yohei Ueki 7d46cf7d42 fix(host-rules): respect hostRules.enabled=false even when noAuth=true (#35048) 2025-03-31 09:20:21 +00:00
Michael Kriese 593a92655e feat: refactor http (#34550) 2025-02-28 14:40:04 +00:00
Zigmas Bitinas c0af153b5e fix(http): allow overwriting default Renovate headers (#33907) 2025-01-29 14:18:51 +00:00
RahulGautamSingh 2eb7c76027 feat(http)!: remove dnsCache option (#29449)
BREAKING CHANGE: dnsCache is now removed
2024-07-25 15:28:16 +02:00
Sergei Zharinov 8d183d6b25 feat(http): Force default rate limits for some known hosts (#30207)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2024-07-22 16:59:29 +00:00
Sergei Zharinov 5c0628bf3b feat(host-rules): Support readOnly request matching (#28562)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-04-23 03:26:20 +00:00
Rhys Arkins 4bfd0f304e fix: Revert "feat: Limit HTTP concurrency and frequency by default" (#27765) 2024-03-07 08:01:34 +00:00
Sergei Zharinov 147d38a2a4 feat: Limit HTTP concurrency and frequency by default (#27621) 2024-03-05 14:50:09 +00:00
Rhys Arkins 9edde4794e refactor: string match function naming (#27392) 2024-02-18 15:46:24 +00:00
Sergei Zharinov de05ef057a refactor: Move irrelevant functions from the regex helper (#27100) 2024-02-06 21:51:41 +00:00
Sergei Zharinov cf5ffe055f feat: Move matchRegexOrMinimatch to string utilities (#27041) 2024-02-03 18:31:16 +00:00
Sergei Zharinov 198e34e0ef refactor: Tidy arguments for matchRegexOrMinimatch (#27026) 2024-02-03 06:22:19 +00:00
François db9d485227 feat(config): implement custom header field inside HostRules (#26225) 2024-01-17 09:22:19 +00:00
Sergei Zharinov 383bc11d4c refactor(http): Separate search and apply of host rules (#26067) 2023-12-01 12:00:20 +00:00
Michael Kriese 8c78b5a733 fix(keep-alive): use camlcase for option name (#26018) 2023-11-28 22:31:18 +00:00
Rhys Arkins f08bad2579 refactor: improve logging for hostRules (#25967) 2023-11-27 18:03:27 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Yun Lai 667f137081 feat: add options to host rules to enable mTLS calls to host (#24155)
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2023-09-06 12:02:34 +00:00
Michael Kriese 69f7240640 feat(datasource): add gitea-tags datasource (#24083) 2023-08-25 14:12:36 +00:00
renovate[bot] fe739befbf chore(deps): update linters to v6 (major) (#23325)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-08-02 15:07:49 +00:00
Sergei Zharinov ce41717678 refactor(http): Fix coverage (#23004)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-06-28 11:55:26 +02:00
RahulGautamSingh c56588eaba refactor: convert PlatformmId to union (#18458) 2022-11-01 14:46:09 +00:00
Sergei Zharinov b2d18d1110 feat(http): maxRequestsPerSecond (#18325) 2022-10-25 11:03:19 +00:00
Rhys Arkins 9bc8b05af3 feat: http keepalives (#17582) 2022-09-02 12:32:34 +02:00
Michael Kriese aabb3abf9a feat(http): use own dns cache (#17574) 2022-09-01 15:23:46 +00:00
Michael Kriese 13574419ba feat(http): support dns cache (#17533) 2022-08-31 11:49:54 +00:00
Michael Kriese 6dd4ea3c74 feat(github): use repo url to get token (#17179) 2022-08-29 07:37:45 +00:00
Richard Versteeg 599958a56b fix(bitbucket-tags): Add hostType and fallback for bitbucket-tags datasource (#13697) 2022-01-20 20:16:17 +00:00
Sergei Zharinov 030b1a61a4 refactor(util/http): Strict null checks for http utils (#13416)
* refactor(util/http): Strict null checks for http utils

* More tests for queue.ts

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-01-09 21:22:27 +00:00
Maksim 1f86b71fd5 refactor: constants (#11690) 2021-10-06 07:43:32 +02:00
Michael Kriese 28222bf762 fix: do not fallback if explicit auth is configured (#11760)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2021-09-15 15:13:17 +00:00
Michael Kriese 8785f70b93 fix(core/http): fallback to github /gitlab hosttype (#11605)
* fix(core/http): fallback to github /gitlab hosttype

* fix: remove generic host rule

* Update lib/util/http/index.ts

Co-authored-by: Rhys Arkins <rhys@arkins.net>
2021-09-06 21:07:52 +02:00
Michael Kriese 60b3d6d933 fix(manager:docker): only pass auth header when required (#11449) 2021-08-30 15:55:16 +02:00
Michael Kriese 607b151f0e feat(http): support custom auth types (#9053) 2021-03-09 19:25:18 +01:00
Kevin James 9e09363305 fix(auth): fix HTTP Basic auth for NOPASS indexes (#8442) 2021-01-29 06:28:52 +01:00
Sergei Zharinov 663117beab feat(http): Support for per-host http concurrency limits (#6983) 2020-12-11 10:09:09 +01:00
Michael Kriese 30f461f7d1 fix: improve logging (#7587) 2020-10-28 13:19:33 +01:00
Michael Kriese 739a561c63 fix(logger): fix logging (#7585) 2020-10-28 11:38:28 +01:00
Michael Kriese bbea59939e feat: add http2 option (#6957) 2020-08-11 11:53:23 +02:00