Ensure ignores are handled properly for multi-line issues

Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
This commit is contained in:
Cosmin Cojocar 2023-11-10 10:28:38 +01:00 committed by Cosmin Cojocar
parent 6d56592f09
commit 3188e3fb8e
2 changed files with 33 additions and 1 deletions

View file

@ -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
}
}

View file

@ -1212,6 +1212,38 @@ func HelloServer(w http.ResponseWriter, r *http.Request) {
if err != nil {
panic(err)
}
}
`}, 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()},
}