Skip to content

deps: moby/buildkit v0.28+ upgrade via testcontainers-go v0.42 migration (closes #64, #65)#935

Merged
oskarszoon merged 8 commits into
bsv-blockchain:mainfrom
oskarszoon:feat/teranode-security-2
May 26, 2026
Merged

deps: moby/buildkit v0.28+ upgrade via testcontainers-go v0.42 migration (closes #64, #65)#935
oskarszoon merged 8 commits into
bsv-blockchain:mainfrom
oskarszoon:feat/teranode-security-2

Conversation

@oskarszoon

Copy link
Copy Markdown
Contributor

Summary

Closes Dependabot alerts #64 (BuildKit malicious frontend file escape) and #65 (BuildKit Git URL subdir traversal). Deferred from #925; tracked in #926.

Bumps github.com/moby/buildkit v0.25.1 → v0.29.0 via the testcontainers-go cascade:

  • testcontainers-go v0.40.0 → v0.42.0 (+ modules/compose, modules/postgres)
  • testcontainers-aerospike-go v0.3.2 → v0.3.7
  • moby/buildkit updated transitively to v0.29.0 (past v0.28.1 fix line)

Source migration nat.Portnetwork.Port across 8 test files (testcontainers v0.42 surface change: MappedPort now returns network.Port struct from moby/moby/api/types/network; takes a raw string; wait.ForSQL callback signature changed; HostConfig lives at moby/moby/api/types/container; PortBinding.HostIP is now netip.Addr).

5 commits:

  1. chore(deps): bump testcontainers-go to v0.42 + aerospike fork to v0.3.7
  2. refactor(test): migrate nat.Port -> network.Port for testcontainers v0.42
  3. chore(deps): go mod tidy after testcontainers v0.42 migration
  4. style(test): fix import ordering in svnode/docker.go
  5. fix(test): parse port in wait.ForSQL callback for postgres container

Test plan

AGENTS.md verification battery (post-rebase smoke):

Notes

  • Pattern surface from the original issue was conservative; only test/longtest/util/postgres/container.go failed to compile on its own after the testcontainers bump (wait.ForSQL callback signature). The other 9 files were migrated anyway for hygiene (no more dangling nat.Port/docker/go-connections/nat references in test/).
  • network.Port is a struct, not a string-alias. Methods: .Num() uint16, .Port() string. The aerospike-go fork's v0.3.7 bump absorbed the API change.
  • HostConfig.PortBindings in moby/moby/api/types/container uses network.PortMap keyed by network.Port structs (via MustParsePort); PortBinding.HostIP is netip.Addr (use netip.IPv4Unspecified() for 0.0.0.0).

Closes #926.

Prepares the cascade required by the moby/buildkit v0.28+ upgrade.

testcontainers-go v0.40 -> v0.42 changes:
- MappedPort return type: nat.Port -> network.Port
- wait.ForSQL callback signature: func(host string, port nat.Port) string -> func(host string, port string) string

testcontainers-aerospike-go v0.3.2 -> v0.3.7 absorbs the same network.Port change in the fork.

Repo is intentionally non-compiling at this commit; source-file migration follows in the next commit.

Issue: bsv-blockchain#926
…0.42

testcontainers-go v0.42 changed the testcontainers Container.MappedPort signature from (ctx, nat.Port) (nat.Port, error) to (ctx, string) (network.Port, error). Updates callers across the test/ packages:

- Drop docker/go-connections/nat imports; switch to github.com/moby/moby/api/types/network.
- MappedPort/GetMappedPort callers now pass raw "<num>/tcp" strings.
- Result is the new network.Port struct; .Int() replaced with int(p.Num()), .Port() unchanged.
- wait.ForSQL callback signature: func(host, port string) string (port pre-extracted).
- test/utils/svnode/docker.go: HostConfigModifier now receives moby/moby/api/types/container.HostConfig; PortBindings/PortMap/PortBinding migrated to network.* equivalents; PortBinding.HostIP is now netip.Addr (use netip.IPv4Unspecified()).

No behavior changes. Build clean after this commit.

Issue: bsv-blockchain#926
Move docker/docker and docker/go-connections to indirect (no longer used directly after the nat.Port -> network.Port migration), and surface moby/moby/api as direct (now imported by test/utils/svnode/docker.go).

Issue: bsv-blockchain#926
The testcontainers v0.42 migration introduced net/netip but placed it after the first third-party import. Move it back to the stdlib block to satisfy gci/goimports.

Issue: bsv-blockchain#926
The previous migration commit (3f7a3bde) inlined the `port` argument directly into the connection string. testcontainers-go v0.42 hands the URL builder the full network.Port.String() representation ("5432/tcp"), not just the port number — the result was an unparseable DSN "postgres://...:5432/tcp/postgres" and the container failed to come up under Test_processTransactionInternalPostgres.

Mirror the canonical pattern from testcontainers-go/modules/postgres@v0.42.0: parse the port via network.MustParsePort and use .Port() to extract the numeric component.

Issue: bsv-blockchain#926
@github-actions

github-actions Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

🤖 Claude Code Review

Status: Complete


Current Review:

This PR successfully migrates testcontainers-go from v0.40 to v0.42 and bumps moby/buildkit to v0.29.0, closing Dependabot security alerts #64 and #65. The migration is well-executed with systematic API surface changes applied consistently across test files.

Changes verified:

  • Dependency updates: Clean cascade from testcontainers-go v0.40.0 → v0.42.0, testcontainers-aerospike-go v0.3.2 → v0.3.7, moby/buildkit transitively updated to v0.29.0 (past CVE fix line)
  • API migrations: Consistent replacement of nat.Port (string alias) → network.Port (struct) across 8 test files
  • Port handling: Correct use of network.MustParsePort(), network.PortMap, and netip.IPv4Unspecified() in HostConfig.PortBindings
  • wait.ForSQL callback: Correctly updated in postgres/container.go:47-51 to parse network.Port using .Port() method
  • Test coverage: PR author reports 8445 tests pass, race detector clean, govulncheck confirms no moby/buildkit findings remain

No issues found. The migration follows the testcontainers v0.42 breaking changes correctly, addresses the security vulnerabilities as intended, and maintains test integrity.

@github-actions

github-actions Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

Benchmark Comparison Report

Baseline: main (unknown)

Current: PR-935 (2040f8d)

Summary

  • Regressions: 0
  • Improvements: 0
  • Unchanged: 144
  • Significance level: p < 0.05
All benchmark results (sec/op)
Benchmark Baseline Current Change p-value
_NewBlockFromBytes-4 1.741µ 1.739µ ~ 1.000
SplitSyncedParentMap_SetIfNotExists/256_buckets-4 61.86n 61.71n ~ 1.000
SplitSyncedParentMap_SetIfNotExists/16_buckets-4 62.06n 61.48n ~ 0.100
SplitSyncedParentMap_SetIfNotExists/1_bucket-4 61.87n 61.59n ~ 0.100
SplitSyncedParentMap_ConcurrentSetIfNotExists/256_buckets... 30.58n 30.83n ~ 0.700
SplitSyncedParentMap_ConcurrentSetIfNotExists/16_buckets_... 52.03n 52.48n ~ 1.000
SplitSyncedParentMap_ConcurrentSetIfNotExists/1_bucket_pa... 119.7n 114.0n ~ 0.400
MiningCandidate_Stringify_Short-4 263.9n 259.6n ~ 0.100
MiningCandidate_Stringify_Long-4 1.883µ 1.922µ ~ 0.100
MiningSolution_Stringify-4 988.5n 986.8n ~ 0.400
BlockInfo_MarshalJSON-4 1.802µ 1.790µ ~ 0.100
NewFromBytes-4 131.5n 129.8n ~ 0.100
AddTxBatchColumnar_Validation-4 2.544µ 2.522µ ~ 0.300
OffsetValidationLoop-4 639.2n 637.5n ~ 0.400
Mine_EasyDifficulty-4 65.03µ 65.17µ ~ 0.700
Mine_WithAddress-4 6.920µ 7.618µ ~ 0.200
DirectSubtreeAdd/4_per_subtree-4 58.80n 59.58n ~ 1.000
DirectSubtreeAdd/64_per_subtree-4 31.43n 30.23n ~ 0.100
DirectSubtreeAdd/256_per_subtree-4 30.29n 29.12n ~ 0.100
DirectSubtreeAdd/1024_per_subtree-4 29.02n 28.20n ~ 0.100
DirectSubtreeAdd/2048_per_subtree-4 28.72n 27.75n ~ 0.100
SubtreeProcessorAdd/4_per_subtree-4 279.7n 285.4n ~ 0.100
SubtreeProcessorAdd/64_per_subtree-4 276.8n 278.6n ~ 0.400
SubtreeProcessorAdd/256_per_subtree-4 280.7n 279.9n ~ 1.000
SubtreeProcessorAdd/1024_per_subtree-4 271.8n 276.7n ~ 0.100
SubtreeProcessorAdd/2048_per_subtree-4 269.9n 274.8n ~ 0.100
SubtreeProcessorRotate/4_per_subtree-4 276.6n 276.3n ~ 1.000
SubtreeProcessorRotate/64_per_subtree-4 275.1n 277.0n ~ 0.700
SubtreeProcessorRotate/256_per_subtree-4 274.6n 276.8n ~ 0.700
SubtreeProcessorRotate/1024_per_subtree-4 280.2n 277.0n ~ 0.100
SubtreeNodeAddOnly/4_per_subtree-4 55.16n 54.40n ~ 0.700
SubtreeNodeAddOnly/64_per_subtree-4 34.65n 34.31n ~ 0.100
SubtreeNodeAddOnly/256_per_subtree-4 34.03n 33.34n ~ 0.200
SubtreeNodeAddOnly/1024_per_subtree-4 33.08n 32.59n ~ 0.100
SubtreeCreationOnly/4_per_subtree-4 119.7n 115.6n ~ 0.100
SubtreeCreationOnly/64_per_subtree-4 441.3n 408.4n ~ 0.100
SubtreeCreationOnly/256_per_subtree-4 1.461µ 1.346µ ~ 0.100
SubtreeCreationOnly/1024_per_subtree-4 4.761µ 4.446µ ~ 0.200
SubtreeCreationOnly/2048_per_subtree-4 8.627µ 8.469µ ~ 0.400
SubtreeProcessorOverheadBreakdown/64_per_subtree-4 275.4n 278.9n ~ 0.400
SubtreeProcessorOverheadBreakdown/1024_per_subtree-4 275.9n 274.1n ~ 0.200
ParallelGetAndSetIfNotExists/1k_nodes-4 2.239m 2.235m ~ 0.700
ParallelGetAndSetIfNotExists/10k_nodes-4 5.423m 5.314m ~ 0.100
ParallelGetAndSetIfNotExists/50k_nodes-4 7.774m 7.270m ~ 0.200
ParallelGetAndSetIfNotExists/100k_nodes-4 10.48m 10.08m ~ 0.100
SequentialGetAndSetIfNotExists/1k_nodes-4 1.988m 1.938m ~ 0.100
SequentialGetAndSetIfNotExists/10k_nodes-4 4.423m 4.405m ~ 0.700
SequentialGetAndSetIfNotExists/50k_nodes-4 12.35m 12.38m ~ 1.000
SequentialGetAndSetIfNotExists/100k_nodes-4 22.01m 22.54m ~ 0.700
ProcessOwnBlockSubtreeNodesParallel/1k_nodes-4 2.294m 2.240m ~ 0.100
ProcessOwnBlockSubtreeNodesParallel/10k_nodes-4 8.122m 8.120m ~ 1.000
ProcessOwnBlockSubtreeNodesParallel/100k_nodes-4 13.45m 13.08m ~ 0.100
ProcessOwnBlockSubtreeNodesSequential/1k_nodes-4 2.028m 1.976m ~ 0.200
ProcessOwnBlockSubtreeNodesSequential/10k_nodes-4 7.677m 7.447m ~ 0.200
ProcessOwnBlockSubtreeNodesSequential/100k_nodes-4 39.73m 40.17m ~ 0.100
BlockAssembler_AddTx-4 0.02317n 0.02349n ~ 1.000
AddNode-4 9.061 9.113 ~ 1.000
AddNodeWithMap-4 9.387 9.114 ~ 0.700
DiskTxMap_SetIfNotExists-4 4.015µ 3.996µ ~ 0.700
DiskTxMap_SetIfNotExists_Parallel-4 3.852µ 3.618µ ~ 0.200
DiskTxMap_ExistenceOnly-4 427.3n 579.0n ~ 0.100
Queue-4 193.7n 188.0n ~ 0.100
AtomicPointer-4 3.248n 3.727n ~ 0.100
ReorgOptimizations/DedupFilterPipeline/Old/10K-4 806.7µ 833.3µ ~ 0.100
ReorgOptimizations/DedupFilterPipeline/New/10K-4 765.2µ 791.1µ ~ 0.100
ReorgOptimizations/AllMarkFalse/Old/10K-4 105.3µ 106.0µ ~ 0.400
ReorgOptimizations/AllMarkFalse/New/10K-4 63.96µ 64.24µ ~ 0.100
ReorgOptimizations/HashSlicePool/Old/10K-4 52.84µ 51.48µ ~ 0.400
ReorgOptimizations/HashSlicePool/New/10K-4 10.92µ 11.12µ ~ 0.700
ReorgOptimizations/NodeFlags/Old/10K-4 4.331µ 4.555µ ~ 0.100
ReorgOptimizations/NodeFlags/New/10K-4 1.486µ 1.559µ ~ 0.100
ReorgOptimizations/DedupFilterPipeline/Old/100K-4 9.891m 9.532m ~ 0.400
ReorgOptimizations/DedupFilterPipeline/New/100K-4 10.57m 10.43m ~ 0.400
ReorgOptimizations/AllMarkFalse/Old/100K-4 1.102m 1.107m ~ 0.200
ReorgOptimizations/AllMarkFalse/New/100K-4 705.7µ 706.2µ ~ 1.000
ReorgOptimizations/HashSlicePool/Old/100K-4 482.4µ 641.7µ ~ 0.100
ReorgOptimizations/HashSlicePool/New/100K-4 216.4µ 222.9µ ~ 1.000
ReorgOptimizations/NodeFlags/Old/100K-4 47.14µ 43.97µ ~ 0.100
ReorgOptimizations/NodeFlags/New/100K-4 16.46µ 14.59µ ~ 0.100
TxMapSetIfNotExists-4 49.44n 50.57n ~ 0.100
TxMapSetIfNotExistsDuplicate-4 41.42n 41.64n ~ 0.100
ChannelSendReceive-4 625.0n 599.8n ~ 0.100
CalcBlockWork-4 474.8n 465.7n ~ 0.400
CalculateWork-4 632.8n 636.7n ~ 0.400
BuildBlockLocatorString_Helpers/Size_10-4 1.340µ 1.635µ ~ 0.100
BuildBlockLocatorString_Helpers/Size_100-4 15.67µ 13.07µ ~ 0.200
BuildBlockLocatorString_Helpers/Size_1000-4 128.8µ 126.6µ ~ 0.700
CatchupWithHeaderCache-4 104.3m 104.2m ~ 0.700
_BufferPoolAllocation/16KB-4 3.757µ 3.922µ ~ 0.700
_BufferPoolAllocation/32KB-4 8.728µ 8.228µ ~ 1.000
_BufferPoolAllocation/64KB-4 15.85µ 20.05µ ~ 0.100
_BufferPoolAllocation/128KB-4 26.74µ 36.23µ ~ 0.400
_BufferPoolAllocation/512KB-4 108.3µ 116.9µ ~ 0.400
_BufferPoolConcurrent/32KB-4 18.23µ 18.77µ ~ 0.400
_BufferPoolConcurrent/64KB-4 29.61µ 30.35µ ~ 0.700
_BufferPoolConcurrent/512KB-4 155.6µ 145.3µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/16KB-4 712.8µ 726.5µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/32KB-4 747.8µ 717.4µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/64KB-4 620.1µ 716.8µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/128KB-4 612.0µ 708.5µ ~ 0.100
_SubtreeDeserializationWithBufferSizes/512KB-4 650.7µ 716.7µ ~ 0.100
_SubtreeDataDeserializationWithBufferSizes/16KB-4 36.66m 36.31m ~ 0.100
_SubtreeDataDeserializationWithBufferSizes/32KB-4 36.67m 35.99m ~ 0.100
_SubtreeDataDeserializationWithBufferSizes/64KB-4 36.56m 36.18m ~ 0.100
_SubtreeDataDeserializationWithBufferSizes/128KB-4 36.53m 36.29m ~ 0.100
_SubtreeDataDeserializationWithBufferSizes/512KB-4 36.46m 35.87m ~ 0.400
_PooledVsNonPooled/Pooled-4 744.2n 738.1n ~ 0.700
_PooledVsNonPooled/NonPooled-4 8.141µ 8.375µ ~ 0.100
_MemoryFootprint/Current_512KB_32concurrent-4 7.004µ 6.641µ ~ 0.100
_MemoryFootprint/Proposed_32KB_32concurrent-4 12.011µ 9.759µ ~ 0.100
_MemoryFootprint/Alternative_64KB_32concurrent-4 10.205µ 9.260µ ~ 0.100
_prepareTxsPerLevel-4 416.4m 417.6m ~ 1.000
_prepareTxsPerLevelOrdered-4 4.282m 4.103m ~ 1.000
_prepareTxsPerLevel_Comparison/Original-4 411.1m 401.6m ~ 0.700
_prepareTxsPerLevel_Comparison/Optimized-4 4.504m 4.740m ~ 0.700
SubtreeSizes/10k_tx_4_per_subtree-4 1.280m 1.306m ~ 0.400
SubtreeSizes/10k_tx_16_per_subtree-4 308.3µ 305.2µ ~ 0.100
SubtreeSizes/10k_tx_64_per_subtree-4 71.39µ 72.26µ ~ 0.200
SubtreeSizes/10k_tx_256_per_subtree-4 17.87µ 18.02µ ~ 0.100
SubtreeSizes/10k_tx_512_per_subtree-4 8.749µ 8.992µ ~ 0.100
SubtreeSizes/10k_tx_1024_per_subtree-4 4.426µ 4.382µ ~ 1.000
SubtreeSizes/10k_tx_2k_per_subtree-4 2.173µ 2.182µ ~ 0.700
BlockSizeScaling/10k_tx_64_per_subtree-4 69.37µ 70.65µ ~ 0.100
BlockSizeScaling/10k_tx_256_per_subtree-4 17.75µ 17.59µ ~ 0.700
BlockSizeScaling/10k_tx_1024_per_subtree-4 4.389µ 4.367µ ~ 0.700
BlockSizeScaling/50k_tx_64_per_subtree-4 368.0µ 374.0µ ~ 1.000
BlockSizeScaling/50k_tx_256_per_subtree-4 89.31µ 88.05µ ~ 0.400
BlockSizeScaling/50k_tx_1024_per_subtree-4 21.71µ 21.65µ ~ 1.000
SubtreeAllocations/small_subtrees_exists_check-4 148.0µ 153.6µ ~ 0.100
SubtreeAllocations/small_subtrees_data_fetch-4 158.0µ 158.9µ ~ 0.400
SubtreeAllocations/small_subtrees_full_validation-4 309.0µ 309.1µ ~ 1.000
SubtreeAllocations/medium_subtrees_exists_check-4 8.814µ 8.934µ ~ 0.100
SubtreeAllocations/medium_subtrees_data_fetch-4 9.287µ 9.270µ ~ 0.700
SubtreeAllocations/medium_subtrees_full_validation-4 17.35µ 17.37µ ~ 0.700
SubtreeAllocations/large_subtrees_exists_check-4 2.100µ 2.096µ ~ 0.500
SubtreeAllocations/large_subtrees_data_fetch-4 2.222µ 2.217µ ~ 1.000
SubtreeAllocations/large_subtrees_full_validation-4 4.357µ 4.319µ ~ 0.700
StoreBlock_Sequential/BelowCSVHeight-4 248.8µ 249.8µ ~ 0.700
StoreBlock_Sequential/AboveCSVHeight-4 247.3µ 250.5µ ~ 0.100
GetUtxoHashes-4 256.0n 264.5n ~ 0.400
GetUtxoHashes_ManyOutputs-4 42.83µ 42.63µ ~ 0.100
_NewMetaDataFromBytes-4 228.7n 230.0n ~ 0.400
_Bytes-4 399.9n 407.9n ~ 0.700
_MetaBytes-4 137.5n 139.4n ~ 0.100

Threshold: >10% with p < 0.05 | Generated: 2026-05-22 15:02 UTC

testcontainers-go v0.42 stopped accepting the legacy "<host>:<container>/proto" combined string in ContainerRequest.ExposedPorts (rejects with "invalid start port"). Host-port pinning now must go through HostConfigModifier's PortBindings.

Migrates four redpanda test launchers to:
- ExposedPorts: ["<port>/tcp"] (container side only)
- HostConfigModifier sets network.PortMap with explicit host:container binding via netip.IPv4Unspecified() for 0.0.0.0

Fixes CI failures introduced by the v0.42 migration:
- util/kafka TestFlushBytesRegression_MessageTooLarge
- util/kafka TestFlushBytesRegression_DefaultBatchMax

Files updated:
- util/kafka/kafkatest/kafkatest.go (MustStartEnv)
- util/kafka/flush_bytes_regression_test.go (startRedpanda)
- test/longtest/util/kafka/container.go (RunTestContainer + RunTestContainerTLS)
- test/longtest/util/kafka/kafka_test.go (NewTestContainerWrapper)

Issue: bsv-blockchain#926
Two related changes:

1. RunPostgresTestContainer: defensively Terminate the container on every
   error path between GenericContainer and the final connectivity check.
   GenericContainer(Started:true) starts the container before running the
   wait strategy; if the strategy returns a non-nil error (as happened with
   the wait.ForSQL signature bug from earlier in this branch, but also
   possible on legitimate timeouts) the previous code returned without
   calling Terminate, leaving a running postgres container per failed run.

2. Restrict the Ryuk-reaper opt-out to CI. Ryuk pulls testcontainers/ryuk
   from Docker Hub which is the documented flake source for CI rate limits;
   that is why the global init() set TESTCONTAINERS_RYUK_DISABLED=true.
   On local dev machines the reaper is the only safety net against
   panic/SIGKILL/OOM leaks (we explicitly cleanup on graceful exit but
   nothing covers ungraceful exit). Detect CI via the CI env var and only
   disable the reaper there; locally the reaper runs and auto-removes
   containers when the test process dies. Users can override either way by
   exporting TESTCONTAINERS_RYUK_DISABLED explicitly.

Issue: bsv-blockchain#926
@sonarqubecloud

Copy link
Copy Markdown

@oskarszoon oskarszoon self-assigned this May 24, 2026

@ordishs ordishs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved.

Closes Dependabot alerts #64 and #65 cleanly via the testcontainers-go v0.42 cascade. The nat.Portnetwork.Port migration is mechanical and consistent across all 8 touched test files. Bundled wins:

  • Postgres container-leak fix on partial GenericContainer failure
  • Ryuk gating refined to CI-only (preserves local panic/SIGKILL cleanup)
  • Full AGENTS.md verification battery green, including smoke + sequential

Non-blocking follow-ups for later:

  • Microsoft/hcsshim v0.14.0-rc.1 is transitive RC — bump off once GA lands
  • k8s.io 0.33.3 → 0.35.2 and structured-merge-diff v4 → v6 are sizeable jumps; worth a sanity check if kuberesolver paths flake post-merge

@oskarszoon oskarszoon merged commit d2e5e09 into bsv-blockchain:main May 26, 2026
25 checks passed
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.

deps: moby/buildkit v0.28+ upgrade requires testcontainers-go nat.Port migration

3 participants