Commit Graph

40 Commits

Author SHA1 Message Date
Sebastian Poxhofer a1971afa78 fix(linters): add linting rule to enforce usage of our regEx utility (#44690)
* ci(linter): add renovate/require-regex-util rule

Adds a custom oxlint rule that flags raw RegExp usage in lib/
production code: any `new RegExp(...)` call and any regex literal
that is not the direct first argument of `regEx(...)`. The regEx()
helper from lib/util/regex.ts uses the RE2 engine for ReDoS-safe
matching and caches compiled patterns. lib/util/regex.ts itself is
exempt.

The rule is disabled for **/*.spec.ts, test/**, and tools/** via
config overrides, because vitest APIs such as expect.stringMatching
need bare RegExp instances (a past commit reverted regEx() there).

Severity is set to "warn" instead of "error": the repo currently has
197 pre-existing violations (above the agreed mechanical-fix
threshold of 80), and a number of them are deliberately
RE2-incompatible patterns (lookahead/lookbehind/named backreferences,
see TODO #12872/#12875 markers in e.g. lib/modules/versioning/rez/
pattern.ts and lib/modules/manager/dockerfile/extract.ts) that need
per-site judgment before they can be wrapped in regEx() or suppressed
with a justified disable comment. No violation fixes are included in
this commit.

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

* ci(linter): enforce renovate/require-regex-util at error

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

* refactor: use regEx() for regex literals and RegExp construction in lib

Burn down all renovate/require-regex-util violations (197):

- wrap RE2-compatible regex literals and RegExp constructions in regEx()
- rewrite lookaround patterns where behavior is provably preserved:
  goproxy separator split, sbt-package link extraction, leiningen
  comment stripping and keyword search, npm GitHub owner validation
  (unit-count bound replaced by an explicit length check)
- keep native RegExp with disable comments where RE2 cannot be used:
  moo / good-enough-parser lexer patterns (moo rejects RE2 instances),
  MigrationsService propertyName (matched via isRegExp, which RE2
  instances fail), rez named backreferences and lookaheads, GitHub
  markdown link negative lookbehind, emoji astral-plane matching
- drop stale TODO #12875 comments for patterns current re2 handles

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

* refactor: reduce require-regex-util disable comments

Rewrite the github massage-markdown-links URL regex to capture an
optional `api.` prefix in a named group (skipped in code) instead of
relying on a negative lookbehind, so both the base and global variants
can use regEx()/RE2 and their two disable comments are removed. Add
spec cases for api-prefixed URLs that match the URL shape.

Consolidate the four related line disables in rez/pattern.ts (bound and
range patterns emulating Python conditional patterns via named
backreferences and lookaheads, which RE2 cannot express) into a single
block disable/enable pair, matching the treatment of the lexer files.

Disable comment count drops from 13 to 8.

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

* refactor(datasource/sbt-package): use named capture group in link regex

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

* refactor(manager/cake): restore original multiLineComment regex spelling

The [^] -> [\\s\\S] rewrite was only needed for an RE2 wrap that was
later reverted; keep the diff minimal.

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

* fix(datasource/go): skip empty GOPROXY segments

The switch from a lookahead split to a capture-group split (needed because
RE2 has no lookahead support) changed how empty GOPROXY segments parse:
`a|,b` yielded `{ url: ',', fallback: '|' }` before and
`{ url: '', fallback: ',' }` after. The comma fallback only continues on
404/410, so a failing proxy ahead of an empty segment silently stopped the
lookup instead of falling through to the remaining proxies.

Empty segments carry no url to query, so drop them.

* refactor(datasource/go): use isTruthy for empty segment filter

* fix(datasource/go): filter empty segments before mapping

Filtering after the map broke the contextual typing from the
GoproxyItem[] annotation, widening fallback to string.

* refactor(platform/github): use regEx() for merge queue query stripping

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 14:30:46 +00:00
palakkhinvasara 728ce9752e fix: keep HTTPS when resolving same origin URLs (#45157)
* pushing

* pushing

* pushing

* pushing

* pushing
2026-08-11 06:14:50 +00:00
Jamie Tanna 7f7b039559 refactor(util): add a helper method for resolveSameOriginUrl
As part of future changes, it would be useful to have a helper method to
handle the correct resolution for `Link` header parsing, where we want
to avoid the risk of a registry/platform providing a link to a different
hostname, which could lead to SSRF.

Co-authored-by: Claude Opus 4.8 <jamie.tanna+claude-code@mend.io>
2026-08-04 08:06:57 +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
Sebastian Poxhofer 73b90e958b refactor: remove string concetation for production code (#43442)
refactor: prefer templates rather than `+`
2026-05-19 13:31:27 +00:00
Sergei Zharinov e0c9bc1961 refactor(lint): move option-dependent rules from ESLint to oxlint (#42215)
Migrate rules that previously stayed in ESLint due to option parity
concerns. oxlint now supports all needed options:

- `no-restricted-imports` (paths: nock, parse-link-header, path)
- `consistent-type-assertions` (objectLiteralTypeAssertions: allow)
- `explicit-function-return-type` (allowExpressions, allowTypedFunctionExpressions)
- `no-unused-vars` (args: none, ignoreRestSiblings)
- `no-empty-object-type` (allowInterfaces: with-single-extends)

Convert eslint-disable comments to oxlint-disable for the allowed
import sites (url.ts wrapper, http-mock.ts test helper).

Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2026-03-30 16:45:02 +00:00
Sergei Zharinov 41bfb8678e refactor(lint): use oxlint for type-aware rules (#41739)
* feat: enable oxlint type-aware linting

Move type-aware typescript-eslint rules from ESLint to oxlint,
leveraging oxlint-tsgolint for type information. This removes
the need for ESLint's projectService and parserOptions.

- Add `options.typeAware: true` to .oxlintrc.json with all
  type-aware rules (recommendedTypeChecked + stylisticTypeChecked)
- Switch ESLint to non-type-aware configs (recommended, stylistic)
- Remove projectService/parserOptions from ESLint config
- Drop @typescript-eslint/naming-convention (no oxlint equivalent)
- Update oxlint/eslint-plugin-oxlint to 1.51.0
- Add oxlint-tsgolint dependency
- Convert eslint-disable comments to oxlint-disable for type-aware rules
- Fix prefer-optional-chain violations newly caught by oxlint

* fix: revert unnecessary code changes, suppress with oxlint-disable instead

* fix: suppress remaining prefer-optional-chain violations

* fix: suppress last prefer-optional-chain violation

* fix: remove redundant --type-aware CLI flag, use config instead
2026-03-09 12:51: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
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
Michael Kriese 593a92655e feat: refactor http (#34550) 2025-02-28 14:40:04 +00:00
Sergei Zharinov 16d5c6ddf0 refactor: Make parseUrl utility idempotent (#32792) 2024-11-28 16:29:27 +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
RahulGautamSingh b8b760768d feat(hostRules/matchHost): massage and validate (#29487)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2024-06-28 07:20:00 +00:00
Sergei Zharinov d6d1e57763 refactor: Rename validateUrl to isHttpUrl (#28484) 2024-04-17 15:57:33 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Sebastian Poxhofer b73cf032d2 chore: allow null value and undefined for validateURL (#25014) 2023-10-04 04:48:58 +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
RahulGautamSingh 012c0ac2fe feat: npm workspaces (#21274)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2023-04-27 12:42:25 +00:00
Jamie Magee cbbeecbefc refactor: satisfy types for unknown arrays (#20878) 2023-03-12 05:53:06 +00:00
Sergei Zharinov cd06651f89 fix(packagist): Replace V2 URL path instead of joining it (#20709) 2023-03-02 14:19:55 +00:00
Hasan Awad 719ab9be4a fix(manager/gitlabci): clean more than one slash (#17132) 2022-08-14 15:57:37 +00:00
eSamS 1da46b0672 fix(go): allow go modules in gitlab subgroups (#14831)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-04-08 08:16:46 +00:00
Sergei Zharinov c1555efb3b refactor(datasource/crate): Enable strict null checks (#13915) 2022-02-07 06:14:23 +00:00
renovate[bot] b0acc97579 build(deps): update dependency parse-link-header to v2 [security] (#13412) 2022-01-13 06:45:50 +01:00
RahulGautamSingh 597da6ff59 refactor: flagged relevant regex (#12976) 2021-12-06 15:05:37 +00:00
RahulGautamSingh ee2e155f1f fix: modify regex to be re2 compatbile (#12778)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2021-11-29 19:16:05 +00:00
Sergei Zharinov f4dbff9bd3 refactor(util/host-rules): Strict null checks for host rules (#12868)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2021-11-28 16:31:11 +01:00
Tobias 87c5e8e022 feat(gomod): use git host rules as authentication for gosum updates (#12230)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2021-10-31 07:06:59 +00:00
RahulGautamSingh 91f067b39f fix: refactor regex to use re2 part3 (#12283)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2021-10-27 14:37:11 +00:00
Jennifer Wilcox 5273cbc1cb fix(docker): handle redundant port in image (#11852) 2021-09-24 12:13:54 +00:00
Michael Kriese c8c8684ea3 fix(datasource): trim trailing slash in registry url (#11392)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
2021-08-30 18:28:32 +02:00
Rhys Arkins 3d4d2529a1 refactor(docker): better url parsing (#10996) 2021-07-28 08:07:20 +02:00
Sergei Zharinov 3527d8b4f3 feat(util): Add lightweight parseUrl function (#9019)
Co-authored-by: Rhys Arkins <rhys@arkins.net>
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2021-03-13 09:41:51 +01:00
Rhys Arkins 9c658a21f0 Revert "feat(internal): Massage registryUrls (#9086)" (#9098) 2021-03-12 12:27:47 +01:00
renovate-testing 9c3b34dbb3 feat(internal): Massage registryUrls (#9086) 2021-03-11 19:23:57 +01:00
Sergei Zharinov ccdb09fe3c fix(go): Improve go-import content parsing (#9022) 2021-03-08 13:12:19 +00:00
Rhys Arkins 2abc088781 fix: validate datasource URLs (#8970)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2021-03-04 06:40:08 +01:00
Rhys Arkins 76d0d42c9e refactor: getQueryString (#8834) 2021-02-24 09:58:21 +01:00
Sergei Zharinov d8df51f20e feat(util): Add resolveBaseUrl function (#7918) 2020-12-09 13:05:31 +01:00
Florian Greinacher e6453ae423 feat(presets): add support for local presets (#5814) 2020-04-14 07:05:30 +02:00