Skip to content

RDODCP-1463: build, scan and publish Chisel from GitHub Actions - #68

Draft
samartha-pm wants to merge 9 commits into
masterfrom
RDODCP-1463
Draft

samartha-pm wants to merge 9 commits into
masterfrom
RDODCP-1463

Conversation

@samartha-pm

@samartha-pm samartha-pm commented Dec 3, 2026 •

Copy link
Copy Markdown

Moves Chisel's build and release into this repository, so the build of a public
product is itself public and verifiable by anyone who uses it.

This was proven first in a sandbox repository, which published three real
releases through these exact workflows before this PR was raised.

What this adds

Workflow Trigger Does
ci.yml PRs, feature branches, and master go test -race, govulncheck, actionlint + zizmor, build the image, run the Trivy/Grype gate. Publishes nothing and holds no write permission
release.yml tag v*-os.* build once, scan, gate, hold for a reviewer, push the image, assert the digest, publish the Release with an SBOM
rescan.yml every 6 hours rescan the published :latest and fail on a finding
promote.yml — inert placeholder, replacing the current 0-byte file

Plus scripts/scan-report.sh, the shared report and gate, so the check that
blocks a pull request is byte-for-byte the check that blocks a release.

Design points worth reviewing

The artifact is compiled once. GoReleaser runs a single time with
--skip=publish. Everything published afterwards comes out of that one dist/
directory, and the final step asserts that the digest the registry resolves the
tag to is the same digest that passed the scanners. "What we scanned is what we
shipped" is checked at run time rather than asserted in a comment.

Publishing is refused, not skipped, for an existing tag. The run fails
before anything is pushed, rather than exiting green having done nothing.

The release job is the only job that can write. The workflow default is
contents: read; release.yml elevates to packages: write for itself alone,
behind a protected Environment that requires a human approval. No repository
secret is referenced anywhere — only the built-in GITHUB_TOKEN.

Both scanners float deliberately. Old Trivy releases are deleted upstream,
so a pinned version becomes a 404 over time; Grype is resolved to its newest
tag at run time because anchore/scan-action pins an older binary internally.

promote.yml is neutered, not deleted. .gitattributes binds merge=ours
to the path. Deleting the file silently removes the protection that keeps
upstream's version — which retags images to latest on two registries with no
vulnerability scan in front of it — from returning at the next upstream sync.
CI pins the file's SHA-256, so an edit fails the build on purpose.

The base image is pinned by digest. Same Alpine 3.21 as before, pinned to
the digest it currently resolves to, with the Dependabot docker ecosystem
added so the pin keeps moving. That commit is deliberately separate so it can
be dropped on its own.

SECURITY.md documents a private disclosure route, so a finder has
somewhere to go that is not a public issue.

What CI found immediately

Turning the pipeline on surfaced problems that were already here and that
nothing was looking for. All are fixed in this branch and CI is now green.

Four failing unit tests. The tests were already in this repository and were
already failing on the default branch — nothing ran them. In every case the
test, and twice the helper function, already existed; only the wiring was
missing. The most serious: InterruptContext registered a signal channel and
then shadowed it with a second one, so a SIGTERM arriving shortly after start
was dropped entirely and the process ignored it — docker stop or a Kubernetes
termination would hang until SIGKILL.

Three vulnerable dependencies.

Advisory Was Now Found by
GO-2026-6859 Go 1.26.10 1.26.11 govulncheck (reachable)
GO-2026-6278 gorilla/websocket v1.5.3 v1.5.4-0.20240701034025-d67f41855da4 govulncheck (reachable)
CVE-2026-78661 golang.org/x/net v0.60.0 v0.62.0 Trivy only

The last one is worth a look. govulncheck classified it as present but not
called
, so that step passed. Trivy does no reachability analysis — it sees the
module in the shipped binary and reports it. Grype reported 0. Trivy is right
to block: unreachable today is a property of the current call graph, not of the
artifact, and a later change can make it reachable without anyone revisiting
the advisory. It is also the clearest argument so far for running both scanners
rather than picking one.

Before this can run for real

