Skip to content

Commit

Permalink
Fix lint warnings by properly formatting the files
Browse files Browse the repository at this point in the history
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
  • Loading branch information
ccojocar committed Dec 8, 2023
1 parent 0e2a618 commit 2aad3f0
Show file tree
Hide file tree
Showing 32 changed files with 259 additions and 321 deletions.
10 changes: 4 additions & 6 deletions testutils/cgo_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package testutils

import "github.com/securego/gosec/v2"

var (
// SampleCodeCgo - Cgo file sample
SampleCodeCgo = []CodeSample{
{[]string{`
// SampleCodeCgo - Cgo file sample
var SampleCodeCgo = []CodeSample{
{[]string{`
package main
import (
Expand Down Expand Up @@ -48,5 +47,4 @@ func main() {
C.printData(cData)
}
`}, 0, gosec.NewConfig()},
}
)
}
26 changes: 12 additions & 14 deletions testutils/g102_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package testutils

import "github.com/securego/gosec/v2"

var (
// SampleCodeG102 code snippets for network binding
SampleCodeG102 = []CodeSample{
// Bind to all networks explicitly
{[]string{`
// SampleCodeG102 code snippets for network binding
var SampleCodeG102 = []CodeSample{
// Bind to all networks explicitly
{[]string{`
package main
import (
Expand All @@ -22,8 +21,8 @@ func main() {
defer l.Close()
}
`}, 1, gosec.NewConfig()},
// Bind to all networks implicitly (default if host omitted)
{[]string{`
// Bind to all networks implicitly (default if host omitted)
{[]string{`
package main
import (
Expand All @@ -39,8 +38,8 @@ func main() {
defer l.Close()
}
`}, 1, gosec.NewConfig()},
// Bind to all networks indirectly through a parsing function
{[]string{`
// Bind to all networks indirectly through a parsing function
{[]string{`
package main
import (
Expand All @@ -61,8 +60,8 @@ func main() {
defer l.Close()
}
`}, 1, gosec.NewConfig()},
// Bind to all networks indirectly through a parsing function
{[]string{`
// Bind to all networks indirectly through a parsing function
{[]string{`
package main
import (
Expand All @@ -84,7 +83,7 @@ func main() {
defer l.Close()
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -102,5 +101,4 @@ func main() {
defer l.Close()
}
`}, 1, gosec.NewConfig()},
}
)
}
14 changes: 6 additions & 8 deletions testutils/g103_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package testutils

import "github.com/securego/gosec/v2"

var (
// SampleCodeG103 find instances of unsafe blocks for auditing purposes
SampleCodeG103 = []CodeSample{
{[]string{`
// SampleCodeG103 find instances of unsafe blocks for auditing purposes
var SampleCodeG103 = []CodeSample{
{[]string{`
package main
import (
Expand All @@ -29,7 +28,7 @@ func main() {
fmt.Printf("\nintPtr=%p, *intPtr=%d.\n\n", intPtr, *intPtr)
}
`}, 2, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -46,7 +45,7 @@ func main() {
fmt.Printf("ptr: %p\n", ptr)
}
`}, 2, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -63,5 +62,4 @@ func main() {
fmt.Printf("ptr: %p\n", ptr)
}
`}, 2, gosec.NewConfig()},
}
)
}
10 changes: 4 additions & 6 deletions testutils/g106_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package testutils

import "github.com/securego/gosec/v2"

var (
// SampleCodeG106 - ssh InsecureIgnoreHostKey
SampleCodeG106 = []CodeSample{
{[]string{`
// SampleCodeG106 - ssh InsecureIgnoreHostKey
var SampleCodeG106 = []CodeSample{
{[]string{`
package main
import (
Expand All @@ -16,5 +15,4 @@ func main() {
_ = ssh.InsecureIgnoreHostKey()
}
`}, 1, gosec.NewConfig()},
}
)
}
26 changes: 12 additions & 14 deletions testutils/g107_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package testutils

import "github.com/securego/gosec/v2"

var (
// SampleCodeG107 - SSRF via http requests with variable url
SampleCodeG107 = []CodeSample{
{[]string{`
// SampleCodeG107 - SSRF via http requests with variable url
var SampleCodeG107 = []CodeSample{
{[]string{`
// Input from the std in is considered insecure
package main
import (
Expand Down Expand Up @@ -33,7 +32,7 @@ func main() {
fmt.Printf("%s", body)
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
// Variable defined a package level can be changed at any time
// regardless of the initial value
package main
Expand All @@ -58,7 +57,7 @@ func main() {
}
fmt.Printf("%s", body)
}`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
// Environmental variables are not considered as secure source
package main
import (
Expand All @@ -81,7 +80,7 @@ func main() {
fmt.Printf("%s", body)
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
// Constant variables or hard-coded strings are secure
package main
Expand All @@ -98,7 +97,7 @@ func main() {
fmt.Println(resp.Status)
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
// A variable at function scope which is initialized to
// a constant string is secure (e.g. cannot be changed concurrently)
package main
Expand All @@ -116,7 +115,7 @@ func main() {
fmt.Println(resp.Status)
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
// A variable at function scope which is initialized to
// a constant string is secure (e.g. cannot be changed concurrently)
package main
Expand All @@ -134,7 +133,7 @@ func main() {
fmt.Println(resp.Status)
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
// A variable at function scope which is initialized to
// a constant string is secure (e.g. cannot be changed concurrently)
package main
Expand All @@ -154,7 +153,7 @@ func main() {
fmt.Println(resp.Status)
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
// An exported variable declared a packaged scope is not secure
// because it can changed at any time
package main
Expand All @@ -174,7 +173,7 @@ func main() {
fmt.Println(resp.Status)
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
// An url provided as a function argument is not secure
package main
Expand All @@ -194,5 +193,4 @@ func main() {
get(url)
}
`}, 1, gosec.NewConfig()},
}
)
}
12 changes: 5 additions & 7 deletions testutils/g108_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package testutils

import "github.com/securego/gosec/v2"

var (
// SampleCodeG108 - pprof endpoint automatically exposed
SampleCodeG108 = []CodeSample{
{[]string{`
// SampleCodeG108 - pprof endpoint automatically exposed
var SampleCodeG108 = []CodeSample{
{[]string{`
package main
import (
Expand All @@ -22,7 +21,7 @@ func main() {
log.Fatal(http.ListenAndServe(":8080", nil))
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -38,5 +37,4 @@ func main() {
log.Fatal(http.ListenAndServe(":8080", nil))
}
`}, 0, gosec.NewConfig()},
}
)
}
20 changes: 9 additions & 11 deletions testutils/g109_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package testutils

import "github.com/securego/gosec/v2"

var (
// SampleCodeG109 - Potential Integer OverFlow
SampleCodeG109 = []CodeSample{
{[]string{`
// SampleCodeG109 - Potential Integer OverFlow
var SampleCodeG109 = []CodeSample{
{[]string{`
package main
import (
Expand All @@ -22,7 +21,7 @@ func main() {
fmt.Println(value)
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -40,7 +39,7 @@ func main() {
}
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -56,7 +55,7 @@ func main() {
fmt.Println(bigValue)
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -79,7 +78,7 @@ func test() {
fmt.Println(value)
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -97,7 +96,7 @@ func main() {
fmt.Println(v)
}
`}, 0, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -110,5 +109,4 @@ func main() {
fmt.Println(b, err)
}
`}, 0, gosec.NewConfig()},
}
)
}
16 changes: 7 additions & 9 deletions testutils/g110_samples.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package testutils

import "github.com/securego/gosec/v2"

var (
// SampleCodeG110 - potential DoS vulnerability via decompression bomb
SampleCodeG110 = []CodeSample{
{[]string{`
// SampleCodeG110 - potential DoS vulnerability via decompression bomb
var SampleCodeG110 = []CodeSample{
{[]string{`
package main
import (
Expand All @@ -31,7 +30,7 @@ func main() {
r.Close()
}`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -58,7 +57,7 @@ func main() {
r.Close()
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand Down Expand Up @@ -97,7 +96,7 @@ func main() {
}
}
`}, 1, gosec.NewConfig()},
{[]string{`
{[]string{`
package main
import (
Expand All @@ -124,5 +123,4 @@ func main() {
}
}
`}, 0, gosec.NewConfig()},
}
)
}
Loading

0 comments on commit 2aad3f0

Please sign in to comment.