Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pkg/settings/cresettings/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ExecutionResponseLimit": "100kb",
"WASMExecutionTimeout": "1m0s",
"WASMMemoryLimit": "100mb",
"WASMBinarySizeLimit": "30mb",
"WASMBinarySizeLimit": "100mb",
"WASMCompressedBinarySizeLimit": "20mb",
"WASMConfigSizeLimit": "30mb",
"WASMSecretsSizeLimit": "30mb",
Expand Down
2 changes: 1 addition & 1 deletion pkg/settings/cresettings/defaults.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ExecutionTimeout = '10m0s'
ExecutionResponseLimit = '100kb'
WASMExecutionTimeout = '1m0s'
WASMMemoryLimit = '100mb'
WASMBinarySizeLimit = '30mb'
WASMBinarySizeLimit = '100mb'
WASMCompressedBinarySizeLimit = '20mb'
WASMConfigSizeLimit = '30mb'
WASMSecretsSizeLimit = '30mb'
Expand Down
2 changes: 1 addition & 1 deletion pkg/settings/cresettings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var Default = Schema{
ExecutionResponseLimit: Size(100 * config.KByte),
WASMExecutionTimeout: Duration(60 * time.Second),
WASMMemoryLimit: Size(100 * config.MByte),
WASMBinarySizeLimit: Size(30 * config.MByte),
WASMBinarySizeLimit: Size(100 * config.MByte),
WASMCompressedBinarySizeLimit: Size(20 * config.MByte),
WASMConfigSizeLimit: Size(30 * config.MByte),
WASMSecretsSizeLimit: Size(30 * config.MByte),
Expand Down
4 changes: 2 additions & 2 deletions pkg/workflows/wasm/host/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func NewModule(ctx context.Context, modCfg *ModuleConfig, binary []byte, opts ..
// this is to prevent decompression bombs
if err := modCfg.MaxCompressedBinaryLimiter.Check(ctx, config.SizeOf(binary)); err != nil {
if errors.Is(err, limits.ErrorBoundLimited[config.Size]{}) {
return nil, fmt.Errorf("compressed binary size exceeds the maximum allowed size of %d bytes: %w", modCfg.MaxCompressedBinarySize, err)
return nil, fmt.Errorf("compressed binary size exceeds the maximum allowed size: %w", err)
}
return nil, fmt.Errorf("failed to check compressed binary size limit: %w", err)
}
Expand All @@ -273,7 +273,7 @@ func NewModule(ctx context.Context, modCfg *ModuleConfig, binary []byte, opts ..
// The Read() method will return io.EOF, and ReadAll will gracefully handle it and return nil.
if err := modCfg.MaxDecompressedBinaryLimiter.Check(ctx, config.SizeOf(binary)); err != nil {
if errors.Is(err, limits.ErrorBoundLimited[config.Size]{}) {
return nil, fmt.Errorf("decompressed binary size reached the maximum allowed size of %d bytes: %w", modCfg.MaxDecompressedBinarySize, err)
return nil, fmt.Errorf("decompressed binary size reached the maximum allowed size: %w", err)
}
return nil, fmt.Errorf("failed to check decompressed binary size limit: %w", err)
}
Expand Down
20 changes: 14 additions & 6 deletions pkg/workflows/wasm/host/wasm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb"
capabilitiespb "github.com/smartcontractkit/chainlink-common/pkg/capabilities/pb"
"github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/settings/limits"
wasmpb "github.com/smartcontractkit/chainlink-common/pkg/workflows/wasm/pb"
valuespb "github.com/smartcontractkit/chainlink-protos/cre/go/values/pb"
)
Expand Down Expand Up @@ -943,8 +945,10 @@ func TestModule_CompressedBinarySize(t *testing.T) {
require.NoError(t, bwr.Close())

_, err = NewModule(t.Context(), &ModuleConfig{IsUncompressed: false, Logger: logger.Test(t)}, binary)
default10mbLimit := fmt.Sprintf("binary size exceeds the maximum allowed size of %d bytes", defaultMaxCompressedBinarySize)
require.ErrorContains(t, err, default10mbLimit)
require.ErrorContains(t, err, "binary size exceeds the maximum allowed size")
var limitErr limits.ErrorBoundLimited[config.Size]
require.ErrorAs(t, err, &limitErr)
assert.Equal(t, defaultMaxCompressedBinarySize, int(limitErr.Limit))
})

t.Run("compressed binary size is bigger than the custom limit", func(t *testing.T) {
Expand All @@ -958,8 +962,10 @@ func TestModule_CompressedBinarySize(t *testing.T) {
require.NoError(t, bwr.Close())

_, err = NewModule(t.Context(), &ModuleConfig{IsUncompressed: false, MaxCompressedBinarySize: customMaxCompressedBinarySize, Logger: logger.Test(t)}, binary)
default10mbLimit := fmt.Sprintf("binary size exceeds the maximum allowed size of %d bytes", customMaxCompressedBinarySize)
require.ErrorContains(t, err, default10mbLimit)
require.ErrorContains(t, err, "binary size exceeds the maximum allowed size")
var limitErr limits.ErrorBoundLimited[config.Size]
require.ErrorAs(t, err, &limitErr)
assert.Equal(t, customMaxCompressedBinarySize, uint64(limitErr.Limit))
})
}

Expand All @@ -979,8 +985,10 @@ func TestModule_DecompressedBinarySize(t *testing.T) {
t.Run("decompressed binary size is bigger than the limit", func(t *testing.T) {
customDecompressedBinarySize := uint64(len(decompedBinary) - 1)
_, err := NewModule(t.Context(), &ModuleConfig{IsUncompressed: false, MaxDecompressedBinarySize: customDecompressedBinarySize, Logger: logger.Test(t)}, binary)
decompressedSizeExceeded := fmt.Sprintf("decompressed binary size reached the maximum allowed size of %d bytes", customDecompressedBinarySize)
require.ErrorContains(t, err, decompressedSizeExceeded)
require.ErrorContains(t, err, "decompressed binary size reached the maximum allowed size")
var limitErr limits.ErrorBoundLimited[config.Size]
require.ErrorAs(t, err, &limitErr)
assert.Equal(t, customDecompressedBinarySize, uint64(limitErr.Limit))
})
}

Expand Down
Loading