32 Commits

Author SHA1 Message Date
Jamie Tanna a9c8f7431f fix(lint): extend prefer-is-helpers to catch more cases (#45474)
This now covers everything that isn't `isObject` or `typeof x === 'number'`.

Co-authored-by: Claude Sonnet 5 <jamie.tanna+claude-code@mend.io>
2026-08-26 10:48:40 +00:00
Jamie Tanna 5b1749983c feat: always set CI=true for subprocesses
As noted in #43761, we had recently set `CI=true` for the Renovate and
Containerbase orgs on Mend-hosted apps due to a pnpm v11 requirement:

    ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY  Aborted removal of
      modules directory due to no TTY

    If you are running pnpm in CI, set the CI environment variable to
      "true", or set "confirmModulesPurge" to "false".

Similarly in #43606, it was noted that we should do this for `mise lock`
to mark the workspace as "trusted".

Although we went with a different situation, there will be cases where
this is useful for tools being executed, for instance when we invoke `yarn`.

We also make sure to keep our documentation up-to-date as we add to the
specific overrides.

With help from Claude Sonnet and Opus to:

- perform some of the mechanical updates as part of this change
- ensure that the Docker sidecar always has `hardcodedProcessEnv` passed
  into it
- catch a needed change to `exposeAllEnv` handling

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-08-24 17:21:24 +01:00
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
Jamie Tanna cbd174e128 docs: add a "deep dive" on environment variables (#43243)
As part of recent work around environment variable handling, it's clear
we should provide more user-facing documentation on how environment
variables are handled, and which are passed to child processes by
default.

We can create a "deep dive" page for this, with an autogenerated list of
the environment variables in `basicEnvVars` that are always passed to
child processes, if they're set.

We can also point self-hosted administrators and users alike to the
options they have to control this, too.

With help from GPT-4.1 for case-insensitive sorting.

Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
Co-authored-by: gpt-4.1 <jamie.tanna+github-copilot@mend.io>
2026-05-29 15:09:28 +00:00
Michael Kriese 2257ab148b fix(env): add windows specific variables (#43272) 2026-05-12 11:36:44 +00:00
Sergei Zharinov 3765595370 fix(git): pass through Git CA certificate env vars (#43221) 2026-05-11 04:54:41 +00:00
Jamie Tanna b10905bc1e fix(util/exec): allow setting PNPM_WORKERS/PNPM_MAX_WORKERS in environment (#43131)
As found in #40942, we've been seeing increased memory usage by pnpm and
Yarn in recent months on Mend-hosted apps.

As a way to provide more control to test + validate fixes, as well as
provide self-serve for other environments, we can allowlist
`PNPM_WORKERS`/`PNPM_MAX_WORKERS` in both the "basic env vars" and the
allowed `global:safeEnv`.
2026-05-06 20:55:22 +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
Michael Kriese 49f1b00af2 fix(exec): pass CI env to child processes (#36153) 2025-05-26 10:12:20 +00:00
Michael Kriese bb9faed9c3 fix: properly pass configured env (#35835) 2025-05-09 11:31:00 +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
Alex Kessock 84e4239c62 feat(corepack): Add env COREPACK_INTEGRITY_KEYS (#29047) 2024-05-14 07:34:51 +00:00
Rhys Arkins 12377e49dd fix(yarn): add COREPACK_ENABLE_UNSAFE_CUSTOM_URLS to env (#28009) 2024-03-18 21:44:16 +00:00
Rhys Arkins 0352aedd0d fix(npm): pass through COREPACK env to child process (#26664) 2024-01-16 14:38:19 +00:00
Dave af6743d7bb fix(manager/nuget): use environment variables required by NuGet on Windows (#26056) 2023-12-01 11:10:16 +00:00
Sergei Zharinov b69416ce17 refactor(prettier): Force trailing commas (#25631) 2023-11-07 15:50:29 +00:00
Michael Kriese 0d0ab69cfe feat(env): pass additional ssl and url replace env to child process (#23887) 2023-08-16 08:30:39 +00:00
Michael Kriese 4f82df4c3d feat(buildpack): enable cache (#16591) 2022-07-21 07:00:02 +00:00
Maksim 06d8c27043 refactor: global config (#12743)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2021-11-23 21:10:45 +01:00
Rhys Arkins 9150854d75 chore: rename config/admin -> config/global 2021-08-17 07:57:45 +02:00
Rhys Arkins bf69924b78 refactor: rename config admin functions to global 2021-08-17 07:57:45 +02:00
jose-ws dd462359b4 feat(proxy): lowercase proxy env (#10025) 2021-05-19 13:37:27 +02:00
Rhys Arkins 1edcf5fc15 fix: Revert "feat(proxy): proxy environment variables available in lowercase for child processes. (#9978)"
This reverts commit 2d9734c3da.
2021-05-14 19:37:02 +02:00
jose-ws 2d9734c3da feat(proxy): proxy environment variables available in lowercase for child processes. (#9978) 2021-05-14 17:27:02 +02:00
Rhys Arkins 8af905e8f5 feat: split trustLevel into separate options (#9388)
Removes trustLevel and replaces it with 3 other options instead. No longer necessary to set anything additional is configuring `allowedPostUpgradeCommands`

BREAKING CHANGE: `trustLevel` is no longer supported and instead broken into `allowCustomCrateRegistries` , `allowScripts` , and `exposeAllEnv`.
2021-04-22 08:47:58 +02:00
Michael Kriese 41fb5b1602 fix: pass docker tls env to childs (#9087) 2021-03-11 17:38:54 +01:00
Rhys Arkins 3357e6333d refactor: Object.assign -> object spread (#9076) 2021-03-11 08:03:37 +01:00
Rhys Arkins 4e1271b702 fix(config): move trustLevel to admin config (#8555) 2021-02-05 12:30:01 +01:00
renovate[bot] 4f59b62da4 chore(deps): update dependency prettier to v2 (#5952)
* chore(deps): update dependency prettier to v2

* Run prettier-fix

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Jamie Magee <jamie.magee@gmail.com>
2020-04-12 18:09:36 +02:00
Sergio Zharinov aa49a21e54 fix(exec): Whitelist LC_ALL and LANG (#5239) 2020-01-29 06:29:53 +01:00
Martín Fernández 8da8d7a072 feat: Add DOCKER_HOST to child env (#5222)
Currently the DOCKER_HOST env variable is not passed to the child
environment making it impossible to use a non default docker host.
2020-01-25 19:30:43 +01:00
Sergio Zharinov 69dabac278 feat: improved exec wrapper (#5131) 2020-01-14 12:12:03 +01:00