fix(lint): Finish to apply linter recommandation
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Matthieu 'JP' DERASSE
2022-08-03 13:36:13 +00:00
parent 660a4ef162
commit 7938ce2dfa
14 changed files with 37 additions and 35 deletions

View File

@ -254,6 +254,7 @@ func (g Golang) PostInstall(path string) error {
if len(lineBashRc) > 1 {
log.Debug("Adding env variable to .bashrc")
//nolint:gosec // we did compute the file path
fh, err := os.OpenFile(
filepath.Join(homeDir, ".bashrc"),
os.O_APPEND|os.O_CREATE|os.O_WRONLY,

View File

@ -162,6 +162,7 @@ func (s Swagger) Install(path string) error {
return errors.Trace(err)
}
//nolint:gosec // we did compute the file path
fh, err := os.OpenFile(
filepath.Join(path, "swagger"),
os.O_RDWR|os.O_CREATE|os.O_TRUNC,
@ -228,6 +229,7 @@ func (s Swagger) PostInstall(path string) error {
if len(lineBashRc) > 1 {
log.Debug("Adding env variable to .bashrc")
//nolint:gosec // we did compute the file path
fh, err := os.OpenFile(
filepath.Join(homeDir, ".bashrc"),
os.O_APPEND|os.O_CREATE|os.O_WRONLY,

View File

@ -21,6 +21,7 @@ import (
// content will probably be untar, ungzip, ....
func downloadFile(url string) (io.Reader, error) {
// Get the data
//nolint:gosec,noctx // we trust the url
resp, err := http.Get(url)
if err != nil {
return nil, errors.Trace(err)
@ -93,7 +94,7 @@ func unTar(reader io.Reader, subdir string, dest string) error {
log.Debugf("Extacting %s", target)
switch header.Typeflag {
// create directory if doesn't exit
// create directory if doesn't exit.
case tar.TypeDir:
if _, err := os.Stat(target); err != nil {
if err := os.MkdirAll(target, 0750); err != nil {
@ -102,6 +103,7 @@ func unTar(reader io.Reader, subdir string, dest string) error {
}
// create file
case tar.TypeReg:
//nolint:gosec // we did compute the file path.
f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, os.FileMode(header.Mode))
if err != nil {
return errors.Trace(err)
@ -113,7 +115,8 @@ func unTar(reader io.Reader, subdir string, dest string) error {
}
}()
// copy contents to file
// copy contents to file.
//nolint:gosec // TODO: do a decompression that protect from decompression bomb.
if _, err := io.Copy(f, tr); err != nil {
return errors.Trace(err)
}
@ -166,6 +169,7 @@ func unZip(reader io.Reader, subdir string, dest string) error {
}
}
} else {
//nolint:gosec // we did compute the file path.
f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, file.Mode())
if err != nil {
return errors.Trace(err)
@ -189,6 +193,7 @@ func unZip(reader io.Reader, subdir string, dest string) error {
}()
// copy contents to file
//nolint:gosec // TODO: do a decompression that protect from decompression bomb.
if _, err := io.Copy(f, fileInArchive); err != nil {
return errors.Trace(err)
}