Skip to content

Commit

Permalink
Ensure ignores are handled properly for multi-line issues
Browse files Browse the repository at this point in the history
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
  • Loading branch information
ccojocar committed Nov 10, 2023
1 parent 6d56592 commit 3188e3f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (i ignores) get(file string, line string) map[string][]issue.SuppressionInf
start, end := i.parseLine(line)
if is, ok := i[file]; ok {
for _, i := range is {
if i.start <= start && i.end >= end {
if start <= i.start && end >= i.end {
return i.suppressions
}
}
Expand Down
32 changes: 32 additions & 0 deletions testutils/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,38 @@ func HelloServer(w http.ResponseWriter, r *http.Request) {
}
}
`}, 0, gosec.NewConfig()},
{[]string{`
package main
import (
"fmt"
"net/http"
"sync"
)
type Server struct {
hs *http.Server
mux *http.ServeMux
mu sync.Mutex
}
func New(listenAddr string) *Server {
mux := http.NewServeMux()
return &Server{
hs: &http.Server{ // #nosec G112 - Not publicly exposed
Addr: listenAddr,
Handler: mux,
},
mux: mux,
mu: sync.Mutex{},
}
}
func main() {
fmt.Print("test")
}
`}, 0, gosec.NewConfig()},
}

// SampleCodeG113 - Usage of Rat.SetString in math/big with an overflow
Expand Down

0 comments on commit 3188e3f

Please sign in to comment.