Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix go imports after rename #334

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sztp-agent/cmd/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package cmd

import (
"github.com/spf13/cobra"
"reflect"
"testing"

"github.com/spf13/cobra"
)

func TestNewDaemonCommand(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/cmd/disable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package cmd

import (
"github.com/spf13/cobra"
"reflect"
"testing"

"github.com/spf13/cobra"
)

func TestNewDisableCommand(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/cmd/enable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package cmd

import (
"github.com/spf13/cobra"
"reflect"
"testing"

"github.com/spf13/cobra"
)

func TestNewEnableCommand(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package cmd

import (
"github.com/spf13/cobra"
"reflect"
"testing"

"github.com/spf13/cobra"
)

func TestNewRunCommand(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/cmd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
package cmd

import (
"github.com/spf13/cobra"
"reflect"
"testing"

"github.com/spf13/cobra"
)

func TestNewStatusCommand(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ import (
"github.com/TwiN/go-color"
"github.com/opiproject/sztp/sztp-agent/cmd"

"github.com/spf13/cobra"
"log"
"os"

"github.com/spf13/cobra"
)

func main() {
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/pkg/secureagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"encoding/json"
"errors"
"fmt"
"github.com/github/smimesign/ietf-cms/protocol"
"io"
"log"
"net/http"
Expand All @@ -27,6 +26,8 @@
"strconv"
"strings"
"time"

"github.com/github/smimesign/ietf-cms/protocol"
)

const (
Expand Down Expand Up @@ -217,8 +218,8 @@
if err != nil {
return err
}
defer file.Close()

Check failure on line 221 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

Error return value of `file.Close` is not checked (errcheck)
defer response.Body.Close()

Check failure on line 222 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

Error return value of `response.Body.Close` is not checked (errcheck)

log.Printf("[INFO] Downloaded file: %s with size: %d", ARTIFACTS_PATH+a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference+filepath.Base(item), size)
log.Println("[INFO] Verify the file checksum: ", ARTIFACTS_PATH+a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference+filepath.Base(item))
Expand All @@ -230,7 +231,7 @@
log.Panic(err)
return err
}
defer f.Close()

Check failure on line 234 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

Error return value of `f.Close` is not checked (errcheck)
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
return err
Expand Down Expand Up @@ -259,7 +260,7 @@
log.Println("[ERROR] creating the configuration file", err.Error())
return err
}
defer file.Close()

Check failure on line 263 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

Error return value of `file.Close` is not checked (errcheck)

plainTest, _ := base64.StdEncoding.DecodeString(a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.Configuration)
_, err = file.WriteString(string(plainTest))
Expand All @@ -267,7 +268,7 @@
log.Println("[ERROR] writing the configuration file", err.Error())
return err
}
err = os.Chmod(ARTIFACTS_PATH+a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference+"-config", 0744)

Check failure on line 271 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

G302: Expect file permissions to be 0600 or less (gosec)
if err != nil {
log.Println("[ERROR] changing the configuration file permission", err.Error())
return err
Expand All @@ -291,12 +292,12 @@
}
log.Println("[INFO] Starting the " + scriptName + "-configuration.")
_ = a.doReportProgress(report)
file, err := os.Create(ARTIFACTS_PATH + a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference + scriptName + "configuration.sh")

Check failure on line 295 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

G304: Potential file inclusion via variable (gosec)
if err != nil {
log.Println("[ERROR] creating the "+scriptName+"-configuration script", err.Error())
return err
}
defer file.Close()

Check failure on line 300 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

Error return value of `file.Close` is not checked (errcheck)

plainTest, _ := base64.StdEncoding.DecodeString(script)
_, err = file.WriteString(string(plainTest))
Expand All @@ -304,7 +305,7 @@
log.Println("[ERROR] writing the "+scriptName+"-configuration script", err.Error())
return err
}
err = os.Chmod(ARTIFACTS_PATH+a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference+scriptName+"configuration.sh", 0755)

Check failure on line 308 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

G302: Expect file permissions to be 0600 or less (gosec)
if err != nil {
log.Println("[ERROR] changing the "+scriptName+"-configuration script permission", err.Error())
return err
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/pkg/secureagent/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
"crypto/x509"
"encoding/json"
"errors"
"github.com/jaypipes/ghw"
"io"
"log"
"net/http"
"os"
"regexp"
"strconv"
"strings"

"github.com/jaypipes/ghw"
)

// Auxiliar function to get lines from file matching with the substr
Expand Down Expand Up @@ -80,7 +81,7 @@
log.Println("Error doing the request", err.Error())
return nil, err
}
defer res.Body.Close()

Check failure on line 84 in sztp-agent/pkg/secureagent/utils.go

View workflow job for this annotation

GitHub Actions / golangci

Error return value of `res.Body.Close` is not checked (errcheck)

bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand Down
Loading