mirror of
https://github.com/edoardottt/cariddi.git
synced 2026-09-10 03:37:46 +02:00
update
This commit is contained in:
+34
-11
@@ -42,18 +42,23 @@ type jsonData struct {
|
||||
StatusCode int `json:"status_code"`
|
||||
Words int `json:"words"`
|
||||
Lines int `json:"lines"`
|
||||
ContentType string `json:"content_type,omit_empty"`
|
||||
ContentLength int `json:"content_length,omit_empty"`
|
||||
ContentType string `json:"content_type,omitempty"`
|
||||
ContentLength int `json:"content_length,omitempty"`
|
||||
Matches MatcherResults `json:"matches,omitempty"`
|
||||
// Host string `json:"host"` # TODO: Add when migrating to Colly 2.x
|
||||
}
|
||||
|
||||
type MatcherResults struct {
|
||||
Secrets []scanner.SecretMatched `json:"secrets,omit_empty"`
|
||||
Parameters []scanner.Parameter `json:"parameters,omit_empty"`
|
||||
FileType scanner.FileType `json:"filetype,omit_empty"`
|
||||
Errors []scanner.ErrorMatched `json:"errors,omit_empty"`
|
||||
Infos []scanner.InfoMatched `json:"infos,omit_empty"`
|
||||
FileType scanner.FileType `json:"filetype,omitempty"`
|
||||
Parameters []scanner.Parameter `json:"parameters,omitempty"`
|
||||
Errors []MatcherResult `json:"errors,omitempty"`
|
||||
Infos []MatcherResult `json:"infos,omitempty"`
|
||||
Secrets []MatcherResult `json:"secrets,omitempty"`
|
||||
}
|
||||
|
||||
type MatcherResult struct {
|
||||
Name string `json:"name"`
|
||||
Match string `json:"match"`
|
||||
}
|
||||
|
||||
func GetJsonString(
|
||||
@@ -89,13 +94,31 @@ func GetJsonString(
|
||||
// Parse lines from body
|
||||
lines := len(strings.Split(string(r.Body), "\n"))
|
||||
|
||||
// Process secrets
|
||||
secretList := []MatcherResult{}
|
||||
for _, secret := range secrets {
|
||||
secretList = append(secretList, MatcherResult{secret.Secret.Name, secret.Match})
|
||||
}
|
||||
|
||||
// Process infos
|
||||
infoList := []MatcherResult{}
|
||||
for _, info := range infos {
|
||||
infoList = append(infoList, MatcherResult{info.Info.Name, info.Match})
|
||||
}
|
||||
|
||||
// Process
|
||||
errorList := []MatcherResult{}
|
||||
for _, error := range errors {
|
||||
errorList = append(errorList, MatcherResult{error.Error.ErrorName, error.Match})
|
||||
}
|
||||
|
||||
// Construct JSON response
|
||||
data := MatcherResults{
|
||||
Secrets: secrets,
|
||||
Parameters: parameters,
|
||||
FileType: filetype,
|
||||
Errors: errors,
|
||||
Infos: infos,
|
||||
Parameters: parameters,
|
||||
Errors: errorList,
|
||||
Infos: infoList,
|
||||
Secrets: secretList,
|
||||
}
|
||||
resp := &jsonData{
|
||||
URL: r.Request.URL.String(),
|
||||
|
||||
@@ -30,8 +30,8 @@ package scanner
|
||||
// Parameter = the name of the parameter.
|
||||
// Attacks = Possible attacks.
|
||||
type Parameter struct {
|
||||
Parameter string `json:"name,omitempty"`
|
||||
Attacks []string `json:"attacks,omitempty"`
|
||||
Parameter string
|
||||
Attacks []string
|
||||
}
|
||||
|
||||
// EndpointMatched struct.
|
||||
|
||||
@@ -27,8 +27,8 @@ package scanner
|
||||
// ErrorName = the name that identifies the error.
|
||||
// Regex = The regular expression to be matched.
|
||||
type Error struct {
|
||||
ErrorName string `json:"name,omitempty"`
|
||||
Regex []string `json:"regex,omitempty"`
|
||||
ErrorName string
|
||||
Regex []string
|
||||
}
|
||||
|
||||
// ErrorMatched struct.
|
||||
@@ -36,9 +36,9 @@ type Error struct {
|
||||
// Url = url in which the error is found.
|
||||
// Match = the string matching the regex.
|
||||
type ErrorMatched struct {
|
||||
Error Error `json:"details,omitempty"`
|
||||
URL string `json:"-"`
|
||||
Match string `json:"match,omitempty"`
|
||||
Error Error
|
||||
URL string
|
||||
Match string
|
||||
}
|
||||
|
||||
// GetErrorRegexes returns all the error structs.
|
||||
|
||||
@@ -30,8 +30,8 @@ package scanner
|
||||
// Extension = the file extension (doc, txt ..etc..).
|
||||
// Severity = the 'importance' of the file found. Higher is better.
|
||||
type FileType struct {
|
||||
Extension string `json:"extension,omitempty"`
|
||||
Severity int `json:"severity,omitempty"`
|
||||
Extension string
|
||||
Severity int
|
||||
}
|
||||
|
||||
// FileTypeMatched struct.
|
||||
|
||||
+5
-5
@@ -27,8 +27,8 @@ package scanner
|
||||
// Name = the name that identifies the information.
|
||||
// Regex = The regular expression to be matched.
|
||||
type Info struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Regex []string `json:"regex,omitempty"`
|
||||
Name string
|
||||
Regex []string
|
||||
}
|
||||
|
||||
// InfoMatched struct.
|
||||
@@ -36,9 +36,9 @@ type Info struct {
|
||||
// Url = url in which the information is found.
|
||||
// Match = the string matching the regex.
|
||||
type InfoMatched struct {
|
||||
Info Info `json:"details,omitempty"`
|
||||
URL string `json:"-"`
|
||||
Match string `json:"match,omitempty"`
|
||||
Info Info
|
||||
URL string
|
||||
Match string
|
||||
}
|
||||
|
||||
// GetInfoRegexes returns all the info structs.
|
||||
|
||||
@@ -33,11 +33,11 @@ package scanner
|
||||
// FalsePositives = A list of known false positives.
|
||||
// PoC = cli command to check if the secret is valid or not.
|
||||
type Secret struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Regex string `json:"regex"`
|
||||
FalsePositives []string `json:"-"`
|
||||
Poc string `json:"-"`
|
||||
Name string
|
||||
Description string
|
||||
Regex string
|
||||
FalsePositives []string
|
||||
Poc string
|
||||
}
|
||||
|
||||
// SecretMatched struct.
|
||||
@@ -45,9 +45,9 @@ type Secret struct {
|
||||
// Url = url in which is present the secret.
|
||||
// Match = the string matching the regex.
|
||||
type SecretMatched struct {
|
||||
Secret Secret `json:"details,omitempty"`
|
||||
URL string `json:"-"`
|
||||
Match string `json:"match,omitempty"`
|
||||
Secret Secret
|
||||
URL string
|
||||
Match string
|
||||
}
|
||||
|
||||
// GetSecretRegexes returns a slice of all
|
||||
|
||||
Reference in New Issue
Block a user