Skip to content

input validation 2 #654

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 88 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
fdaf809
enable additional linters
faddat Dec 22, 2024
016154b
Merge branch 'faddat/testifylint' into faddat/bump-go
faddat Dec 22, 2024
71b2d1e
adjust golang version in circleci
faddat Dec 22, 2024
f371399
bump go...
faddat Dec 22, 2024
cbde717
remove dupl
faddat Dec 22, 2024
08ea4c4
lint main.go
faddat Jan 2, 2025
7a812f5
lints...
faddat Jan 2, 2025
65039a5
complete
faddat Jan 2, 2025
ada59f4
Merge branch 'main' into faddat/bump-go
faddat Jan 16, 2025
a06cd0d
remove mutext lock in lib_test.go
faddat Jan 17, 2025
1118f26
remove unused variable
faddat Jan 17, 2025
d6c14e6
restore comments
faddat Jan 17, 2025
d943802
fix lint in .golangci.yml
faddat Jan 17, 2025
f9e29a6
Merge branch 'faddat/errcheck' into faddat/bump-go
faddat Feb 1, 2025
ce052d6
lint
faddat Feb 1, 2025
59fa5a4
Refactor test helper function for creating message binary
faddat Feb 14, 2025
20aaea0
revert unnecessary change
faddat Feb 18, 2025
19d75a5
resolve merge conflict and reduce required go version
faddat Feb 19, 2025
f74e259
adjust loop to go 1.21
faddat Feb 19, 2025
4b11854
Merge branch 'main' into faddat/bump-go
faddat Mar 14, 2025
27e6cf1
merge in main and update lints`
faddat Mar 14, 2025
911008b
match local lint version
faddat Mar 14, 2025
2ebfdeb
bumps
faddat Mar 22, 2025
4d60b62
Merge remote-tracking branch 'origin/main' into faddat/bump-go
faddat Apr 16, 2025
c6229a8
lint...
faddat Apr 16, 2025
f79f7b4
cleanup
faddat Apr 16, 2025
6c21a8d
add docs
faddat Apr 16, 2025
e8af78d
variable names
faddat Apr 16, 2025
c0fde34
hand out bumps to the cosmwasm crew
faddat Apr 17, 2025
7d87acb
bumps
faddat Apr 18, 2025
d5fc267
Merge branch 'faddat/bumps' into faddat/bump-go
faddat Apr 18, 2025
00a598d
fix test
faddat Apr 18, 2025
61f2fdd
fix ibc_test.go
faddat Apr 18, 2025
f0c9656
modernize
faddat Apr 18, 2025
ab26cd4
run modernize and reduce linter config
faddat Apr 18, 2025
93b7037
modernize
faddat Apr 18, 2025
796529c
fix tests and lint
faddat Apr 18, 2025
d62722c
BuiltInShadow
faddat Apr 18, 2025
b4a77fc
resolve cpuloop issues
faddat Apr 18, 2025
4cd1937
revive
faddat Apr 18, 2025
3eda296
add uniffi
faddat Apr 18, 2025
1ef0e24
fix additional tests
faddat Apr 18, 2025
322ed5e
fix all tests
faddat Apr 18, 2025
b93a7a5
use constants
faddat Apr 18, 2025
56ad1fa
more constants...
faddat Apr 18, 2025
6a191ff
add a no-cgo liblib file
faddat Apr 18, 2025
d7c0edf
update linter fixes
faddat Apr 18, 2025
1334555
fix golangci-lint config
faddat Apr 18, 2025
eaeaf7d
refactor: update function signatures to use ContractCallParams struct…
faddat Apr 18, 2025
e3315f7
localtestexecute
faddat Apr 18, 2025
485020c
assignment mismatches
faddat Apr 18, 2025
8ec232e
finish implementing revive
faddat Apr 18, 2025
d8e56bd
Merge remote-tracking branch 'origin/main' into faddat/bump-go
faddat Apr 21, 2025
6a99a76
restore missing ibc tests
faddat Apr 21, 2025
dc7da81
lint
faddat Apr 21, 2025
e99c796
update tests
faddat Apr 21, 2025
a4d515e
add checksum validation to wasmvm
faddat Apr 22, 2025
ea7efcf
validate gas
faddat Apr 22, 2025
6223342
Add memory validation and safe wrappers for byte slices and unmanaged…
faddat Apr 22, 2025
6807857
Refactor error handling to use safe wrappers in Go API and Storage
faddat Apr 22, 2025
6e844ed
Refactor error handling in iterator and querier to use safe wrappers
faddat Apr 22, 2025
90a1bb7
Update error messages in tests for gas limit and checksum validation
faddat Apr 22, 2025
c0620e7
add deny.toml
faddat Apr 22, 2025
bcc8973
add cargo audit and cargo deny to github actions
faddat Apr 22, 2025
316304f
use stable rust only
faddat Apr 22, 2025
fb6826c
fix up deny github action
faddat Apr 22, 2025
9cff35a
Use SafeUnmanagedVector
faddat Apr 22, 2025
4550e8e
add example code and rebuild before migration
faddat Apr 22, 2025
5cc6397
Add example for vector debugging and enhance SafeUnmanagedVector trac…
faddat Apr 22, 2025
65e6edf
safe ffi
faddat Apr 22, 2025
304576f
add safe api example
faddat Apr 22, 2025
8d934b1
fix safe code usage
faddat Apr 22, 2025
3e17f66
Refactor contract function implementations to use SafeUnmanagedVector…
faddat Apr 22, 2025
54c6751
Refactor contract functions to consistently use SafeUnmanagedVector f…
faddat Apr 22, 2025
e15cbba
Refactor tests to utilize SafeUnmanagedVector for improved memory safety
faddat Apr 22, 2025
8d99eee
Enhance gas cost handling in contract functions
faddat Apr 22, 2025
567a907
Add availability check and improve error handling in SafeByteSlice an…
faddat Apr 22, 2025
5899d1e
clean up dead code
faddat Apr 22, 2025
a0cebe6
Add non-camel case type allowance for cache_t struct
faddat Apr 22, 2025
9fb28d7
memory test
faddat Apr 22, 2025
8a33f1d
memory test
faddat Apr 22, 2025
23b8044
remove uniffi stubs
faddat Apr 22, 2025
b97465d
have a rest
faddat Apr 22, 2025
337b250
Enhance address validation and testing
faddat Apr 22, 2025
5f7faf8
validate-address-formats
faddat Apr 22, 2025
144d245
Merge remote-tracking branch 'origin/main' into faddat/input-validati…
faddat Apr 22, 2025
7827f5a
lint json size
faddat Apr 22, 2025
e805294
wasmvm
faddat Apr 22, 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
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:

format-go:
docker:
- image: cimg/go:1.22.12
- image: cimg/go:1.23.4
steps:
- run:
name: Install gofumpt
Expand All @@ -186,7 +186,7 @@ jobs:
# Build types and cosmwam package without cgo
wasmvm_no_cgo:
docker:
- image: cimg/go:1.22.12
- image: cimg/go:1.23.4
steps:
- checkout
- run:
Expand All @@ -205,7 +205,7 @@ jobs:
# Build types and cosmwasm with libwasmvm linking disabled
nolink_libwasmvm:
docker:
- image: cimg/go:1.22.12
- image: cimg/go:1.23.4
steps:
- checkout
- run:
Expand All @@ -223,7 +223,7 @@ jobs:

tidy-go:
docker:
- image: cimg/go:1.22.12
- image: cimg/go:1.23.4
steps:
- checkout
- run:
Expand All @@ -241,7 +241,7 @@ jobs:

format-scripts:
docker:
- image: cimg/go:1.22.12
- image: cimg/go:1.23.4
steps:
- run:
name: Install shfmt
Expand Down Expand Up @@ -299,7 +299,7 @@ jobs:
# Test the Go project and run benchmarks
wasmvm_test:
docker:
- image: cimg/go:1.22.12
- image: cimg/go:1.23.4
environment:
GORACE: "halt_on_error=1"
BUILD_VERSION: $(echo ${CIRCLE_SHA1} | cut -c 1-10)
Expand Down
6 changes: 6 additions & 0 deletions .cursor/rules/wasmvm-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 both go and rust. Please make sure to frequently check both golangci-lint and cargo clippy.
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
35 changes: 35 additions & 0 deletions .github/workflows/cargo-deny.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Cargo Deny

on:
push:
branches: [main]
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- "**/deny.toml"
- ".github/workflows/cargo-deny.yml"
pull_request:
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- "**/deny.toml"
- ".github/workflows/cargo-deny.yml"

jobs:
cargo-deny:
runs-on: ubuntu-latest
strategy:
matrix:
checks:
- advisories
- bans
- licenses
- sources
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check ${{ matrix.checks }}
arguments: --all-features --exclude-dev
rust-version: stable
manifest-path: libwasmvm/Cargo.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
103 changes: 84 additions & 19 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,95 @@ version: "2"

run:
tests: true
timeout: 5m

linters:
# Enable specific linters
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- misspell
- testifylint
- thelper
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
- copyloopvar # Detect copy loops
- errcheck # Detect unchecked errors
- govet # Reports suspicious constructs
- ineffassign # Detect unused assignments
- staticcheck # Go static analysis
- unused # Detect unused constants, variables, functions and types

# Additional recommended linters
- gocritic # A more opinionated linter
- gosec # Security checker
- misspell # Find commonly misspelled words
- revive # a metalinter with more checks
- maintidx
- bodyclose # Check HTTP response bodies are closed
- goconst # Find repeated strings that could be constants
- gocyclo # Check function complexity
- gocognit # Check cognitive complexity
- whitespace # Check trailing whitespace
- thelper # Detect test helpers not using t.Helper()
- usetesting # Detect incorrect usage of testing package
- tparallel # Detect incorrect usage of t.Parallel()

settings:
gocritic:
enabled-tags:
- diagnostic
- style
- performance
disabled-checks:
- dupSubExpr
- paramTypeCombine
- dupImport
- hugeParam
- rangeValCopy
- ptrToRefParam

gocyclo:
min-complexity: 15
gocognit:
min-complexity: 20
dupl:
threshold: 100
goconst:
min-len: 3
min-occurrences: 3
revive:
enable-all-rules: true

rules:
# https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#var-naming
- name: var-naming
severity: warning
disabled: true
exclude: [""]
arguments:
- ["ID"] # AllowList
- ["VM"] # DenyList
- - upperCaseConst: true # Extra parameter (upperCaseConst|skipPackageNameChecks)
- name: line-length-limit
severity: warning
disabled: true
exclude: [""]
arguments: [80]
- name: add-constant
disabled: true
- name: exported
disabled: true
- name: function-length
disabled: true
- name: nested-structs
disabled: true
- name: flag-parameter
disabled: true
- name: max-public-structs
disabled: false
severity: warning
arguments: [100]







issues:
max-issues-per-linter: 0
Expand All @@ -46,12 +116,7 @@ formatters:
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
# Drops lexical ordering for custom sections.
# Default: false
no-lex-order: true
exclusions:
# Skip generated files.
Expand Down
Loading
Loading