Skip to content

fix: audit hardening, retry/timeout & state fixes, and prepare v0.3.0 - #22

Merged
loverustfs merged 1 commit into
mainfrom
fix/audit-hardening-v0.3.0
Dec 1, 2026
Merged

loverustfs merged 1 commit into
mainfrom
fix/audit-hardening-v0.3.0

Conversation

@loverustfs

Copy link
Copy Markdown
Contributor

Summary

Comprehensive codebase and post-v0.2.0 change audit fixes, regression tests, i18n documentation synchronization, and v0.3.0 release preparation:

  1. S3 Retry Budget & Shared AWS Config Isolation (internal/s3client/client.go)
    • Prevent awsconfig.LoadDefaultConfig (NewEnvConfig) from failing on invalid/non-integer AWS_MAX_ATTEMPTS when MaxAttempts is already resolved via --max-attempts or MAX_ATTEMPTS, without mutating process-wide environment variables, while preserving AWS_CA_BUNDLE and shared profile ca_bundle / region / sdk_ua_app_id.
    • Pass awsconfig.WithRetryer(...) and clear o.RetryMaxAttempts = 0 inside s3.NewFromConfig so s3.New's finalizeRetryMaxAttempts never overwrites the resolved attempt budget with a lower AWS_MAX_ATTEMPTS or shared-config max_attempts, nor leaks ambient AWS_MAX_ATTEMPTS into derived test clients.
  2. Idle-Timeout Body EOF Race (internal/s3client/timeout.go)
    • Preserve clean io.EOF when the per-read idle timer fires concurrently with the final chunk read, avoiding spurious context.DeadlineExceeded failures on completed object reads.
    • Strengthen TestRetryQuotaDoesNotExhaustAcrossSustainedTransientTimeouts so the negative control genuinely drains the 500-token SDK retry quota (64 * 9 = 576 > 500) and add unit tests for AWS_MAX_ATTEMPTS / profile precedence and io.EOF timer races.
  3. CLI State Binding, Diff JSONL Creation & Log Escaping (cmd/root.go)
    • Avoid binding an unvalidated/placeholder new.endpoint (e.g. from config.example.yaml) during source-only migration scan, while keeping migration run target binding ahead of BeginScan() so target mismatches fail before invalidating an existing completed scan.
    • Delay migration diff --issues-jsonl file creation until after S3 client initialization succeeds so TLS/CA configuration errors do not leave an empty .jsonl file blocking retries.
    • Escape db_path via safeoutput.Escape in scan completion logs.
  4. Endpoint Port Validation, Store Symlink WAL Check & Spool Error Provenance
    • Validate endpoint TCP port range (1..65535) in internal/config at startup.
    • Canonicalize symlinks via filepath.EvalSymlinks in store.OpenExisting before hasNoUncheckpointedWAL so symlinked DB paths cannot mask active -wal files and open with immutable=1.
    • Separate local spool temp-file disk failures (CreateTemp / Write / Seek) from source S3 stream read errors (sourceReadError) in internal/migrator.
    • Fix internal/fakes3 encoding-type=url key escaping so literal + is encoded as %2B and handle max-keys=0.
  5. Packaging, i18n Docs & v0.3.0 Bump
    • Normalize .tar.gz archive member ownership to 0:0 (root:root) in scripts/package.py.
    • Document AWS_CA_BUNDLE and synchronize list_max_keys / response_header_timeout / max_attempts across cmd/helptext.go, config.example.yaml, and all 8 localized README*.md and docs/MANUAL*.md guides; update default version references to 0.3.0.

Verification

  • go vet -tags real_s3 ./...
  • go test -race -count=1 ./... (including hermeticity under ambient AWS_MAX_ATTEMPTS / LIST_MAX_KEYS / WORKERS)
  • python3 -m unittest discover -s scripts -v

- s3client: prevent invalid or lower AWS_MAX_ATTEMPTS / profile max_attempts from overriding or breaking resolved MaxAttempts without mutating process env, while preserving AWS_CA_BUNDLE and shared TLS/region settings
- s3client: preserve clean io.EOF in idleTimeoutBody when idle timer races final chunk read, and strengthen retry-quota test coverage
- cmd: avoid binding unvalidated target endpoint during source-only scan, delay diff --issues-jsonl creation until after S3 client init, and escape db_path in scan logs
- config: validate endpoint TCP port bounds (1..65535) and isolate config/CLI test suites from ambient shell env vars
- store: resolve symlinks in OpenExisting before checking uncheckpointed WAL files
- migrator: distinguish local spool disk errors from source S3 stream read errors
- fakes3: encode literal '+' as %2B under encoding-type=url and handle max-keys=0
- package & docs: normalize tar.gz ownership to root:root, document AWS_CA_BUNDLE and new pagination/timeout/retry options across all 8 languages, and bump default version to 0.3.0
Copilot AI balanced review requested due to automatic review settings December 1, 2026 06:06
@loverustfs
loverustfs merged commit 801b20e into main Dec 1, 2026
7 checks passed
@loverustfs
loverustfs deleted the fix/audit-hardening-v0.3.0 branch December 1, 2026 06:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The retry override can silently suppress errors for a missing AWS_DEFAULT_PROFILE, and the symlink regression test does not exercise OpenExisting’s handling of uncheckpointed WAL.

2 open issues
What changed in this PR

This PR hardens the S3 migration tool’s retry handling, state safety, and error reporting, while preparing the v0.3.0 release.

Changes:

  • Fix retry-budget precedence, timeout EOF handling, scan target binding, and diff output creation.
  • Strengthen endpoint validation, symlink-aware database opening, spool error attribution, and regression coverage.
  • Normalize archive ownership and update release references, CLI help, and localized configuration guides.
File Description
scripts/​test_package.py Tests normalized archive ownership.
scripts/​package.py Normalizes tar ownership and updates fallback version.
README.md Updates installation examples to v0.3.0.
README_ZH.md Updates Chinese installation examples.
README_KO.md Updates Korean release and configuration guidance.
README_JA.md Updates Japanese release and configuration guidance.
README_IT.md Updates Italian release and configuration guidance.
README_FR.md Updates French release and configuration guidance.
README_ES.md Updates Spanish release and configuration guidance.
README_DE.md Updates German release and configuration guidance.
Makefile Updates fallback build version.
internal/​store/​store.go Resolves database symlinks before WAL checks.
internal/​store/​audit_test.go Adds a symlink-target WAL check test.
internal/​s3client/​timeout.go Preserves EOF during timeout races.
internal/​s3client/​timeout_test.go Tests retry quotas, configuration precedence, and EOF races.
internal/​s3client/​client.go Isolates resolved retries from ambient AWS settings.
internal/​migrator/​migrator.go Distinguishes local spool failures from source errors.
internal/​migrator/​audit_transfer_test.go Tests local spool error attribution.
internal/​fakes3/​fakes3.go Fixes plus-sign escaping and zero-size listings.
internal/​config/​safety_test.go Tests invalid endpoint ports.
internal/​config/​config.go Validates endpoint TCP port ranges.
internal/​config/​config_test.go Clears ambient configuration for tests.
docs/​MANUAL.md Updates release examples and documents tuning flags.
docs/​MANUAL_ZH.md Updates Chinese release examples and tuning flags.
docs/​MANUAL_KO.md Expands Korean configuration and troubleshooting guidance.
docs/​MANUAL_JA.md Expands Japanese configuration and troubleshooting guidance.
docs/​MANUAL_IT.md Expands Italian configuration and troubleshooting guidance.
docs/​MANUAL_FR.md Expands French configuration and troubleshooting guidance.
docs/​MANUAL_ES.md Expands Spanish configuration and troubleshooting guidance.
docs/​MANUAL_DE.md Expands German configuration and troubleshooting guidance.
config.example.yaml Lists AWS_CA_BUNDLE in configuration comments.
cmd/​root.go Adjusts target binding, JSONL creation, and path escaping.
cmd/​helptext.go Sets v0.3.0 and lists custom CA configuration.
cmd/​help_test.go Checks custom CA help text.
cmd/​cli_regression_test.go Adds retry, state-binding, and JSONL regression tests.

Review effort: Balanced

}

func loadAWSConfigWithoutEnvMaxAttempts(ctx context.Context, ep config.Endpoint, creds awsv2.CredentialsProvider) (awsv2.Config, *http.Transport, error) {
explicitProfile := os.Getenv("AWS_PROFILE") != ""
Comment thread internal/store/store.go
Comment on lines +222 to +224
if canonical, err := filepath.EvalSymlinks(path); err == nil {
path = canonical
}
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