The problem

Take an online shop in a monorepo, driven by moon. The Symfony services order and stock lock their dependencies in their composer.lock, the Vue front shop in the workspace's yarn.lock. Each project inherits an audit task that the quality gate requires, as described in our article on moon task inheritance.

One morning, a security advisory is published for a Symfony package that both order and stock lock. The pull request that adds a field to Reservation turns red on the audit, and so does the one that fixes a test in order. Neither of them touched a dependency.

The audit is not a check like the others. Lint and tests judge the diff: same commit, same verdict. The audit compares a lockfile with an advisory database that changes without a commit: the same commit, green yesterday, is red this morning.

Without a routine, the day goes badly. Everyone re-runs their job hoping for a false positive, or slips a full composer update into their feature. Someone adds an undated exception, then the audit task gets disabled "temporarily".

Meanwhile, Dependabot alerts point at a lockfile that nothing reads any more. The team learns to stop looking at them.

The options

Taking the audit out of the quality gate

  • What it solves: each pull request depends on its diff alone. A scheduled job on main publishes the report.
  • What it costs: a report nobody has to read. A merge can add a known vulnerable dependency with nothing to hold it back.

Auditing only what the pull request changes

  • What it solves: the verdict goes back to being a function of the diff. On GitHub, dependency-review-action fails when the pull request introduces a vulnerable dependency.
  • What it costs: vulnerabilities already on main no longer block anything. On a private repository, the action needs a GitHub Advanced Security licence.

Blocking above a severity threshold

  • What it solves: fewer interruptions. yarn npm audit --severity high, or ignore-severity on the Composer side, let minor advisories through.
  • What it costs: the severity describes the package, not your use of it. A medium advisory on the parser that reads your requests matters more than a high one in a build tool.

Keeping the audit blocking, with a remediation routine

  • What it solves: no known vulnerability stays on main beyond the remediation, and every exception is written down.
  • What it costs: an unpredictable interruption, to be handled fast, and a routine to know before you need it.

Our recommendation

Keep the audit blocking over all the lockfiles, and answer each advisory with a dedicated, minimal remediation pull request, merged first.

Blocked pull requests are not fixed one by one. A single pull request, which touches only the flagged packages, unblocks them all as soon as it is merged. When no patched version exists, it carries a dated exception instead of an update.

One minimal remediation PR unblocks every red PR at once 1. An advisory is published the advisory database changes: no commit, no diff 2. Every affected PR turns red the audit judges the lockfile, not the PR's diff if a patched version exists 3. A dedicated, minimal remediation PR only the flagged packages, with their dependencies 4. Merged into main first Dependabot closes its alerts on the default branch 5. The waiting PRs, once updated, turn green merge main or rebase; re-running the job is not enough no patched version Dated exception ID, reason, review date in the remediation PR Review on the set date if a fix has shipped, back to step 3 Minimum age: a fix that is too recent waits out the delay, or is pre-approved at its exact version.

Situation Move
Patched version allowed by the constraints targeted update: composer update -w -m, yarn up -R
Patched version outside a parent's range Yarn resolution scoped to that parent
No patched version reasoned exception, with a review date
Alert on a lockfile that nothing reads removal of the orphan lockfile
Fix published an hour ago minimum age gate, or pre-approval of the exact version

A deprecated or abandoned package also arrives without a diff, but it exposes you to nothing new on the day it is flagged. So it does not block the gate: the scheduled report on main lists it, and the regular updates deal with it.

We write this routine into the repository's instructions file (AGENTS.md, CLAUDE.md). A coding agent follows it, instead of drowning a red audit in a full composer update.

The trade-offs we accept

A pull request can stay red for a reason that has nothing to do with it. We accept it, provided the remediation goes in before any other merge. The red says something true: main contains a known vulnerability.

A resolution imposes a version the parent has not tested. We read what the parent calls in the package, then we run the build and the tests. The resolution goes away as soon as a version of the parent accepts the fix.

An exception is an accepted risk. It says why the code is not exposed, and until when that analysis holds. Without a date, it becomes permanent by oversight.

The age gate delays fixes too. A patched version published an hour ago is invisible to the installer. For an urgent advisory, we pre-approve that exact version, not the whole package.

The signal that should make us revisit these choices: remediations that drag on for days, a list of exceptions that keeps growing, an audit task that gets bypassed. The severity threshold or the diff-only audit are then worth evaluating again.

Implementation

The examples use Composer 2.10.2 or later, Yarn 4.18, Symfony 7.4 and moon 2.

1. One audit task per project, without cache

Our article on moon task inheritance defines the audit task: inherited from .moon/tasks/, without cache. On a pull request, it only runs in the affected projects. With runInCI: always, which audits every project, the remediation would have to fix Composer and Yarn if both are hit together, or it would stay red.

By default, yarn npm audit only looks at the workspace's direct dependencies; --recursive adds the transitive ones. Yarn 4 also reports deprecated packages, at the "moderate" level, and --no-deprecations takes them out of the gate. On the Composer side, --abandoned=report, which we add to composer audit --locked, does the same for abandoned packages.

2. A minimal Composer remediation

# services/order: update only the flagged packages
packages=$(composer audit --locked --format=json | jq -r '.advisories | keys | join(" ")')
# Empty list: run nothing, a composer update without arguments updates everything
[ -n "$packages" ] && composer update $packages --with-dependencies --minimal-changes
composer audit --locked

The JSON from composer audit groups the advisories by package name. --with-dependencies (-w) allows their dependencies to be updated, except those composer.json requires directly. --minimal-changes (-m, Composer 2.7) only changes them when it has to.

The listed packages move up to the latest allowed version; with Flex, extra.symfony.require (7.4.*) keeps them within the minor version. During an update, Composer also refuses by default a version an advisory covers: audit.block-insecure since 2.9, policy.advisories.block since 2.10.

We run the same command in stock: both services end up on the same versions, in the same pull request. The lockfile diff is limited to the flagged packages and what they require: it is quick to review.

3. On the Yarn side: yarn up -R, then a resolution scoped to the parent

# Workspace root: who pulls the package, then resolve all its ranges again
yarn why vulnerable-lib -R
yarn up -R vulnerable-lib
yarn npm audit --all --recursive
yarn dedupe --check

For each advisory, Yarn's report gives its numeric identifier (ID), the URL of the GitHub advisory and the packages that depend on it. yarn up -R resolves again every range that targets the package, often to the highest allowed version, and only writes to yarn.lock. If a parent still requires ^3.0.0 while the fix only exists in 4, the command can do nothing.

You then need a resolution, scoped to the parent:

// package.json (workspace root, excerpt)
{
  "resolutions": {
    "parent-plugin/vulnerable-lib": "^4.0.1"
  }
}

This key only replaces the copy pulled by parent-plugin. A global key, vulnerable-lib alone, would also replace the copies of another major version, whose API may differ. Yarn accepts a single level of specificity: parent/dep, optionally with the parent's version.

Before merging, we check that the API the parent calls has not changed, then moon run shop:build shop:test does the rest. package.json does not accept comments: the reason and the removal condition go in the pull request description.

4. No patched version: a dated exception

// services/order/composer.json (excerpt)
{
  "config": {
    "policy": {
      "advisories": {
        "ignore-id": {
          "GHSA-xxxx-xxxx-xxxx": "No patched version. The affected function only reads our own configuration, never external input. Review on 2027-01-31."
        }
      }
    }
  }
}

The policy block (Composer 2.10) accepts a GHSA, CVE or Packagist (PKSA) identifier, with a free-text reason. Since 2.11, it is part of the composer.lock hash: composer update --lock goes with the exception. Yarn only accepts a list of identifiers:

# .yarnrc.yml (excerpt)
npmAuditIgnoreAdvisories:
  # unmaintained-lib <= 2.3.1 (GHSA-xxxx-xxxx-xxxx, low): no patched version.
  # Only parent: a build plugin that merges nothing but its own defaults.
  # Review on 2027-01-31, or as soon as a patched version ships.
  - '1234567'

Yarn matches this list against the numeric identifier the npm registry returns, never against the GHSA. So the comment keeps both. A scheduled review reads the dates:

#!/usr/bin/env sh
# tools/audit-exceptions-due.sh: fails when an exception has reached its review date
set -eu
today=$(date +%F)
due=$(grep -hoE 'Review on [0-9]{4}-[0-9]{2}-[0-9]{2}' .yarnrc.yml services/*/composer.json \
  | awk -v today="$today" '$3 <= today { print $3 }')
if [ -n "$due" ]; then
  echo "Audit exceptions to review: $due"
  exit 1
fi

This script runs in the scheduled job on main, not in the gate. A passed date would turn every pull request red on the same day: exactly the problem we started from.

5. Hunting down orphan lockfiles

GitHub's dependency graph recognises package-lock.json, yarn.lock and composer.lock, and Dependabot raises alerts on what they declare. A package-lock.json forgotten in a front managed by Yarn serves no install, but produces alerts. Conversely, the lockfile of a tool without an audit task hides real vulnerabilities from the gate.

#!/usr/bin/env sh
# tools/check-lockfiles.sh: every tracked lockfile must be read by an audit task
set -eu
unexpected=$(git ls-files '*composer.lock' '*package-lock.json' '*pnpm-lock.yaml' '*yarn.lock' \
  | grep -vxE 'yarn\.lock|services/[a-z-]+/composer\.lock' || true)
if [ -n "$unexpected" ]; then
  echo "Lockfiles without an audit task: $unexpected"
  exit 1
fi

This check depends on the diff: it belongs in the gate. Each file it flags is deleted if nothing reads it, or attached to a project that audits it. Dependabot only marks the alert as fixed after a change on the default branch, so after the merge.

6. A minimum age, and an escape hatch for fixes

# .yarnrc.yml (excerpt)
npmMinimalAgeGate: 3d
npmPreapprovedPackages:
  # Fix for GHSA-xxxx-xxxx-xxxx, published before the end of the delay.
  # Review on 2027-01-31: remove once the delay has passed.
  - '[email protected]'

npmMinimalAgeGate (Yarn 4.10.0, 18 September 2025) rules out any version younger than this delay. Since Yarn 4.15.0 (19 May 2026), it defaults to one day, but an existing project keeps the old behaviour when it upgrades. So we write it down, with three days: the 72 hours during which npm allows a new package to be unpublished.

The downside: a fix younger than the delay is invisible, and yarn up -R keeps the vulnerable version. npmPreapprovedPackages exempts an exact version (package@version), visibly in the repository; --no-time-gate (Yarn 4.15) lifts the delay for a single command. On the PHP side, Composer 2.11.0 (29 October 2026) adds a cooldown policy, with per-package exceptions and the --no-cooldown option.

7. Unblocking the waiting pull requests

Once the remediation is merged, re-running the job of a blocked pull request is not enough. GitHub replays the same GITHUB_SHA, the merge commit computed before the fix. The branch has to be updated, by merging main or rebasing.

If the branch changes a lockfile too, we replay its command (composer require, yarn add) after the rebase. Resolving the conflict by hand produces a lockfile that nobody computed.

Checklist

  • One audit task per project, without cache, required by the quality gate.
  • Deprecated or abandoned packages reported without blocking (--no-deprecations, --abandoned=report).
  • A dedicated remediation pull request, merged before the others.
  • Targeted updates: composer update <packages> -w -m, yarn up -R <package>.
  • Resolutions scoped to their parent, removed as soon as the parent catches up.
  • Reasoned, dated exceptions: GHSA or CVE for Composer, numeric npm identifier for Yarn.
  • A scheduled review of the exception dates, outside the gate.
  • Every tracked lockfile read by an audit task, checked on each pull request.
  • An explicit minimum age, and pre-approval of an exact version for an urgent fix.
  • Blocked branches updated from main, not just re-run.

Sources

Versions checked on 15 November 2026: Composer 2.11.2, Yarn 4.18.1.