Documentation ¶
Index ¶
- func ExtractLineFragment(line, substr string, key bool) string
- func GenerateSubstrings(key string, extractedString [][]string) (substr1Res, substr2Res string)
- func GetAdjacentVulnLines(idx, adj int, lines []string) []model.CodeLine
- func GetBracketValues(expr string, list [][]string, restOfString string) [][]string
- func GetLineBySearchLine(pathComponents []string, file *model.FileMetadata) (int, error)
- func SelectLineWithMinimumDistance(distances map[int]int, startingFrom int) int
- type DefaultDetectLineResponse
- type DetectLine
- func (d *DetectLine) Add(detector kindDetectLine, kind model.FileKind) *DetectLine
- func (d *DetectLine) DetectLine(file *model.FileMetadata, searchKey string, logWithFields *zerolog.Logger) model.VulnerabilityLines
- func (d *DetectLine) GetAdjecent(file *model.FileMetadata, line int) model.VulnerabilityLines
- func (d *DetectLine) SetupLogs(logger *zerolog.Logger)
- func (d *DetectLine) SplitLines(file *model.FileMetadata) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractLineFragment ¶
ExtractLineFragment will prepare substr for line detection
func GenerateSubstrings ¶
GenerateSubstrings returns the substrings used for line searching depending on search key '.' is new line '=' is value in the same line '[]' is in the same line
func GetAdjacentVulnLines ¶
GetAdjacentVulnLines is used to get the lines adjacent to the line that contains the vulnerability adj is the amount of lines wanted
func GetBracketValues ¶
GetBracketValues gets values inside "{{ }}" ignoring any "{{" or "}}" inside
func GetLineBySearchLine ¶ added in v1.4.2
func GetLineBySearchLine(pathComponents []string, file *model.FileMetadata) (int, error)
GetLineBySearchLine makes use of the gjson pkg to find the line of a key in the original file with it's path given by a slice of strings
Types ¶
type DefaultDetectLineResponse ¶ added in v1.5.9
type DefaultDetectLineResponse struct { CurrentLine int IsBreak bool FoundAtLeastOne bool Lines []string ResolvedFile string ResolvedFiles map[string]model.ResolvedFileSplit }
DefaultDetectLineResponse is the default response for struct DetectLine
func (*DefaultDetectLineResponse) DetectCurrentLine ¶ added in v1.5.9
func (d *DefaultDetectLineResponse) DetectCurrentLine(str1, str2 string, recurseCount int) *DefaultDetectLineResponse
DetectCurrentLine uses levenshtein distance to find the most accurate line for the vulnerability
type DetectLine ¶
type DetectLine struct {
// contains filtered or unexported fields
}
DetectLine is a struct that associates a kindDetectLine to its FileKind
func NewDetectLine ¶
func NewDetectLine(outputLines int) *DetectLine
NewDetectLine creates a new DetectLine's reference
func (*DetectLine) Add ¶
func (d *DetectLine) Add(detector kindDetectLine, kind model.FileKind) *DetectLine
Add adds a new kindDetectLine to the caller and returns it
func (*DetectLine) DetectLine ¶
func (d *DetectLine) DetectLine(file *model.FileMetadata, searchKey string, logWithFields *zerolog.Logger) model.VulnerabilityLines
DetectLine will use the correct kindDetectLine according to the files kind if file kind is not in detectors default detect line is called
func (*DetectLine) GetAdjecent ¶ added in v1.4.2
func (d *DetectLine) GetAdjecent(file *model.FileMetadata, line int) model.VulnerabilityLines
GetAdjecent finds and returns the lines adjecent to the line containing the vulnerability
func (*DetectLine) SetupLogs ¶
func (d *DetectLine) SetupLogs(logger *zerolog.Logger)
SetupLogs will change the logger feild to be used in kindDetectLine DetectLine method
func (*DetectLine) SplitLines ¶ added in v1.4.2
func (d *DetectLine) SplitLines(file *model.FileMetadata) []string
SplitLines splits lines splits the file by lines based on the type of file