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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

### Security

- **Source Link tooling moved off a vulnerable release.** `Microsoft.SourceLink.GitHub` is bumped
from 8.0.0 to 10.0.404. 8.0.0 depends on `Microsoft.Build.Tasks.Git` 8.0.0, flagged by
[GHSA-23fw-v26w-5fgq](https://github.com/advisories/GHSA-23fw-v26w-5fgq) (CVE-2026-62900, .NET
information disclosure) with no patched 8.x release. Build-time only (`PrivateAssets="All"`):
package consumers gain no new dependency. The build SDK floor moves to 10.0.400 (`global.json`).

- **VT-escape injection gap closed.** Consumer text passed to `Segment`, `Line.FromText`, or
`LineBuilder` is now sanitized at construction. A raw escape sequence embedded in user-supplied
text could previously defeat the synchronized-output fence, reposition the cursor, or trigger
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ paraphrase them.
- `make build` — `dotnet build`; must be clean (analyzers run as warnings-as-errors; nullable enabled).
- `make test` — `dotnet test`; all green.
- `make format` — `dotnet format --verify-no-changes`; a check, never a rewrite.
- `make validate` — `openspec validate <change> --strict` for every active change; passes (and says so) when there is none.
- `make validate` — `openspec validate <change> --strict` for every active change; passes (and says so) when there is none; fails on a change folder whose name isn't `[A-Za-z0-9._-]`.
- `make gates` — all of the above.

`make deps` is separate: it checks that every tool and login in `docs/dependencies.md` is present.
Expand Down
32 changes: 23 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@

SHELL := /bin/bash

CHANGES := $(notdir $(patsubst %/,%,$(filter-out %/archive/,$(wildcard openspec/changes/*/))))
# Active changes are found by the shell at run time, never expanded by make into recipe text,
# so a folder name under openspec/changes/ can't inject commands. Names outside
# [A-Za-z0-9._-] (or starting with `-`) are reported and refused rather than passed on.
FOR_EACH_CHANGE := for d in openspec/changes/*/; do \
[ -d "$$d" ] || continue; \
c=$$(basename "$$d"); \
[ "$$c" = archive ] && continue; \
if [[ ! "$$c" =~ ^[A-Za-z0-9._][A-Za-z0-9._-]*$$ ]]; then \
printf 'refusing change folder with unsafe name: %q\n' "$$c" >&2; bad=1; continue; \
fi;

.PHONY: build test format validate changes gates deps

Expand All @@ -21,17 +30,22 @@ format:

# Validates every active change. With no active change there is nothing to validate,
# so it passes — but says so, rather than passing silently.
# An unsafe folder name fails validation.
validate:
@fail=0; \
if [ -z "$(CHANGES)" ]; then \
echo "no active change under openspec/changes/ — nothing to validate"; \
else \
for c in $(CHANGES); do openspec validate $$c --strict || fail=1; done; \
fi; \
@fail=0; bad=0; found=0; \
$(FOR_EACH_CHANGE) \
found=1; openspec validate "$$c" --strict || fail=1; \
done; \
[ $$bad -eq 0 ] || fail=1; \
[ $$found -eq 1 ] || [ $$bad -eq 1 ] || echo "no active change under openspec/changes/ — nothing to validate"; \
echo "VALIDATE_EXIT:$$fail"; exit $$fail

# One active change per line.
changes:
@echo "$(CHANGES)"
@bad=0; \
$(FOR_EACH_CHANGE) \
printf '%s\n' "$$c"; \
done

gates:
@$(MAKE) --no-print-directory -k build test format validate; code=$$?; \
Expand All @@ -42,7 +56,7 @@ gates:
deps:
@fail=0; \
dotnet --version >/dev/null 2>&1 || { echo "MISSING dotnet — brew install --cask dotnet-sdk"; fail=1; }; \
dotnet --version 2>/dev/null | grep -qE '^10\.0\.([3-9][0-9]{2})' || { echo "WRONG VERSION dotnet — need 10.0.300+"; fail=1; }; \
dotnet --version 2>/dev/null | grep -qE '^10\.0\.[4-9][0-9]{2}' || { echo "WRONG VERSION dotnet — need 10.0.400+"; fail=1; }; \
openspec --version >/dev/null 2>&1 || { echo "MISSING openspec — npm install -g @fission-ai/openspec"; fail=1; }; \
openspec --version 2>/dev/null | grep -q '^2\.' || { echo "WRONG VERSION openspec — need 2.x"; fail=1; }; \
gh --version >/dev/null 2>&1 || { echo "MISSING gh — brew install gh"; fail=1; }; \
Expand Down
2 changes: 1 addition & 1 deletion docs/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Every SDK, CLI and login needed to build, test and ship dcli. `make deps` checks

| Tool | Version | Why | Check | Install | Auth check |
|---|---|---|---|---|---|
| .NET SDK | 10.0.300+ (`global.json`, `latestPatch`) | build, test, format, pack | `dotnet --version` | `brew install --cask dotnet-sdk` | — |
| .NET SDK | 10.0.400+ (`global.json`, `latestPatch`) | build, test, format, pack | `dotnet --version` | `brew install --cask dotnet-sdk` | — |
| OpenSpec CLI | 2.x | validate and archive changes | `openspec --version` | `npm install -g @fission-ai/openspec` | — |
| GitHub CLI | any | open PRs, watch CI | `gh --version` | `brew install gh` | `gh auth status` → `gh auth login` |
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.300",
"version": "10.0.400",
"rollForward": "latestPatch"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-12-01
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Design

## Context

Source Link is wired in each packable project: `PublishRepositoryUrl`, `EmbedUntrackedSources`,
`IncludeSymbols` and `SymbolPackageFormat=snupkg`, plus a direct `Microsoft.SourceLink.GitHub` 8.0.0
reference with `PrivateAssets="All"`. NuGet audit is on by default and `TreatWarningsAsErrors` (in
`Directory.Build.props`) turns `NU1902` into a restore error. There is no central package management.

## Goals / Non-Goals

**Goals:**
- Restore, build, test and format pass with NuGet audit left fully on.
- Packages keep their Source Link and symbol output.

**Non-Goals:**
- Central package management (`Directory.Packages.props`) — a separate change if wanted.
- Bumping test-only packages (`xunit`, `Microsoft.NET.Test.Sdk`, `coverlet`) unless audit flags them.
- Changing `global.json` or the CI SDK selection.

## Decisions

### Bump `Microsoft.SourceLink.GitHub` to 10.0.404

The advisory lists `Microsoft.Build.Tasks.Git` `= 8.0.0` with no patch, and vulnerable 10.x ranges up to
10.0.301 (fixed in 10.0.111 and 10.0.303). 10.0.404 is the newest 10.x on nuget.org and outside every
range. Both projects move together so they never diverge.

*Alternatives considered:*
- **Remove the reference and use the SDK-bundled Source Link** (built into the .NET 8+ SDK). Less to
maintain, but whether the build is safe then depends on each machine's SDK patch level, and NuGet
audit can no longer see the dependency. Rejected for being implicit.
- **Suppress `NU1902`** (`NoWarn` or `NuGetAuditSuppress`). Rejected: it hides a real advisory.
- **Bump plus central package management.** Rejected as scope creep for a security fix.

### Keep audit strict

No change to `NuGetAudit`, `NuGetAuditLevel` or `WarningsAsErrors`. The new `packaging` spec makes the
fail-on-advisory behaviour an explicit contract rather than a side effect.

## Risks / Trade-offs

- [SourceLink 10.x needs a newer SDK than 8.x] → the repo already pins SDK 10.0.300+ and CI installs
`10.0.x`; verify with a full `make gates` and a `dotnet pack -c Release`.
- [Source Link output changes shape across major versions] → check the packed PDB still carries a
GitHub document map (`dotnet sourcelink test` or inspecting the `.snupkg`).
- [Another advisory appears later in the test-project graph] → audit catches it at restore, which is the
intended behaviour; it would be its own change.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Section 1 done — SourceLink bumped, gates green

<!-- Section: 1 · Tasks: 1.1–1.3 · Base: 24ee939 -->

`Microsoft.SourceLink.GitHub` 8.0.0 → 10.0.404 in `src/Dcli` and `src/Dcli.Testing`. Chosen by Emmz
over removing the reference (SDK-bundled Source Link: safety would depend on each machine's SDK patch
and audit couldn't see it) and over adding central package management (scope creep).

Restore is clean; `dotnet list package --vulnerable --include-transitive` reports no vulnerable packages
in any of the six projects. Self-review: two one-line csproj edits, nothing else — clean.

Gates: `BUILD_EXIT:0`, `TEST_EXIT:0` (890 passed), `FORMAT_EXIT:0`, `VALIDATE_EXIT:0`, `GATES_EXIT:0`.

Section 3 (Makefile hardening) was added to this change at Emmz's request, after an automated security
review flagged `validate`/`changes` expanding folder names into recipe text.

## Next

- Section 2, task 2.1: `dotnet pack -c Release` for both packages, check `.snupkg` and the Source Link
map in the PDB.
- The working tree carries unstaged deletions of `.claude/commands/opsx/*` and
`.claude/skills/openspec-*` that predate this change. Emmz knows; keep them out of every commit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Section 2 done — packaging verified, fix recorded, SDK floor 10.0.400

<!-- Section: 2 · Tasks: 2.1–2.3 · Base: d2c8323 -->

`dotnet pack -c Release` produced `.nupkg` + `.snupkg` for both `dcli` and `Dcli.Testing`. Each packed
PDB carries the Source Link map
`/Users/…/dcli/* → https://raw.githubusercontent.com/daemonicai/dcli/<commit>/*` — SourceLink 10.x
output matches what 8.0.0 produced.

Emmz bumped `global.json` to `10.0.400` mid-section (on her own, not asked for). Task 2.3 was added to
carry it: `docs/dependencies.md` row and the `make deps` version regex now say 10.0.400+ (regex
`^10\.0\.[4-9][0-9]{2}` rejects 10.0.303, accepts 10.0.404). This supersedes design.md's non-goal
"Changing `global.json`". SDK 10.0.404 is installed and resolves; CI's `setup-dotnet` `10.0.x`
installs the latest 10.0 band, so it satisfies the new floor.

Self-review: changelog entry, regex, dependency row, `global.json` — clean.

Gates: `DEPS_EXIT:0`, `BUILD_EXIT:0`, `TEST_EXIT:0` (890 passed), `FORMAT_EXIT:0`, `VALIDATE_EXIT:0`,
`GATES_EXIT:0`.

## Next

- Section 3, task 3.1: rewrite `validate` and `changes` in `Makefile` to loop over folders in the shell,
quoted, with no `CHANGES` make variable.
- Unstaged `.claude/commands/opsx/*` and `.claude/skills/openspec-*` deletions predate this change —
keep them out of every commit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Section 3 done — Makefile change discovery hardened

<!-- Section: 3 · Tasks: 3.1–3.2 · Base: 9d4e1e8 -->

The `CHANGES` make variable is gone. A shared `FOR_EACH_CHANGE` shell fragment globs
`openspec/changes/*/` at run time, skips `archive`, quotes every name, and refuses any name not matching
`^[A-Za-z0-9._][A-Za-z0-9._-]*$` (so `-rf` is refused too), printing it `%q`-escaped to stderr.
`validate` fails on a refused name; `changes` reports it and lists the rest, one per line (was
space-separated on one line).

Why allowlist as well as quoting: quoting alone stops shell injection, but a name starting with `-`
would still reach `openspec validate` as an option. Refusing is simpler than finding out whether
openspec accepts `--`.

Hostile test in a scratch copy (`…/scratchpad/hostile1`) with folders `x;touch pwned1`,
`$(touch pwned2)`, `` `touch pwned3` `` and `-rf`: all four refused, `VALIDATE_EXIT:1`, `make changes`
listed only `fix-sourcelink-nu1902`, and 0 `pwned*` files created. A no-active-change copy
(`…/scratchpad/empty1`) still gives `VALIDATE_EXIT:0` with the "nothing to validate" message. The
scratch copies were left in the scratchpad: a Claude Code safety check blocked the `rm -rf`.

`CLAUDE.md`'s `make validate` line now mentions the unsafe-name failure.

Gates: `BUILD_EXIT:0`, `TEST_EXIT:0` (890 passed), `FORMAT_EXIT:0`, `VALIDATE_EXIT:0`, `GATES_EXIT:0`.

## Next

- Whole-change review: `git diff 24ee939..HEAD` (base 24ee939 is the proposal commit), then the
change-done note, offer `code-review`, then offer `/openspec-archive-change`.
- Not pushed yet; the branch `change/fix-sourcelink-nu1902` is local only.
- Unstaged `.claude/commands/opsx/*` and `.claude/skills/openspec-*` deletions predate this change —
keep them out of every commit.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Change done — whole-change review

<!-- Tasks: 1.1–3.2 · Base: 24ee939 -->

Reviewed `git diff 24ee939..HEAD` (11 files). The `packaging` spec is satisfied: the `.snupkg` and the
Source Link map were verified in §2, and restore stays audit-strict with no suppression (§1).
No leftover scaffolding, no duplicated logic.

One drift, accepted: design.md lists "Changing `global.json`" as a non-goal, but Emmz bumped it to
10.0.400 during §2 and the change carries it (task 2.3). Recorded here rather than by editing design.md.

## Next

- Offer the `code-review` skill on `change/fix-sourcelink-nu1902`. If fixes come out of it, add them
as a new `## 4. Review fixes` section.
- Then offer `/openspec-archive-change`, then push and open a PR.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Proposal

## Why

`dotnet build`, `dotnet test` and `dotnet format` all fail at restore with `NU1902` (a NuGet audit
warning, made an error by `TreatWarningsAsErrors`). `Microsoft.SourceLink.GitHub` 8.0.0 — referenced by
`src/Dcli` and `src/Dcli.Testing` — pulls in `Microsoft.Build.Tasks.Git` 8.0.0, which advisory
GHSA-23fw-v26w-5fgq (CVE-2026-62900, .NET information disclosure, published 2026-09-08) marks as
vulnerable with no patched 8.x release. Every gate is red until the reference moves.

## What Changes

- Bump `Microsoft.SourceLink.GitHub` from 8.0.0 to 10.0.404 in `src/Dcli/Dcli.csproj` and
`src/Dcli.Testing/Dcli.Testing.csproj`. 10.0.404 is outside every vulnerable range in the advisory.
- Harden the `Makefile`'s `validate` and `changes` targets so folder names under `openspec/changes/`
are never expanded into shell recipe text (flagged by an automated security review: a crafted folder
name could run commands when a gate runs).
- Record the fix under `### Security` in `CHANGELOG.md` `[Unreleased]`.
- No public API change. The reference stays `PrivateAssets="All"`, so consumers of the `dcli` and
`Dcli.Testing` packages gain no new dependency.

## Capabilities

### New Capabilities

- `packaging`: how dcli's NuGet packages are built — Source Link metadata for debugging into dcli
source, and a restore that fails on any dependency with a known vulnerability.

### Modified Capabilities

None.

## Impact

- **Code:** two `.csproj` files, `CHANGELOG.md`. No source changes.
- **Build:** restore, build, test and format go green again; `make gates` reaches its real result.
- **Packages:** `.nupkg`/`.snupkg` contents unchanged apart from the Source Link tooling version used
to produce them.
- **CI:** `ci.yml` and `release.yml` install `10.0.x` SDKs; SourceLink 10.0.404 runs on any 10.0 SDK.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Spec Delta

## Purpose

Defines how dcli's NuGet packages are produced: what debugging metadata they carry and which supply-chain
checks the build enforces before anything is packed.

## ADDED Requirements

### Requirement: Packages carry Source Link metadata
The `dcli` and `Dcli.Testing` packages SHALL ship with a symbol package and Source Link metadata that
maps their sources to the public GitHub repository, so a consumer can step into dcli source in a
debugger.

#### Scenario: Packed library maps sources to GitHub
- **WHEN** `dotnet pack -c Release` builds the `dcli` package
- **THEN** a `.snupkg` is produced alongside the `.nupkg`
- **AND** the assembly's PDB contains a Source Link document map pointing at the GitHub repository

### Requirement: Restore rejects known-vulnerable dependencies
The build SHALL fail at restore when any direct or transitive NuGet dependency of a dcli project has a
known vulnerability of moderate severity or higher, rather than warning and continuing.

#### Scenario: Clean dependency graph restores
- **WHEN** `dotnet restore` runs on the solution and no dependency matches a published advisory
- **THEN** restore succeeds with no `NU1901`–`NU1904` diagnostics

#### Scenario: Vulnerable dependency stops the build
- **WHEN** a dependency of a dcli project matches a published advisory of moderate severity or higher
- **THEN** restore fails with the corresponding `NU190x` error and no build output is produced
18 changes: 18 additions & 0 deletions openspec/changes/archive/2026-12-01-fix-sourcelink-nu1902/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Tasks

## 1. Bump Source Link and restore the gates

- [x] 1.1 Change `Microsoft.SourceLink.GitHub` from 8.0.0 to 10.0.404 in `src/Dcli/Dcli.csproj` and `src/Dcli.Testing/Dcli.Testing.csproj`; verify `dotnet restore` succeeds with no `NU190x` diagnostics
- [x] 1.2 Run `dotnet list package --vulnerable --include-transitive` across the solution; verify it reports no vulnerable packages
- [x] 1.3 Run `make gates`; verify `BUILD_EXIT:0`, `TEST_EXIT:0`, `FORMAT_EXIT:0` and `VALIDATE_EXIT:0`

## 2. Verify packaging and record the fix

- [x] 2.1 Run `dotnet pack -c Release` for `src/Dcli` and `src/Dcli.Testing`; verify each produces a `.nupkg` and `.snupkg`, and the packed PDB carries a Source Link map to the GitHub repository
- [x] 2.2 Add a `### Security` entry to `CHANGELOG.md` `[Unreleased]` naming GHSA-23fw-v26w-5fgq and the SourceLink bump; verify `make format` still passes
- [x] 2.3 Carry the `global.json` SDK bump to 10.0.400 (made by Emmz): update the .NET SDK row in `docs/dependencies.md` and the `make deps` version check to 10.0.400+; verify `make deps` prints `DEPS_EXIT:0` with SDK 10.0.404 and that the check rejects a 10.0.3xx version string

## 3. Harden Makefile change discovery

- [x] 3.1 Rewrite `validate` and `changes` in `Makefile` to loop over `openspec/changes/*/` inside the shell, skip `archive`, and quote every name, so no folder name is ever pasted into recipe text; remove the `CHANGES` make variable; verify `make validate` and `make changes` list and validate `fix-sourcelink-nu1902`
- [x] 3.2 Verify a hostile folder name is inert: create `openspec/changes/x;touch pwned/` (or equivalent) in a scratch copy, run `make changes` and `make validate`, and confirm no `pwned` file appears; remove the folder afterwards
30 changes: 30 additions & 0 deletions openspec/specs/packaging/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# packaging Specification

## Purpose

Defines how dcli's NuGet packages are produced: what debugging metadata they carry and which supply-chain
checks the build enforces before anything is packed.

## Requirements

### Requirement: Packages carry Source Link metadata
The `dcli` and `Dcli.Testing` packages SHALL ship with a symbol package and Source Link metadata that
maps their sources to the public GitHub repository, so a consumer can step into dcli source in a
debugger.

#### Scenario: Packed library maps sources to GitHub
- **WHEN** `dotnet pack -c Release` builds the `dcli` package
- **THEN** a `.snupkg` is produced alongside the `.nupkg`
- **AND** the assembly's PDB contains a Source Link document map pointing at the GitHub repository

### Requirement: Restore rejects known-vulnerable dependencies
The build SHALL fail at restore when any direct or transitive NuGet dependency of a dcli project has a
known vulnerability of moderate severity or higher, rather than warning and continuing.

#### Scenario: Clean dependency graph restores
- **WHEN** `dotnet restore` runs on the solution and no dependency matches a published advisory
- **THEN** restore succeeds with no `NU1901`–`NU1904` diagnostics

#### Scenario: Vulnerable dependency stops the build
- **WHEN** a dependency of a dcli project matches a published advisory of moderate severity or higher
- **THEN** restore fails with the corresponding `NU190x` error and no build output is produced
2 changes: 1 addition & 1 deletion src/Dcli.Testing/Dcli.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.404" PrivateAssets="All" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Dcli/Dcli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.404" PrivateAssets="All" />
</ItemGroup>

</Project>
Loading