Skip to content

v0.11.0: subcommands, a security gate, and prices that know their region - #263

Merged
scttfrdmn merged 6 commits into
mainfrom
v0.11.0-cli-subcommands
Aug 3, 2026
Merged

scttfrdmn merged 6 commits into
mainfrom
v0.11.0-cli-subcommands

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes the v0.11.0 milestone — 28 issues, 0 open.

What is in it

feat: subcommands, and a systemd unit that matches the binary (e8750eb). The documented first command could not run: main.go required exactly two positional arguments and there were no subcommands at all, so every example in the README was unrunnable. The shipped systemd unit invoked a form the binary did not accept.

ci: make the release security scan a gate, from a clean baseline (2eee49d). security-scan already scanned the exact binary publish attaches, which is the right shape, but it could not fail — trivy-action's exit-code has no default, so findings uploaded as SARIF and the step passed. It now exits 1 on HIGH,CRITICAL with ignore-unfixed. Verifying the baseline found something to fix: GO-2026-5841, an out-of-bounds read in klauspost/compress/s2, present in the module the binary is built from. Bumped, with the compress/PUT/GET/decompress round-trip fuzzer passing 12k executions on the new version. Closes #196.

fix: make the pricing region select prices (7c70dc0). pricing_config.region was read at exactly one line in the repository, and only to label a summary. Every rate came from a package-level table built at init, which cannot see a configuration, so every cost ObjectFS reported was us-east-1's — region: sa-east-1 produced us-east-1 numbers labeled sa-east-1, and sa-east-1 Standard storage is 76% higher. A wrong number that names the region it is not from is worse than no number.

Rates are now generated, not written: 36 regions × 8 storage classes × 6 fields, produced by the new internal/awsrates/offerfile package from AWS's public price list offer files. Those need no credentials, so go generate ./internal/awsrates/... refreshes every number in one command anyone can run. Not the Pricing API — it needs credentials, and its Go client forces smithy-go ≥1.26.0 under the S3 client on the data path.

It also found a live second defect: Glacier PUT was reading Requests-Tier3, which is the restore price, 67% too high. The test that existed to catch exactly this agreed with it — it transcribed the queries a second time and named Requests-Tier3 itself, and it shelled out to aws pricing get-products, so it skipped without a configured profile, including in CI. A drift check that skips is not a drift check. Closes #161.

test: pin the compressed-upload bypass to the routing, not the result (851af8e). The corruption was fixed in 0.10.1, but the test covering it asserted only that the stored object carried a Content-Encoding header — one step removed from the mechanism. It now asserts which upload path ran, with a control half that fails if the transporter is not running at all. Closes #153, and files scttfrdmn/cargoship#353 upstream for the missing Archive.ContentEncoding field, still absent in v0.20.0.

Verification

Every gate green with verified exit codes:

  • go build ./... — 0
  • gofmt -l . — clean
  • go test -count=1 -race -coverprofile ./... — 0, zero FAILs
  • ./scripts/coverage-gate.sh — 34/34 packages at or above their floor
  • golangci-lint run --new-from-merge-base=origin/main — 0 issues

internal/awsrates is at 100% coverage; the generator command at 74.4%.

Mutation-verified rather than inspected. 14 mutations across lookup, the awsrates region accessors, PricingManager.StorageRate, the generator's skip/refuse-to-write rules, the emit sort order, and both halves of the CargoShip routing test — all caught. One on the generated table itself (0.0405 → 0.0406) is caught by the live drift test, which passed against AWS with no credentials across 5 regions × 8 classes × 6 fields.

Not in scope, stated rather than left silent

internal/cost and internal/analytics stay region-blind. Nothing imports either package, so a region argument there would have no caller to be wrong for, and the region belongs in a constructor that a package-level var cannot have. Both now say so in code, naming awsrates.AllForRegion and PricingManager as the shape to copy when either acquires a caller.

`objectfs mount`, `objectfs unmount` (also `umount`), `version`, `help`. The
form without a subcommand still works and is not deprecated — it is what every
invocation written before this release looks like. A first argument carrying a
URI scheme or a leading dash routes to mount; a bare word that is not a command
is a usage error naming itself, so `objectfs moutn s3://b /mnt` does not become
an attempt to mount a bucket called "moutn".

