fix linting

This commit is contained in:
Olivier Cervello
2023-03-21 14:10:16 +00:00
parent 4f40416f8c
commit 03d9ce059b
3 changed files with 17 additions and 13 deletions
+1 -1
View File
@@ -219,7 +219,7 @@ func New(scan *Scan) *Results {
}
}
if scan.JSON {
jsonOutput, err := output.GetJsonString(
jsonOutput, err := output.GetJSONString(
r, secrets, parameters, filetype, errors, infos,
)
if err == nil {
+2 -2
View File
@@ -49,7 +49,7 @@ func Beautify() {
bannerPart2 := banner6 + banner7 + banner8 + banner9
color.Set(color.FgCyan)
fmt.Fprintf(os.Stderr, bannerPart1)
fmt.Fprint(os.Stderr, bannerPart1)
color.Unset()
fmt.Fprintf(os.Stderr, bannerPart2)
fmt.Fprint(os.Stderr, bannerPart2)
}
+14 -10
View File
@@ -35,7 +35,7 @@ import (
"github.com/gocolly/colly"
)
type JsonData struct {
type JSONData struct {
URL string `json:"url"`
Method string `json:"method"`
StatusCode int `json:"status_code"`
@@ -60,7 +60,7 @@ type MatcherResult struct {
Match string `json:"match"`
}
func GetJsonString(
func GetJSONString(
r *colly.Response,
secrets []scanner.SecretMatched,
parameters []scanner.Parameter,
@@ -68,22 +68,28 @@ func GetJsonString(
errors []scanner.ErrorMatched,
infos []scanner.InfoMatched,
) ([]byte, error) {
// Parse response headers
headers := r.Headers
contentTypes := (*headers)["Content-Type"]
contentLengths := (*headers)["Content-Length"]
contentType := ""
contentLength := 0
errorList := []MatcherResult{}
infoList := []MatcherResult{}
secretList := []MatcherResult{}
// Set content type
if len(contentTypes) > 0 {
contentType = contentTypes[0]
}
contentLength := 0
contentLengths := (*headers)["Content-Length"]
// Set content length
if len(contentLengths) > 0 {
ret, err := strconv.Atoi(contentLengths[0])
if err != nil {
return nil, err
}
contentLength = ret
}
@@ -94,21 +100,19 @@ func GetJsonString(
lines := len(strings.Split(string(r.Body), "\n"))
// Process secrets
secretList := []MatcherResult{}
for _, secret := range secrets {
secretMatch := MatcherResult{secret.Secret.Name, secret.Match}
secretList = append(secretList, secretMatch)
}
// Process infos
infoList := []MatcherResult{}
for _, info := range infos {
secretMatch := MatcherResult{info.Info.Name, info.Match}
infoList = append(infoList, secretMatch)
}
// Process
errorList := []MatcherResult{}
// Process errors
for _, error := range errors {
errorMatch := MatcherResult{error.Error.ErrorName, error.Match}
errorList = append(errorList, errorMatch)
@@ -122,7 +126,7 @@ func GetJsonString(
Infos: infoList,
Secrets: secretList,
}
resp := &JsonData{
resp := &JSONData{
URL: r.Request.URL.String(),
Method: r.Request.Method,
StatusCode: r.StatusCode,