diff --git a/issue.go b/issue.go index 1668baa..aa58c34 100644 --- a/issue.go +++ b/issue.go @@ -131,6 +131,7 @@ func (c Score) String() string { return "UNDEFINED" } +// codeSnippet extracts a code snippet based on the ast reference func codeSnippet(file *os.File, start int64, end int64, n ast.Node) (string, error) { if n == nil { return "", fmt.Errorf("invalid AST node provided") diff --git a/output/formatter.go b/output/formatter.go index 7d7f18f..2159a0e 100644 --- a/output/formatter.go +++ b/output/formatter.go @@ -322,6 +322,7 @@ func highlight(t string, s gosec.Score) string { } } +// printCodeSnippet prints the code snippet from the issue by adding a marker to the affected line func printCodeSnippet(issue *gosec.Issue) string { scanner := bufio.NewScanner(strings.NewReader(issue.Code)) var buf bytes.Buffer