11 Commits

Author SHA1 Message Date
Sebastian Poxhofer f0dd862bd5 fix(python): share PyPI index credential resolution (#46127)
* refactor(python): share PyPI index credential resolution

pipenv, poetry, uv, pip-compile and the pypi datasource each resolved
index credentials differently, so a host rule that worked for one Python
manager did not necessarily work for the next. Add
`findPypiIndexCredentials()` in `lib/modules/datasource/pypi/host-rules.ts`,
which strips the URL's own `user:password@` part, runs a `pypi`-scoped
`hostRules.find()`, and only falls back to Google Artifact Registry when
the matched rule has no username and no password. The repeated
`.pkg.dev` test moves into a single `isGoogleArtifactRegistry()`
predicate next to `getGoogleAuthHostRule()`.

Behaviour changes:

- pipenv now supports Google Artifact Registry; previously it only ever
  consulted host rules.
  Spec: manager/pipenv/artifacts > "passes Google Artifact Registry
  credential environment vars"
- pip-compile now supports Google Artifact Registry.
  Spec: manager/pip-compile/common > getRegistryCredVarsFromPackageFiles()
  > "supports Google Artifact Registry"
- pip-compile now matches `hostType: pypi` rules; its find call was
  unscoped, so such rules were skipped.
  Spec: manager/pip-compile/common > getRegistryCredVarsFromPackageFiles()
  > "ignores a rule scoped to another hostType"
- pip-compile now matches a `matchHost` that contains a path; it reduced
  every registry URL to its origin first, and `matchesHost()` compares
  with `href.startsWith()`, so a path-scoped rule could never match.
  Spec: manager/pip-compile/common > getRegistryCredVarsFromPackageFiles()
  > "matches a rule scoped to a path"
- poetry and uv now strip `${USER}:${PASS}@` style placeholders from the
  index URL before matching, so a `matchHost` can match those URLs too.
  Spec: datasource/pypi/host-rules > "strips credentials from the URL
  before matching"
- poetry now falls back to Google Artifact Registry when the matched rule
  carries no username or password; any non-empty rule used to suppress
  the fallback. Its dead unscoped `find({ url })` fallback is gone: a
  `pypi`-scoped find already matches every rule an unscoped one would.
  Spec: manager/poetry/artifacts > "falls back to Google auth when the
  matching rule has no credentials"
- the pypi datasource now prefers host rule credentials over the Google
  token for `*.pkg.dev`; it took the Google token unconditionally, and
  the resulting `authorization` header made `applyHostRule()` skip the
  configured credentials.
  Spec: datasource/pypi/index > getReleases > "prefers host rule
  credentials over Google Auth"

`getRegistryCredEnvVars()` also no longer logs the whole matched host
rule as the log merge object.

* test(pipenv): inline the Google Artifact Registry Pipfile

The fixture was used by a single spec case; inline it as requested in the
review of #46127.

* test(datasource/pypi): cover partial Google Artifact Registry credentials

A host rule that carries only a username or only a password still produces a
Basic header, but nothing exercised those two `?? ''` fallbacks, so the merge
queue failed the global branch threshold.
2026-09-18 10:53:11 +00:00
Jamie Tanna 7d2335ed07 fix(datasource/nuget): don't follow Link headers with different hosts
To prevent potential SSRF attempts, we can ignore a
misconfigured/malicious `next` link, and log a warning.

Co-authored-by: Claude Opus 4.8 <jamie.tanna+claude-code@mend.io>
2026-08-04 08:56:59 +01:00
Jamie Tanna 8a9f9cd9fe fix(datasource/docker): don't follow Link headers with different hosts
To prevent potential SSRF attempts, we can ignore a
misconfigured/malicious `next` link, and log a warning.

For self-hosted users, we can provide an experimental override if they
need to opt back in.

Co-authored-by: Claude Opus 4.8 <jamie.tanna+claude-code@mend.io>
Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-08-04 08:54:23 +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
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
Maxime Brunet 84017e05cc refactor: refactor Google Auth util (#33486) 2025-01-09 10:35:47 +00:00
Maxime Brunet 80f03a86dc feat(uv): support GCloud credentials for Google Artifact Registry when locking (#32545) 2024-11-17 09:01:33 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Koen van Zuijlen 080d642593 feat(datasource/maven): Add Artifact Registry support via Google ADC (#24657)
Co-authored-by: Johannes Feichtner <343448+Churro@users.noreply.github.com>
2023-10-15 06:29:29 +00:00
Sergei Zharinov 45328c57b6 refactor: Extract datasource result filters to separate file (#23587) 2023-07-28 08:09:41 +00:00