Some of this is repository configuration rather than code, and has to be set up
separately — an Environment with required reviewers, branch and tag protection,
Issues enabled for scan alerting, and the package linked to this repository.
Raised as draft until those are in place.

🤖 Generated with Claude Code

@wiz-code-outsystems

wiz-code-outsystems Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings -
Software Management Finding Software Management Findings -
Total -

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio.

Pull Request Developer Guidance

Questions? See the Wiz FAQ.

Please contact the Security Office if you encounter issues with Wiz pull request scanning.

samartha-pm and others added 6 commits December 3, 2026 01:18
Moves the build and release of this project into this repository, so the
build of a public product is itself public and verifiable.

  ci.yml       PRs, feature branches and master. Unit tests with -race,
               govulncheck, actionlint + zizmor, then build the image and
               run the Trivy/Grype gate. Publishes nothing and holds no
               write permission.
  release.yml  tag v*-os.* -- build once, scan, gate, hold at a protected
               Environment for a reviewer, then push the image and create
               the Release. Asserts the published digest equals the digest
               that passed the gate.
  rescan.yml   every 6h against the published :latest, and FAILS on a
               finding rather than only alerting.
  promote.yml  replaces the 0-byte file with an inert placeholder.

The artifact is compiled ONCE. GoReleaser runs a single time with
--skip=publish, everything published afterwards comes out of that one dist/
directory, and the registry digest is asserted equal to the scanned digest
at run time.

Re-publishing an existing tag fails before anything is pushed, rather than
exiting green having done nothing.

No repository secret is referenced anywhere. The workflow default is
contents: read; the release job elevates to packages: write for itself
alone, behind the Environment approval.

promote.yml is neutered, not deleted: .gitattributes binds merge=ours to
the PATH, so deleting it would silently remove the protection that keeps
upstream's unscanned retag workflow out at the next upstream sync. CI pins
its SHA-256.

CODEOWNERS now covers the pipeline itself, so a change to the gate cannot
ride along in an unrelated review.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
SECURITY.md documents a coordinated disclosure route via GitHub private
vulnerability reporting, so a finder has somewhere to go that is not a
public issue. Enabling the feature itself is a repository setting and has
to be done separately; it cannot be turned on by a commit.

The file carries a TODO for the named response owner, which must be
answered before it is relied on.

dependabot.yml gains the `docker` ecosystem so the digest pin added in the
next commit does not freeze us on a stale base -- Dependabot understands
`FROM image:tag@sha256:...` and bumps both halves. github-actions moves
from monthly to weekly because anchore/scan-action pins the Grype binary
inside the action, so bumping the action is the only way that pin moves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`alpine:3.21` is a floating tag. Whoever controls it controls what lands in
the image, and it can be repointed after we have scanned it -- so the scan
result stops describing what we ship. A digest cannot move.

The base image itself is unchanged: the same Alpine 3.21 we build on today,
pinned to the digest it currently resolves to. The tag is kept beside the
digest so the line stays legible, and the Dependabot docker ecosystem added
in the previous commit updates both.

This commit is deliberately separate so it can be dropped on its own.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
These tests are already in this repository and are already failing on the
default branch. Nothing ran them, so nobody saw it. ci.yml runs them, which
is how they surfaced.

In every case the test -- and twice the helper function -- already existed.
Only the wiring was missing.

client: NewClient never applied the documented retry-interval defaults.
  A zero value was passed straight to backoff.Backoff, which substitutes its
  OWN defaults of 100ms and 10s instead of the documented 1s and 5m, so a
  disconnected client reconnected ten times more aggressively than the help
  text promises. An inverted Min/Max range also made Backoff return Max on
  every attempt, silently disabling backoff altogether.
  Fixes TestRetryIntervalDefaults, TestRetryIntervalExplicit.

share/tunnel: keepAliveLoop carried its own inline ping instead of calling
  keepAlivePing, the helper written for it, which was dead code. It also
  clamped any interval below 5s up to 5s, so --keepalive 1s was silently
  ignored. The reply timeout is now capped at the interval so pings cannot
  queue up behind each other on a slow link.
  Fixes TestKeepAliveLoopTimeout, TestKeepAliveLoopHealthy.

share/cos: InterruptContext registered a signal channel, then created and
  registered a SECOND one inside its goroutine, shadowing the first. Signal
  delivery is non-blocking per channel, so a SIGTERM arriving before that
  goroutine was scheduled went only to the outer channel, which nothing ever
  read, and was dropped -- the process then ignored the signal entirely.
  `docker stop` or a Kubernetes termination shortly after start would hang
  until the grace period expired and SIGKILL landed.

client_test: TestCustomHeaders bound hardcoded port 9000 and failed on any
  machine already using it. Uses the existing availableTCPPort helper.

Verified with `go build ./...`, `go vet ./...` and `go test -race` across
client/ and share/.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both are REACHABLE -- govulncheck reports them as called, not merely present
-- and both block the new build gate.

  GO-2026-6859  stdlib               1.26.10 -> 1.26.11
  GO-2026-6278  gorilla/websocket    v1.5.3  -> v1.5.4-0.20240701034025-d67f41855da4

The go directive moves to 1.26.11 because that is the fixing toolchain.
setup-go reads go-version-file: go.mod, so CI follows it without a second
place to update.

The websocket fix is only published as a pseudo-version; that is what the
advisory names as the fixed version, not a choice.

govulncheck now reports: "Your code is affected by 0 vulnerabilities."
Three findings remain PRESENT BUT NOT CALLED (x/crypto GO-2026-5932, x/net
GO-2026-6860 and GO-2026-6866). Those are informational and do not block;
leaving them to the normal Dependabot flow rather than widening this change.

Verified with go build, go vet, go test -race and govulncheck.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Trivy flags this as HIGH in the compiled binary (CVE-2026-78661,
golang.org/x/net v0.60.0, fixed in 0.62.0) and the gate blocks on it.

Worth noting WHY this needed a separate fix. govulncheck classifies the
same advisories (GO-2026-6860, GO-2026-6866) as "present but NOT called",
so the govulncheck step passed. Trivy does no reachability analysis: it
sees the module in the shipped binary and reports it. Grype reported 0.

Trivy is right to block here. Unreachable today is a property of the
current call graph, not of the artifact -- the vulnerable code is in the
binary we would publish, and a later change can make it reachable without
anyone revisiting the advisory. This is also the clearest argument so far
for running both scanners rather than picking one.

