diff --git a/.github/workflows/release.go b/.github/workflows/release.go index af6bef2..6ae36ac 100644 --- a/.github/workflows/release.go +++ b/.github/workflows/release.go @@ -104,7 +104,7 @@ func (c *controller) update() error { } fmt.Println(readme) - body, err := json.Marshal(map[string]interface{}{ + body, err := json.Marshal(map[string]any{ "body": readme, }) @@ -219,7 +219,7 @@ func (c *controller) request(method, url string, body io.Reader) (*http.Request, return req, nil } -func (c *controller) perform(req *http.Request, v interface{}) error { +func (c *controller) perform(req *http.Request, v any) error { response, err := http.DefaultClient.Do(req) if err != nil { return fmt.Errorf("do: %w", err) diff --git a/Taskfile.yml b/Taskfile.yml index 52e6c67..51c4e92 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -4,7 +4,7 @@ version: '3' vars: - VERSION: 0.10.1 + VERSION: 0.11.0 REVISION: { sh: git rev-parse HEAD } WORKDIR: { sh: pwd } diff --git a/go.mod b/go.mod index 7645540..e60ebf4 100644 --- a/go.mod +++ b/go.mod @@ -13,21 +13,23 @@ require ( github.com/gdamore/tcell/v2 v2.6.0 github.com/gofrs/uuid v4.4.0+incompatible github.com/golang-jwt/jwt v3.2.2+incompatible + github.com/golang-jwt/jwt/v5 v5.0.0 github.com/knadh/koanf v1.5.0 - github.com/labstack/echo/v4 v4.10.2 + github.com/labstack/echo-jwt/v4 v4.2.0 + github.com/labstack/echo/v4 v4.11.0 github.com/mdouchement/middlewarex v0.3.4 github.com/mdouchement/simple-argon2 v0.1.5 github.com/o1egl/paseto/v2 v2.1.1 github.com/oleiade/reflections v1.0.1 github.com/pkg/errors v0.9.1 github.com/sanity-io/litter v1.5.5 - github.com/sirupsen/logrus v1.9.0 - github.com/spf13/cobra v1.6.1 + github.com/sirupsen/logrus v1.9.3 + github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.1 - github.com/ugorji/go/codec v1.2.10 + github.com/ugorji/go/codec v1.2.11 github.com/valyala/fastjson v1.6.4 github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 - golang.org/x/crypto v0.6.0 + golang.org/x/crypto v0.11.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 ) @@ -35,15 +37,13 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gdamore/encoding v1.0.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.3 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/labstack/echo-jwt/v4 v4.1.0 // indirect github.com/labstack/gommon v0.4.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -56,13 +56,13 @@ require ( github.com/valyala/fasttemplate v1.2.2 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect go.etcd.io/bbolt v1.3.7 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/term v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/net v0.12.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/term v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index c856b47..9c3d1b4 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,8 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU= -github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -114,8 +114,9 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -172,7 +173,6 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKe github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hjson/hjson-go/v4 v4.0.0 h1:wlm6IYYqHjOdXH1gHev4VoXCaW20HdQAGCxdOEEg2cs= github.com/hjson/hjson-go/v4 v4.0.0/go.mod h1:KaYt3bTw3zhBjYqnXkYywcYctk0A2nxeEFTse3rH13E= -github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -199,10 +199,10 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/labstack/echo-jwt/v4 v4.1.0 h1:eYGBxauPkyzBM78KJbR5OSz5uhKMDkhJZhTTIuoH6Pg= -github.com/labstack/echo-jwt/v4 v4.1.0/go.mod h1:DHSSaL6cTgczdPXjf8qrTHRbrau2flcddV7CPMs2U/Y= -github.com/labstack/echo/v4 v4.10.2 h1:n1jAhnq/elIFTHr1EYpiYtyKgx4RW9ccVgkqByZaN2M= -github.com/labstack/echo/v4 v4.10.2/go.mod h1:OEyqf2//K1DFdE57vw2DRgWY0M7s65IVQO2FzvI4J5k= +github.com/labstack/echo-jwt/v4 v4.2.0 h1:odSISV9JgcSCuhgQSV/6Io3i7nUmfM/QkBeR5GVJj5c= +github.com/labstack/echo-jwt/v4 v4.2.0/go.mod h1:MA2RqdXdEn4/uEglx0HcUOgQSyBaTh5JcaHIan3biwU= +github.com/labstack/echo/v4 v4.11.0 h1:4Dmi59tmrnFzOchz4EXuGjJhUfcEkU28iDKsiZVOQgw= +github.com/labstack/echo/v4 v4.11.0/go.mod h1:YuYRTSM3CHs2ybfrL8Px48bO6BAnYIN4l8wSTMP6BDQ= github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8= github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= @@ -220,19 +220,15 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mdouchement/middlewarex v0.3.3 h1:00lIljgr4VcqCsSnjp2ykMTH77KUppJMCkVEuCzQEso= -github.com/mdouchement/middlewarex v0.3.3/go.mod h1:IVMO63e7mUTUuGZiMXMrxdP9l6iof/d/BLzwfH+OccE= github.com/mdouchement/middlewarex v0.3.4 h1:/cBI13lNy/lTj/PSPGW764WcHvpByc6kvbPhfdpM1/w= github.com/mdouchement/middlewarex v0.3.4/go.mod h1:NuBC5qRireJ4Moar7OG0LIWWJcBYd3+DgVc32nJaO8M= -github.com/mdouchement/simple-argon2 v0.1.3 h1:eMDzS1TwbU5QVeJcHQ51niFfXTf9gDo8NZUpd4pVUFM= -github.com/mdouchement/simple-argon2 v0.1.3/go.mod h1:WaGSWY2QGGFudO6CEpvrPzAD8n0x49sOxzs4Oh+Yd0g= github.com/mdouchement/simple-argon2 v0.1.5 h1:bJaepWCNp7iaBSfsaosaUKz7tj//VJL0AF8KBtabTRA= github.com/mdouchement/simple-argon2 v0.1.5/go.mod h1:QVVxtoGz3Dn8qXUjTBKyjlRWqZk+eoiPzJ7rPay8VlI= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= @@ -314,10 +310,10 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= -github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= -github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -335,8 +331,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/ugorji/go/codec v1.2.10 h1:eimT6Lsr+2lzmSZxPhLFoOWFmQqwk0fllJJ5hEbTXtQ= -github.com/ugorji/go/codec v1.2.10/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ= @@ -368,8 +364,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -400,8 +396,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -457,13 +453,16 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -471,8 +470,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -524,8 +524,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/client/backup.go b/internal/client/backup.go index a4675ea..82d1ef1 100644 --- a/internal/client/backup.go +++ b/internal/client/backup.go @@ -58,7 +58,7 @@ func Backup() error { return errors.Wrap(err, "items") } -func backup(v interface{}, filename string) error { +func backup(v any, filename string) error { payload, err := json.MarshalIndent(v, "", " ") if err != nil { return errors.Wrap(err, "could not serialize value to backup") diff --git a/internal/client/tui/item.go b/internal/client/tui/item.go index be85b76..48757ee 100644 --- a/internal/client/tui/item.go +++ b/internal/client/tui/item.go @@ -75,7 +75,7 @@ func (w *Item) RenderSize(size gowid.IRenderSize, focus gowid.Selector, app gowi } // UserInput implements gowid.IWidget -func (w *Item) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool { +func (w *Item) UserInput(ev any, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool { return w.presentation.UserInput(ev, size, focus, app) } @@ -142,7 +142,7 @@ func (w *ItemEditor) clickDownArrow(app gowid.IApp, iw gowid.IWidget) { } // UserInput implements gowid.IWidget -func (w *ItemEditor) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool { +func (w *ItemEditor) UserInput(ev any, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool { box, _ := size.(gowid.IRenderBox) w.sb.Top, w.sb.Middle, w.sb.Bottom = w.e.CalculateTopMiddleBottom(gowid.MakeRenderBox(box.BoxColumns()-1, box.BoxRows())) diff --git a/internal/client/tui/logger.go b/internal/client/tui/logger.go index 037e212..3068da5 100644 --- a/internal/client/tui/logger.go +++ b/internal/client/tui/logger.go @@ -14,7 +14,7 @@ import ( ) // nolint:deadcode,unused -func debug(v interface{}, verbose ...bool) { +func debug(v any, verbose ...bool) { if len(verbose) > 0 && verbose[0] { NewLogger().Println(litter.Sdump(v)) return diff --git a/internal/client/tui/note_list.go b/internal/client/tui/note_list.go index 12d41df..76e61cc 100644 --- a/internal/client/tui/note_list.go +++ b/internal/client/tui/note_list.go @@ -76,7 +76,7 @@ func (w *NoteList) RenderSize(size gowid.IRenderSize, focus gowid.Selector, app } // UserInput implements gowid.IWidget -func (w *NoteList) UserInput(ev interface{}, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool { +func (w *NoteList) UserInput(ev any, size gowid.IRenderSize, focus gowid.Selector, app gowid.IApp) bool { ok := w.presentation.UserInput(ev, size, focus, app) if evm, ok := ev.(*tcell.EventMouse); !ok || evm.Buttons() != tcell.ButtonNone { diff --git a/internal/client/tui/tui.go b/internal/client/tui/tui.go index eea1618..0aaf5e1 100644 --- a/internal/client/tui/tui.go +++ b/internal/client/tui/tui.go @@ -119,7 +119,7 @@ func layout(ui *TUI) gowid.AppArgs { // // //////////////////// -func (ui *TUI) unhandled(app gowid.IApp, ev interface{}) bool { +func (ui *TUI) unhandled(app gowid.IApp, ev any) bool { evk, ok := ev.(*tcell.EventKey) if !ok { return false diff --git a/internal/server/middlewares/binder.go b/internal/server/middlewares/binder.go index 85a6aeb..08f7468 100644 --- a/internal/server/middlewares/binder.go +++ b/internal/server/middlewares/binder.go @@ -23,7 +23,7 @@ func NewBinder() echo.Binder { } // Bind implements the echo.Bind interface. -func (b *binder) Bind(i interface{}, c echo.Context) (err error) { +func (b *binder) Bind(i any, c echo.Context) (err error) { if c.Request().ContentLength == 0 && b.methodsWithBody[c.Request().Method] { return echo.NewHTTPError(http.StatusBadRequest, "Request body can't be empty") } diff --git a/internal/server/serializer/session.go b/internal/server/serializer/session.go index b203bb5..b3b2995 100644 --- a/internal/server/serializer/session.go +++ b/internal/server/serializer/session.go @@ -3,8 +3,8 @@ package serializer import "github.com/mdouchement/standardfile/internal/model" // Session serializes the render of a session. -func Session(m *model.Session) map[string]interface{} { - r := map[string]interface{}{ +func Session(m *model.Session) map[string]any { + r := map[string]any{ "uuid": m.ID, "created_at": m.CreatedAt.UTC(), "updated_at": m.UpdatedAt.UTC(), @@ -16,8 +16,8 @@ func Session(m *model.Session) map[string]interface{} { } // Sessions serializes the render of sessions. -func Sessions(m []*model.Session) []map[string]interface{} { - sessions := make([]map[string]interface{}, len(m)) +func Sessions(m []*model.Session) []map[string]any { + sessions := make([]map[string]any, len(m)) for i, s := range m { sessions[i] = Session(s) } diff --git a/internal/server/serializer/user.go b/internal/server/serializer/user.go index 3697933..219faa2 100644 --- a/internal/server/serializer/user.go +++ b/internal/server/serializer/user.go @@ -6,8 +6,8 @@ import ( ) // User serializes the render of a user. -func User(m *model.User) map[string]interface{} { - r := map[string]interface{}{ +func User(m *model.User) map[string]any { + r := map[string]any{ "uuid": m.ID, "created_at": m.CreatedAt.UTC(), "updated_at": m.UpdatedAt.UTC(), diff --git a/internal/server/service/service.go b/internal/server/service/service.go index 47e9757..331167f 100644 --- a/internal/server/service/service.go +++ b/internal/server/service/service.go @@ -3,7 +3,7 @@ package service import "github.com/mdouchement/standardfile/internal/model" // M is an arbitrary map. -type M map[string]interface{} +type M map[string]any // Params are the basic fields used in requests. type Params struct { diff --git a/internal/server/service/sync.go b/internal/server/service/sync.go index 545a369..447b59d 100644 --- a/internal/server/service/sync.go +++ b/internal/server/service/sync.go @@ -69,9 +69,7 @@ func NewSync(db database.Client, user *model.User, params SyncParams) (s SyncSer return s } -// // Get -// func (s *syncServiceBase) get() ([]*model.Item, bool, error) { if s.Params.SyncToken == "" { // If it's the first sync request, front-load all exisitng items keys @@ -107,7 +105,6 @@ func (s *syncServiceBase) get() ([]*model.Item, bool, error) { noDeleted, s.Params.Limit) } -// // Compute data signature for integrity check // // https://github.com/standardfile/sfjs/blob/499fd0bc7ebddfc72f8b1dc3c9cbf134e92016d3/lib/app/lib/modelManager.js#L664-L677 @@ -131,9 +128,7 @@ func (s *syncServiceBase) computeDataSignature() (string, error) { return fmt.Sprintf("%x", sha256.Sum256(b)), nil } -// // PrepareDelete -// func (s *syncServiceBase) prepareDelete(item *model.Item) { item.Content = "" item.EncryptedItemKey = "" diff --git a/internal/server/service/sync_20161215.go b/internal/server/service/sync_20161215.go index 2e21c1c..bb9722f 100644 --- a/internal/server/service/sync_20161215.go +++ b/internal/server/service/sync_20161215.go @@ -89,9 +89,7 @@ func (s *syncService20161215) Execute() error { return nil } -// // Save -// func (s *syncService20161215) save() (saved []*model.Item, unsaved []*UnsavedItem) { saved = make([]*model.Item, 0) unsaved = make([]*UnsavedItem, 0) @@ -128,9 +126,7 @@ func (s *syncService20161215) save() (saved []*model.Item, unsaved []*UnsavedIte return } -// // Check conflicts -// func (s *syncService20161215) checkForConflicts() map[string]bool { // Saved is the smallest slice. saved := make(map[string]*model.Item) diff --git a/internal/server/service/sync_20190520.go b/internal/server/service/sync_20190520.go index 0ccfb0a..35d8104 100644 --- a/internal/server/service/sync_20190520.go +++ b/internal/server/service/sync_20190520.go @@ -93,9 +93,7 @@ func (s *syncService20190520) Execute() error { return nil } -// // Save -// func (s *syncService20190520) save() (saved []*model.Item, conflicts []*ConflictItem, tobedeleted map[string]bool) { saved = make([]*model.Item, 0) conflicts = make([]*ConflictItem, 0) diff --git a/internal/server/service/user.go b/internal/server/service/user.go index b651ba7..c7a8138 100644 --- a/internal/server/service/user.go +++ b/internal/server/service/user.go @@ -14,7 +14,7 @@ import ( type ( // A Render is an arbitrary payload serializable in JSON by the API. - Render interface{} + Render any // A UserService is a service used for handle API versioning of the user. UserService interface { diff --git a/internal/server/session/manager.go b/internal/server/session/manager.go index 954ed80..a97ac35 100644 --- a/internal/server/session/manager.go +++ b/internal/server/session/manager.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/golang-jwt/jwt/v4" + "github.com/golang-jwt/jwt/v5" "github.com/mdouchement/middlewarex" "github.com/mdouchement/standardfile/internal/database" "github.com/mdouchement/standardfile/internal/model" @@ -38,7 +38,7 @@ type ( // Regenerate regenerates the session's tokens. Regenerate(session *model.Session) error // UserFromToken the user for the given token. - UserFromToken(token interface{}) (*model.User, error) + UserFromToken(token any) (*model.User, error) } manager struct { @@ -155,7 +155,7 @@ func (m *manager) Regenerate(session *model.Session) error { return errors.Wrap(m.db.Save(session), "could not save session after refreshing session") } -func (m *manager) UserFromToken(token interface{}) (*model.User, error) { +func (m *manager) UserFromToken(token any) (*model.User, error) { if jwt, ok := token.(*jwt.Token); ok { return m.JWT(jwt) } diff --git a/pkg/libsf/client.go b/pkg/libsf/client.go index 0788636..7022041 100644 --- a/pkg/libsf/client.go +++ b/pkg/libsf/client.go @@ -37,7 +37,7 @@ type ( SyncItems(si SyncItems) (SyncItems, error) } - p map[string]interface{} + p map[string]any client struct { http *http.Client apiversion string diff --git a/pkg/libsf/doc.go b/pkg/libsf/doc.go index 619c999..6f864a8 100644 --- a/pkg/libsf/doc.go +++ b/pkg/libsf/doc.go @@ -2,7 +2,6 @@ // libsf is client that interacts with StandardFile/StandardNotes API for syncing encrypted notes. // -// // Create client // // client, err := libsf.NewDefaultClient("https://notes.nas.lan") @@ -10,7 +9,6 @@ // log.Fatal(err) // } // -// // Authenticate // // email := "george.abitbol@nas.lan" @@ -34,7 +32,6 @@ // log.Fatal(err) // } // -// // Get all items // // items := libsf.NewSyncItems() @@ -90,7 +87,6 @@ // } // } // -// // Update an item // // item := items.Retrieved[last] @@ -117,5 +113,4 @@ // log.Fatal("items conflict") // } // fmt.Println("Updated!") -// package libsf diff --git a/pkg/libsf/item.go b/pkg/libsf/item.go index 203e53f..e5f8293 100644 --- a/pkg/libsf/item.go +++ b/pkg/libsf/item.go @@ -105,11 +105,12 @@ func (i *Item) Seal(keychain *KeyChain) error { return errors.Wrap(err, "could not generate encryption key") } + old := i.key i.key, err = create(i.Version, i.ID) if err != nil { return errors.Wrap(err, "could not create vault") } - i.key.setup(i) + i.key.setup(i, old) err = i.key.seal(keyKeyChain(keychain, i), []byte(ik)) if err != nil { @@ -130,11 +131,12 @@ func (i *Item) Seal(keychain *KeyChain) error { return errors.Wrap(err, "could not serialize note") } + old = i.content i.content, err = create(i.Version, i.ID) if err != nil { return errors.Wrap(err, "could not create content vault") } - i.content.setup(i) + i.content.setup(i, old) err = i.content.seal(contentKeyChain(i.Version, ik), note) if err != nil { diff --git a/pkg/libsf/item_test.go b/pkg/libsf/item_test.go index 5868892..914c970 100644 --- a/pkg/libsf/item_test.go +++ b/pkg/libsf/item_test.go @@ -202,3 +202,44 @@ func TestItem_SealUnseal4_Note(t *testing.T) { assert.Equal(t, note.Text, item.Note.Text) } } + +func TestItem_UnsealSeal4_NoteWithAdditionnalData(t *testing.T) { + auth := libsf.NewAuth("a@a.lan", libsf.ProtocolVersion4, "66d463427f417c5c8660733ffb1f7a4786d14fe3d7946b5116b5388f9cf80123", 0) + keychain := &libsf.KeyChain{ + Version: libsf.ProtocolVersion4, + MasterKey: auth.SymmetricKeyPair("12345678").MasterKey, + ItemsKey: map[string]string{ + "3393636f-959f-4365-aa4c-4c473d6c84e7": "cfee40a7a0e53eeb0a06d70d46a9c7d69e0c5924fd1b0be7c7d6bedcaa3eeefb", + }, + } + + key := "004:6d0f5ebd7ba9b89a9e90c765599c6c0d7fd6a43e9ff64e0a:aj2EVQ9tm94qczo17hQRHLceTlAHddTMur/7TOSHXOTcDuA/B/bp/dXFMLWdvQpIjK5u7jSTiRlNhT7UuonpMkU1tO5L2qZ4FLBhohWROG8=:eyJ1IjoiMTUwMzViM2QtZDAzZi00Y2E0LWJkZWYtYzU1OTQwNDcwNjFkIiwidiI6IjAwNCJ9:eyJ0ZXN0Ijo0Mn0=" + content := "004:226c5b03350ca61629f54f97db035e3f978dfa06ee7f6746:srs9J6p3KQxhRkfXSu9yytvyR8CkyfSILXtImHOpN2jS9raDpYBXmT7W64ZIorT7SMgNXm3jWPVwgKweRH9KxUzyf8dNd+ezeWAHwqaHzlLBR/7BZulTRFoGryWNMY+t5Agx+6EzCNLiVsnCxICkjsG2rOf8VgZvQH5v1f/RhKm+ZEYaprW3jDfl5p8TuZUYhkHl1BhCz1ARfvFzIliSIYYAL+5S9qcuS3af0CwlN4C9lBN778Y=:eyJ1IjoiMTUwMzViM2QtZDAzZi00Y2E0LWJkZWYtYzU1OTQwNDcwNjFkIiwidiI6IjAwNCJ9:eyJ0ZXN0Ijo0Mn0=" + item := &libsf.Item{ + ID: "15035b3d-d03f-4ca4-bdef-c5594047061d", + UserID: "d26846e8-7669-43fb-a168-253f8a97778a", + ContentType: libsf.ContentTypeNote, + ItemsKeyID: "3393636f-959f-4365-aa4c-4c473d6c84e7", + Deleted: false, + EncryptedItemKey: key, + Content: content, + // Internal stuff + Version: libsf.ProtocolVersion4, + AuthParams: auth, + } + + err := item.Unseal(keychain) + if assert.NoError(t, err) { + assert.Equal(t, "The Title", item.Note.Title) + assert.Equal(t, "The text", item.Note.Text) + } + + err = item.Seal(keychain) + if assert.NoError(t, err) { + assert.NotEqual(t, key, item.EncryptedItemKey) + assert.True(t, strings.HasSuffix(item.EncryptedItemKey, ":eyJ0ZXN0Ijo0Mn0="), item.EncryptedItemKey) + + assert.NotEqual(t, content, item.Content) + assert.True(t, strings.HasSuffix(item.Content, ":eyJ0ZXN0Ijo0Mn0="), item.Content) + } +} diff --git a/pkg/libsf/vault.go b/pkg/libsf/vault.go index 648cecf..419c445 100644 --- a/pkg/libsf/vault.go +++ b/pkg/libsf/vault.go @@ -7,7 +7,7 @@ import ( ) type vault interface { - setup(i *Item) + setup(i *Item, old vault) seal(keychain *KeyChain, payload []byte) error serialize() (string, error) unseal(keychain *KeyChain) ([]byte, error) diff --git a/pkg/libsf/vault3.go b/pkg/libsf/vault3.go index e305d82..f2de9ed 100644 --- a/pkg/libsf/vault3.go +++ b/pkg/libsf/vault3.go @@ -160,7 +160,7 @@ func (v *vault3) unseal(keychain *KeyChain) ([]byte, error) { /// // -func (v *vault3) setup(i *Item) { +func (v *vault3) setup(i *Item, _ vault) { v.params = i.AuthParams } diff --git a/pkg/libsf/vault4.go b/pkg/libsf/vault4.go index ae1b720..8b3f09a 100644 --- a/pkg/libsf/vault4.go +++ b/pkg/libsf/vault4.go @@ -14,11 +14,12 @@ import ( type ( vault4 struct { - version string - nonce string - ciphertext string - rawauth string - auth authenticatedData + version string + nonce string + ciphertext string + rawauth string + auth authenticatedData + additionaldata string } authenticatedData struct { @@ -36,14 +37,20 @@ type ( func parse4(components []string) (vault, error) { v := &vault4{} - if len(components) != 4 { + if len(components) < 4 || len(components) > 5 { return v, errors.New("invalid secret format") } + // https://github.com/standardnotes/app/blob/main/packages/snjs/specification.md#encryption---specifics v.version = components[0] v.nonce = components[1] v.ciphertext = components[2] v.rawauth = components[3] + if len(components) > 4 { + // This part is not defined in the specification but implemented in StandardNotes official implementation. + // https://github.com/standardnotes/app/commit/b032eb9c9b4b98a1a256d3d03863866bb4136ec8#diff-cb607afd3ffe76488f6ba1f7885d16f853810e799c9f223a1dd7673d15928396 + v.additionaldata = components[4] // Default value is `e30=' (aka `{}' in base64). + } auth, err := base64.StdEncoding.DecodeString(v.rawauth) if err != nil { @@ -138,9 +145,14 @@ func (v *vault4) unseal(keychain *KeyChain) ([]byte, error) { /// // -func (v *vault4) setup(i *Item) { +func (v *vault4) setup(i *Item, old vault) { v.auth.KeyParams = *i.AuthParams.(*auth) v.auth.from = i.ContentType + + if vault, ok := old.(*vault4); ok { + // Forward additional data from vault used to unseal to the new one created for sealing. + v.additionaldata = vault.additionaldata + } } func (v *vault4) configure(i *Item) { @@ -153,7 +165,11 @@ func (v *vault4) configure(i *Item) { // func (v *vault4) serialize() (string, error) { - return fmt.Sprintf("%s:%s:%s:%s", v.version, v.nonce, v.ciphertext, v.rawauth), nil + payload := fmt.Sprintf("%s:%s:%s:%s", v.version, v.nonce, v.ciphertext, v.rawauth) + if v.additionaldata != "" { + payload = fmt.Sprintf("%s:%s", payload, v.additionaldata) + } + return payload, nil } //// diff --git a/pkg/stormbinc/binc.go b/pkg/stormbinc/binc.go index dc46c46..8274771 100644 --- a/pkg/stormbinc/binc.go +++ b/pkg/stormbinc/binc.go @@ -14,7 +14,7 @@ var Codec = new(bincCodec) type bincCodec int -func (c bincCodec) Marshal(v interface{}) ([]byte, error) { +func (c bincCodec) Marshal(v any) ([]byte, error) { var b bytes.Buffer enc := codec.NewEncoder(&b, &codec.BincHandle{}) err := enc.Encode(v) @@ -24,7 +24,7 @@ func (c bincCodec) Marshal(v interface{}) ([]byte, error) { return b.Bytes(), nil } -func (c bincCodec) Unmarshal(b []byte, v interface{}) error { +func (c bincCodec) Unmarshal(b []byte, v any) error { r := bytes.NewReader(b) dec := codec.NewDecoder(r, &codec.BincHandle{}) return dec.Decode(v) diff --git a/pkg/stormcbor/cbor.go b/pkg/stormcbor/cbor.go index 8a57ca3..4f00900 100644 --- a/pkg/stormcbor/cbor.go +++ b/pkg/stormcbor/cbor.go @@ -15,7 +15,7 @@ var Codec = new(cborCodec) type cborCodec int -func (c cborCodec) Marshal(v interface{}) ([]byte, error) { +func (c cborCodec) Marshal(v any) ([]byte, error) { var b bytes.Buffer enc := codec.NewEncoder(&b, &codec.CborHandle{}) err := enc.Encode(v) @@ -25,7 +25,7 @@ func (c cborCodec) Marshal(v interface{}) ([]byte, error) { return b.Bytes(), nil } -func (c cborCodec) Unmarshal(b []byte, v interface{}) error { +func (c cborCodec) Unmarshal(b []byte, v any) error { r := bytes.NewReader(b) dec := codec.NewDecoder(r, &codec.CborHandle{}) return dec.Decode(v) diff --git a/pkg/stormsql/select.go b/pkg/stormsql/select.go index 4e67632..beaf955 100644 --- a/pkg/stormsql/select.go +++ b/pkg/stormsql/select.go @@ -94,14 +94,14 @@ func parsWhereExpr(expr sqlparser.Expr) q.Matcher { // case *sqlparser.ComparisonExpr: field := v.Left.(*sqlparser.ColName).Name.String() - var value interface{} + var value any // Parse value switch sqlvalue := v.Right.(type) { case sqlparser.BoolVal: value = sqlvalue case sqlparser.ValTuple: - var tuple []interface{} + var tuple []any for _, t := range sqlvalue { tuple = append(tuple, parseSQLVal(t.(*sqlparser.SQLVal))) } @@ -171,7 +171,7 @@ func parsWhereExpr(expr sqlparser.Expr) q.Matcher { } } -func parseSQLVal(v *sqlparser.SQLVal) (value interface{}) { +func parseSQLVal(v *sqlparser.SQLVal) (value any) { switch v.Type { case sqlparser.StrVal: value = string(v.Val) diff --git a/pkg/structs/fields.go b/pkg/structs/fields.go index 0c5b099..d1a57b1 100644 --- a/pkg/structs/fields.go +++ b/pkg/structs/fields.go @@ -3,7 +3,7 @@ package structs import "github.com/oleiade/reflections" // GetField returns the value of the provided obj field. obj can whether be a structure or pointer to structure. -func GetField(obj interface{}, name string) interface{} { +func GetField(obj any, name string) any { v, err := reflections.GetField(obj, name) if err != nil { panic(err) @@ -15,7 +15,7 @@ func GetField(obj interface{}, name string) interface{} { // SetField sets the provided obj field with provided value. // obj param has to be a pointer to a struct, otherwise it will soundly fail. // Provided value type should match with the struct field you're trying to set. -func SetField(obj interface{}, name string, value interface{}) { +func SetField(obj any, name string, value any) { if err := reflections.SetField(obj, name, value); err != nil { panic(err) } diff --git a/tools/console/main.go b/tools/console/main.go index dd8ebf7..0c43d4c 100644 --- a/tools/console/main.go +++ b/tools/console/main.go @@ -71,7 +71,7 @@ func main() { } func count(sc *stormsql.SelectClause, query storm.Query) error { - var records interface{} + var records any switch sc.Tablename { case "users": records = &model.User{} @@ -93,7 +93,7 @@ func count(sc *stormsql.SelectClause, query storm.Query) error { } func list(sc *stormsql.SelectClause, query storm.Query) error { - var records interface{} + var records any switch sc.Tablename { case "users": records = &[]*model.User{} @@ -118,7 +118,7 @@ func list(sc *stormsql.SelectClause, query storm.Query) error { return nil } -func jsondump(v interface{}) { +func jsondump(v any) { d, err := json.MarshalIndent(v, "", " ") if err != nil { panic(err)