`objectfs unmount` is the one that had to exist. Unmounting was "signal the
mount process", which an ExecStop cannot do once that process is gone, so the
shipped unit called fusermount3 directly — absent on a minimal image, spelled
fusermount on libfuse 2, and a bare exit status to systemd either way. The
subcommand tries the libfuse 3 helper, the libfuse 2 helper, umount, then
umount(2), and on failure reports which ran, which were not installed, and the
lsof invocation that names what is holding the mount. No candidate unmounts
lazily or forcibly, and a test asserts none ever passes -z/-l/-f: those detach
the name while the filesystem still serves open files, so they report a finished
unmount with writes in flight — and adding one would make every other unmount
test pass, which is why it is a test and not a comment.

Flags now precede positionals, because Go's flag package stops at the first
non-flag argument: `mount s3://b /mnt --foreground` left --foreground as a third
positional and silently did not apply it. Each subcommand gets its own FlagSet
for the same reason.

The systemd template mounts and unmounts the way the binary works: --config for
the bucket, --mount-point for the instance path, `objectfs unmount` to stop,
TimeoutStopSec stated rather than inherited because that is the flush window,
Restart=on-failure so a clean `systemctl stop` does not remount. What it
replaces was valid systemd and wrong four ways, including `ExecStart=... s3://%i
/mnt/objectfs/%i`, which makes the instance name and the bucket name one string,
and RequiresMountsFor on the mount this unit creates.

Two gates for it, checking different things. TestSystemdUnit* parses the unit's
Exec* lines through the documentation gate's own parser and checks every
subcommand and flag against the sets scraped from main.go, so no list is
maintained by hand. A systemd-unit CI job runs `systemd-analyze verify` for the
half a Go test cannot see. Neither alone catches the old unit: analyze passes
it, and a Go test cannot tell whether RequiresMountsFor means what its author
thought. Joining `\` continuations turned out to be load-bearing — verified by
mutation, a raw-line loop left --mount-point unchecked.

cmd/objectfs has a coverage floor for the first time (77%): main() is three
lines around run(args, stdout, stderr) int, where it used to call log.Fatalf,
which calls os.Exit, which takes the test binary with it.

Also: a one-character bucket name reported "is 1 characters". `s3://b` is what
someone types while testing, so that is a message operators read.

Closes #134, closes #135
`security-scan` already scanned the exact binary `publish` attaches, which is
the right shape, but it could not fail: trivy-action's `exit-code` has no
default, so findings uploaded as SARIF and the step passed. It now exits 1 on
HIGH,CRITICAL, with ignore-unfixed and scanners: vuln.

Each of those is a decision. MEDIUM and below still upload and stay visible
without stopping a publish. ignore-unfixed because an advisory with no released
fix cannot be actioned by a release — blocking on one means the project cannot
ship until an upstream maintainer acts, which is an availability problem wearing
a security posture. The SARIF upload is now if: always(), so the findings that
failed the step are the ones that reach the security tab; without it a HIGH
stopped the job before the upload and left whoever was cutting the release with
an exit code and no way to see the cause.

