Commit 91477d1
authored
* feat(build-tests): add Phase 1 dry-run regression suite for demo_build.sh
Phase 1 of issue #146: per-PR regression coverage that catches the
PR #142 (printf '-' dash) and PR #145 (SC2115 rm -fr footguns) class
of bug at PR time in seconds, rather than waiting for the nightly
host reset to surface them.
Three pieces:
- demo_build.sh: additive --dry-run flag + ACTION_LOG emitter
(run_action / run_action_sh / run_action_capture helpers).
With no flag and no ACTION_LOG env, helpers degrade to plain
exec -- production behavior is unchanged.
- tools/build-tests/: fixture-test harness mirroring the
tools/auto-derive/fixtures-and-tests/ pattern. 6 scenarios
cover branch-pinned/tag-pinned/release-packageserve/fork-URL/
light-reset/multi-demo paths.
- .github/workflows/build-tests.yml: runs the suite on every
PR that touches demo_build.sh or tools/build-tests/**.
Phase 2 (separate PR) will add a slower nightly job that actually
executes demo_build.sh end-to-end against a compose stack, reusing
the same fixtures + action-log emitter, and asserting the dry-run
log matches what live execution produces -- the integrity check
that keeps Phase 1 honest.
Refs: #146
Assisted-by: Claude Code
* feat(build-tests): address rabbit review + add capsule-path-traversal fixture
Rabbit-flagged fixes:
- .github/workflows/build-tests.yml: drop the stale "includes
derive-ip-map.yml" comment that didn't match the actual paths
filter (and didn't need to -- changes to that workflow file
don't affect build behavior).
- demo_build.sh: add a _emit_action_log helper that redacts
`-p<password>` (mariadb root pass flag) and `rootpass=<password>`
from action-log lines before append. Best-effort; documented
that ACTION_LOG should not be enabled in production without
further review. Phase 2 live-run work will extend this with
composer auth tokens and Authorization headers when those
become real values rather than dry-run stubs.
- demo_build.sh: document the trust assumption on run_action_sh
(wrapped strings come from ip_map_branch.txt + docker env, not
user input). Eval is intentional for pipes/redirects; refactor
is out of scope for this PR.
- demo_build.sh: unwrap two `mkdir` calls in the packageServe
block so subsequent `cd` commands work in dry-run, where the
intervening rsync is skipped. Same pattern already used for
$WEB/log and $OPENEMR earlier in the script.
New fixture:
- capsule-path-traversal: synthetic ip_map row with `capsule`
column = "../etc", exercising the case statement guard PR #145
added (demo_build.sh lines ~617-622). Pins the rejection so a
future regression that drops the guard fails CI -- otherwise
it would silently re-enable path traversal in dry code, since
no production row currently sets `capsule`.
- tools/build-tests/test.sh: extends harness with the
`expected/fail.txt` pattern (mirrors auto-derive harness):
substring check on stderr/stdout + assert non-zero exit.
All 7 fixtures pass. Verified negative test: stripping the case
guard from demo_build.sh fails ONLY capsule-path-traversal.
Refs: #146 (issue), #147 (this PR)
Assisted-by: Claude Code
* fix(build-tests): rabbit-review-2 fixes for test.sh harness
Two findings from rabbit's second review pass:
- Fail-expected check used `cat $stdout $stderr | grep -qF`, which
under `set -o pipefail` (enabled at the top of the script) can
flip a real PASS into a false FAIL: grep closes stdin on the
first match, cat dies on SIGPIPE, pipeline exits non-zero. Read
the files directly with `grep -qF -- $msg $stdout $stderr` —
no pipe, no false negative.
- normalize_action_log was called unconditionally even when the
script produced no action log. If a future regression makes
demo_build.sh exit 0 without writing ACTION_LOG, `sed -i` on
the missing file would trip `set -e` and abort the whole
harness mid-run, killing later fixtures and the summary. Added
an explicit `[[ -f $action_log ]]` guard that fails just the
affected fixture with a clear message and lets the run finish.
Refs: #146 (issue), #147 (this PR)
Assisted-by: Claude Code
* fix(build-tests): redaction false-positive on --unsafe-perm
The `-p<pass>` redaction regex matched anywhere in a line, including
inside `--unsafe-perm` (npm flag), turning legitimate command args
into `--unsafe-p<REDACTED>` in the action log.
Surfaced by an in-progress Phase 2 smoke run — first time live mode
exercised the npm install branch end-to-end.
Anchor the pattern to start-of-line or whitespace so it only matches
the standalone mariadb `-p<password>` flag. Regen the 6 goldens that
contained the false-positive form.
Refs: #146 (issue), #147 (this PR)
Assisted-by: Claude Code
* fix(build-tests): extend redaction + fix fixture-extras path docstring
Address two rabbit findings (PR #148, applies to Phase 1):
* Latent secret leak in live mode: _emit_action_log only redacted
-p<pass> and rootpass=<pass>. The script also emits the github
api token via `curl -H "Authorization: token $GITHUB_KEY_COMPOSER"`
(rate-limit probe) and `composer config --auth github-oauth.github.com
$KEY`. In dry-run those values are stubbed (placeholders have <>
which %q-escapes to \<\>, dodging the new pattern's [A-Za-z0-9_]+
body match), but Phase 2 live runs with a real /home/openemr/
github-key mounted would otherwise commit the raw token to
ACTION_LOG. Added two more sed patterns to cover both shapes.
* test.sh docstring example was stale: the harness does
`cp -a "$extra_dir/." "$work/"` which mirrors the work-tree
layout. Fixtures need to put version.php at
extra/web/openemr/version.php, not extra/openemr/version.php
(which silently lands at the wrong root and never overrides
$WEB/openemr/version.php).
Phase 1 goldens are unchanged — the new redaction patterns don't fire
against the dry-run stubs.
Refs: #146 (issue), #147 (this PR), #148 (Phase 2)
Assisted-by: Claude Code
1 parent 000d131 commit 91477d1
27 files changed
Lines changed: 973 additions & 114 deletions
File tree
- .github/workflows
- tools/build-tests
- fixtures
- branch-pinned-master
- expected
- capsule-path-traversal
- expected
- light-reset
- expected
- multi-demo
- expected
- release-packageserve
- expected
- tag-pinned-with-data
- expected
- extra/git/demo_farm_openemr/pieces
- up-for-grabs-fork
- expected
- extra/git/demo_farm_openemr/pieces
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments