mirror of
https://github.com/securego/gosec.git
synced 2024-12-24 03:25:53 +00:00
Sarif provide Snippet with Issue.Code
* Provide Snippet with Issue.Code * Fix documentation
This commit is contained in:
parent
1325319325
commit
3a9a6ad8b3
2 changed files with 15 additions and 2 deletions
|
@ -58,6 +58,19 @@ func NewRegion(startLine int, endLine int, startColumn int, endColumn int, sourc
|
|||
}
|
||||
}
|
||||
|
||||
//WithSnippet defines the Snippet for the current Region
|
||||
func (r *Region) WithSnippet(snippet *ArtifactContent) *Region {
|
||||
r.Snippet = snippet
|
||||
return r
|
||||
}
|
||||
|
||||
//NewArtifactContent instantiate an ArtifactContent
|
||||
func NewArtifactContent(text string) *ArtifactContent {
|
||||
return &ArtifactContent{
|
||||
Text: text,
|
||||
}
|
||||
}
|
||||
|
||||
//NewTool instantiate a Tool
|
||||
func NewTool(driver *ToolComponent) *Tool {
|
||||
return &Tool{
|
||||
|
|
|
@ -172,12 +172,12 @@ func parseSarifRegion(issue *gosec.Issue) (*Region, error) {
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
col, err := strconv.Atoi(issue.Col)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return NewRegion(startLine, endLine, col, col, "go"), nil
|
||||
snippet := NewArtifactContent(issue.Code)
|
||||
return NewRegion(startLine, endLine, col, col, "go").WithSnippet(snippet), nil
|
||||
}
|
||||
|
||||
func getSarifLevel(s string) Level {
|
||||
|
|
Loading…
Reference in a new issue