Verified with go build and go test.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread share/tunnel/tunnel.go
Comment on lines 189 to 211
func (t *Tunnel) keepAliveLoop(sshConn ssh.Conn) {
//ping forever
keepAliveInterval := t.Config.KeepAlive
if keepAliveInterval < 5*time.Second {
keepAliveInterval = 5 * time.Second
//The caller only starts this when KeepAlive > 0, but never spin if that
//ever changes.
interval := t.Config.KeepAlive
if interval <= 0 {
return
}

reply_timeout := 2 * time.Second
//A reply timeout longer than the ping interval would let pings queue up
//behind each other on a slow link, so cap it at the interval.
timeout := 2 * time.Second
if interval < timeout {
timeout = interval
}
//ping until one fails, then drop the connection so the client reconnects
for {
time.Sleep(keepAliveInterval)

errChannel := make(chan error, 2)

timeoutTimer := time.AfterFunc(reply_timeout, func() {
errChannel <- errors.New("KEEPALIVE REPLY TIMEOUT ERROR")
})

go func() {
_, b, err := sshConn.SendRequest("ping", true, nil)

ret_err := err

if err == nil && len(b) > 0 && !bytes.Equal(b, []byte("pong")) {
t.Debugf("strange ping response")
ret_err = errors.New("strange ping response")
}

errChannel <- ret_err
}()

err := <-errChannel

// explicitly stop the timer, as it's no longer needed at this point.
timeoutTimer.Stop()
// errChannel should be garbage collected, as it won't be in use, even on a timeout,
// as SendRequest will be unblocked on connection closure, the goroutine will send
// an error message and finish, therefore releasing the channel.

if err != nil {
time.Sleep(interval)
if err := t.keepAlivePing(sshConn, timeout); err != nil {
t.Debugf("keepalive failed: %s", err)
break
}
}
//close ssh connection on abnormal ping
sshConn.Close()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this PR and, with the help of Claude, I have three small suggestions to improve keepAliveLoop. The current change already makes TestKeepAliveLoopTimeout and TestKeepAliveLoopHealthy pass. The suggestions are not regressions compared to master, but they differ from upstream v1.12.0:

  1. Stop when the connection closes. With time.Sleep(interval), the loop keeps waiting after the connection is closed (up to the full interval, 25s by default) before it exits. Upstream uses a ticker and a channel closed by sshConn.Wait().
  2. Honour CHISEL_PING_TIMEOUT. The README documents it, but nothing reads it. Upstream reads it with settings.EnvDuration("PING_TIMEOUT", ...).
  3. Log the failure at info level. Debugf is only visible with -v, so on the server a dead connection is dropped silently by default.

The suggestion below does all three and keeps your behaviour at the default settings: the reply timeout stays at 2s, capped at the interval. I tried it on top of this PR's head: build and vet pass, the keepalive tests pass, and so does the whole suite, including -race for share/tunnel.

Suggested change
func (t *Tunnel) keepAliveLoop(sshConn ssh.Conn) {
//ping forever
keepAliveInterval := t.Config.KeepAlive
if keepAliveInterval < 5*time.Second {
keepAliveInterval = 5 * time.Second
//The caller only starts this when KeepAlive > 0, but never spin if that
//ever changes.
interval := t.Config.KeepAlive
if interval <= 0 {
return
}
reply_timeout := 2 * time.Second
//A reply timeout longer than the ping interval would let pings queue up
//behind each other on a slow link, so cap it at the interval.
timeout := 2 * time.Second
if interval < timeout {
timeout = interval
}
//ping until one fails, then drop the connection so the client reconnects
for {
time.Sleep(keepAliveInterval)
errChannel := make(chan error, 2)
timeoutTimer := time.AfterFunc(reply_timeout, func() {
errChannel <- errors.New("KEEPALIVE REPLY TIMEOUT ERROR")
})
go func() {
_, b, err := sshConn.SendRequest("ping", true, nil)
ret_err := err
if err == nil && len(b) > 0 && !bytes.Equal(b, []byte("pong")) {
t.Debugf("strange ping response")
ret_err = errors.New("strange ping response")
}
errChannel <- ret_err
}()
err := <-errChannel
// explicitly stop the timer, as it's no longer needed at this point.
timeoutTimer.Stop()
// errChannel should be garbage collected, as it won't be in use, even on a timeout,
// as SendRequest will be unblocked on connection closure, the goroutine will send
// an error message and finish, therefore releasing the channel.
if err != nil {
time.Sleep(interval)
if err := t.keepAlivePing(sshConn, timeout); err != nil {
t.Debugf("keepalive failed: %s", err)
break
}
}
//close ssh connection on abnormal ping
sshConn.Close()
}
func (t *Tunnel) keepAliveLoop(sshConn ssh.Conn) {
//The caller only starts this when KeepAlive > 0, but never spin if that
//ever changes.
interval := t.Config.KeepAlive
if interval <= 0 {
return
}
//A reply timeout longer than the ping interval would let pings queue up
//behind each other on a slow link, so the default is capped at the interval.
pingTimeout := settings.EnvDuration("PING_TIMEOUT", min(2*time.Second, interval))
ticker := time.NewTicker(interval)
defer ticker.Stop()
//stop the loop when the connection closes
closed := make(chan struct{})
go func() {
sshConn.Wait()
close(closed)
}()
//ping until one fails, then drop the connection so the client reconnects
for {
select {
case <-closed:
return
case <-ticker.C:
}
if err := t.keepAlivePing(sshConn, pingTimeout); err != nil {
t.Infof("keepalive failed: %s", err)
break
}
}
sshConn.Close()
}

samartha-pm and others added 3 commits December 3, 2026 23:18
Changing the base image is out of scope for this change. The Dockerfile is
now byte-identical to master again.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The four fixes are moving to their own ticket. This change is the pipeline
only, so the four tests that were already failing on master go back to
failing, and the unit test job reports them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants