Skip to content

input validation 3 #662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9908d21
Debug failing tests iterator
pinosu Mar 26, 2025
bc95309
Add workflow
pinosu Mar 26, 2025
0243050
Add lib_test.go
pinosu Mar 26, 2025
179d142
Add lib_libwasmvm_test.go
pinosu Mar 26, 2025
743a26c
Fix test TestStoreCodeStress
pinosu Mar 26, 2025
cf6d253
Add memory_test.go
pinosu Mar 27, 2025
b1da814
Add sleep after runtime.GC() to allow GC to complete
pinosu Mar 27, 2025
ba7adb6
Fix tests
pinosu Mar 27, 2025
af326ba
Fix lint errors
pinosu Mar 27, 2025
af42e5f
yeah I should have mentioned that the heinous input validation issues…
faddat Apr 27, 2025
2eca366
run the tests right
faddat Apr 27, 2025
bf3dcb8
update rust version
faddat Apr 27, 2025
fb04911
use strip_prefix method
faddat Apr 27, 2025
38004bd
always use latest rustr
faddat Apr 27, 2025
0686a57
update circleci config
faddat Apr 27, 2025
c016094
test a change
faddat Apr 27, 2025
910e2a4
delete cargo deny action
faddat Apr 27, 2025
937120d
update tests to match updated rust
faddat Apr 27, 2025
8779553
remove typo checker because it's worse than useless
faddat Apr 27, 2025
ae3ea24
Merge remote-tracking branch 'origin/debug_failing_tests_iterator' in…
faddat Apr 27, 2025
9781a57
all tests including iterator pass.
faddat Apr 27, 2025
899c8ce
small test cleanups
faddat Apr 27, 2025
74b81c5
Update Bech32 dependency and enhance address validation in API
faddat Apr 27, 2025
a15aac6
improve tests
faddat Apr 27, 2025
71538be
complete eip-55
faddat Apr 27, 2025
ae52130
lint
faddat Apr 27, 2025
9502c47
add new tests
faddat Apr 28, 2025
225b143
fix failing tests from upgrade to wasmer v6
faddat Apr 28, 2025
e83e9dd
update failing tests
faddat Apr 28, 2025
75aa34b
update tests and fix Makefile
faddat Apr 28, 2025
62bac92
further fix test running...
faddat Apr 28, 2025
e39d1bf
enhance memory testing
faddat Apr 28, 2025
2169f06
update deps
faddat Apr 28, 2025
7573afa
build
faddat Apr 28, 2025
ad7770e
final cleanup (hopefully)
faddat Apr 29, 2025
1426818
fix remaining tests
faddat Apr 29, 2025
cea1539
return to mainline cw
faddat Apr 29, 2025
6f706d4
update module version to v3 and implement IBC2 packet timeout functio…
faddat Apr 29, 2025
f1891c1
tidy
faddat Apr 29, 2025
a51b591
fix path issue
faddat Apr 29, 2025
54b2218
tidy
faddat Apr 29, 2025
a277a0b
remove unused function
faddat Apr 29, 2025
6aa7479
remove test invalidation
faddat May 4, 2025
d2dacd1
update pr
faddat May 7, 2025
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
28 changes: 14 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
# All checks on the codebase that can run in parallel to build_shared_library
libwasmvm_sanity:
docker:
- image: cimg/rust:1.81.0
- image: cimg/rust:1.86.0
steps:
- checkout
- run:
Expand All @@ -18,8 +18,8 @@ jobs:
command: rustup component add rustfmt
- restore_cache:
keys:
- cargocache-v3-libwasmvm_sanity-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.81.0-
- cargocache-v3-libwasmvm_sanity-rust:1.86.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cargocache-v3-libwasmvm_sanity-rust:1.86.0-
- run:
name: Ensure libwasmvm/bindings.h is up-to-date
working_directory: libwasmvm
Expand Down Expand Up @@ -62,7 +62,7 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-libwasmvm_sanity-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-libwasmvm_sanity-rust:1.86.0-{{ checksum "libwasmvm/Cargo.lock" }}

libwasmvm_clippy:
parameters:
Expand Down Expand Up @@ -113,15 +113,15 @@ jobs:
command: |
set -o errexit
curl -sS --output rustup-init.exe https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.81.0 -y
./rustup-init.exe --no-modify-path --profile minimal --default-toolchain 1.86.0 -y
echo 'export PATH="$PATH;$USERPROFILE/.cargo/bin"' >> "$BASH_ENV"
- run:
name: Show Rust version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cachev4-libwasmvm_sanity_windows-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.81.0-
- cachev4-libwasmvm_sanity_windows-rust:1.86.0-{{ checksum "libwasmvm/Cargo.lock" }}
- cachev4-libwasmvm_sanity_windows-rust:1.86.0-
- run:
name: Run unit tests
working_directory: libwasmvm
Expand All @@ -133,13 +133,13 @@ jobs:
- libwasmvm/target/debug/.fingerprint
- libwasmvm/target/debug/build
- libwasmvm/target/debug/deps
key: cachev4-libwasmvm_sanity_windows-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cachev4-libwasmvm_sanity_windows-rust:1.86.0-{{ checksum "libwasmvm/Cargo.lock" }}

libwasmvm_audit:
docker:
# The audit tool might use a more modern Rust version than the build jobs. See
# "Tooling Rust compiler" in docs/COMPILER_VERSIONS.md
- image: cimg/rust:1.81.0
- image: cimg/rust:1.86.0
steps:
- checkout
- run:
Expand All @@ -152,8 +152,8 @@ jobs:
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- v3-libwasmvm_audit-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
- v3-libwasmvm_audit-rust:1.81.0-
- v3-libwasmvm_audit-rust:1.86.0-{{ checksum "libwasmvm/Cargo.lock" }}
- v3-libwasmvm_audit-rust:1.86.0-
- run:
name: Install cargo-audit
command: cargo install --debug cargo-audit --version 0.21.0 --locked
Expand All @@ -164,7 +164,7 @@ jobs:
- save_cache:
paths:
- ~/.cargo/registry
key: v3-libwasmvm_audit-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: v3-libwasmvm_audit-rust:1.86.0-{{ checksum "libwasmvm/Cargo.lock" }}

format-go:
docker:
Expand Down Expand Up @@ -294,7 +294,7 @@ jobs:
- libwasmvm/target/release/.fingerprint
- libwasmvm/target/release/build
- libwasmvm/target/release/deps
key: cargocache-v3-build_shared_library-rust:1.81.0-{{ checksum "libwasmvm/Cargo.lock" }}
key: cargocache-v3-build_shared_library-rust:1.86.0-{{ checksum "libwasmvm/Cargo.lock" }}

# Test the Go project and run benchmarks
wasmvm_test:
Expand Down Expand Up @@ -456,7 +456,7 @@ workflows:
matrix:
parameters:
# Run with MSRV and some modern stable Rust
rust-version: ["1.81.0", "1.82.0"]
rust-version: ["1.86.0", "1.86.0"]
- libwasmvm_audit
- format-go
- wasmvm_no_cgo
Expand Down
6 changes: 6 additions & 0 deletions .cursor/rules/project-description.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
description:
globs:
alwaysApply: true
---
This project is written in go, c and rust, and it serves as the interop layer between cosmwasm's vm and cosmos blockchains written in go. Please be attentive to the multi-lingual nature of the project when working with it.
27 changes: 27 additions & 0 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on: [push, pull_request]
name: Test
jobs:
test:
strategy:
matrix:
go-version: [1.24.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- run: make test
build:
strategy:
matrix:
go-version: [1.24.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- run: make build
38 changes: 38 additions & 0 deletions .github/workflows/cargo-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Cargo Audit

on:
push:
branches: [main]
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- ".github/workflows/cargo-audit.yml"
pull_request:
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- ".github/workflows/cargo-audit.yml"
schedule:
- cron: "0 0 * * 0" # Run weekly on Sundays at midnight

jobs:
cargo-audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install cargo-audit
run: cargo install cargo-audit

- name: Run cargo audit
working-directory: ./libwasmvm
run: cargo audit
continue-on-error: ${{ github.event_name == 'schedule' }} # Don't fail scheduled runs

- name: Run cargo audit with ignore unmaintained
working-directory: ./libwasmvm
run: cargo audit --ignore RUSTSEC-2024-0436 --ignore RUSTSEC-2024-0370
# These are the unmaintained crates we're already tracking in deny.toml
2 changes: 1 addition & 1 deletion .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23.4"
go-version: "1.24"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
Expand Down
19 changes: 0 additions & 19 deletions .github/workflows/typo-check.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ build-go:
.PHONY: test
test:
# Use package list mode to include all subdirectores. The -count=1 turns off caching.
RUST_BACKTRACE=1 go test -v -count=1 ./...
CGO_ENABLED=1 RUST_BACKTRACE=1 go test -v -count=1 ./...

.PHONY: test-safety
test-safety:
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/CosmWasm/wasmvm/v3
go 1.22

require (
github.com/CosmWasm/wasmvm/v2 v2.2.3
github.com/google/btree v1.0.0
github.com/shamaton/msgpack/v2 v2.2.0
github.com/stretchr/testify v1.8.1
Expand All @@ -11,8 +12,8 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/CosmWasm/wasmvm/v2 v2.2.3 h1:LVaAdkCMbgfUTSFOANmp2OOU1rIgz4iylow4SFD/lqs=
github.com/CosmWasm/wasmvm/v2 v2.2.3/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand All @@ -8,7 +10,6 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
Expand Down
7 changes: 3 additions & 4 deletions internal/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestValidateAddressFailure(t *testing.T) {

// if the human address is larger than 32 bytes, this will lead to an error in the go side
longName := "long123456789012345678901234567890long"
msg := []byte(`{"verifier": "` + longName + `", "beneficiary": "bob"}`)
msg := []byte(`{"verifier": "` + longName + `", "beneficiary": "` + SafeBech32Address("bob") + `"}`)

// make sure the call doesn't error, but we get a JSON-encoded error result from ContractResult
igasMeter := types.GasMeter(gasMeter)
Expand All @@ -41,7 +41,6 @@ func TestValidateAddressFailure(t *testing.T) {
require.NoError(t, err)

// ensure the error message is what we expect
require.Nil(t, result.Ok)
// with this error
require.Equal(t, "Generic error: addr_validate errored: human encoding too long", result.Err)
require.NotNil(t, result.Err)
require.Contains(t, result.Err, "addr_validate errored: Invalid Bech32 address")
}
Loading
Loading