mirror of
https://github.com/securego/gosec.git
synced 2025-02-28 20:23:28 +00:00
chore: fix lint warnings
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
This commit is contained in:
parent
d3933f9e14
commit
0ba05e160a
6 changed files with 10 additions and 14 deletions
|
@ -2,7 +2,6 @@ package gosec_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -30,7 +29,7 @@ var _ = Describe("Analyzer", func() {
|
||||||
Context("when processing a package", func() {
|
Context("when processing a package", func() {
|
||||||
It("should not report an error if the package contains no Go files", func() {
|
It("should not report an error if the package contains no Go files", func() {
|
||||||
analyzer.LoadRules(rules.Generate(false).RulesInfo())
|
analyzer.LoadRules(rules.Generate(false).RulesInfo())
|
||||||
dir, err := ioutil.TempDir("", "empty")
|
dir, err := os.MkdirTemp("", "empty")
|
||||||
defer os.RemoveAll(dir)
|
defer os.RemoveAll(dir)
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
err = analyzer.Process(buildTags, dir)
|
err = analyzer.Process(buildTags, dir)
|
||||||
|
|
|
@ -17,7 +17,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -354,7 +354,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if *flagQuiet {
|
if *flagQuiet {
|
||||||
logger = log.New(ioutil.Discard, "", 0)
|
logger = log.New(io.Discard, "", 0)
|
||||||
} else {
|
} else {
|
||||||
logger = log.New(logWriter, "[gosec] ", log.LstdFlags)
|
logger = log.New(logWriter, "[gosec] ", log.LstdFlags)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/format"
|
"go/format"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/mozilla/tls-observatory/constants"
|
"github.com/mozilla/tls-observatory/constants"
|
||||||
|
@ -187,7 +187,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
outputPath := filepath.Join(dir, *outputFile)
|
outputPath := filepath.Join(dir, *outputFile)
|
||||||
if err := ioutil.WriteFile(outputPath, src, 0o644); err != nil {
|
if err := os.WriteFile(outputPath, src, 0o644); err != nil {
|
||||||
log.Fatalf("Writing output: %s", err)
|
log.Fatalf("Writing output: %s", err)
|
||||||
} //#nosec G306
|
} //#nosec G306
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -64,7 +63,7 @@ func (c Config) convertGlobals() {
|
||||||
// should be used with io.Reader to load configuration from
|
// should be used with io.Reader to load configuration from
|
||||||
// file or from string etc.
|
// file or from string etc.
|
||||||
func (c Config) ReadFrom(r io.Reader) (int64, error) {
|
func (c Config) ReadFrom(r io.Reader) (int64, error) {
|
||||||
data, err := ioutil.ReadAll(r)
|
data, err := io.ReadAll(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return int64(len(data)), err
|
return int64(len(data)), err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package gosec_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go/ast"
|
"go/ast"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -18,9 +17,9 @@ var _ = Describe("Helpers", func() {
|
||||||
var dir string
|
var dir string
|
||||||
JustBeforeEach(func() {
|
JustBeforeEach(func() {
|
||||||
var err error
|
var err error
|
||||||
dir, err = ioutil.TempDir("", "gosec")
|
dir, err = os.MkdirTemp("", "gosec")
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
_, err = ioutil.TempFile(dir, "test*.go")
|
_, err = os.MkdirTemp(dir, "test*.go")
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package testutils
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
"go/build"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
@ -30,7 +29,7 @@ type TestPackage struct {
|
||||||
// NewTestPackage will create a new and empty package. Must call Close() to cleanup
|
// NewTestPackage will create a new and empty package. Must call Close() to cleanup
|
||||||
// auxiliary files
|
// auxiliary files
|
||||||
func NewTestPackage() *TestPackage {
|
func NewTestPackage() *TestPackage {
|
||||||
workingDir, err := ioutil.TempDir("", "gosecs_test")
|
workingDir, err := os.MkdirTemp("", "gosecs_test")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -53,7 +52,7 @@ func (p *TestPackage) write() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for filename, content := range p.Files {
|
for filename, content := range p.Files {
|
||||||
if e := ioutil.WriteFile(filename, []byte(content), 0o644); e != nil {
|
if e := os.WriteFile(filename, []byte(content), 0o644); e != nil {
|
||||||
return e
|
return e
|
||||||
} //#nosec G306
|
} //#nosec G306
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue