Fix golangci-lint warnings
This commit is contained in:
parent
175a72298d
commit
4c24e4692b
6 changed files with 48 additions and 9 deletions
|
@ -27,9 +27,10 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.cacert.org/cacert-gosigner/pkg/messages"
|
|
||||||
"github.com/justincpresley/go-cobs"
|
"github.com/justincpresley/go-cobs"
|
||||||
"github.com/shamaton/msgpackgen/msgpack"
|
"github.com/shamaton/msgpackgen/msgpack"
|
||||||
|
|
||||||
|
"git.cacert.org/cacert-gosigner/pkg/messages"
|
||||||
)
|
)
|
||||||
|
|
||||||
const cobsDelimiter = 0x00
|
const cobsDelimiter = 0x00
|
||||||
|
@ -94,7 +95,7 @@ func (c *clientSimulator) handleInput(ctx context.Context) error {
|
||||||
default:
|
default:
|
||||||
count, err := os.Stdin.Read(buf)
|
count, err := os.Stdin.Read(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("reading input failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
|
@ -107,7 +108,7 @@ func (c *clientSimulator) handleInput(ctx context.Context) error {
|
||||||
|
|
||||||
err = cobs.Verify(data, cobsConfig)
|
err = cobs.Verify(data, cobsConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("frame verification failed: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.responses <- cobs.Decode(data, cobsConfig)
|
c.responses <- cobs.Decode(data, cobsConfig)
|
||||||
|
@ -157,7 +158,7 @@ func (c *clientSimulator) Run() error {
|
||||||
var inputError, commandError error
|
var inputError, commandError error
|
||||||
|
|
||||||
go func(inputErr error) {
|
go func(inputErr error) {
|
||||||
inputError = c.handleInput(ctx)
|
_ = c.handleInput(ctx)
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
|
@ -165,7 +166,7 @@ func (c *clientSimulator) Run() error {
|
||||||
}(inputError)
|
}(inputError)
|
||||||
|
|
||||||
go func(commandErr error) {
|
go func(commandErr error) {
|
||||||
commandErr = c.handleCommands(ctx)
|
_ = c.handleCommands(ctx)
|
||||||
|
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ package messages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
msgpack "github.com/shamaton/msgpackgen/msgpack"
|
msgpack "github.com/shamaton/msgpackgen/msgpack"
|
||||||
dec "github.com/shamaton/msgpackgen/msgpack/dec"
|
dec "github.com/shamaton/msgpackgen/msgpack/dec"
|
||||||
enc "github.com/shamaton/msgpackgen/msgpack/enc"
|
enc "github.com/shamaton/msgpackgen/msgpack/enc"
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
/*
|
||||||
|
Copyright 2022 CAcert Inc.
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package helper
|
package helper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -9,7 +26,7 @@ import (
|
||||||
// GenerateRandomSerial generates a random serial number to be used in X.509 certificates. The implementation is
|
// GenerateRandomSerial generates a random serial number to be used in X.509 certificates. The implementation is
|
||||||
// compliant to https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.2.
|
// compliant to https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.2.
|
||||||
func GenerateRandomSerial() (*big.Int, error) {
|
func GenerateRandomSerial() (*big.Int, error) {
|
||||||
serial, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 160))
|
serial, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 160)) //nolint:gomnd
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not generate random serial number: %w", err)
|
return nil, fmt.Errorf("could not generate random serial number: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,28 @@
|
||||||
|
/*
|
||||||
|
Copyright 2022 CAcert Inc.
|
||||||
|
SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package helper_test
|
package helper_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGenerateRandomSerial(t *testing.T) {
|
func TestGenerateRandomSerial(t *testing.T) {
|
||||||
|
|
|
@ -28,10 +28,11 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
|
||||||
|
|
||||||
"git.cacert.org/cacert-gosigner/pkg/x509/revoking"
|
"git.cacert.org/cacert-gosigner/pkg/x509/revoking"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,10 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"git.cacert.org/cacert-gosigner/pkg/x509/helper"
|
||||||
|
|
||||||
"git.cacert.org/cacert-gosigner/pkg/x509/signing"
|
"git.cacert.org/cacert-gosigner/pkg/x509/signing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue