Sarif provide Snippet with Issue.Code

* Provide Snippet with Issue.Code

* Fix documentation
This commit is contained in:
Matthieu MOREL 2021-05-13 16:02:28 +02:00 committed by GitHub
parent 1325319325
commit 3a9a6ad8b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -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{

View file

@ -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 {