How-to guide
Fix vulnerabilities
How to close the findings of a project: with an upgrade to a fixed version, or with a TuxCare build of the version that you use now. The CLI makes the change, checks it, and keeps it current.
Two ways to fix #
| Upgrade the package | Use a TuxCare build | |
|---|---|---|
| What changes | The version: you move to the lowest version that fixes the advisory. | The source: the same version, built by TuxCare from source with the fix added. Its version ends in -tuxcare.N (Python: +tuxcare.N). |
| Use it when | The fixed version is close, and its changes do not break your code. | The fix is in a new major version, or the project that made the package no longer fixes your version. |
| How | tuxcarectl fix writes the change for you. By hand, for a direct dependency: your package manager, with the flag that pins the exact version, for example npm install --save-exact lodash@4.17.21. For pnpm the flag is also --save-exact, and for Yarn and Bun it is --exact. Without it, package.json gets a range such as ^4.17.21. A named install also sorts the dependency list of package.json again: that is your package manager, not harden. For a transitive package, see Upgrade a package. | tuxcarectl harden. See TuxCare builds. |
| Needs | Nothing more. tuxcarectl fix needs a portal token and no TuxCare registry. | A subscription with TuxCare builds. |
The portal tells you which fix applies:
- The Fix plan tab of a repository lists each package to change, the version to move to, and where the fix comes from:
upstream
or a TuxCare build. - The page of a finding shows How to fix: the recommended fix, the alternatives, and the command to run.
- The TuxCare coverage tab of Packages counts the packages of the workspace that a TuxCare build can fix.
This page is about the packages of a project. An OS package of a server is not a dependency of a project: tuxcarectl harden and tuxcarectl fix do not change it. Its How to fix card gives the update command of the package manager of the server, for example sudo yum update nettle nettle-devel. See Update an OS package.
For a language package, the portal recommends one fix in this order:
- A TuxCare build of the version that you use now, for example
7.29.3-tuxcare.4for 7.29.3. A TuxCare build fixes only the version that it was built from. - Else the lowest upstream version above yours that fixes the finding.
- Else, when no upstream version has the fix, the TuxCare build of the nearest higher version.
Upgrade a package #
- Open the Fix plan tab of the repository. The packages with the worst severity come first. Inside one severity, a package with a known-exploited finding comes first.
- Run
tuxcarectl fix, or change the version of the package with your package manager. For a transitive package, upgrade the direct dependency that pulls it in, or pin it with the mechanism of your tool:overridesfor npm, pnpm, and Bun,resolutionsfor Yarn, a constraints file for pip,dependencyManagementfor Maven, aconstraintsblock for Gradle, a directPackageReferencefor NuGet, ordependency_overridesfor Dart. With Go,go getmoves it. With Cargo, Composer, and Bundler,cargo update,composer update, andbundle updatemove it inside the ranges of its parents; outside them, a parent must move. The How to fix card gives the line or the command when one fits your tool. On npm and PyPI, do not install a transitive package by name: that adds a new direct dependency, and the copy under its parent can stay vulnerable. For a TuxCare build,tuxcarectl hardenwrites the override. - Run your tests, and commit the manifest and the lockfile.
- Run
tuxcarectl sca, or let the CI job run it. The finding closes when the portal gets a scan that does not have it.
The fix plan marks an upgrade to a new major version with major version
. Such an upgrade can break your code. A TuxCare build avoids it.
Write the upgrade: tuxcarectl fix #
tuxcarectl fix (CLI 0.1.81 or later) writes the upstream fix for each open finding, runs the install command of your package manager, and checks the result. It needs a portal token and no TuxCare registry. It also needs no .tuxcare.yaml. On Maven and Gradle, it needs no BOM file.
tuxcarectl fix --dry-run # print each change; write nothing
tuxcarectl fix
--dry-run prints each change that the write makes, and writes nothing in the project: your package manager runs on a temporary copy. It reads the findings as tuxcarectl sca does, so it sends the package list to your workspace when the portal has no scan of that list.
fix runs the code of the project, also with --dry-run. To compute each change, fix starts your package manager, and the package manager runs the code that the project gives it: for example the pnpmfile, the Yarn release and the Yarn plugins of the project, the Gemfile, mix.exs, Package.swift, conanfile.py, the Podfile, the cpanfile, the .Rprofile, the MSBuild and Bazel files, and the build of a Gradle or Maven project. The preview writes nothing in the project, but the tools run on its copy in the same way. --run-project-hooks does not change this. So run fix only on a project that you trust. Do not run it on a merge request from outside, or run it in a sandbox job that holds no secret.
For each package, fix writes the first change that applies:
- The lockfile entry, when the fix fits each range that requests the package. Your package manager chooses the version, which can be above the fix. On Bun, the lock moves to the fix, not to the newest version.
- The range in the manifest, with the same operator, when that range refuses the fix.
- A new release of the parent, when a transitive range refuses the fix and a release of each parent takes it. Except on renv,
fixdoes not move a parent to a new major version: that is your choice. Where your tool has an override,fixwrites the override, and a note names the release. Where it has none,fixleaves the finding. - An override, where your tool has one, scoped so that it does not move another version of the package.
The rest of what fix does:
- It moves a package to an upstream version, never to a TuxCare build. It does not change a TuxCare build or a pin that
hardenwrote: for these, runtuxcarectl update. - It does not replace an override that you wrote.
- When it cannot write one change for a finding, it leaves the finding, and prints the reason for each one. The run then ends with exit code 1, and the changes that it wrote stay.
- When your package manager refuses one change, and another change of the same tool lands, the refused change becomes a left finding with the code
not_movedand the line of the tool.fixwrites and checks the other changes, and the run ends with exit code 1. When no change of the tool lands, the run stops with exit code 5 and writes nothing, so a tool that cannot run still stops the run. Two refusals are left findings also for a single change:failed to select a version
of Cargo, and a version thatgo getrefuses. A tool that solves all its changes in one call gets at most 24 solves to find the refused change. After that, the run stops with exit code 5. Only a refusal of your package manager is a left finding: a step of the tool on the copy of the project failed, the tool refused the change, orfixcould not write the change into the build files of Maven or Gradle. An error of the machine around the tool, for example a failed copy of your project or a file that does not read or write, stops the run at its own exit code: 7, or 5 for a project thatfixcannot read. Then there is no left finding, andfixwrites nothing. On Maven and Gradle, CLI 0.1.92 and earlier read such an error as exit code 5, or as a left findingnot_moved. - When the check after the install names packages that did not land,
fixputs your files back and runs again without those changes, at most two times. Each such package becomes a left finding with the codenot_moved, and the run ends with exit code 1. Each other failure of the check ends with exit code 6, also a failure after the last try, andfixputs your files back. - On npm, pnpm, Yarn, and Bun, a package can leave the dependency tree with another change. Its finding closes,
fixkeeps the write, and its change readsremoved. - These rules need a CLI release after 0.1.84. With CLI 0.1.84 or earlier, a refused change other than these two refusals stops the run with exit code 5. A package that did not land, or that left the tree, ends the run with exit code 6. In both cases
fixputs your files back. - When the install fails,
fixputs your files back and exits with code 5. See Exit codes. - A tool that resolves the whole lockfile at each change, such as Bundler, Pub, or Mix, can take an earlier package back below its fix with a later change of the same run. Such a package becomes a left finding with the code
not_moved, and its reason names the later changes.fixwrites the other changes, and the run ends with exit code 1, also with--dry-run. When no change of the tool stays,fixwrites nothing for that tool. CLI 0.1.92 and earlier showed such a package as a change with no new version:--dry-runended with exit code 0, and a real run failed the check after the install. - When
fixcannot vouch that no finding stays open, the run ends with an exit code that is not 0, ascheckdoes. These are the four cases:- A finding with the code
unplaced, also when it is the only open finding: exit code 1. - A part of the project that
scadid not read: exit code 5. The refusal of each part says what to do. If a manifest has no lockfile, commit the lockfile if your package manager creates one, or leave out the manifest with--exclude <file>or theignorekey in the project file (CLI 0.1.95 or later). - A Gradle runtime that Gradle reports empty over declared packages, under
--gradle-empty-runtime fail(the default): exit code 5. - A part that the check after the install could not read: exit code 5 when your package manager stopped part-way, 2 for a part that tuxcarectl cannot judge, and 7 for each other refusal. When the first read of the project could read that part,
fixalso puts your files back.
fixleft comes first: the run then ends with exit code 1. Else the highest code of these cases applies, in this order: 7, 5, 2. CLI 0.1.85 to 0.1.92 keep exit code 0 and the write in these four cases, with a warning that names the new exit code. - A finding with the code
--on-unvouched warnis deprecated.--on-unvouched warn, or the keyfix_on_unvouched: warnof.tuxcare.yaml, keeps exit code 0 and the write in these four cases until 2027-12-01. The option wins over the key. The default isfail. Each case still gives a warning, and each run that useswarnprints one deprecation warning, on standard error and inwarningsof--output json. A finding thatfixleft with another code still gives exit code 1, and a stop before the end, for example a failed install, keeps its exit code. After 2027-12-01 a release removes the valuewarn. Fix what each warning names, and remove the option and the key before that date.- It calls no package registry: your package manager asks its own registry. On GitHub Actions, your
gitreads the tags from github.com, also with--dry-run, and sends only the name of the repository. - It sends nothing to the portal after the write. Run your tests, commit the manifest and the lockfile, and run
tuxcarectl sca. The finding closes when the portal gets a scan that does not have it.
The tools of tuxcarectl fix #
fix covers each package manager that tuxcarectl reads: npm, pnpm, Yarn classic, Yarn Berry, Bun, Deno, uv, PDM, Poetry, Pipenv, pip, pip-tools, conda, Maven, Gradle, Cargo, NuGet, Bundler, Composer, Stack, Cabal, CocoaPods, Julia, renv, CPAN, Pub, Mix, SwiftPM, Paket, Bazel rules_jvm_external, Go modules, GitHub Actions, and Conan.
CLI 0.1.81 covers the JavaScript tools, the Python tools, Maven, Gradle, and Cargo. Each other tool needs a CLI release after 0.1.81. CLI 0.1.81 leaves the findings of such a tool with the code no_fixer, names the tool and the file to edit by hand, and ends with exit code 1.
| Tools | What fix writes | The override |
|---|---|---|
| npm, pnpm, Yarn classic, Yarn Berry, Bun, Deno | The lockfile, with the tool, and the range in package.json. On Deno: the imports of deno.json. | overrides on npm and Bun, the override block that your version of pnpm reads, and resolutions on Yarn. Bun also takes resolutions when the manifest declares only that block. Deno has no override. |
| uv, PDM, Poetry, Pipenv, pip-tools | A lower bound on the fix, name>=version, and the tool chooses the version in its lockfile. On pip-tools, the lockfile is the compiled requirements.txt. | tool.uv.override-dependencies on uv and tool.pdm.resolution.overrides on PDM. The others have no override. |
| pip | pip has no lockfile: a line in the constraints file that requirements.txt reads, or in a new constraints.txt with a new -c line. | None. |
| conda | conda has no lockfile: a line of the pip: list, also for a package that a conda spec names. fix does not edit a conda spec. | The pip: list. |
| Maven | The <version>, the property, or the dependencyManagement entry that the report names. | dependencyManagement in the pom of the module. It outranks a BOM and a parent pom outside the project, and fix moves neither of them. |
| Gradle | The coordinate, the variable, or the key of the version catalog that the report names. Then --update-locks of each gradle.lockfile. | The block upstream-fix in the settings file, before the block of harden. update and unharden leave it. |
| Bazel rules_jvm_external | The version in the module file, then a repin, which writes the lock file. | A new entry in the artifacts list, for a transitive artifact. |
| Cargo, Bundler, Composer, SwiftPM, CocoaPods, Julia, CPAN | The update command of the tool for the package and its parents, for example cargo update. Else the version in the declaration, with the same operator. On Julia, a package whose name two packages of Manifest.toml share (for example a fork beside the package of the General registry) gets no move: fix leaves its finding with the reason, and a parent of such a name is not given to Pkg.update either. | None: when no release of a parent on its line takes the fix, fix leaves the finding. |
| renv | renv::install of the fix, then renv::snapshot of the package. Else the version in DESCRIPTION, with the same operator. The package whose record refuses the fix moves to its newest release, also to a new major version. | None: when such a move does not take the fix, fix leaves the finding. |
| NuGet | The Version of the PackageReference, its VersionOverride, or the PackageVersion of Directory.Packages.props. fix does not search the releases of a parent. | A direct PackageReference at the fix. Under central package management, a PackageVersion in Directory.Packages.props, and a PackageReference with no version where the PackageVersion alone moves nothing. |
| Pub, Mix, Paket | The update command of the tool for the package and its parents. Else the version in pubspec.yaml, mix.exs, or paket.dependencies, with the same operator. | dependency_overrides on Pub, override: true on Mix, and nuget <id> == <version> on Paket. |
| Stack, Cabal | The extra-dep line of stack.yaml, or the line of cabal.project.freeze. fix does not widen a range of your project. | None. |
| Go modules | go get of the module at the fix, in each module that requires it, then the vendor step of a vendored project. | None. fix does not change a replace: the reason gives the edit. |
| GitHub Actions | The uses: line of the workflow or of the composite action: a release tag at or above the fix. A tag of the major or the minor stays in that form when it stands at such a release. A full commit stays a full commit. | None. |
| Conan | conan.lock, the line of conanfile.txt or conanfile.py that refuses the fix, or the line of a parent on its major version (0.x: on its minor version). | override=True in conanfile.py, and the key overrides of conan.lock for conanfile.txt. |
fix runs your package manager, so the tool must be on the computer, also for --dry-run. tuxcarectl sca reads many lockfiles with no tool, and fix does not. So Cargo needs cargo, NuGet needs dotnet, Conan needs Conan 2, Bazel needs bazel or bazelisk, and GitHub Actions needs git. The same holds for bundle, composer, stack, cabal, pod, julia, Rscript, carton, dart, mix, swift, paket, and go. With no such tool, the run stops with exit code 5, and the message names the tool. With no npm or uv, fix leaves the finding with the code no_file.
The findings that fix leaves #
fix leaves a finding that has no single edit. It prints the reason for each one, and the file to edit by hand when there is one. --output json gives the same in fix.left, with a code. A left finding never reads as fixed. Each code gives exit code 1, with these exceptions. fixed_by_tuxcare, no_fix_planned, and live_patched do not change the exit code. A finding that TuxCare is investigating on a TuxCare build is not open, and the portal does not send it, so fix does not see it (see Findings with no fix planned). unplaced also gives exit code 1 when it is the only open finding. CLI 0.1.85 to 0.1.92 keep exit code 0 there with a warning, and so does the deprecated --on-unvouched warn.
Each finding of sca is a finding of fix, with one exception. A lockfile beside the tree of your tool can count the same package again, for example a gradle.lockfile. fix then keeps only the finding of the tree. It does this only when the tree covers the directory of the lockfile. A lockfile in a directory that the tree does not cover is a project of its own, also when the root holds the same package. For example, a website/package-lock.json below a root npm project gets the code no_file, and the reason names tuxcarectl fix --dir website. This rule needs CLI 0.1.84 or later. On a Gradle build of several projects, the finding of the gradle.lockfile of a subproject is a copy of the finding of the tree, on Gradle 8 and on Gradle 9: fix moves the package in that lockfile, and the run ends with exit code 0 (measured on Gradle 8.14.3 and 9.7.0). A subproject whose directory is outside the root is a project of its own, and its finding gets the code no_file.
| Code | The finding |
|---|---|
no_upstream_fix | The portal names no upstream version. |
several_fixes | The portal names several versions, and no comparison chooses one. |
no_file | The report names no file for the package: no lockfile, or a lockfile that no tool of this run read. For example, its tool is not on the computer, or the lockfile is a second project below the directory. The reason names the directory. Run tuxcarectl fix --dir <directory> where the tool is installed, or edit the file by hand. |
pinned | The file of the tool states the version with no range that fix can move. On NuGet: a packages.config entry. |
environment | The package is the tooling of a Python environment, or the Go toolchain. Upgrade the environment, or build with the fixed Go. |
range_assumed | The change rests on a range that the CLI assumed. fix writes no edit on a guess. |
manifest_range | A declaration that fix cannot move and keep its meaning: a compound range, a tag, a URL, or an alias. On Stack and Cabal, a range of your project. On Go, a fix in another major version. On GitHub Actions, a branch or a short commit. |
customer_override | An override that you wrote already matches the package. This includes a Go replace. fix does not replace your line. |
hardened | The project holds a TuxCare build of the package, or a pin that harden wrote. Run tuxcarectl update. |
override_scope | No key moves this copy and leaves another version as it is. |
no_override | The tool has no override, and no parent that the project declares moves the package: Deno. On Mix and Pub: a file with no place for a new line. |
no_parent_release | No release on the line of the parent takes the fix, and the tool has no override for it. On NuGet: the range of a parent stops below the fix. |
not_moved | The tool ran, and the old version stayed. This includes a change that your package manager refused and a package that did not land: the reason keeps the line of the tool. It also includes a package that a later change of the same run took back below its fix: the reason names the later changes. |
no_ref | GitHub Actions: git cannot read the repository, or the repository has no release tag at or above the fix. |
residual | The new version landed, and a copy stayed on the old version. The run keeps the write. |
fixed_by_tuxcare | The build in the project already closes the finding. fix has nothing to write. |
no_fix_planned | TuxCare stated that it will not fix the finding on the build, so no version closes it. fix has nothing to write. This code needs a CLI release after 0.1.84. |
live_patched | A live patch that is loaded on the host closes the finding. fix has nothing to write. This code needs a CLI release after 0.1.84. |
unplaced | No step of the run placed the finding: no change and no other left finding names it. A defect of tuxcarectl. Move the package by hand. This code needs a CLI release after 0.1.84. |
TuxCare builds #
TuxCare builds the open-source packages that your projects use from their source, and serves the builds from the TuxCare registry. When a vulnerability is found in a version, TuxCare adds the fix to that version and publishes a new build. TuxCare also fixes versions that the project that made them no longer maintains. A new upstream version reaches the registry only after TuxCare checks it, for example for malicious code.
The CLI moves a project to the builds in three steps: init one time for each repository, registry login one time for each computer, and harden each time you want to apply the builds.
If Renovate or Dependabot updates the dependencies of the repository, give it the rule of Renovate and Dependabot. Without the rule, the bot can replace a TuxCare build with an upstream release.
What you need #
- A subscription with TuxCare builds.
tuxcarectl auth statusshows it in the linesubscription.SecureChain no, ELS nomeans that your workspace has none. Contact TuxCare. - A registry token in the workspace. An admin saves it one time under Settings › Registry and CLI › Registry token.
- The setting Use the TuxCare registry on for the workspace or the repository. It is on by default.
- A committed lockfile, for example
package-lock.json. - A supported package manager: npm, pnpm, Yarn, Bun, pip, uv, Poetry, PDM, Pipenv, conda, Maven, or Gradle. Deno: the
importsofdeno.jsononly. Maven and Gradle need no BOM file.
Use the TuxCare registry, or your own repositories #
The setting Use the TuxCare registry says whether the CLI uses the TuxCare registry for the projects of the workspace. It is on by default.
- On: the portal gives the CLI the address of the TuxCare registry and the registry token. The CLI points the package managers of the project at the TuxCare registry, and
tuxcarectl auth loginandregistry loginwrite the registry token into the user files of your package managers, for example~/.npmrc. - Off: the portal gives the CLI no registry address and no registry token.
auth loginandregistry loginthen write no registry and no token into the files of your package managers. Turn it off when your builds use only your own package repositories, for example Artifactory or Nexus. A mirror that serves the TuxCare builds is not such a case: keep the setting on (see Your own mirror).
The TuxCare registry needs a SecureChain or an ELS subscription. A workspace with neither gets no registry, whatever the setting says: the portal gives the CLI no registry address and no registry token, also for a repository with the value On. The CLI then gets the reason the TuxCare registry needs a SecureChain or an ELS subscription, and this workspace has neither
, and the repository page shows Use the TuxCare registry: Not available with the same reason. The values of the setting stay as they are. When TuxCare adds a subscription, the values apply again: with the default, every repository uses the TuxCare registry. Contact TuxCare to add a subscription.
An admin sets the value of the workspace under Settings › Registry and CLI › Use the TuxCare registry. A repository can have a value of its own: open the repository, select More, and under Use the TuxCare registry select Workspace default, On, or Off. In a clone of the repository, tuxcarectl registry use on, off, or default does the same, and prints the value that applies now. When the workspace has neither SecureChain nor ELS, it prints the reason and stops with exit code 3. The value of the repository wins in both directions: a repository with On uses the TuxCare registry in a workspace with the value off. Only an admin can change the value of the workspace. A member or an admin of a repository can change the value of that repository: a person with the role viewer on the repository, a token of one repository or of one department (a CI token), and a TuxCare staff session cannot. A token of a person needs the permission write. The other people see the values on the repository page. The Audit log records each change as settings.registry_use.
For a token of one repository, the portal uses the value of that repository. For another token, it uses the value of a repository only when the CLI names the repository by its git remote. Else it uses the value of the workspace.
After an admin turns the setting off. The files that an earlier auth login, registry login, or init wrote still point your package managers at the TuxCare registry. Remove those lines. Each line names the registry host: the registry: line of .tuxcare.yaml names it, and on sc.tuxcare.cloud it is artifacts.tuxcare.com. git grep -n artifacts.tuxcare.com finds the lines in a repository. A registry: line that names your own mirror is your choice: keep it. While the setting is on, a new auth login writes the lines again.
- On each computer where you ran
auth loginorregistry login: runtuxcarectl auth logoutwith no--tenant, thentuxcarectl auth loginagain.auth logoutremoves the registry lines from the user files of your package managers, for example~/.npmrc,~/.yarnrc.yml,~/.netrc,pip.conf,uv.toml, and~/.m2/settings.xml, with the securechain header line at the top of each file, and it removes the kept registry credential. It changes no other line. It also removes every sign-in of the computer. The newauth loginwrites no registry line. Ifauth logoutcannot find the registry, it changes no file and a warning names the files: run it in a repository whereinitran, or remove the lines by hand. If you also use a workspace where the setting is on, runtuxcarectl registry loginin a repository of that workspace after the new sign-in.auth logoutcannot find apip.confthat a relativePIP_CONFIG_FILEnames: it warns, and you remove thatindex-urlline by hand. - In a repository where
harden,update, ormigrateran: runtuxcarectl unharden. It removes the TuxCare builds and the registry lines ofinit. Then remove theregistry:line of.tuxcare.yamlwhen it names the TuxCare registry. Do not remove it beforeunharden:unhardenfinds the registry lines through it. - In a repository where only
initran: remove the registry lines ofinitby hand, for example in.npmrc,.yarnrc.yml,pnpm-workspace.yaml,bunfig.toml,pyproject.toml,requirements.inorrequirements.txt,Pipfile,environment.yml,.github/dependabot.yml, andrenovate.json. With Bun 1.4.0 or later on thePATH,initalso writes[install] registryinto an existingbunfig.tomlwhose registry is the public npm registry, because that Bun readsbunfig.tomlbefore.npmrc. Each of these files exceptrenovate.jsonalso holds the securechain header line ofinit:# securechain wrote the TuxCare registry lines in this file. Run "securechain unharden" to remove them.Remove that line too. Also remove theregistry:line of.tuxcare.yamlwhen it names the TuxCare registry. Whereinitchanged a line that was there before, theunharden:block of.tuxcare.yamlholds the old text: put that text back, then remove the block. Commit the result.
The command reference lists the options of auth logout, auth login, and registry login.
Set up a project #
cd path/to/your/project
tuxcarectl init # one time for each repository
tuxcarectl registry login # one time for each computer
initwrites.tuxcare.yamland makes the TuxCare registry the package source of the project, for example in.npmrc. It writes no credential. Commit the files that it names.init --dry-runshows the changes and writes nothing.registry logingets the registry credential from your workspace and writes it into the configuration of your package managers in your home directory, for example~/.npmrc. It lists the files that it changed, andtuxcarectl auth logoutremoves its lines: see The files that auth login and registry login write. Each person who installs the project runs it one time. Run it again when an admin changes the registry token.- If the project already uses your own registry, such as Artifactory or Nexus,
initandregistry loginkeep it and tell you so.--replace-sourcemakes the TuxCare registry the source. To get the TuxCare builds through your mirror, see Your own mirror: Artifactory or Nexus.
Move the project to the builds: harden #
tuxcarectl harden --dry-run # show the plan and the changes; write nothing
tuxcarectl harden
hardenasks the portal which TuxCare builds your subscription has for the dependencies of the project.- It writes those builds into the manifest and the lockfile.
- It can also change
.yarnrc.yml,pnpm-workspace.yaml, orbunfig.toml, for example for the release-age excludes. Each such file gets the securechain header line as its first line.package.jsonanddeno.jsonget no header, and a warning ofhardennames each one.unhardenremoves the header with the lines. - It runs the install command of your package manager.
- It checks that each planned build is installed. If the check fails, it puts your files back and exits with code 6.
- It sends the new package list to your workspace.
Then run your tests, and commit the manifest, the lockfile, and each other file that harden changed.
hardenkeeps the version of each package.1.3.1moves to the newest build of1.3.1, for example1.3.1-tuxcare.2.--allow-minor-upgradeslets a package move to a later version with the same major and minor numbers, when only that version has a build that closes the findings.1.3.1can move to1.3.2-tuxcare.1, never to1.4.0.--includeand--excludelimit the run to the packages that you name.
Keep the builds current: update #
tuxcarectl update --check-only # exit code 1 when a newer build exists; write nothing
tuxcarectl update
TuxCare publishes a new build when it fixes a new vulnerability in a version. update moves each TuxCare build of the project to the newest build of the same version, for example from 1.3.1-tuxcare.2 to 1.3.1-tuxcare.3. It installs and checks the result, as harden does. Run it on a schedule, or when the portal shows a finding that a newer build fixes.
The gate: check #
tuxcarectl check reads the installed dependencies and changes nothing. It exits with code 1 when the project is not in the state that harden made:
- A package has a finding, your subscription has a TuxCare build that fixes it, and the project does not use the build.
- A newer TuxCare build exists for a build that the project uses.
- The lockfile points at the public registry for a package that
hardenmoved to a TuxCare build.
--explain prints the evidence and the fix for each problem.
TuxCare builds in CI #
A job that installs TuxCare builds needs the registry credential before the install step. The job does three things in this order: get the credential, install, run check.
GitHub Actions:
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@v4
- uses: TuxCare/tuxcarectl-action@v0
with:
command: registry
portal-token: ${{ secrets.TUXCARE_PORTAL_TOKEN }}
- run: npm ci
- uses: TuxCare/tuxcarectl-action@v0
if: always()
with:
portal-token: ${{ secrets.TUXCARE_PORTAL_TOKEN }}
registry-login: none
- The first use of the action gets the credential for the install step.
- The second use runs
tuxcarectl checkand sends its result to GitHub code scanning.if: always()runs it after a failed install too: its last step removes the credential of the job.
GitLab CI:
tuxcarectl:
image: node:22 # any image that has curl and your package manager
script:
- curl -fsSL https://securechain.tuxcare.com/get/tuxcarectl | sh
- out="$(tuxcarectl registry env --job-dir "/tmp/tuxcarectl-job-$CI_JOB_ID" --format shell)"; eval "$out"
- env -u TUXCARE_PORTAL_TOKEN npm ci
- tuxcarectl check --output junit > report.xml
after_script:
- rm -rf "/tmp/tuxcarectl-job-$CI_JOB_ID"
artifacts:
reports:
junit: report.xml
registry env --job-dirwrites the credential into a directory for this job, and prints the variables that point npm, pnpm, Yarn 1, and the Python tools at it. It changes no file in the home directory of the runner.- From CLI version 0.1.89,
registry env --job-direxits 5, writes no job directory, and prints no variable when an.npmrcor apnpm-workspace.yamlof the checkout setsstrict-ssl(strictSsl) to a value other thantrue, and the pnpm of the job takes that setting: pnpm 12.0 to 12.15 for.npmrc, pnpm 10.6 to 10.x forpnpm-workspace.yaml. With CLI 0.1.99 or later, the CLI reads more spellings of the.npmrckey before it decides: a key under a[section](pnpm 12.0 to 12.15 read it at the top level), and a key with a variable such as${X?}read as empty. On a pnpm in the range of the file it also refuses a key in quotes or with a JSON escape, a key after a bare carriage return, and a key cut at#: pnpm 11 or a later pnpm 12 reads such a spelling, and the refusal is wider than each pnpm on purpose. An.npmrcthat setsstrict-ssl=falseand thentrueon a later line with the key in another spelling (in quotes, in upper case, or with_,--, or[]) is refused too: pnpm 12.0 to 12.15 take only the keystrict-ssl, so for them thefalsestays. The commands that run pnpm with the registry credential stop at the same settings before pnpm starts.tuxcarectl checkreports astrict-sslvalue other thantruein each of these readings asregistry-transport-in-project, whatever pnpm version the project uses. Such a pnpm would send the registry credential over a connection that it does not verify. Remove the setting from the file. If your network needs a certificate authority, put it in your own~/.npmrc(cafile), or use pnpm 12.16 or later (11.0 or later forpnpm-workspace.yaml). From CLI version 0.1.90, the refusal also judges the pnpm that apackage.jsonof the checkout pins inpackageManagerordevEngines.packageManager: pnpm starts that pinned version in place of the pnpm on thePATH. So a pin in the range of the file (adevEnginesrange that holds such a version, or a pin that the CLI cannot read) is refused also when the pnpm on thePATHis newer. Name pnpm 12.16 or later (11.0 or later forpnpm-workspace.yaml) in those fields ofpackage.jsontoo.--pnpm-project-strict-ssl warnofregistry env, orTUXCARE_PNPM_PROJECT_STRICT_SSL=warn, keeps the warning of earlier versions in place of the refusal until 2027-12-01. Each run with it prints a deprecation warning. registry env --job-diralso exits 5, writes no job directory, and prints no variable when a project file of the checkout names anhttpURL on the host of the TuxCare registry. It reads each.npmrc,.yarnrc,package.json,package-lock.json,npm-shrinkwrap.json,pnpm-lock.yaml,pnpm-workspace.yaml,yarn.lock,bunfig.toml, andbun.lockof the checkout, but notnode_modules. The job gives npm, pnpm, Yarn 1, and Bun 1.4.4 and later the registry key of that host, and each of them sends the key to each address on the host, also over plainhttp. So a step of the job would send the registry credential in plain text. The message names the file and the line. To fix it, usehttpsin that line. In a lockfile, change the URL, or remove the entry and install again. A$NAMEor${NAME}of abunfig.tomlor.npmrccounts with each value that a.envfile of Bun in the checkout sets:.env,.env.local,.env.development,.env.production, or.env.test, each also with.localat the end. Bun can load these files and fill in the variable. When such a value is anhttpURL on the host, the message also names the.envfile. To fix it, usehttpsin that value.env -u TUXCARE_PORTAL_TOKENruns the install without the access token, so the install scripts of your dependencies cannot read it.- On gitlab.com, the CI/CD component does these steps for you, also for Yarn 2 and later and for Bun. When the
installcommand fails, the job exits 5, not with the code of the install (from the CLI release after version 0.1.72):
include:
- component: $CI_SERVER_FQDN/tuxcare/tuxcarectl-ci/check@0
inputs:
stage: test
install: npm ci
Rules for a project with TuxCare builds #
- Commit the lockfile, and install from it. In CI, use the install command that follows the lockfile, for example
npm ci. - Move TuxCare builds with
tuxcarectl updateonly. Give your update bot the rule of Renovate and Dependabot. A version that ends in-tuxcare.Nis not in the public registry.npm update,npm audit fix, and other tools that select versions by themselves do not know these builds. They stop withETARGET, or they put the public version back. - Add a new dependency as usual, for example with
npm install --save-exact name. Then runtuxcarectl hardenagain, so that the new packages get their builds. - On Bun, record each edit of the override block with one install on the builds path.
bun.lockkeeps a copy of the block that Bun reads:overridesinpackage.json, elseresolutions. When you add a key of your own, or change a key thathardenwrote, the nextbun installresolves every override again, not only the changed key. The registry of the project is/npm-upstream/, which has no TuxCare builds (see the two paths of the registry). So the install stops with exit code 1 and does not changebun.lock. Bun shows a line such asNo version matching "2.1.3-tuxcare.2" found for specifier "ms"
, andms@^2.1.3 failed to resolve
for each build.bun install --frozen-lockfilestops in the same way. TuxCare measured this on Bun 1.3.14 and 1.4.4. A change of a nested value, for example"debug": {"ms": "2.1.2"}, stops the install on Bun 1.4.4 only. To fix it, run this command once in the directory ofbun.lock, and then commitbun.lock:BUN_CONFIG_REGISTRY=https://registry host/npm/ bun install. The registry host is in theregistry:line of.tuxcare.yaml. Keep the slash at the end. After that, each install from the lockfile passes. Whenregistry:names your own mirror, which serves the builds at the address of the project, run a plainbun installonce and commitbun.lock.tuxcarectl checkreports this state asbun-lockfile-overrides, at high severity, and its fix gives the command. For some forms of key, for example a path such asdebug>ms, the two Bun versions record the block in different ways:checkthen does not judge the block, and a warning names the key. npm and Yarn 1 keep the other builds after such an edit.
npm: the two paths of the registry #
For npm, the TuxCare registry has two paths on one host:
/npm-upstream/serves the packages of the public npm registry, byte for byte.initandregistry loginwrite it as the registry of the project and of your computer./npm/serves the TuxCare builds.hardenandupdatewrite it into the lockfile lines of the builds, with the hash of each build.
So a new TuxCare build never changes what an existing lockfile installs, and the install does not fail with EINTEGRITY. pnpm and Yarn 2 or later also use /npm-upstream/ as the source: harden writes /npm/ into the lockfile entry of each build. A project that a CLI before 0.1.21 set up names /npm/ as the source of pnpm and Yarn 2 or later. The next tuxcarectl init changes it, and keeps the lockfile.
A tool that selects a version for a TuxCare build against /npm-upstream/ stops, because that path has no TuxCare builds: npm update and an install with no lockfile stop with ETARGET. On Bun, an edit of the override block has the same effect: see the rule for Bun.
Remove TuxCare builds: unharden #
tuxcarectl unharden --dry-run # show the changes; write nothing
tuxcarectl unharden
unharden undoes init and harden. Use it when you stop the subscription, or to go back to the public packages.
- It puts back each line that
init,harden, andupdatechanged. These commands keep the original text underunharden:in.tuxcare.yaml. With--configorTUXCARE_CONFIG,harden,update,migrate, andunhardenkeep theunharden:record in that file, not in the.tuxcare.yamlof--dir. Rununhardenwith the same--dirand the same--configasharden. For a line with no record,unhardenwrites the base version of the build:4.4.3for4.4.3-tuxcare.5. - It removes the registry lines, the overrides, and the bot rules that the CLI added, with the securechain header line of each file, and the
unharden:block of.tuxcare.yaml. It keeps the rest of.tuxcare.yaml, also theregistry:line. - It installs again from the public registry and checks that no TuxCare build is left. If the check fails, it puts your files back and exits with code 6.
- It needs no token, so it works after the subscription ends.
Then run your tests, and commit the changed files.
Next: Malicious packages