detector

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectCurrentLine

func DetectCurrentLine(lines []string, str1, str2 string,
	curLine int, foundOne bool) (foundRes bool, lineRes int, breakRes bool)

DetectCurrentLine uses levenshtein distance to find the most acurate line for the vulnerability

func ExtractLineFragment

func ExtractLineFragment(line, substr string, key bool) string

ExtractLineFragment will prepare substr for line detection

func GenerateSubstrings

func GenerateSubstrings(key string, extractedString [][]string) (substr1Res, substr2Res string)

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

func GetAdjacentVulnLines(idx, adj int, lines []string) []model.CodeLine

GetAdjacentVulnLines is used to get the lines adjecent to the line that contains the vulnerability adj is the amount of lines wanted

func GetBracketValues

func GetBracketValues(expr string, list [][]string, restOfString string) [][]string

GetBracketValues gets values inside "{{ }}" ignoring any "{{" or "}}" inside

func SelectLineWithMinimumDistance

func SelectLineWithMinimumDistance(distances map[int]int, startingFrom int) int

SelectLineWithMinimumDistance will search a map of levenshtein distances to find the minimum distance

Types

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) 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) SetupLogs

func (d *DetectLine) SetupLogs(logger *zerolog.Logger)

SetupLogs will change the logger feild to be used in kindDetectLine DetectLine method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL