From 7931d035d6639a047daf3692e8e869a29a24d150 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Thu, 22 Jun 2023 13:21:09 +0900 Subject: [PATCH] Update TinyGo to 0.28.1 (#207) Co-authored-by: Crypt Keeper <64215+codefromthecrypt@users.noreply.github.com> --- .github/workflows/ci.yaml | 2 +- .github/workflows/nightly-coraza-check.yaml | 2 +- go.mod | 12 ++++----- go.sum | 24 +++++++++--------- init_tinygo.go | 28 ++++++++++++++++++--- magefiles/magefile.go | 2 +- 6 files changed, 45 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 13d8799..6032aec 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -13,7 +13,7 @@ on: env: GO_VERSION: 1.19 - TINYGO_VERSION: 0.27.0 + TINYGO_VERSION: 0.28.1 # Run e2e tests against latest two releases and latest dev ENVOY_IMAGES: > envoyproxy/envoy:v1.26-latest diff --git a/.github/workflows/nightly-coraza-check.yaml b/.github/workflows/nightly-coraza-check.yaml index fc718f9..84a8f02 100644 --- a/.github/workflows/nightly-coraza-check.yaml +++ b/.github/workflows/nightly-coraza-check.yaml @@ -9,7 +9,7 @@ on: env: GO_VERSION: 1.19 - TINYGO_VERSION: 0.27.0 + TINYGO_VERSION: 0.28.1 jobs: test: diff --git a/go.mod b/go.mod index 82bf0f2..3a3ac2f 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module github.com/corazawaf/coraza-proxy-wasm go 1.19 require ( - github.com/corazawaf/coraza-wasilibs v0.0.0-20230510100417-e8a89d2b2f05 + github.com/corazawaf/coraza-wasilibs v0.0.0-20230620081031-05a5097dbea3 github.com/corazawaf/coraza/v3 v3.0.0 github.com/stretchr/testify v1.8.0 github.com/tetratelabs/proxy-wasm-go-sdk v0.22.0 github.com/tidwall/gjson v1.14.4 - github.com/wasilibs/nottinygc v0.3.0 + github.com/wasilibs/nottinygc v0.4.0 ) require ( @@ -18,12 +18,12 @@ require ( github.com/magefile/mage v1.15.0 // indirect github.com/petar-dambovaliev/aho-corasick v0.0.0-20211021192214-5ab2d9280aa9 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/tetratelabs/wazero v1.1.0 // indirect + github.com/tetratelabs/wazero v1.2.1 // indirect github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.1 // indirect - github.com/wasilibs/go-aho-corasick v0.4.0 // indirect - github.com/wasilibs/go-libinjection v0.3.0 // indirect - github.com/wasilibs/go-re2 v1.1.0 // indirect + github.com/wasilibs/go-aho-corasick v0.5.0 // indirect + github.com/wasilibs/go-libinjection v0.4.0 // indirect + github.com/wasilibs/go-re2 v1.2.0 // indirect golang.org/x/net v0.10.0 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index fb9c079..204d388 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/corazawaf/coraza-wasilibs v0.0.0-20230510100417-e8a89d2b2f05 h1:X7hj8/9mLUt98pOB3wQJtBP7qdvhVWcojE2RdPHtf4Q= -github.com/corazawaf/coraza-wasilibs v0.0.0-20230510100417-e8a89d2b2f05/go.mod h1:rhPJNQQO6tShOjrB3RQzFQBCWYrayxYSzDkqy92mhxo= +github.com/corazawaf/coraza-wasilibs v0.0.0-20230620081031-05a5097dbea3 h1:c6INlbuM6RdeUU0ySzQsk6lzlqdGdm4GSQhN3qpcvkg= +github.com/corazawaf/coraza-wasilibs v0.0.0-20230620081031-05a5097dbea3/go.mod h1:Ks3GxgMzwgVeo2nbVEPvmw94sOvJ+VjikPGLD5sNXUU= github.com/corazawaf/coraza/v3 v3.0.0 h1:GvTzxcgtfQ76LneYL19Nkb1/T+2E/s3BRAOEt6h2sY0= github.com/corazawaf/coraza/v3 v3.0.0/go.mod h1:MjV/iyO+B+JcVEWUJi4O2r1sfHeFzlF28MnvAqWfea0= github.com/corazawaf/libinjection-go v0.1.2 h1:oeiV9pc5rvJ+2oqOqXEAMJousPpGiup6f7Y3nZj5GoM= @@ -27,8 +27,8 @@ github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PK github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/tetratelabs/proxy-wasm-go-sdk v0.22.0 h1:kS7BvMKN+FiptV4pfwiNX8e3q14evxAWkhYbxt8EI1M= github.com/tetratelabs/proxy-wasm-go-sdk v0.22.0/go.mod h1:qkW5MBz2jch2u8bS59wws65WC+Gtx3x0aPUX5JL7CXI= -github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ= -github.com/tetratelabs/wazero v1.1.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= +github.com/tetratelabs/wazero v1.2.1 h1:J4X2hrGzJvt+wqltuvcSjHQ7ujQxA9gb6PeMs4qlUWs= +github.com/tetratelabs/wazero v1.2.1/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM= github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= @@ -36,14 +36,14 @@ github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JT github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/wasilibs/go-aho-corasick v0.4.0 h1:dPa/vF341zewXGiKh6Qih0H5MC1yVlDcAEp6fc14Nms= -github.com/wasilibs/go-aho-corasick v0.4.0/go.mod h1:d5wspqdBMcfs1ZAFfkijwXKohocUb5vnP5bmxWLbJ74= -github.com/wasilibs/go-libinjection v0.3.0 h1:X2zERL6bjRRPTnOWPI5CT6t1LMJNw7f+FZuTQTxJiTM= -github.com/wasilibs/go-libinjection v0.3.0/go.mod h1:pjrvsp+uswZLkflpghGhrgKpGEZlemqkLwKOJyIsvj4= -github.com/wasilibs/go-re2 v1.1.0 h1:RF/qHrnaFRIYaxnDFIZ4I8cZJTU+wE9DkOHtEHOUA18= -github.com/wasilibs/go-re2 v1.1.0/go.mod h1:9j8kG6X6t8KQoB9odr0+WEieocbZwbKUgTo8GjNUdV4= -github.com/wasilibs/nottinygc v0.3.0 h1:0L1jsJ1MsyN5tdinmFbLfuEA0TnHRcqaBM9pDTJVJmU= -github.com/wasilibs/nottinygc v0.3.0/go.mod h1:oDcIotskuYNMpqMF23l7Z8uzD4TC0WXHK8jetlB3HIo= +github.com/wasilibs/go-aho-corasick v0.5.0 h1:Y8G8eJ7usuC14sd93IxxnZH43K5Bz5C90a6LsAYGjmY= +github.com/wasilibs/go-aho-corasick v0.5.0/go.mod h1:1XPgz4lvFZA+Ytd8vfeCoqnwy4CSe0MxnLfRQJVqpJM= +github.com/wasilibs/go-libinjection v0.4.0 h1:dr1Y/kM/gmoA7eSfdf+CvCcmzwsz2jVYjNdakgladDU= +github.com/wasilibs/go-libinjection v0.4.0/go.mod h1:zD7fNXKSaTKoSTmrfuP9Gc16alNEgwkZaHIeDDk3WWM= +github.com/wasilibs/go-re2 v1.2.0 h1:EBE8PqqetncIYi4HyQiH3q73ZVWcrL2UATSm8+jL6Ng= +github.com/wasilibs/go-re2 v1.2.0/go.mod h1:NdBnojD1uYA206Q0pBK/OKX12YZjIxg3fkvK75AbXIo= +github.com/wasilibs/nottinygc v0.4.0 h1:h1TJMihMC4neN6Zq+WKpLxgd9xCFMw7O9ETLwY2exJQ= +github.com/wasilibs/nottinygc v0.4.0/go.mod h1:oDcIotskuYNMpqMF23l7Z8uzD4TC0WXHK8jetlB3HIo= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= diff --git a/init_tinygo.go b/init_tinygo.go index 1f8d9be..11fb7e9 100644 --- a/init_tinygo.go +++ b/init_tinygo.go @@ -5,13 +5,33 @@ package main -import _ "github.com/wasilibs/nottinygc" +import ( + "unsafe" -// Compiled by nottinygc for delayed free but Envoy doesn't stub it yet, -// luckily nottinygc doesn't actually call the function, so it's fine to -// stub it out. + _ "github.com/wasilibs/nottinygc" +) + +// Some host functions that are not implemented by Envoy end up getting imported anyways +// by code that gets compiled but not executed at runtime. Because we know they are not +// executed, we can stub them out to allow functioning on Envoy. Note, these match the +// names and signatures of wasi-libc, used by TinyGo, not WASI ABI. Review these exports when either +// the minimum supported version of Envoy changes or the maximum version of TinyGo. //export sched_yield func sched_yield() int32 { return 0 } + +// fdopendir is re-exported to avoid TinyGo 0.28's import of wasi_snapshot_preview1.fd_readdir. +// +//export fdopendir +func fdopendir(fd int32) unsafe.Pointer { + return nil +} + +// readdir is re-exported to avoid TinyGo 0.28's import of wasi_snapshot_preview1.fd_readdir. +// +//export readdir +func readdir(unsafe.Pointer) unsafe.Pointer { + return nil +} diff --git a/magefiles/magefile.go b/magefiles/magefile.go index d8bc0f0..5a4e96d 100644 --- a/magefiles/magefile.go +++ b/magefiles/magefile.go @@ -20,7 +20,7 @@ import ( ) var minGoVersion = "1.19" -var tinygoMinorVersion = "0.27" +var tinygoMinorVersion = "0.28" var addLicenseVersion = "04bfe4ee9ca5764577b029acc6a1957fd1997153" // https://github.com/google/addlicense var golangCILintVer = "v1.48.0" // https://github.com/golangci/golangci-lint/releases var gosImportsVer = "v0.3.1" // https://github.com/rinchsan/gosimports/releases/tag/v0.3.1