Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
afcffcf
feat(artifacts): extract blob transport and back CI stores with it (A…
osterman Oct 31, 2026
006b6c2
feat(artifacts): add local directory and archive repositories (A04)
osterman Oct 31, 2026
9a4a5fc
fix(artifacts): make local backends and tests Windows-safe, quiet Cod…
osterman Nov 8, 2026
38c29ff
fix(artifacts): drop the S3 fake's response-writer pass-through that …
osterman Nov 9, 2026
3dc69d1
fix: tighten S3 test server request handling
osterman Nov 11, 2026
0a8a176
fix: validate blob inputs and preserve local names
osterman Nov 11, 2026
860b452
fix: harden artifact recovery and conditional operations
osterman Nov 11, 2026
ea77e1a
fix: bound evidence scanning and test retry paths
osterman Nov 11, 2026
ec3ab0e
fix: preserve unmanaged files and support single upload fallback
osterman Nov 11, 2026
93e82cf
fix: confine local blob paths to their root
osterman Nov 11, 2026
c1a62ef
perf: reuse local listing snapshots across pages
osterman Nov 11, 2026
2a92783
fix: preserve attributes on directory conflicts
osterman Nov 11, 2026
cc0846d
test: honor Windows artifact filesystem semantics
osterman Nov 12, 2026
7140fe2
test: propagate range response read errors
osterman Nov 12, 2026
a93f959
ci: record govulncheck resource pressure
osterman Nov 12, 2026
da4d947
ci: measure scanner garbage collection tradeoff
osterman Nov 12, 2026
b8134d9
fix: keep local blob content and attributes consistent
osterman Nov 12, 2026
8d280f8
fix(artifact): read S3 tags for the headed object version
osterman Nov 12, 2026
01ec244
refactor(artifact): define the aws-chunked terminator sentinel centrally
osterman Nov 12, 2026
452a683
refactor(artifact): reduce complexity flagged by code scanning
osterman Nov 13, 2026
dc88205
fix(artifact): harden S3 probe, multipart completion, and condition v…
osterman Nov 13, 2026
f6aeb2d
fix(artifact): tighten blob tag, key, prefix, and staging handling
osterman Nov 13, 2026
0e5051f
fix(artifact): harden layout identifiers and make location rendering …
osterman Nov 13, 2026
86a9354
fix(artifact): refuse an unusable signer before local signing runs
osterman Nov 13, 2026
ff26d9b
refactor(artifact): keep local signing within lint limits
osterman Nov 13, 2026
9b25ff8
fix(artifact/blob): give unclassified blob failures a shared sentinel
osterman Nov 14, 2026
5fa2487
fix(artifact/blob/local): prefix deletes, case-folded names, cancelab…
osterman Nov 14, 2026
babb0b5
fix(ci/artifact/local): keep attribute-looking artifacts independent …
osterman Nov 14, 2026
b55a6ed
fix(artifact/blob/s3): honor cancellation, keep worker errors, share …
osterman Nov 14, 2026
6ea33bf
fix(artifact/layout): validate representation descriptors
osterman Nov 14, 2026
f25a9c1
fix(artifact/local): lock evidence writes, filter exports by subject,…
osterman Nov 14, 2026
cfa49de
fix(artifact/blob/local): refuse conditional operations a plain-file …
osterman Nov 14, 2026
5bef473
fix(artifact/service): hold the reference lock while signing
osterman Nov 14, 2026
a283b44
test(artifact/blob/local): release held guards and roots when a test …
osterman Nov 14, 2026
33b84ee
test(artifact/service): bound the wait for the signer and free gates …
osterman Nov 14, 2026
ed5bcf7
test(artifact/local): release held locks and handles when a test aborts
osterman Nov 14, 2026
e8b7a4b
test(artifact): bound S3 probe waits and close readers when a test ab…
osterman Nov 14, 2026
737aced
test(artifacts): bound the guard acquisition in holdGuard
osterman Nov 15, 2026
c44c1d9
test(artifacts): join the commit before closing its root
osterman Nov 15, 2026
c928122
fix(artifacts): clear code-scanning lint findings in the CI stores
osterman Nov 15, 2026
6951aa0
fix(artifact): keep the destination's file mode when an upload replac…
osterman Nov 15, 2026
69ede65
fix(artifact): keep CI S3 uploads on one PutObject so write-only role…
osterman Nov 15, 2026
992587d
fix(artifact): preserve sentinel ordering from historical integration
osterman Nov 17, 2026
739c801
Merge L3 review fixes into artifacts backends local
osterman Nov 17, 2026
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
40 changes: 40 additions & 0 deletions .github/scripts/govulncheck-monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Run the scanner unchanged while recording resource pressure for slow CI jobs.
set -u

monitor() {
local sleeper=""
trap 'kill "$sleeper" 2>/dev/null || :; exit 0' TERM INT
while :; do
{
echo "--- govulncheck resources $(date -u +%FT%TZ) ---"
free -m || :
for resource in cpu memory io; do
if [[ -r "/proc/pressure/$resource" ]]; then
echo "$resource pressure:"
cat "/proc/pressure/$resource" || :
fi
done
# Show the largest processes and the scanner even if it is not among them.
ps -eo pid,ppid,stat,pcpu,rss,vsz,comm --sort=-rss | head -n 26 || :
for pid in $(pgrep -x govulncheck || :); do
echo "govulncheck pid $pid:"
awk '/^(State|VmRSS|VmSwap):/ { print }' "/proc/$pid/status" 2>/dev/null || :
done
} >&2
sleep 60 &
sleeper=$!
wait "$sleeper" || :
sleeper=""
done
}

monitor &
monitor_pid=$!
cleanup() {
kill "$monitor_pid" 2>/dev/null || :
wait "$monitor_pid" 2>/dev/null || :
}
trap cleanup EXIT

"$@"
20 changes: 20 additions & 0 deletions .github/scripts/govulncheck-monitor.test.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const assert = require('node:assert/strict');
const { spawnSync } = require('node:child_process');
const { test } = require('node:test');

// Run the script by its name from its own directory, so no absolute path reaches the command line.
const script = 'govulncheck-monitor.sh';
const options = { skip: process.platform === 'win32' };

for (const status of [0, 23]) {
test(`preserves scanner output and exit status ${status}, and stops the monitor`, options, () => {
const result = spawnSync('bash', [script, 'bash', '-c',
`sleep 0.2; printf '%s' '{"version":"2.1.0"}'; printf 'scanner diagnostic\\n' >&2; exit ${status}`],
{ cwd: __dirname, encoding: 'utf8', timeout: 5000 });
assert.ifError(result.error);
assert.equal(result.status, status);
assert.equal(result.stdout, '{"version":"2.1.0"}');
assert.match(result.stderr, /govulncheck resources/);
assert.match(result.stderr, /scanner diagnostic/);
});
}
8 changes: 7 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,16 @@ jobs:
# (govulncheck's SSA construction parallelizes via goroutines, which
# -p doesn't govern) while nearly tripling run time.
GOMEMLIMIT: "32GiB"
# Controlled scanner-only comparison against the GOGC=100 baseline.
# GC traces report live heap and collection cost on scanner stderr.
ATMOS_VULNCHECK_GOGC: "50"
ATMOS_VULNCHECK_GCTRACE: "1"
# The target also removes exact duplicate stacks from the report: the
# SARIF schema requires them to be unique and the upload rejects the
# report otherwise. See internal/ci/vulncheck.
run: go tool mage ci:vulncheck govulncheck.sarif
# Diagnostics run separately on stderr; the scanner and SARIF output
# are unchanged. They help distinguish pressure from a stalled scan.
run: bash .github/scripts/govulncheck-monitor.sh go tool mage ci:vulncheck govulncheck.sarif

- name: Upload SARIF file
# Setup failures produce no report; preserve the original failure without
Expand Down
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ linters:
# pkg/ci/artifact/s3 is the S3-backed CI artifact store; it legitimately
# depends on the AWS SDK, same rationale as pkg/ci/planfile/s3 above.
- "!**/pkg/ci/artifact/s3/**"
# pkg/artifact/blob/s3 is the shared AWS SDK object transport behind the artifact S3
# repository and the CI artifact S3 adapter (including its in-process S3 test fake).
# The provider-neutral contract is pkg/artifact/blob, which imports no SDK.
- "!**/pkg/artifact/blob/s3/**"
# The S3 downloader signs source requests with request-scoped AWS credentials.
# Only this cloud-specific leaf imports the SDK; the parent downloader stays generic.
- "!**/pkg/downloader/s3/**"
Expand Down
48 changes: 48 additions & 0 deletions errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -2131,6 +2131,10 @@ var (
// reconciled: the completed reference could not be proven to hold, or to lack, the expected content.
ErrArtifactPublicationAmbiguous = errors.New("artifact publication outcome is ambiguous")

// ErrArtifactEvidenceMalformed is returned when a subject's evidence directory holds more malformed
// entries than the repository is willing to read, so valid evidence may be hidden behind them.
ErrArtifactEvidenceMalformed = errors.New("too many malformed evidence files")

// ErrSymlinkLoop is returned when resolving a path follows more symlinks than the bound allows, which
// means the links form a loop.
ErrSymlinkLoop = errors.New("symlink loop")
Expand All @@ -2140,6 +2144,50 @@ var (
ErrArtifactStreamFailed = errors.New("artifact stream failed")
)

// Blob transport sentinels. They classify outcomes of the transport-only object I/O in
// pkg/artifact/blob so callers can branch with errors.Is without depending on a backend SDK.
var (
// ErrBlobNotFound is returned when the addressed object does not exist.
ErrBlobNotFound = errors.New("blob object not found")

// ErrBlobPreconditionFailed is returned when a conditional write or delete (if-absent or if-match) lost its race.
ErrBlobPreconditionFailed = errors.New("blob precondition failed")

// ErrBlobConditionalUnsupported is returned when the endpoint cannot enforce a required condition.
// The operation is rejected instead of silently overwriting.
ErrBlobConditionalUnsupported = errors.New("blob endpoint cannot enforce the required condition")

// ErrBlobOutcomeUnknown is returned when a mutation was sent but its result was not observed
// (timeout, connection reset, server error). Callers must reconcile by reading the object.
ErrBlobOutcomeUnknown = errors.New("blob mutation outcome is unknown")

// ErrBlobInvalid is returned for malformed keys, tags, options, sizes, or ranges.
ErrBlobInvalid = errors.New("invalid blob request")

// ErrBlobIdentityUnresolved is returned when a configured identity cannot be resolved to credentials.
// The generic blob transport fails closed instead of falling back to ambient credentials.
ErrBlobIdentityUnresolved = errors.New("blob identity could not be resolved")

// ErrBlobOperationFailed is the sentinel for blob failures without a more specific class, such as
// local I/O errors or an SDK failure with no mapped meaning. The underlying cause stays in the chain.
ErrBlobOperationFailed = errors.New("blob operation failed")

// ErrBlobTaggingDenied is returned by tests that simulate a version-specific object tagging denial.
ErrBlobTaggingDenied = errors.New("blob tagging denied")

// ErrBlobInvalidChunk is returned by the S3 test endpoint when an aws-chunked request body cannot
// be decoded: an unreadable or non-hex chunk size, or a chunk cut short.
ErrBlobInvalidChunk = errors.New("invalid aws-chunked body")

// ErrBlobTooManyTags is returned by the S3 test endpoint when a request carries more object tags
// than S3 allows.
ErrBlobTooManyTags = errors.New("object tags cannot be greater than 10")

// ErrBlobInvalidChunkTerminator is returned by the S3 test endpoint when an aws-chunked request
// body has a chunk that is not followed by the required CRLF terminator.
ErrBlobInvalidChunkTerminator = errors.New("invalid aws-chunked chunk terminator")
)

// ExitCodeError is a typed error that preserves subcommand exit codes.
// This allows the root command to exit with the same code as the subcommand.
// When Code is 0, it indicates successful completion that should exit cleanly without printing errors.
Expand Down
13 changes: 13 additions & 0 deletions internal/ci/vulncheck/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ func scan(ctx context.Context, params *Params, run commandRunner) error {

func runCommand(ctx context.Context, stdout, stderr io.Writer, name string, args ...string) error {
cmd := exec.CommandContext(ctx, name, args...) // #nosec G204 -- fixed tool name, mage-target-controlled args.
// These optional CI experiment settings affect only the scanner child, not
// Mage, compilation, or other Go processes in the job.
cmd.Env = cmd.Environ()
if gc, ok := os.LookupEnv("ATMOS_VULNCHECK_GOGC"); ok && gc != "" {
cmd.Env = append(cmd.Env, "GOGC="+gc)
}
if trace, ok := os.LookupEnv("ATMOS_VULNCHECK_GCTRACE"); ok && trace == "1" {
debug, _ := os.LookupEnv("GODEBUG")
if debug != "" {
debug += ","
}
cmd.Env = append(cmd.Env, "GODEBUG="+debug+"gctrace=1")
}
cmd.Stdout = stdout
cmd.Stderr = stderr
return cmd.Run()
Expand Down
19 changes: 19 additions & 0 deletions internal/ci/vulncheck/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,25 @@ func TestRunCommand_MissingBinary(t *testing.T) {
require.Error(t, err)
}

func TestRunCommand_ScannerEnvironment(t *testing.T) {
if os.Getenv("VULNCHECK_ENV_HELPER") == "1" {
_, _ = io.WriteString(os.Stdout, os.Getenv("GOGC")+"|"+os.Getenv("GODEBUG"))
return
}
t.Setenv("VULNCHECK_ENV_HELPER", "1")
t.Setenv("GOGC", "100")
t.Setenv("GODEBUG", "invalidptr=1")
t.Setenv("ATMOS_VULNCHECK_GOGC", "50")
t.Setenv("ATMOS_VULNCHECK_GCTRACE", "1")
exe, err := os.Executable()
require.NoError(t, err)
var stdout, stderr bytes.Buffer
require.NoError(t, runCommand(context.Background(), &stdout, &stderr, exe, "-test.run=^TestRunCommand_ScannerEnvironment$"))
assert.Contains(t, stdout.String(), "50|invalidptr=1,gctrace=1")
assert.Equal(t, "100", os.Getenv("GOGC"))
assert.Equal(t, "invalidptr=1", os.Getenv("GODEBUG"))
}

func TestScan_ReportsMissingGovulncheck(t *testing.T) {
// With nothing on PATH the real runner cannot find the tool, and Scan must
// say so instead of writing an empty report.
Expand Down
1 change: 1 addition & 0 deletions pkg/archive/deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func TestWriteDeterministic_ZipEntries(t *testing.T) {
assert.NotZero(t, byName["link"].Mode()&fs.ModeSymlink)
rc, err := byName["link"].Open()
require.NoError(t, err)
t.Cleanup(func() { _ = rc.Close() })
target, err := io.ReadAll(rc)
require.NoError(t, err)
require.NoError(t, rc.Close())
Expand Down
75 changes: 75 additions & 0 deletions pkg/artifact/artifacttest/verifier.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package artifacttest

import (
"context"
"encoding/json"
"fmt"

errUtils "github.com/cloudposse/atmos/errors"
"github.com/cloudposse/atmos/pkg/artifact"
"github.com/cloudposse/atmos/pkg/perf"
)

// FakeVerifier is an [artifact.Verifier] for the evidence [FakeSigner] produces. Repositories that
// delegate cryptography to an injected verifier (the local repositories) use it in conformance
// tests, so those tests exercise the real storage and policy flow without Sigstore. It is a
// harness: it checks subject binding and the trust set, nothing cryptographic.
type FakeVerifier struct{}

var _ artifact.Verifier = (*FakeVerifier)(nil)

// Formats implements [artifact.Verifier].
func (*FakeVerifier) Formats() []artifact.EvidenceFormat {
defer perf.Track(nil, "artifacttest.FakeVerifier.Formats")()

return []artifact.EvidenceFormat{FakeEvidenceFormat}
}

// Verify implements [artifact.Verifier]. Every trust set must be satisfied by at least one
// evidence item bound to the subject. Malformed, unsupported, and unrelated evidence is reported
// and ignored; it can never override matching evidence.
func (*FakeVerifier) Verify(_ context.Context, subject artifact.SignatureSubject, evidence []artifact.EvidenceBlob, policy artifact.VerificationPolicy) (*artifact.VerificationResult, error) {
defer perf.Track(nil, "artifacttest.FakeVerifier.Verify")()

result := &artifact.VerificationResult{Subject: subject, Status: artifact.VerificationFailed}
if fingerprint, err := policy.Fingerprint(); err == nil {
result.PolicyFingerprint = fingerprint
}
if !policy.HasTrustConstraints() {
result.Status = artifact.VerificationUnchecked
return result, nil
}
var claims []artifact.SignerClaim
for index := range evidence {
claim, ok := authenticateFake(subject, &evidence[index], result)
if ok {
claims = append(claims, claim)
result.EvidenceDigests = append(result.EvidenceDigests, evidence[index].Evidence.Descriptor.Digest)
}
}
if !satisfies(policy, claims) {
result.Diagnostics = append(result.Diagnostics, artifact.Diagnostic{Severity: artifact.SeverityError, Code: "no-permitted-signature", Message: "no valid permitted signature satisfies the trust set"})
return result, fmt.Errorf("%w: no valid permitted signature for %s", errUtils.ErrArtifactVerificationFailed, subject.Digest)
}
result.Claims = claims
result.Status = artifact.VerificationVerified
return result, nil
}

func authenticateFake(subject artifact.SignatureSubject, held *artifact.EvidenceBlob, result *artifact.VerificationResult) (artifact.SignerClaim, bool) {
skip := func(code, message string) (artifact.SignerClaim, bool) {
result.Diagnostics = append(result.Diagnostics, artifact.Diagnostic{Severity: artifact.SeverityWarning, Code: code, Message: message})
return artifact.SignerClaim{}, false
}
if held.Evidence.Format != FakeEvidenceFormat {
return skip("unsupported-evidence", "evidence in an unsupported format was ignored")
}
var parsed fakeEvidence
if err := json.Unmarshal(held.Data, &parsed); err != nil {
return skip("malformed-evidence", "malformed evidence was ignored")
}
if parsed.Subject != subject.Digest || held.Evidence.Subject.Digest != subject.Digest {
return skip("subject-mismatch", "evidence bound to a different subject was ignored")
}
return artifact.SignerClaim{Identity: parsed.Identity, Issuer: parsed.Issuer}, true
}
Loading
Loading