Skip to content

Commit

Permalink
Fix gosec warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
maruel committed Aug 9, 2024
1 parent 807f84d commit 68f6b37
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
6 changes: 2 additions & 4 deletions cmd/efe/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ func wpaPSK(passphrase, ssid string) string {

func setupFirstBoot(boot string) error {
fmt.Printf("- First boot setup script\n")
/* #nosec G306 */
if err := os.WriteFile(filepath.Join(boot, "firstboot.sh"), img.GetSetupSH(), 0o755); err != nil {
if err := os.WriteFile(filepath.Join(boot, "firstboot.sh"), img.GetSetupSH(), 0o755); err != nil /* #nosec G306 */ {
return err
}
if len(*sshKey) != 0 {
Expand All @@ -291,8 +290,7 @@ func setupFirstBoot(boot string) error {
// up automatically.
if (image.Distro == img.RaspiOS || image.Distro == img.RaspiOS64) && len(*wifiSSID) != 0 {
c := fmt.Sprintf(raspberryPiWPASupplicant, *wifiCountry, *wifiSSID, wpaPSK(*wifiPass, *wifiSSID))
/* #nosec G306 */
if err := os.WriteFile(filepath.Join(boot, "wpa_supplicant.conf"), []byte(c), 0o644); err != nil {
if err := os.WriteFile(filepath.Join(boot, "wpa_supplicant.conf"), []byte(c), 0o644); err != nil /* #nosec G306 */ {
return err
}
}
Expand Down
9 changes: 3 additions & 6 deletions img/boards.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ func fetchHardKernel() (string, error) {
if err != nil {
return "", err
}
/* #nosec G304 */
if f, _ := os.Open(imgpath); f != nil {
if f, _ := os.Open(imgpath); f != nil /* #nosec G304 */ {
fmt.Printf("- Reusing Ubuntu minimal image %s\n", imgpath)
_ = f.Close()
return imgpath, nil
Expand All @@ -330,8 +329,7 @@ func fetchRPiRaspiOSLite(is64bits bool) (string, error) {
if err != nil {
return "", err
}
/* #nosec G304 */
if f, _ := os.Open(imgpath); f != nil {
if f, _ := os.Open(imgpath); f != nil /* #nosec G304 */ {
name := "RaspiOS"
if is64bits {
name += "64"
Expand All @@ -356,8 +354,7 @@ func fetchRPiUbuntu() (string, error) {
if err != nil {
return "", err
}
/* #nosec G304 */
if f, _ := os.Open(imgpath); f != nil {
if f, _ := os.Open(imgpath); f != nil /* #nosec G304 */ {
fmt.Printf("- Reusing Ubuntu %s image %s\n", ver, imgpath)
_ = f.Close()
return imgpath, nil
Expand Down
3 changes: 1 addition & 2 deletions img/img.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ func FindPublicKey() string {
home := getHome()
for _, i := range []string{"authorized_keys", "id_ed25519.pub", "id_ecdsa.pub", "id_rsa.pub"} {
p := filepath.Join(home, ".ssh", i)
/* #nosec G304 */
if f, _ := os.Open(p); f != nil {
if f, _ := os.Open(p); f != nil /* #nosec G304 */ {
_ = f.Close()
return p
}
Expand Down

0 comments on commit 68f6b37

Please sign in to comment.