From 4ec161791b3c404829444c045d9e1627a1e89a83 Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Sun, 15 Sep 2024 12:07:03 +0200 Subject: [PATCH 1/2] Fix staticcheck warnings $ staticcheck ./... | fmt -w 80 -s internal/format/format.go:204:17: error strings should not end with punctuation or newlines (ST1005) internal/stream/stream.go:15:2: "golang.org/x/crypto/poly1305" is deprecated: Poly1305 as implemented by this package is a cryptographic building block that is not safe for general purpose use. For encryption, use the full ChaCha20-Poly1305 construction implemented by golang.org/x/crypto/chacha20poly1305. For authentication, use a general purpose MAC such as HMAC implemented by crypto/hmac. (SA1019) plugin/client.go:385:2: field stderr is unused (U1000) $ gotip vet ./cmd/... cmd/age-keygen/keygen.go:161:13: non-constant format string in call to log.Printf --- cmd/age-keygen/keygen.go | 2 +- internal/format/format.go | 2 +- internal/stream/stream.go | 3 +-- plugin/client.go | 2 -- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cmd/age-keygen/keygen.go b/cmd/age-keygen/keygen.go index 3971d371..549d3cf8 100644 --- a/cmd/age-keygen/keygen.go +++ b/cmd/age-keygen/keygen.go @@ -158,5 +158,5 @@ func errorf(format string, v ...interface{}) { } func warning(msg string) { - log.Printf("age-keygen: warning: " + msg) + log.Printf("age-keygen: warning: %s", msg) } diff --git a/internal/format/format.go b/internal/format/format.go index aa77b756..4382610e 100644 --- a/internal/format/format.go +++ b/internal/format/format.go @@ -201,7 +201,7 @@ func (r *StanzaReader) ReadStanza() (s *Stanza, err error) { b, err := DecodeString(strings.TrimSuffix(string(line), "\n")) if err != nil { if bytes.HasPrefix(line, footerPrefix) || bytes.HasPrefix(line, stanzaPrefix) { - return nil, fmt.Errorf("malformed body line %q: stanza ended without a short line\nNote: this might be a file encrypted with an old beta version of age or rage. Use age v1.0.0-beta6 or rage to decrypt it.", line) + return nil, fmt.Errorf("malformed body line %q: stanza ended without a short line\nNote: this might be a file encrypted with an old beta version of age or rage. Use age v1.0.0-beta6 or rage to decrypt it", line) } return nil, errorf("malformed body line %q: %v", line, err) } diff --git a/internal/stream/stream.go b/internal/stream/stream.go index 7cf02c47..7551274b 100644 --- a/internal/stream/stream.go +++ b/internal/stream/stream.go @@ -12,7 +12,6 @@ import ( "io" "golang.org/x/crypto/chacha20poly1305" - "golang.org/x/crypto/poly1305" ) const ChunkSize = 64 * 1024 @@ -29,7 +28,7 @@ type Reader struct { } const ( - encChunkSize = ChunkSize + poly1305.TagSize + encChunkSize = ChunkSize + chacha20poly1305.Overhead lastChunkFlag = 0x01 ) diff --git a/plugin/client.go b/plugin/client.go index dca1a521..2b50989a 100644 --- a/plugin/client.go +++ b/plugin/client.go @@ -9,7 +9,6 @@ package plugin import ( "bufio" - "bytes" "fmt" "io" "math/rand" @@ -382,7 +381,6 @@ type clientConnection struct { cmd *exec.Cmd io.Reader // stdout io.Writer // stdin - stderr bytes.Buffer close func() } From 5e9131c56ebdf71f30df7b6835e9792d9fc5ca2b Mon Sep 17 00:00:00 2001 From: Filippo Valsorda Date: Wed, 18 Dec 2024 15:54:48 +0100 Subject: [PATCH 2/2] Update format.go --- internal/format/format.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/format/format.go b/internal/format/format.go index 4382610e..0f22e6fa 100644 --- a/internal/format/format.go +++ b/internal/format/format.go @@ -201,7 +201,7 @@ func (r *StanzaReader) ReadStanza() (s *Stanza, err error) { b, err := DecodeString(strings.TrimSuffix(string(line), "\n")) if err != nil { if bytes.HasPrefix(line, footerPrefix) || bytes.HasPrefix(line, stanzaPrefix) { - return nil, fmt.Errorf("malformed body line %q: stanza ended without a short line\nNote: this might be a file encrypted with an old beta version of age or rage. Use age v1.0.0-beta6 or rage to decrypt it", line) + return nil, fmt.Errorf("malformed body line %q: stanza ended without a short line\nnote: this might be a file encrypted with an old beta version of age or rage; use age v1.0.0-beta6 or rage to decrypt it", line) } return nil, errorf("malformed body line %q: %v", line, err) }