Skip to content

Commit

Permalink
upgrade dependencies (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored May 17, 2024
1 parent 8e38d8c commit 2b8420b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 35 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.20.x]
go-version: [1.22.x]
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
Expand All @@ -33,15 +33,15 @@ jobs:

- name: golangci-lint
run: |
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
$(go env GOPATH)/bin/golangci-lint run --config ./.golangci.yml
test:
name: Testing Go ${{ matrix.go-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.18.x, 1.19.x, 1.20.x]
go-version: [1.21.x, 1.22.x]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
Expand All @@ -63,4 +63,4 @@ jobs:
env:
GO111MODULE: on
run: |
go test -race ./...
go test -race ./...
21 changes: 13 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@ linters-settings:
misspell:
locale: US

staticcheck:
checks: ['all', '-SA6002']

linters:
disable-all: true
enable:
- typecheck
- durationcheck
- gocritic
- gofumpt
- goimports
- misspell
- gomodguard
- govet
- ineffassign
- gosimple
- unused
- prealloc
- unconvert
- misspell
- revive
- staticcheck
- tenv
- typecheck
- unconvert
- unused

issues:
exclude-use-default: false
exclude:
- should have a package comment
- error strings should not be capitalized or end with punctuation or a newline
- don't use ALL_CAPS in Go names
service:
golangci-lint-version: 1.33.0 # use the fixed version to not introduce new linters unexpectedly
19 changes: 10 additions & 9 deletions cmd/ncrypt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (

"github.com/minio/sio"
"golang.org/x/crypto/scrypt"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)

const (
Expand Down Expand Up @@ -172,7 +172,7 @@ func parseIOArgs() (*os.File, *os.File) {
fmt.Fprintf(os.Stderr, "Failed to open '%s': %v\n", args[0], err)
exit(codeError)
}
cleanFn = append(cleanFn, func(code int) { in.Close() })
cleanFn = append(cleanFn, func(_ int) { in.Close() })
return in, os.Stdout
case 2:
in, err := os.Open(args[0])
Expand All @@ -196,21 +196,21 @@ func parseIOArgs() (*os.File, *os.File) {
}

func readPassword(src *os.File) []byte {
state, err := terminal.GetState(int(src.Fd()))
state, err := term.GetState(int(src.Fd()))
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to read password:", err)
exit(codeError)
}
cleanFn = append(cleanFn, func(code int) {
stat, _ := terminal.GetState(int(src.Fd()))
stat, _ := term.GetState(int(src.Fd()))
if code == codeCancel && stat != nil && *stat != *state {
fmt.Fprintln(src, "\nFailed to read password: Interrupted")
}
terminal.Restore(int(src.Fd()), state)
term.Restore(int(src.Fd()), state)
})

fmt.Fprint(src, "Enter password:")
password, err := terminal.ReadPassword(int(src.Fd()))
password, err := term.ReadPassword(int(src.Fd()))
if err != nil {
fmt.Fprintln(os.Stderr, "Failed to read password:", err)
exit(codeError)
Expand All @@ -228,11 +228,12 @@ func deriveKey(dst, src *os.File) []byte {
password []byte
salt = make([]byte, 32)
)
if passwordFlag != "" {
switch {
case passwordFlag != "":
password = []byte(passwordFlag)
} else if src == os.Stdin {
case src == os.Stdin:
password = readPassword(os.Stderr)
} else {
default:
password = readPassword(os.Stdin)
}
if decryptFlag {
Expand Down
4 changes: 2 additions & 2 deletions dare.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (h headerV10) SetVersion() { h[0] = Version10 }
func (h headerV10) SetCipher(suite byte) { h[1] = suite }
func (h headerV10) SetLen(length int) { binary.LittleEndian.PutUint16(h[2:], uint16(length-1)) }
func (h headerV10) SetSequenceNumber(num uint32) { binary.LittleEndian.PutUint32(h[4:], num) }
func (h headerV10) SetRand(randVal []byte) { copy(h[8:headerSize], randVal[:]) }
func (h headerV10) SetRand(randVal []byte) { copy(h[8:headerSize], randVal) }
func (h headerV10) Nonce() []byte { return h[4:headerSize] }
func (h headerV10) AddData() []byte { return h[:4] }

Expand Down Expand Up @@ -256,7 +256,7 @@ func (ad *authDecV20) Open(dst, src []byte) error {
ad.finalized = true
refNonce[0] |= 0x80 // set final flag
}
if subtle.ConstantTimeCompare(header.Nonce(), refNonce[:]) != 1 {
if subtle.ConstantTimeCompare(header.Nonce(), refNonce) != 1 {
return errNonceMismatch
}

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/minio/sio

require (
golang.org/x/crypto v0.6.0
golang.org/x/sys v0.5.0
golang.org/x/crypto v0.23.0
golang.org/x/sys v0.20.0
)

require golang.org/x/term v0.5.0 // indirect
require golang.org/x/term v0.20.0

go 1.18
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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/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/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
4 changes: 1 addition & 3 deletions sio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,9 @@ func TestDecryptBuffer(t *testing.T) {

for _, version := range versions {
t.Run(fmt.Sprintf("v-%x", version), func(t *testing.T) {

config.MinVersion, config.MaxVersion = version, version
for i, test := range ioTests {
t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) {

data := make([]byte, test.datasize)
if _, err := io.ReadFull(rand.Reader, data); err != nil {
t.Fatalf("Version %d: Test %d: Failed to generate random data: %v", version, i, err)
Expand Down Expand Up @@ -468,7 +466,7 @@ func testFile(t *testing.T, file string) {

func TestFiles(t *testing.T) {
fileList := []string{}
err := filepath.Walk(".", func(path string, f os.FileInfo, err error) error {
err := filepath.Walk(".", func(path string, f os.FileInfo, _ error) error {
if !f.IsDir() {
fileList = append(fileList, path)
}
Expand Down

0 comments on commit 2b8420b

Please sign in to comment.