mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
Add some comments
Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
parent
d1467ac998
commit
4d4e5949c6
2 changed files with 2 additions and 0 deletions
1
issue.go
1
issue.go
|
@ -131,6 +131,7 @@ func (c Score) String() string {
|
||||||
return "UNDEFINED"
|
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) {
|
func codeSnippet(file *os.File, start int64, end int64, n ast.Node) (string, error) {
|
||||||
if n == nil {
|
if n == nil {
|
||||||
return "", fmt.Errorf("invalid AST node provided")
|
return "", fmt.Errorf("invalid AST node provided")
|
||||||
|
|
|
@ -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 {
|
func printCodeSnippet(issue *gosec.Issue) string {
|
||||||
scanner := bufio.NewScanner(strings.NewReader(issue.Code))
|
scanner := bufio.NewScanner(strings.NewReader(issue.Code))
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
Loading…
Reference in a new issue