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
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

All notable changes to Wasit are recorded here. Versions follow [Semantic Versioning](https://semver.org/): patch releases are fixes, minor releases add checks or features without breaking existing usage, major releases break something.

## [Unreleased]

**Results can change on upgrade.**
- The GitHub Action runs on `pull_request`, `push`, `schedule`,
`workflow_dispatch` and `merge_group` only. Any other event
(`pull_request_target` as before, now also `issue_comment`, `workflow_run`
and the rest) stops the job with exit 2 in the step that checks the inputs:
on those events a workflow can hand a pull request's code the base
repository's token, and the service Wasit starts would be that code.
- Every step of the Action sets `BASH_ENV`, `ENV`, `LD_PRELOAD`,
`LD_LIBRARY_PATH` and `LD_AUDIT` empty, as it does `NODE_OPTIONS`: a file the
shell runs before a step, or a library loaded into `bash`, `node` or `gh`,
no longer comes from the workflow's env into the steps that hold the token or
the payer key. A service Wasit starts no longer inherits them from the
workflow's env either; set what it needs in `service.start`.

**Fixed.**
- In the coloured output of `wasit test` (at a terminal, or with
`FORCE_COLOR`), a wrapped line of a fix could start with `::name::` or
`##[name]` from the middle of the text, which a GitHub job log reads as a
workflow command. Every wrapped line is now broken the way the sanitiser
breaks the start of a text.
- `wasit ci-report` keeps a settlement reference from a report file only on a
PASS, as `wasit run` writes it; on any other status it is dropped.

## [0.8.0-beta.1] - 2026-11-20

A pre-release for beta testers, on npm under the `beta` tag
Expand Down
66 changes: 64 additions & 2 deletions action/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ description: >-
Runs Wasit's x402 checks against your service inside the job, comments the
result on the pull request, and compares it with main. The payment tier pays
on test networks only, on push to the default branch, schedule and
workflow_dispatch. Linux runners. Needs Node 22 or later (add
actions/setup-node before this step).
workflow_dispatch. Runs on pull_request, push, schedule, workflow_dispatch
and merge_group, and refuses any other event. Linux runners. Needs Node 22
or later (add actions/setup-node before this step).

inputs:
config:
Expand Down Expand Up @@ -57,6 +58,17 @@ runs:
# through GITHUB_ENV: seen on runner 2.338.2, 2026-11-20.) A service Wasit
# starts no longer inherits NODE_OPTIONS from the workflow's env: put the
# options it needs in its service.start command.
# For the same reason BASH_ENV and ENV (a file the shell runs before the
# step) and LD_PRELOAD, LD_LIBRARY_PATH and LD_AUDIT (libraries loaded into
# bash, node and gh) are set empty in every step, so the workflow's env does
# not reach them, and neither does an earlier step's GITHUB_ENV: seen for
# BASH_ENV on a GitHub-hosted runner, 2026-11-21 (each step of this action
# showed it empty, a plain step after the earlier one ran the file). A
# service that needs one sets it in its service.start command. None of this
# keeps the steps apart from code that ran earlier in the job as the
# runner's user: such code can also put a program of its own first on PATH
# (GITHUB_PATH), change files on disk, or leave a process running; the
# example workflow states that limit.

- name: Check the runner
shell: bash
Expand All @@ -68,6 +80,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
run: |
if [ "$RUNNER_OS" != "Linux" ]; then
echo "Wasit: this action runs on Linux runners in this version." >&2
Expand All @@ -94,6 +111,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
INPUT_CONFIG: ${{ inputs.config }}
INPUT_ENVIRONMENT: ${{ inputs.environment }}
INPUT_TIER: ${{ inputs.tier }}
Expand All @@ -114,6 +136,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
run: |
cd "$ACTION_PATH/.."
npm ci --ignore-scripts --no-audit --no-fund
Expand All @@ -138,6 +165,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
GH_TOKEN: ${{ github.token }}
INPUT_ENVIRONMENT: ${{ inputs.environment }}
run: node "$ACTION_PATH/scripts/announce.mjs" start
Expand All @@ -154,6 +186,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
GH_TOKEN: ${{ github.token }}
run: node "$ACTION_PATH/scripts/baseline.mjs"

Expand All @@ -165,6 +202,11 @@ runs:
env:
ACTION_PATH: ${{ github.action_path }}
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
INPUT_CONFIG: ${{ inputs.config }}
INPUT_ENVIRONMENT: ${{ inputs.environment }}
INPUT_TIER: ${{ inputs.tier }}
Expand All @@ -189,6 +231,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
BASELINE_PATH: ${{ steps.baseline.outputs.path }}
HISTORY_PATH: ${{ steps.baseline.outputs.history }}
BASELINE_RUN: ${{ steps.baseline.outputs.run }}
Expand All @@ -207,6 +254,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
GH_TOKEN: ${{ github.token }}
WASIT_COMMENT_FILE: ${{ runner.temp }}/wasit/comment.md
run: node "$ACTION_PATH/scripts/comment.mjs"
Expand All @@ -225,6 +277,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
GH_TOKEN: ${{ github.token }}
CHECK_RUN_ID: ${{ steps.announce.outputs.check_run_id }}
REPORT_OUTCOME: ${{ steps.report.outcome }}
Expand All @@ -244,6 +301,11 @@ runs:
COMMITMENT_SECRET_HEX: ""
WASIT_MAINNET_PAYER_SECRET: ""
NODE_OPTIONS: ""
BASH_ENV: ""
ENV: ""
LD_PRELOAD: ""
LD_LIBRARY_PATH: ""
LD_AUDIT: ""
with:
name: wasit-baseline
path: ${{ runner.temp }}/wasit/baseline-next.json
Expand Down
9 changes: 6 additions & 3 deletions action/examples/wasit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
# The service Wasit starts is not given that variable, and neither is it given
# the key variables or WASIT_RPC_URL. Never put a key in wasit.config.json.
#
# Do not use pull_request_target. It would give the code of a pull request the
# token and the secrets of your repository.
# The action runs on pull_request, push, schedule, workflow_dispatch and
# merge_group, and refuses any other event: pull_request_target, issue_comment,
# workflow_run and the like can give the code of a pull request the token and
# the secrets of your repository.

name: Wasit

Expand Down Expand Up @@ -71,7 +73,8 @@ jobs:
# given to a pull request run is refused before your service starts. On a
# GitHub-hosted runner your service then runs as a separate user, so it
# cannot read the key from Wasit's process; code that ran earlier in the job
# as the runner's user is not kept from it.
# as the runner's user is not kept from it, nor from the job's token, which
# the action gives to the steps that call gh.
- uses: wasit-dev/wasit/action@<tag-or-commit-sha>
with:
config: wasit.config.json
20 changes: 20 additions & 0 deletions action/scripts/inputs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export class MainnetRefusedError extends InputError {
/** An event name as GitHub writes them; anything else is never echoed. */
const EVENT_NAME = /^[a-z_]{1,64}$/;

/**
* The events the action runs on. A pull request runs the read-only checks; the
* payment tier pays only on push to the default branch, schedule and
* workflow_dispatch (the CLI decides, D-022a); merge_group runs the read-only
* checks on the merge queue's commit.
*/
export const SUPPORTED_EVENTS = Object.freeze(["pull_request", "push", "schedule", "workflow_dispatch", "merge_group"]);

function trimmed(value) {
return typeof value === "string" ? value.trim() : "";
}
Expand Down Expand Up @@ -75,6 +83,18 @@ export function parseInputs(env) {
// B12: no mainnet opt-in in this version. Refused before anything else is read.
checkMainnet(env);

// The events this action is built for. Others (issue_comment, workflow_run, ...) run with the
// base repository's write token, and a workflow on them often checks out a pull request's code:
// the service Wasit starts would be that code, in the job that holds the token.
const event = typeof env["GITHUB_EVENT_NAME"] === "string" ? env["GITHUB_EVENT_NAME"] : "";
if (!SUPPORTED_EVENTS.includes(event)) {
throw new InputError(
`this action runs on ${SUPPORTED_EVENTS.join(", ")} only, and this run's event is ` +
`${EVENT_NAME.test(event) ? event : "another event"}. On other events a workflow can hand a pull request's code ` +
"the base repository's token, and the service Wasit starts would be that code.",
);
}

// Whether this event may pay is the CLI's to say (D-022a): on a pull request it runs the
// read-only checks and says so, and it refuses a payer key given to a run that may not pay.
const tier = trimmed(env["INPUT_TIER"]) || "read-only";
Expand Down
23 changes: 23 additions & 0 deletions action/test/action-yaml.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,29 @@ describe("action.yml", () => {
});
});

describe("what changes how a step's shell or programs start (2026-11-21)", () => {
it("sets BASH_ENV, ENV, LD_PRELOAD, LD_LIBRARY_PATH and LD_AUDIT empty in every step, the run step and the upload step included", () => {
for (const step of steps) {
for (const name of ["BASH_ENV", "ENV", "LD_PRELOAD", "LD_LIBRARY_PATH", "LD_AUDIT"]) assert.equal(step.env?.[name], "", `${step.name}: ${name}`);
}
});
});

describe("the check run is completed only from what the report step wrote (2026-11-20)", () => {
it("runs Finish whenever the announcement started a check run, and only then", () => {
assert.equal(stepByName("Finish the check run").if, "${{ always() && steps.announce.outputs.check_run_id != '' }}");
});

it("hands Finish the report step's outcome and the announcement's id, so a file the report step did not write is not used", () => {
const env = stepByName("Finish the check run").env;
assert.equal(env.REPORT_OUTCOME, "${{ steps.report.outcome }}");
assert.equal(env.CHECK_RUN_ID, "${{ steps.announce.outputs.check_run_id }}");
assert.equal(env.WASIT_CHECK_RUN_FILE, "${{ runner.temp }}/wasit/check-run.json");
assert.equal(stepByName("Write the report").id, "report");
assert.equal(stepByName("Announce the run").id, "announce");
});
});

describe("the running comment is always replaced (2026-11-20 screening)", () => {
it("writes the report and the comment whenever the announcement ran, even if Run Wasit was skipped", () => {
for (const name of ["Write the report", "Comment on the pull request"]) {
Expand Down
31 changes: 29 additions & 2 deletions action/test/inputs.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,35 @@ describe("parseInputs", () => {
);
});

it("allows push, pull_request, workflow_dispatch and schedule", () => {
for (const name of ["push", "pull_request", "workflow_dispatch", "schedule"]) assert.doesNotThrow(() => parseInputs(env({ GITHUB_EVENT_NAME: name })), name);
it("allows push, pull_request, workflow_dispatch, schedule and merge_group", () => {
for (const name of ["push", "pull_request", "workflow_dispatch", "schedule", "merge_group"]) {
assert.doesNotThrow(() => parseInputs(env({ GITHUB_EVENT_NAME: name })), name);
}
});

it("refuses every other event, as pull_request_target: they hand a pull request's code the base repository's token", () => {
for (const name of ["issue_comment", "workflow_run", "pull_request_review", "pull_request_review_comment", "repository_dispatch", "release"]) {
assert.throws(
() => parseInputs(env({ GITHUB_EVENT_NAME: name })),
(error) =>
error instanceof InputError &&
/^this action runs on pull_request, push, schedule, workflow_dispatch, merge_group only/.test(error.message) &&
error.message.includes(`this run's event is ${name}.`),
name,
);
}
});

it("refuses a run with no event name, and never quotes one that is not an event name", () => {
const unset = env();
delete unset.GITHUB_EVENT_NAME;
for (const given of [unset, env({ GITHUB_EVENT_NAME: "" }), env({ GITHUB_EVENT_NAME: "push; id" })]) {
assert.throws(
() => parseInputs(given),
(error) => error instanceof InputError && /this run's event is another event\./.test(error.message) && !error.message.includes("; id"),
JSON.stringify(given.GITHUB_EVENT_NAME),
);
}
});

describe("names that would be shell text", () => {
Expand Down
Loading
Loading