From fa7be5ac3c3dfaf4121ea564e25b829a647e6cb1 Mon Sep 17 00:00:00 2001 From: edoardottt Date: Sat, 3 Sep 2022 13:05:48 +0200 Subject: [PATCH] linter (godot) --- crawler/colly.go | 2 +- crawler/requests.go | 6 +++--- input/check.go | 4 ++-- input/flags.go | 4 ++-- output/color.go | 12 ++++++------ output/txt.go | 2 +- scanner/endpoints.go | 16 ++++++++-------- scanner/errors.go | 18 +++++++++--------- scanner/extensions.go | 16 ++++++++-------- scanner/info.go | 18 +++++++++--------- scanner/secrets.go | 24 ++++++++++++------------ utils/files.go | 8 ++++---- utils/slice.go | 8 ++++---- utils/urls.go | 24 ++++++++++++------------ 14 files changed, 81 insertions(+), 81 deletions(-) diff --git a/crawler/colly.go b/crawler/colly.go index bd45f04..58f665c 100644 --- a/crawler/colly.go +++ b/crawler/colly.go @@ -45,7 +45,7 @@ import ( //Crawler it's the actual crawler engine. //It controls all the behaviours of a scan -//(event handlers, secrets, errors, extensions and endpoints scanning) +//(event handlers, secrets, errors, extensions and endpoints scanning). func Crawler(target string, txt string, html string, delayTime int, concurrency int, ignore string, ignoreTxt string, cache bool, timeout int, intensive bool, rua bool, proxy string, insecure bool, secrets bool, secretsFile []string, plain bool, endpoints bool, diff --git a/crawler/requests.go b/crawler/requests.go index e855c3c..7566195 100644 --- a/crawler/requests.go +++ b/crawler/requests.go @@ -34,7 +34,7 @@ import ( ) //GetRequest performs a GET request and return -//a string (the body of the response) +//a string (the body of the response). func GetRequest(target string) (string, error) { resp, err := http.Get(target) if err != nil { @@ -57,7 +57,7 @@ func GetRequest(target string) (string, error) { //a string (the body of the response) //the map in the input should contains the data fields and values //in this way for example: -//{ email: test@example.com, password: stupid_pwd } +//{ email: test@example.com, password: stupid_pwd }. func PostRequest(target string, data map[string]string) (string, error) { postBody, _ := json.Marshal(data) responseBody := bytes.NewBuffer(postBody) @@ -80,7 +80,7 @@ func PostRequest(target string, data map[string]string) (string, error) { } //HeadRequest performs a HEAD request and return -//a string (the headers of the response) +//a string (the headers of the response). func HeadRequest(target string) (string, error) { resp, err := http.Head(target) if err != nil { diff --git a/input/check.go b/input/check.go index d9dfade..2897763 100644 --- a/input/check.go +++ b/input/check.go @@ -36,7 +36,7 @@ import ( //CheckDataPost should take as input a string and checks //if it's correctly formatted to be represented as post data -//TODO - for now cariddi sends only GET requests +//TODO - for now cariddi sends only GET requests. func CheckDataPost(input string) (map[string]string, error) { // ===== TODO ======= return map[string]string{}, nil @@ -55,7 +55,7 @@ func CheckOutputFile(input string) bool { return true } -//CheckFlags checks the flags taken as input +//CheckFlags checks the flags taken as input. func CheckFlags(flags Input) { if flags.TXT != "" { if !CheckOutputFile(flags.TXT) { diff --git a/input/flags.go b/input/flags.go index 72ce13c..f9a8677 100644 --- a/input/flags.go +++ b/input/flags.go @@ -30,8 +30,8 @@ import ( "flag" ) -//Input struct -//It contains all the possible options +//Input struct. +//It contains all the possible options. type Input struct { Version bool Delay int diff --git a/output/color.go b/output/color.go index 486c3c7..3b158ed 100644 --- a/output/color.go +++ b/output/color.go @@ -33,7 +33,7 @@ import ( ) //EncapsulateGreen takes as input a string and -//print a green prefix +//print a green prefix. func EncapsulateGreen(inp string) { // Create a custom print function for convenience green := color.New(color.FgGreen).PrintfFunc() @@ -42,7 +42,7 @@ func EncapsulateGreen(inp string) { } //EncapsulateRed takes as input a string and -//print a red prefix +//print a red prefix. func EncapsulateRed(inp string) { // Create a custom print function for convenience red := color.New(color.FgRed).PrintfFunc() @@ -51,7 +51,7 @@ func EncapsulateRed(inp string) { } //EncapsulateYellow takes as input a string and -//print a yellow prefix +//print a yellow prefix. func EncapsulateYellow(inp string) { // Create a custom print function for convenience yellow := color.New(color.FgYellow).PrintfFunc() @@ -60,7 +60,7 @@ func EncapsulateYellow(inp string) { } //EncapsulateCustomGreen takes as input a string and -//print it with the green color +//print it with the green color. func EncapsulateCustomGreen(alert string, inp string) { // Create a custom print function for convenience green := color.New(color.FgGreen).PrintfFunc() @@ -69,7 +69,7 @@ func EncapsulateCustomGreen(alert string, inp string) { } //EncapsulateCustomRed takes as input a string and -//print it with the red color +//print it with the red color. func EncapsulateCustomRed(alert string, inp string) { // Create a custom print function for convenience red := color.New(color.FgRed).PrintfFunc() @@ -78,7 +78,7 @@ func EncapsulateCustomRed(alert string, inp string) { } //EncapsulateCustomYellow takes as input a string and -//print it with the yellow color +//print it with the yellow color. func EncapsulateCustomYellow(alert string, inp string) { // Create a custom print function for convenience yellow := color.New(color.FgYellow).PrintfFunc() diff --git a/output/txt.go b/output/txt.go index 8c921ab..360b22d 100644 --- a/output/txt.go +++ b/output/txt.go @@ -32,7 +32,7 @@ import ( ) //AppendOutputToTxt opens the output file and append -//the string taken as input +//the string taken as input. func AppendOutputToTxt(output string, filename string) { file, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0644) if err != nil { diff --git a/scanner/endpoints.go b/scanner/endpoints.go index 3cdad3b..230649b 100644 --- a/scanner/endpoints.go +++ b/scanner/endpoints.go @@ -26,23 +26,23 @@ along with this program. If not, see http://www.gnu.org/licenses/. package scanner -//Parameter struct -// Parameter = the name of the parameter -// Attacks = Possible attacks +//Parameter struct. +// Parameter = the name of the parameter. +// Attacks = Possible attacks. type Parameter struct { Parameter string Attacks []string } -//EndpointMatched struct -// Parameters = a list of parameters in a particular endpoint -// Url = url (aka endpoint) +//EndpointMatched struct. +// Parameters = a list of parameters in a particular endpoint. +// Url = url (aka endpoint). type EndpointMatched struct { Parameters []Parameter URL string } -//GetJuicyParameters returns juicy parameters and their possible attacks +//GetJuicyParameters returns juicy parameters and their possible attacks. func GetJuicyParameters() []Parameter { var juicyParameters = []Parameter{ {"apikey", []string{"Info"}}, @@ -186,7 +186,7 @@ func GetJuicyParameters() []Parameter { return juicyParameters } -//RemovDuplicateEndpoints removes duplicate endpoints found +//RemovDuplicateEndpoints removes duplicate endpoints found. func RemovDuplicateEndpoints(input []EndpointMatched) []EndpointMatched { keys := make(map[string]bool) list := []EndpointMatched{} diff --git a/scanner/errors.go b/scanner/errors.go index 6fcd673..2958229 100644 --- a/scanner/errors.go +++ b/scanner/errors.go @@ -23,25 +23,25 @@ along with this program. If not, see http://www.gnu.org/licenses/. package scanner -//Error struct -// ErrorName = the name that identifies the error -// Regex = The regular expression to be matched +//Error struct. +// ErrorName = the name that identifies the error. +// Regex = The regular expression to be matched. type Error struct { ErrorName string Regex []string } -//ErrorMatched struct -// Error = Error struct -// Url = url in which the error is found -// Match = the string matching the regex +//ErrorMatched struct. +// Error = Error struct. +// Url = url in which the error is found. +// Match = the string matching the regex. type ErrorMatched struct { Error Error URL string Match string } -//GetErrorRegexes returns all the error structs +//GetErrorRegexes returns all the error structs. func GetErrorRegexes() []Error { var regexes = []Error{ { @@ -150,7 +150,7 @@ func GetErrorRegexes() []Error { return regexes } -//RemoveDuplicateErrors removes duplicates from Errors found +//RemoveDuplicateErrors removes duplicates from Errors found. func RemoveDuplicateErrors(input []ErrorMatched) []ErrorMatched { keys := make(map[string]bool) list := []ErrorMatched{} diff --git a/scanner/extensions.go b/scanner/extensions.go index 7337c96..36c9039 100644 --- a/scanner/extensions.go +++ b/scanner/extensions.go @@ -26,23 +26,23 @@ along with this program. If not, see http://www.gnu.org/licenses/. package scanner -//FileType struct -// Extension = the file extension (doc, txt ..etc..) -// Severity = the 'importance' of the file found. Higher is better +//FileType struct. +// Extension = the file extension (doc, txt ..etc..). +// Severity = the 'importance' of the file found. Higher is better. type FileType struct { Extension string Severity int } -//FileTypeMatched struct -// Filetype = Filetype struct -// Url = url of the file found +//FileTypeMatched struct. +// Filetype = Filetype struct. +// Url = url of the file found. type FileTypeMatched struct { Filetype FileType URL string } -//GetExtensions returns all the extension structs +//GetExtensions returns all the extension structs. func GetExtensions() []FileType { //extensions contains a list of known extensions //and the TYPICAL (also say `in general`) associated severity. @@ -111,7 +111,7 @@ func GetExtensions() []FileType { return extensions } -//RemoveDuplicateExtensions removes duplicates from Extensions found +//RemoveDuplicateExtensions removes duplicates from Extensions found. func RemoveDuplicateExtensions(input []FileTypeMatched) []FileTypeMatched { keys := make(map[string]bool) list := []FileTypeMatched{} diff --git a/scanner/info.go b/scanner/info.go index 805b67f..2d79b69 100644 --- a/scanner/info.go +++ b/scanner/info.go @@ -23,25 +23,25 @@ along with this program. If not, see http://www.gnu.org/licenses/. package scanner -//Info struct -// Name = the name that identifies the information -// Regex = The regular expression to be matched +//Info struct. +// Name = the name that identifies the information. +// Regex = The regular expression to be matched. type Info struct { Name string Regex []string } -//InfoMatched struct -// Info = Info struct -// Url = url in which the information is found -// Match = the string matching the regex +//InfoMatched struct. +// Info = Info struct. +// Url = url in which the information is found. +// Match = the string matching the regex. type InfoMatched struct { Info Info URL string Match string } -//GetInfoRegexes returns all the info structs +//GetInfoRegexes returns all the info structs. func GetInfoRegexes() []Info { var regexes = []Info{ { @@ -83,7 +83,7 @@ func GetInfoRegexes() []Info { return regexes } -//RemoveDuplicateInfos removes duplicates from Infos found +//RemoveDuplicateInfos removes duplicates from Infos found. func RemoveDuplicateInfos(input []InfoMatched) []InfoMatched { keys := make(map[string]bool) list := []InfoMatched{} diff --git a/scanner/secrets.go b/scanner/secrets.go index 4c9506e..f6098d7 100644 --- a/scanner/secrets.go +++ b/scanner/secrets.go @@ -26,12 +26,12 @@ along with this program. If not, see http://www.gnu.org/licenses/. package scanner -//Secret struct -// Name = the name that identifies the secret -// Description -// Regex = The regular expression matching the secret -// FalsePositives = A list of known false positives -// PoC = cli command to check if the secret is valid or not +//Secret struct. +// Name = the name that identifies the secret. +// Description. +// Regex = The regular expression matching the secret. +// FalsePositives = A list of known false positives. +// PoC = cli command to check if the secret is valid or not. type Secret struct { Name string Description string @@ -40,10 +40,10 @@ type Secret struct { Poc string } -//SecretMatched struct -// Secret = The secret matched (struct) -// Url = url in which is present the secret -// Match = the string matching the regex +//SecretMatched struct. +// Secret = The secret matched (struct). +// Url = url in which is present the secret. +// Match = the string matching the regex. type SecretMatched struct { Secret Secret URL string @@ -51,7 +51,7 @@ type SecretMatched struct { } //GetSecretRegexes returns a slice of all -//the secret structs +//the secret structs. func GetSecretRegexes() []Secret { var regexes = []Secret{ { @@ -342,7 +342,7 @@ func GetSecretRegexes() []Secret { return regexes } -//RemoveDuplicateSecrets removes duplicates from secrets found +//RemoveDuplicateSecrets removes duplicates from secrets found. func RemoveDuplicateSecrets(input []SecretMatched) []SecretMatched { keys := make(map[string]bool) list := []SecretMatched{} diff --git a/utils/files.go b/utils/files.go index b756280..76dbca2 100644 --- a/utils/files.go +++ b/utils/files.go @@ -37,7 +37,7 @@ import ( ) //CreateOutputFolder creates the output folder -//If it fails exits with an error message +//If it fails exits with an error message. func CreateOutputFolder() { //Create a folder/directory at a full qualified path err := os.Mkdir("output-cariddi", 0755) @@ -97,7 +97,7 @@ func CreateOutputFile(target string, subcommand string, format string) string { } //ReplaceBadCharacterOutput replaces forward-slashes -//with dashes (to avoid problems with output folder) +//with dashes (to avoid problems with output folder). func ReplaceBadCharacterOutput(input string) string { result := strings.ReplaceAll(input, "/", "-") return result @@ -123,7 +123,7 @@ func ReadFile(inputFile string) []string { return text } -//ElementExists returns whether the given file or directory exists +//ElementExists returns whether the given file or directory exists. func ElementExists(path string) (bool, error) { _, err := os.Stat(path) if err == nil { @@ -138,7 +138,7 @@ func ElementExists(path string) (bool, error) { } //ReadHTTPRequestFromFile reads from a file an HTTP -//request and returns a *http.Request object +//request and returns a *http.Request object. func ReadHTTPRequestFromFile(inputFile string) (*http.Request, error) { f, err := os.Open(inputFile) if err != nil { diff --git a/utils/slice.go b/utils/slice.go index 436249b..b42f621 100644 --- a/utils/slice.go +++ b/utils/slice.go @@ -32,7 +32,7 @@ import ( ) //RemoveDuplicateValues removes duplicates from a slice -//of strings +//of strings. func RemoveDuplicateValues(strSlice []string) []string { keys := make(map[string]bool) list := []string{} @@ -49,8 +49,8 @@ func RemoveDuplicateValues(strSlice []string) []string { //CheckInputArray checks the basic rules to //be valid and then returns the array as input. -// - Delete duplicates -// - Avoid empty strings +// - Delete duplicates. +// - Avoid empty strings. func CheckInputArray(input string) []string { delimiter := byte(',') sliceOut := strings.Split(input, string(delimiter)) @@ -69,7 +69,7 @@ func CheckInputArray(input string) []string { //CheckCookies checks if the string provided to the //-cookie option is valid. //format: "name1:value1;name2:value2" -//It returns a slice of Cookies +//It returns a slice of Cookies. func CheckCookies(input string) []*http.Cookie { var result []*http.Cookie if input == "" { diff --git a/utils/urls.go b/utils/urls.go index cd0b60f..e9cf8a2 100644 --- a/utils/urls.go +++ b/utils/urls.go @@ -35,7 +35,7 @@ import ( //GetHost takes as input a string and //tries to parse it as url, if it's a //well formatted url this function returns -//the host (the domain if you prefer) +//the host (the domain if you prefer). func GetHost(input string) string { u, err := url.Parse(input) if err != nil { @@ -48,7 +48,7 @@ func GetHost(input string) string { //GetProtocol takes as input a string and //tries to parse it as url, if it's a //well formatted url this function returns -//the protocol (the scheme if you prefer) +//the protocol (the scheme if you prefer). func GetProtocol(input string) string { u, err := url.Parse(input) if err != nil { @@ -61,7 +61,7 @@ func GetProtocol(input string) string { //GetRootHost takes as input a string and //tries to parse it as url, if it's a //well formatted url this function returns -//the second level domain +//the second level domain. func GetRootHost(input string) (string, error) { u, err := url.Parse(input) if err != nil { @@ -80,15 +80,15 @@ func GetRootHost(input string) (string, error) { //HasProtocol takes as input a string and //checks if it has a protocol ( like in a -//URI/URL) +//URI/URL). func HasProtocol(input string) bool { res := strings.Index(input, "://") return res >= 0 } //RemoveProtocol removes the protocol from -//the input string (something://...) -//If it's not present it returns the input +//the input string (something://...). +//If it's not present it returns the input. func RemoveProtocol(input string) string { res := strings.Index(input, "://") if res >= 0 { @@ -98,8 +98,8 @@ func RemoveProtocol(input string) string { return input } -//RemovePort removes port from the input string -//If it's not present it returns the input +//RemovePort removes port from the input string. +//If it's not present it returns the input. func RemovePort(input string) string { res := strings.Index(input, ":") if res >= 0 { @@ -111,7 +111,7 @@ func RemovePort(input string) string { //RetrieveParameters takes as input a string and //if it's correctly url-formatted returns a slice -//of strings that are the parameters of the URL +//of strings that are the parameters of the URL. func RetrieveParameters(input string) []string { var result []string @@ -129,7 +129,7 @@ func RetrieveParameters(input string) []string { } //AbsoluteURL takes as input a protocol, a domain and a path -//and returns the absolute URL with protocol + domain + path +//and returns the absolute URL with protocol + domain + path. func AbsoluteURL(protocol string, target string, path string) string { // if the path variable starts with a scheme, it means that the // path is itself an absolute path. @@ -144,7 +144,7 @@ func AbsoluteURL(protocol string, target string, path string) string { return protocol + "://" + target + "/" + path } -//SameDomain checks if two urls have the same domain +//SameDomain checks if two urls have the same domain. func SameDomain(url1 string, url2 string) bool { u1, err := url.Parse(url1) if err != nil { @@ -164,7 +164,7 @@ func SameDomain(url1 string, url2 string) bool { } //GetPath returns the path of the input string -//(if correctly URL-formatted) +//(if correctly URL-formatted). func GetPath(input string) (string, error) { u, err := url.Parse(input) if err != nil {