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
10 changes: 5 additions & 5 deletions .github/workflows/nuget-prepare.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Registered preparation workflow: 394955059 (NuGet preparation).
# Acceptance tags only; the repository switch is off until an approved test.
# Production tags only; preparation stays disabled until separate activation approval.
name: NuGet preparation

on:
push:
tags: ["sonar-poc/nuget/*/v*"]
tags: ["v*"]

permissions:
contents: read
Expand All @@ -16,7 +16,7 @@ concurrency:

jobs:
prepare:
if: ${{ vars.SONAR_NUGET_ACCEPTANCE_ENABLED == 'true' && github.repository == 'andregoepel/core' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/sonar-poc/nuget/') }}
if: ${{ false && github.repository == 'andregoepel/core' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-24.04
environment: sonar-nuget-prepare
timeout-minutes: 75
Expand All @@ -38,8 +38,8 @@ jobs:
test "$GITHUB_WORKFLOW_SHA" = "$GITHUB_SHA"
test "$GITHUB_WORKFLOW_REF" = "$GITHUB_REPOSITORY/.github/workflows/nuget-prepare.yml@$GITHUB_REF"
[[ "$GITHUB_SHA" =~ ^[a-f0-9]{40}$ ]]
[[ "$GITHUB_REF_NAME" =~ ^sonar-poc/nuget/[a-f0-9]{32}/v(0|[1-9][0-9]{0,4})\.(0|[1-9][0-9]{0,4})\.(0|[1-9][0-9]{0,4})$ ]]
version="${GITHUB_REF_NAME##*/v}"
[[ "$GITHUB_REF_NAME" =~ ^v(0|[1-9][0-9]{0,4})\.(0|[1-9][0-9]{0,4})\.(0|[1-9][0-9]{0,4})$ ]]
version="${GITHUB_REF_NAME#v}"
jq -e --arg ref "$GITHUB_REF" '
.repository.full_name == "andregoepel/core" and
.ref == $ref and .created == true and .deleted == false and .forced == false and
Expand Down
64 changes: 54 additions & 10 deletions docs/nuget-quality-gate.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
# Core publication gate: review and migration

Tracks [#29](https://github.com/andregoepel/core/issues/29) and the source-change
evidence in [#30](https://github.com/andregoepel/core/issues/30). This change prepares
the tagged no-upload test and removes the legacy tag publisher from CI. Production
publication stays disabled. The NuGet account policy is not changed by this PR.
evidence in [#30](https://github.com/andregoepel/core/issues/30). The legacy CI
publisher was removed and the tagged no-upload test passed. The separately
authorized NuGet policy migration, protected production environments and immutable
release-tag controls are complete. Production publication stays disabled.

## Production preparation transition

Preparation now declares the `v*` push trigger and validates strict `vX.Y.Z`
versions, with no leading zeros, prerelease/build suffixes or component above
99999. It preserves the first-attempt, original creation, exact-main, workflow
revision and readiness checks, including the original annotated-tag object.
The preparation job has a literal-false guard: merging this change does not run
preparation, enable publishing or authorize a release. The former
`SONAR_NUGET_ACCEPTANCE_ENABLED` switch cannot activate this production job.

`nuget-policy.json` binds workflow 394955059 to the SHA-256 of the exact LF bytes
of `nuget-prepare.yml`. The trigger, guard, event validation and hash must be
reviewed together. Changing the guard for eventual activation requires another
hash update. No other workflow changes are included: `nuget-publish.yml` retains
literal-false job/step guards, and the old acceptance consumer stays off.

The existing event fixtures execute the production preparation check and both
consumer checks offline. They verify version extraction, lightweight/annotated
events, malformed and former test tags, altered events, wrong revisions, reruns
and stale main. This does not claim a hosted production-tag run or NuGet upload.

### Controls verified on October 24, 2026

- NuGet has one exact `AndreGoepel.Core` policy for `andregoepel/core`, workflow
`nuget-publish.yml`, environment `nuget-publish`, and new versions only. It
replaced the old `ci.yml` mapping in place. The authenticated audit found sole
owner `andre.goepel`, no API keys and no alternative matching/wildcard policies.
- `sonar-nuget-prepare` permits only tags matching `v*`; `nuget-publish` permits
only branch `main`. Both require `andregoepel` review, permit the agreed
single-operator self-review and prohibit administrator bypass. The explicitly
approved existing Core Sonar credential copies are configured.
- [Immutable release tags](https://github.com/andregoepel/core/rules/25781835)
forbid updates/deletions of `refs/tags/v*`, with no bypass actors. An equivalent
disposable-tag drill rejected all four update/deletion attempts. Test resources
were removed; original tags and default-branch rules were unchanged.

After merge, verify exact-main CI and Sonar. Leave both preparation and publishing
disabled until separately authorized activation is reviewed. The first real
release then needs fresh evidence and explicit approval. Historical test receipts
cannot authorize it. No actual NuGet login/upload has been tested, and the package
owner can still introduce future credentials or policies. Keep #29 open.

## Inventory and proposed mapping

Expand All @@ -27,8 +70,8 @@ Core Trusted Publisher policy and an empty API-key inventory. No other policy in
that account matched Core or a wildcard covering Core. No credentials were read,
created or changed. This is a point-in-time audit; repeat it before cutover. The
owner retains administrative control and can create new credentials or upload
manually, so the pipeline does not constrain future owner actions. The active
`ci.yml` policy remains a known bypass until the separately approved migration.
manually, so the pipeline does not constrain future owner actions. The then-active
`ci.yml` policy was a known bypass; the October 24 migration above retired it.

Proposed single policy: package `AndreGoepel.Core`; account `andre.goepel`;
GitHub owner `andregoepel`; repository `core`; workflow `nuget-publish.yml`;
Expand All @@ -43,14 +86,15 @@ own environment with a reviewed `v*` tag policy; it has no OIDC permission.
exact package inventory and the independently pinned publication verifier.
- `scripts/sonar/nuget-policy.json` pins preparation workflow identity, exact
content hash, required successful steps and a 120-minute maximum age.
- `.github/workflows/nuget-prepare.yml` now accepts only isolated acceptance tags.
It and the new `nuget-acceptance.yml` require the off-by-default repository
switch `SONAR_NUGET_ACCEPTANCE_ENABLED`. Neither can publish packages.
- `.github/workflows/nuget-prepare.yml` declares production tags with a
literal-false job guard. The unchanged historical `nuget-acceptance.yml`
still requires `SONAR_NUGET_ACCEPTANCE_ENABLED`, which remains false.
- `nuget-publish.yml` remains unchanged, with **literal-false job and step guards**.
CI loses only `pack-and-publish`; its build/test job and triggers are preserved.
`main-policy.json` records the new exact CI file hash. Sonar, the earlier manual
rehearsal and all other existing Actions remain unchanged.
- `scripts/sonar/publication/release-tags.ruleset.json` is an unapplied proposal.
- `scripts/sonar/publication/release-tags.ruleset.json` is the applied, verified
release-tag rule definition.
- The companion [workflows PR #31](https://github.com/andregoepel/workflows/pull/31)
adapts the accepted app-foundation verifier
to consumer-supplied identities. Core does not copy its C# implementation or
Expand Down Expand Up @@ -116,7 +160,7 @@ Shared support and Core preparation were merged in their respective PR #31s.
Main CI passed in both repositories, and #30's nonempty central new-code check
is recorded in [the evidence report](sonar-new-code.md). Core PR #32 merged the
disabled standby workflows, and Core PR #33 merged their assigned-ID registration.
The production cutover remains unexecuted:
Steps 1–4 below are complete; step 5 remains a separate authorization boundary:

1. Review and merge the bundled CI publisher removal, acceptance workflow pair,
matching CI/preparation hashes and [tagged test runbook](nuget-tagged-acceptance.md).
Expand Down
28 changes: 20 additions & 8 deletions docs/nuget-tagged-acceptance.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Core tagged no-upload handoff acceptance

Part of [Core #29](https://github.com/andregoepel/core/issues/29). This runbook and
its workflow changes are prepared for review. The new hosted tagged test has not
run. It can run only after this revision reaches main and the operator authorizes
the test setup. Merging this PR removes the legacy CI publisher but does not
change NuGet policies or enable publication.
Historical runbook for the completed [Core #29](https://github.com/andregoepel/core/issues/29)
test on revision `3e18daa24f74ab439e17ff5278eaf7a500a5d4a4` (PR #35).
[Preparation 40092501057](https://github.com/andregoepel/core/actions/runs/40092501057)
and [acceptance 40092632653](https://github.com/andregoepel/core/actions/runs/40092632653)
passed on attempt 1; independent inspection passed before expiry. The temporary
tag, environments and credential copies were removed; the acceptance switch is
false. No package was uploaded.

The production preparation transition replaces the test-tag route with `v*`
and a literal-false job guard. The sections below describe the historical test
revision, not instructions to run against current production environments. Do not
recreate the old tag, repurpose those environments or rerun the completed consumer.
Any future hosted acceptance needs a separately reviewed test revision and approval.
See [the current production plan](nuget-quality-gate.md) for active controls and
remaining activation steps.

## Boundaries and workflow roles

Expand Down Expand Up @@ -146,6 +156,8 @@ bash scripts/sonar/publication/tests/outcomes.sh
bash scripts/sonar/publication/tests/outcomes.sh .github/workflows/nuget-acceptance.yml acceptance-outcomes
```

These execute the actual workflow Bash/jq blocks: 27 event/credential scenarios
and 11 outcome scenarios for each of the production and acceptance recorders.
They complement shared contract tests; they do not replace the hosted handoff.
These execute the actual workflow Bash/jq blocks. The event fixtures now cover
production tag preparation and the unchanged production/acceptance consumers,
including rejection of the former acceptance tag by production. Each outcome
recorder has 11 scenarios. These complement shared contract tests; they do not
enable jobs, request credentials or replace a hosted handoff.
2 changes: 1 addition & 1 deletion scripts/sonar/nuget-policy.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"workflowId": 394955059,
"workflowSha256": "74fbacd96fb4c4a6a204eb26ba65998508aaa32f3e077b685a8b156d21c73db0",
"workflowSha256": "a49a26f7b48f74980aa6429950a7e79784d6d7898cfa6d14217082b5d3bacdad",
"maximumAgeMinutes": 120,
"jobs": {
"prepare": ["Verify tag push", "Prepare NuGet batch", "Publish package batch", "Publish origin"]
Expand Down
43 changes: 36 additions & 7 deletions scripts/sonar/publication/tests/tagged-handoff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export PATH="$workspace/bin:$PATH"
export FIXTURE_SHA
FIXTURE_SHA=$(printf 'a%.0s' {1..40})
export FIXTURE_MAIN="$FIXTURE_SHA"
tag="sonar-poc/nuget/$(printf 'b%.0s' {1..32})/v0.0.0"
tag=v1.2.3
acceptance_tag="sonar-poc/nuget/$(printf 'b%.0s' {1..32})/v0.0.0"

cat > "$workspace/bin/gh" <<'STUB'
#!/usr/bin/env bash
Expand All @@ -34,21 +35,23 @@ extract() {
}
extract nuget-prepare 'Verify tag push' producer
extract nuget-acceptance 'Validate publication trigger' consumer
extract nuget-publish 'Validate publication trigger' publisher
extract nuget-acceptance 'Obtain temporary NuGet credentials' login

jq -n --arg sha "$FIXTURE_SHA" --arg ref "refs/tags/$tag" '{
repository: {full_name: "andregoepel/core"}, ref: $ref,
created: true, deleted: false, forced: false,
before: "0000000000000000000000000000000000000000", after: $sha
}' > "$workspace/producer.json"
jq -n --arg sha "$FIXTURE_SHA" --arg tag "$tag" '{
jq -n --arg sha "$FIXTURE_SHA" --arg tag "$acceptance_tag" '{
action: "completed", repository: {full_name: "andregoepel/core"}, workflow_run: {
repository: {full_name: "andregoepel/core"}, head_repository: {full_name: "andregoepel/core"},
workflow_id: 394955059, path: ".github/workflows/nuget-prepare.yml", name: "NuGet preparation",
event: "push", status: "completed", conclusion: "success", head_sha: $sha,
head_branch: $tag, id: 456, run_attempt: 1
}
}' > "$workspace/consumer.json"
jq --arg tag "$tag" '.workflow_run.head_branch = $tag' "$workspace/consumer.json" > "$workspace/publisher.json"

run_case() (
local name=$1 kind=$2 filter=$3 expected=$4 code=0
Expand All @@ -64,6 +67,9 @@ run_case() (
else
export GITHUB_EVENT_NAME=workflow_run GITHUB_REF=refs/heads/main
export GITHUB_WORKFLOW_REF=andregoepel/core/.github/workflows/nuget-acceptance.yml@refs/heads/main
if [[ "$kind" == publisher ]]; then
export GITHUB_WORKFLOW_REF=andregoepel/core/.github/workflows/nuget-publish.yml@refs/heads/main
fi
fi
jq "$filter" "$workspace/$kind.json" > "$GITHUB_EVENT_PATH"
: > "$GITHUB_OUTPUT"
Expand All @@ -74,12 +80,17 @@ run_case() (
# Assert
if [[ "$expected" == pass ]]; then
test "$code" = 0
grep -qx 'version=0.0.0' "$GITHUB_OUTPUT"
local expected_version=1.2.3 expected_tag="$tag"
if [[ "$kind" == consumer ]]; then
expected_version=0.0.0
expected_tag="$acceptance_tag"
fi
grep -qx "version=$expected_version" "$GITHUB_OUTPUT"
if [[ "$kind" == producer ]]; then
digest=$(sha256sum -- "$GITHUB_EVENT_PATH")
grep -qx "event-sha256=${digest%% *}" "$GITHUB_OUTPUT"
else
grep -qx "tag=$tag" "$GITHUB_OUTPUT"
grep -qx "tag=$expected_tag" "$GITHUB_OUTPUT"
grep -qx 'run=456' "$GITHUB_OUTPUT"
fi
else
Expand All @@ -89,15 +100,22 @@ run_case() (
printf 'PASS %s\n' "$name"
)

run_case lightweight-tag producer '.' pass
run_case annotated-tag-original-object producer '.after = "cccccccccccccccccccccccccccccccccccccccc"' pass
run_case release-lightweight-tag producer '.' pass
run_case release-annotated-tag-original-object producer '.after = "cccccccccccccccccccccccccccccccccccccccc"' pass
run_case updated-tag producer '.created = false | .before = .after' reject
run_case deleted-tag producer '.deleted = true' reject
run_case forced-tag producer '.forced = true' reject
run_case wrong-producer-repository producer '.repository.full_name = "attacker/core"' reject
run_case changed-push-ref producer '.ref = "refs/tags/v0.0.0"' reject
run_case producer-rerun producer '.' reject GITHUB_RUN_ATTEMPT=2
run_case release-tag producer '.' reject GITHUB_REF_NAME=v0.0.0 GITHUB_REF=refs/tags/v0.0.0 GITHUB_WORKFLOW_REF=andregoepel/core/.github/workflows/nuget-prepare.yml@refs/tags/v0.0.0
for invalid_tag in "$acceptance_tag" v01.2.3 v1.02.3 v1.2.03 v1.2 v1.2.3-preview v1.2.3+build v100000.2.3 v1.2.3/extra; do
run_case "invalid-release-tag-$invalid_tag" producer ".ref = \"refs/tags/$invalid_tag\"" reject \
GITHUB_REF_NAME="$invalid_tag" GITHUB_REF="refs/tags/$invalid_tag" \
GITHUB_WORKFLOW_REF="andregoepel/core/.github/workflows/nuget-prepare.yml@refs/tags/$invalid_tag"
done
run_case producer-branch producer '.' reject GITHUB_REF_TYPE=branch
run_case producer-dispatch producer '.' reject GITHUB_EVENT_NAME=workflow_dispatch
run_case producer-wrong-revision producer '.' reject GITHUB_WORKFLOW_SHA=cccccccccccccccccccccccccccccccccccccccc
run_case stale-main producer '.' reject FIXTURE_MAIN=cccccccccccccccccccccccccccccccccccccccc
run_case full-consumer-event consumer '.' pass
run_case wrong-consumer-repository consumer '.workflow_run.head_repository.full_name = "attacker/core"' reject
Expand All @@ -110,6 +128,17 @@ run_case production-tag-consumer consumer '.workflow_run.head_branch = "v0.0.0"'
run_case consumer-rerun consumer '.' reject GITHUB_RUN_ATTEMPT=2
run_case wrong-consumer-revision consumer '.' reject GITHUB_WORKFLOW_SHA=cccccccccccccccccccccccccccccccccccccccc
run_case production-consumer-context consumer '.' reject GITHUB_WORKFLOW_REF=andregoepel/core/.github/workflows/nuget-publish.yml@refs/heads/main
run_case full-production-event publisher '.' pass
run_case acceptance-tag-production-consumer publisher ".workflow_run.head_branch = \"$acceptance_tag\"" reject
run_case wrong-production-producer-id publisher '.workflow_run.workflow_id = 1' reject
run_case wrong-production-producer-path publisher '.workflow_run.path = ".github/workflows/ci.yml"' reject
run_case failed-production-producer publisher '.workflow_run.conclusion = "failure"' reject
run_case wrong-production-source publisher '.workflow_run.head_sha = "cccccccccccccccccccccccccccccccccccccccc"' reject
run_case production-producer-second-attempt publisher '.workflow_run.run_attempt = 2' reject
run_case production-consumer-rerun publisher '.' reject GITHUB_RUN_ATTEMPT=2
run_case production-wrong-revision publisher '.' reject GITHUB_WORKFLOW_SHA=cccccccccccccccccccccccccccccccccccccccc
run_case production-stale-main publisher '.' reject FIXTURE_MAIN=cccccccccccccccccccccccccccccccccccccccc
run_case acceptance-context-production-consumer publisher '.' reject GITHUB_WORKFLOW_REF=andregoepel/core/.github/workflows/nuget-acceptance.yml@refs/heads/main

# Act: the simulated login must succeed without any credential channel.
env -u ACTIONS_ID_TOKEN_REQUEST_TOKEN -u ACTIONS_ID_TOKEN_REQUEST_URL -u NUGET_API_KEY -u NUGET_SYMBOL_API_KEY -u NUGET_AUTH_TOKEN bash "$workspace/login.sh" > /dev/null
Expand Down
Loading