The reason it was not a gate before is the reason it can be one now: the first
run of this scan found a MODERATE in the pinned aws-sdk-go-v2 (#195), and
switching the gate on then would have blocked every release on a scan nobody had
triaged. A gate turned on against existing findings is a broken build everyone
learns to bypass.

Verifying that baseline found something to fix. govulncheck reports 0 called
vulnerabilities but one under "packages you import": GO-2026-5841, an
out-of-bounds read in klauspost/compress/s2, fixed in v1.18.7. Unreachable from
this code, present in the module the binary is built from — which is exactly what
a binary scan sees, and what the new gate would have failed on. Bumped. The
compress/PUT/GET/decompress round-trip fuzzer passes 12k executions on the new
version, since this module is the zstd codec on the write path.

The asymmetry #196 names is resolved toward gating: govulncheck in security.yml
exits non-zero and has always gated main and every PR, while the artifact users
download was not gated at all. The repo-wide `trivy fs` scan there is
deliberately still not a gate and now says why — it reports on the source tree
rather than on what ships, including test-only dependencies — but picks up the
same severity floor and ignore-unfixed, so a finding in one place means what a
finding in the other means.

Closes #196
`pricing_config.region` was read at exactly one line in the whole repo, and only
to label a summary. Every rate came from a package-level table built at init, so
every cost ObjectFS reported was us-east-1's regardless of where the bucket was —
`region: sa-east-1` yielded us-east-1 numbers *labelled* sa-east-1, and Standard
storage in sa-east-1 is 76% higher. A wrong number that names the region it is
not from is worse than no number.

The fix is structural rather than a plumbing change. `StorageTierInfo` no longer
has a `CostPerGBMonth` field: a rate on a package-level struct cannot know which
region produced it, and that field *was* the mechanism. It is removed rather than
filled from the configured region, because filling it would put a region-specific
number on a value shared process-wide by every manager — the same defect with an
extra step. `PricingManager` resolves the region once in its constructor and owns
every rate lookup; the compiler found the callers.

`internal/awsrates` now covers 36 regions × 8 storage classes × 6 rates, and none
of it is hand-written. `rates_generated.go` is produced by the new
`internal/awsrates/offerfile` package from AWS's public per-region price list
offer files, which need no credentials, so `go generate ./internal/awsrates/...`
refreshes every number in one command anyone can run.

Not the Pricing API, deliberately. It needs credentials, and its Go client forces
smithy-go ≥1.26.0 under the S3 client on the data path. The offer files are the
same data over plain HTTPS.

Three extraction rules exist because the obvious query returns a plausible number
from the wrong SKU, and each is documented in the package with the case that
forced it:

  - `usagetype` alone is not a key for a rate. `Requests-GLACIER-Tier1` has 15
    SKUs at 2 prices, separated by the `operation` attribute. This is a live bug
    fixed here, not a hypothetical: Glacier PUT was reading `Requests-Tier3`,
    which is the *restore* price, and was 67% too high.
  - The region prefix must be derived structurally, not templated. us-east-1's is
    the empty string, us-west-2's is `USW2-`, eu-west-1's is `EU-`.
  - Egress comes from the `AWSDataTransfer` offer file keyed on `fromLocation`.
    S3's own `DataTransfer-Out-Bytes` usagetype is the Multi-Region Access Point
    routing charge.

The test that existed to catch the Glacier defect agreed with it. It shelled out
to `aws pricing get-products`, so it skipped for anyone without a configured
profile — including CI, and a drift check that skips is not a drift check — and it
transcribed the queries a second time, naming `Requests-Tier3` for Glacier PUT.
It now fetches the same offer files over plain HTTPS with no credentials, drives
its queries from `offerfile.Queries()` rather than its own copy, and compares the
whole committed table across five regions spanning every band AWS publishes.

Verified by mutation, not by inspection: 12 mutations across `lookup`, the region
accessors, `PricingManager.StorageRate`, and the generator's skip/refuse-to-write
rules; all 12 caught. One on the generated table itself (0.0405 → 0.0406) is
caught by the live drift test, which passed against AWS with no credentials.

`internal/awsrates` reaches 100% coverage, the generator command 74.4%, and all
three floors are recorded in `.coverage-floors`.

`internal/cost` and `internal/analytics` stay region-blind, stated in code rather
than left silent: nothing imports either one, so a region argument there would
have no caller to be wrong for, and the region belongs in a constructor that a
package-level var cannot have.

Closes #161
The corruption was fixed in 0.10.1 — a compressed object does not go through
CargoShip's transporter, which cannot set `Content-Encoding` — but the test
covering it asserted only that the stored object carried the header. That is the
property users need and it is one step removed from the mechanism. It would also
pass if the transporter had acquired header support, and it would keep passing if
the bypass were replaced by anything else that produced a correct object. The
comment in `PutObject` explaining why the transporter must not carry a compressed
body had nothing asserting the branch it describes.

This asserts which path ran, via the `cargoship-created-by` metadata the
transporter stamps on everything it uploads. That is the only observable that
distinguishes them: both paths end in a PutObject to the same endpoint with the
same body, so the object alone cannot tell them apart, and asserting on a log
line would test the logging rather than the routing.

The control half is equally load-bearing. A 1 KiB object, below the compression
threshold, *must* carry the stamp — without that the test would pass on a build
where the transporter never runs at all, silently measuring a disabled feature
instead of the bypass.

Both halves verified by mutation: neutering the bypass condition fails the
assertion (and the metadata dump in the failure shows the defect exactly —
`content-encoding: zstd` as user metadata beside an empty header), and setting
`EnableCargoShipOptimization` false fails the control with the reason.

Filed scttfrdmn/cargoship#353 for the upstream gap: `Archive` has no field that
maps to `Content-Encoding` and neither transporter sets the header, still true in
v0.20.0. `CompressionType` looks like the field and is not — `buildMetadata` puts
it in user metadata, and CargoShip's own tests use `"none"` for it, which is not a
valid content coding, so deriving the header from it would not work either.

The remaining acceptance criteria were already met: the header lands
(TestDefaultConfigDoesNotCorruptCompressedObjects), a full read round-trips
byte-for-byte, a partial read at a non-zero offset returns the right slice
(TestPartialReadSurvivesAnAlgorithmChange), and the "4.6x" comment was corrected
repo-wide. The ordering constraint held too: `use_cargoship` was plumbed through
`buildS3Config` only after this bypass existed.

Closes #153
Comment thread internal/fuse/unmount_path.go Fixed
…just lint's

There are two gosec runs and they read different directives. golangci-lint's
honors `//nolint:gosec`; the standalone gosec in security.yml, whose SARIF feeds
GitHub code scanning, honors only `#nosec`. Both sites here already carried a
reasoned `//nolint:gosec`, so `lint` passed and the `gosec` check on PR #263
failed with two new alerts — G306 on the generator's `WriteFile` and G204 on the
unmount helper's `exec.CommandContext`.

Neither is a real finding, and the existing comments already say why: the
generator writes committed Go source holding published AWS list prices, and the
unmount helper spawns no shell, takes its program name from a fixed platform
table, and passes the mount point as a single argv element. Both now carry
`#nosec` alongside, with a note at each site recording that the duplication is
about two tools rather than about two risks.

Verified by installing the same gosec the workflow does and reproducing both
findings locally, then confirming they clear. Also verified the suppression is
line-scoped rather than file-wide: an added unsuppressed `0o644` write in the same
function is still reported at its own line.

This is a pre-existing gap, not a new one — six other sites suppress for
golangci-lint only and are open code-scanning alerts on main today
(`difftest/fs.go`, `awsname.go`, `congestion_linux.go` ×2, `s3/config.go`,
`testaws.go`). Filed separately rather than fixed here, since each needs its own
judgment about whether the finding is real.
The two-runs-two-directives gap is the kind of thing that reads as a CI
quirk in a commit message and as a real constraint in a changelog: anyone
adding a gosec suppression after this needs to know that `//nolint:gosec`
alone passes lint and fails the security check.
@scttfrdmn
scttfrdmn merged commit f687100 into main Aug 3, 2026
24 checks passed
scttfrdmn added a commit that referenced this pull request Aug 3, 2026
First release to follow the rule v0.10.3 established. The milestone was at 0
open / 28 closed and PR #263 was merged before the version constant moved, so
this tag holds all of the work it is named for — unlike v0.10.1, tagged two
hours before the module-path fix it existed to ship, and v0.10.2, tagged when
the first of its twelve issues closed.

CHANGELOG: [Unreleased] promoted to [0.11.0] with a preamble stating what the
release is, and the two `### Changed` headings the section had accumulated
merged into one. Two PRs each appended their own, which Keep a Changelog does
not forbid but which splits a category a reader scans once; the released
sections below are all single-heading, so this matches them rather than
introducing a shape. Order is Added / Fixed / Changed / Removed, as in [0.10.3].

Link references: [0.11.0] added comparing from v0.10.3, and [Unreleased] moved
to compare from v0.11.0. Both are checked by
internal/config/changelog_test.go — the consecutiveness test would fail on a
definition copied from the release below with only its right-hand side edited,
which is the most natural way to get one wrong by hand.

SECURITY.md: 0.11.0 supported. 0.10.3 marked superseded with the reason spelled
out, since it differs from the two below it: no known security defect and no
data loss, it simply predates this release, and only the latest gets fixes.

Verified: the release workflow's two gates run by hand before tagging. The tag
matches the version constant, and the CHANGELOG extraction yields a 69,867-byte
section — under the 120,000 budget, so the full notes publish rather than the
summary fallback. go build ./... clean; gofmt clean; go test -count=1 -race
./... exit 0 across 36 packages; coverage gate 34 packages at or above floor;
golangci-lint 0 issues.
@scttfrdmn
scttfrdmn deleted the v0.11.0-cli-subcommands branch September 20, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants