Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/node-maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ See the [tested versions](../node/runtime/toolchain.json).
| --- | --- |
| `validationScript` | Existing nonempty package script; default `"build"`. Names start with a letter or digit and contain only letters, digits, `:`, `_`, `.`, or `-`. |
| `localPatches` | Project-local declarations identifying advisories mitigated by local patches. These are maintainer assertions, never inherited or counted as independently confirmed security fixes. See [local patches](#local-security-patches). |
| `advisoryNotes` | Project-local text keyed by GHSA ID explaining decisions such as deferral. Display only; findings and repair eligibility stay unchanged. See [advisory notes](#advisory-notes). |
| `minimumReleaseAgeDays` | Minimum release cooldown in days; nonnegative integer, default `10`. pnpm workspace policy must be at least this strict. |
| `maintenance.mode` | `"security-only"` or `"security-and-maintenance"`. A schedule object defaults to security-only unless a mode is supplied locally or inherited. |
| `maintenance.upgradeScope` | Maximum routine direct upgrade level: `"patch"`, `"minor"` including patches, or `"major"` including both (default). Security fixes are handled separately. |
Expand Down Expand Up @@ -468,6 +469,37 @@ Use a workflow revision whose `node/contract.json` includes `local_patches`
support. Use `@v1` or update both immutable pins together; older version-6 revisions do not
accept `localPatches`.

## Advisory notes

Add context for an advisory in `.github/node-maintenance.json`:

```json
{
"advisoryNotes": {
"GHSA-5gmw-xhrv-c9v3": "Deferred: the affected worker feature is disabled in this project. Reassess before enabling it or changing the parent dependency."
}
}
```

Merge this field into the existing configuration. Up to 32 GHSA IDs are supported,
each with nonempty single-line plain text of at most 2048 characters. The existing
64 KiB configuration limit still applies. Formatting is displayed as text. Notes
stay local to the repository and are not inherited from shared defaults.

Matching notes appear beside current package findings in audit and selected-repair
reports. They persist through report regeneration because they come from project
configuration. Notes are omitted when their advisory is absent; the configuration
entry remains for later matching audits. Review and remove stale notes yourself.

A note explains a maintainer decision. It does not certify mitigation, suppress
the advisory, change severity or counts, prevent a repair, or count as a fix.
Use `localPatches` separately for actual local patch assertions. Notes are not
copied into raw audit evidence or each retained repair attempt. Configuration
is public project data and notes appear in published reports; do not include secrets.

Use workflows whose `node/contract.json` declares `advisory_notes` support. Older
version-6 revisions reject this field. Adoption needs no new permissions.

## Update or migrate an installation

For an earlier Docusaurus installation, use the [migration checklist](node-migration.md).
Expand Down
7 changes: 7 additions & 0 deletions node/contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@
"automatic_patch_removal": false,
"notification": "one issue per repository for published official fixes"
},
"advisory_notes": {
"config_key": "advisoryNotes",
"inherited": false,
"maximum_notes": 32,
"maximum_characters_per_note": 2048,
"effect": "display only; findings and repair eligibility are unchanged"
},
"breaking_changes": {
"previous_component": "docusaurus",
"old_configuration": ".github/docusaurus.json",
Expand Down
6 changes: 6 additions & 0 deletions node/maintenance.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ evidence. It does not prove patch application or security effectiveness, remove
raw findings, or count as a confirmed security fix. See
[declaring local patches](../docs/node-maintenance.md#local-security-patches).

For decisions such as deferring an advisory, use project-local `advisoryNotes`
instead of declaring a patch. These plain-text notes accompany matching current
findings without changing evidence, severity, counts or repair eligibility. They
are not inherited or duplicated into repair history. See
[advisory notes](../docs/node-maintenance.md#advisory-notes).

Upgrade audits attempt security fixes first, then routine stable upgrades.
`maintenance.upgradeScope` limits routine **direct** upgrades to `patch`, `minor`
(including patches), or `major` (the default, including both). Restricted scopes
Expand Down
57 changes: 57 additions & 0 deletions node/runtime/advisory_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Display project-local context without changing advisory evidence or decisions."""

import html
import re
import unicodedata

GHSA = r"GHSA-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}"


def validate(value):
if not isinstance(value, dict) or len(value) > 32:
raise ValueError("advisoryNotes must be an object of at most 32 notes")
for advisory, text in value.items():
if not isinstance(advisory, str) or not re.fullmatch(GHSA, advisory):
raise ValueError("advisoryNotes requires a GHSA identifier")
if (
not isinstance(text, str)
or not text.strip()
or len(text) > 2048
or any(unicodedata.category(c) in {"Cc", "Cs", "Zl", "Zp"} for c in text)
):
raise ValueError(
"advisoryNotes values must be nonempty single-line Unicode text of at most 2048 characters"
)
return value


def render(data, notes):
"""Match exact GitHub advisory URLs and show each active note once."""
validate(notes)
if not notes or not isinstance(data, dict):
return ""
reported = {
detail.get("url")
for vulnerability in data.get("vulnerabilities", {}).values()
for detail in vulnerability.get("via", [])
if isinstance(detail, dict)
}
rows = []
for advisory, text in sorted(notes.items()):
if "https://github.com/advisories/" + advisory not in reported:
continue
# Encode formatting as text, including table separators and task markers.
escaped = re.sub(
r"[\\`*_\[\]~!|]",
lambda match: f"&#{ord(match[0])};",
html.escape(text),
)
rows.append(f"- **{advisory}**: {escaped}")
if not rows:
return ""
return (
"**Maintainer notes**\n\n"
"Project context only. Findings, severity and repair eligibility are unchanged.\n\n"
+ "\n".join(rows)
+ "\n\n"
)
5 changes: 4 additions & 1 deletion node/runtime/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

SCHEDULING = runpy.run_path(str(Path(__file__).with_name("scheduling.py")))
LOCAL_PATCHES = runpy.run_path(str(Path(__file__).with_name("local_patches.py")))
ADVISORY_NOTES = runpy.run_path(str(Path(__file__).with_name("advisory_notes.py")))

MAX_BYTES = 65536
MAX_SOURCES = 8
SHARED_KEYS = {"toolchain", "maintenance", "minimumReleaseAgeDays", "schedule"}
LOCAL_KEYS = {"directory", "validationScript", "localPatches"}
LOCAL_KEYS = {"directory", "validationScript", "localPatches", "advisoryNotes"}


def json_object(data, location, max_bytes=MAX_BYTES):
Expand Down Expand Up @@ -77,6 +78,8 @@ def validate_settings(config, location):
raise ValueError(f"{location}: unknown configuration fields: {sorted(unknown)}")
if "localPatches" in config:
LOCAL_PATCHES["validate_declarations"](config["localPatches"])
if "advisoryNotes" in config:
ADVISORY_NOTES["validate"](config["advisoryNotes"])
if "schedule" in config:
SCHEDULING["validate_schedule"](config["schedule"])
if "defaults" in config:
Expand Down
7 changes: 7 additions & 0 deletions node/runtime/fleet.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,13 @@ def check_caller(root, config, selected, github, default_branch="main"):
raise ValueError(
"Pinned workflows do not support localPatches; update both workflow pins"
)
if (
"advisoryNotes" in config
and contract.get("advisory_notes", {}).get("config_key") != "advisoryNotes"
):
raise ValueError(
"Pinned workflows do not support advisoryNotes; update both workflow pins"
)
toolchain = CONFIGURATION["json_object"](
source.read("node/runtime/toolchain.json"), "pinned toolchain support"
).get("supported", {})
Expand Down
29 changes: 26 additions & 3 deletions node/runtime/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,17 @@ def report_rows(report):


def cumulative_report(
history, expected, directory, selected, snapshot, candidate, before, after, fixed
history,
expected,
directory,
selected,
snapshot,
candidate,
before,
after,
fixed,
*,
advisory_notes=None,
):
project = directory.relative_to(Path.cwd().resolve()).as_posix()
state = ENGINE["dependency_state"](snapshot)
Expand Down Expand Up @@ -1148,7 +1158,10 @@ def cumulative_report(
"| Package | Update | Severity | Advisories | Action / blocker | Security evidence |\n| --- | --- | --- | --- | --- | --- |\n"
+ "\n".join(rows)
)
report += "\n\n" + ENGINE["history_marker"](record) + "\n"
report += "\n\n" + ENGINE["ADVISORY_NOTES"]["render"](
after, {} if advisory_notes is None else advisory_notes
)
report += ENGINE["history_marker"](record) + "\n"
if len(report.encode()) > 1048576:
raise ValueError("Cumulative history exceeds its bound; no artifact sealed")
return report
Expand Down Expand Up @@ -1448,6 +1461,7 @@ def prepare_candidate(expected, artifact):
):
raise ValueError("Preparation requires a clean checkout of the expected head")
directory, selected, snapshot = project_context()
config = PROJECT["CONFIGURATION"]["local_configuration"](root)
history = native_history(expected, directory, snapshot)
deadline = time.monotonic() + 40 * 60
before = ENGINE["audit"](directory, deadline=deadline)
Expand Down Expand Up @@ -1503,7 +1517,16 @@ def prepare_candidate(expected, artifact):
)
validate_envelope(envelope, expected, envelope["project_directory"])
report = cumulative_report(
history, expected, directory, selected, snapshot, candidate, proof, after, fixed
history,
expected,
directory,
selected,
snapshot,
candidate,
proof,
after,
fixed,
advisory_notes=config.get("advisoryNotes", {}),
)
if artifact.resolve() != artifact or artifact.is_relative_to(root):
raise ValueError("Candidate artifacts must be outside the project checkout")
Expand Down
16 changes: 16 additions & 0 deletions node/runtime/templates/dependency_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import yaml

LOCAL_PATCHES = runpy.run_path(str(Path(__file__).parents[1] / "local_patches.py"))
ADVISORY_NOTES = runpy.run_path(str(Path(__file__).parents[1] / "advisory_notes.py"))
NODE_RELEASES = runpy.run_path(str(Path(__file__).parents[1] / "node_releases.py"))
HISTORY = runpy.run_path(str(Path(__file__).parents[1] / "history.py"))
REPAIR_CHOICES = runpy.run_path(str(Path(__file__).parents[1] / "repair_choices.py"))
Expand Down Expand Up @@ -3270,6 +3271,7 @@ def prepare(
maintenance_mode="security-and-maintenance",
upgrade_scope="major",
local_patches=None,
advisory_notes=None,
validate_only=False,
prepare_only=False,
platform=None,
Expand Down Expand Up @@ -3298,6 +3300,9 @@ def prepare(
"Valid manifest, one deployment lockfile and package-manager policy are required"
)
declared_patches = LOCAL_PATCHES["validate_declarations"](local_patches or [])
advisory_notes = ADVISORY_NOTES["validate"](
{} if advisory_notes is None else advisory_notes
)
scripts = initial_snapshot[2].get("scripts", {})
if (
not isinstance(validation_script, str)
Expand Down Expand Up @@ -3992,6 +3997,7 @@ def published_patch_versions(specifier, *, all_versions=False):
)
if isinstance(after, str):
report += f"{after}\n\n"
report += ADVISORY_NOTES["render"](after, advisory_notes)
report += LOCAL_PATCHES["render"](patch_report)
if initial_ids is not None and remaining_ids is not None:
new_count = len(new_ids)
Expand Down Expand Up @@ -4479,11 +4485,18 @@ def main() -> None:
or installed_manager.stdout.strip() != record["manager_version"]
):
raise ValueError("Installed toolchain differs from sealed evidence")
project = runpy.run_path(str(Path(__file__).parents[1] / "project.py"))
config = (
project["CONFIGURATION"]["local_configuration"](Path.cwd())
if (Path.cwd() / ".github/node-maintenance.json").exists()
else {}
)
report = prepare(
directory,
validation=validation,
validate_only=True,
validation_script=record["validation_script"],
advisory_notes=config.get("advisoryNotes", {}),
)
if node_plan is not None:
node_proposal["verify_candidate"](Path.cwd().resolve(), node_plan)
Expand All @@ -4508,6 +4521,7 @@ def main() -> None:
return
try:
patches = []
advisory_notes = {}
node_plan = None
if args.node_update is not None:
node_proposal = runpy.run_path(
Expand All @@ -4525,6 +4539,7 @@ def main() -> None:
raise ValueError("Selected directory differs from the resolved project")
resolved = json.loads(args.resolved_config.read_bytes())
patches = resolved["configuration"].get("localPatches", [])
advisory_notes = resolved["configuration"].get("advisoryNotes", {})
report = prepare(
directory,
validation=validation,
Expand All @@ -4533,6 +4548,7 @@ def main() -> None:
maintenance_mode=args.maintenance_mode,
upgrade_scope=args.upgrade_scope,
local_patches=patches,
advisory_notes=advisory_notes,
validate_only=args.validate_only,
prepare_only=args.prepare_only,
platform=NODE_RELEASES["collect"](node_plan),
Expand Down
Loading
Loading