Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions controllers/scan_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"fmt"
"log/slog"
"net/http"
"time"

cdx "github.com/CycloneDX/cyclonedx-go"
Expand Down Expand Up @@ -404,6 +405,9 @@ func (s *ScanController) FirstPartyVulnScan(ctx shared.Context) error {

var sarifScan sarif.SarifSchema210Json

var maxSize int64 = 16 * 1024 * 1024 //Max Upload Size 16mb

ctx.Request().Body = http.MaxBytesReader(ctx.Response(), ctx.Request().Body, maxSize)
defer ctx.Request().Body.Close()

if err := ctx.Bind(&sarifScan); err != nil {
Expand Down
29 changes: 23 additions & 6 deletions services/scan_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,29 @@ func (s *scanService) HandleFirstPartyVulnResult(ctx context.Context, org models
loc := result.Locations[0]
firstPartyVulnerability.URI = utils.OrDefault(loc.PhysicalLocation.ArtifactLocation.URI, "")

snippetContent := dtos.SnippetContent{
StartLine: utils.OrDefault(loc.PhysicalLocation.Region.StartLine, 0),
EndLine: utils.OrDefault(loc.PhysicalLocation.Region.EndLine, 0),
StartColumn: utils.OrDefault(loc.PhysicalLocation.Region.StartColumn, 0),
EndColumn: utils.OrDefault(loc.PhysicalLocation.Region.EndColumn, 0),
Snippet: utils.OrDefault(loc.PhysicalLocation.Region.Snippet.Text, ""),
var snippetContent dtos.SnippetContent

if loc.PhysicalLocation.Region == nil {
snippetContent = dtos.SnippetContent{
StartLine: 0,
EndLine: 0,
StartColumn: 0,
EndColumn: 0,
Snippet: "",
}
} else {
var checkedSnippet = ""
if loc.PhysicalLocation.Region.Snippet != nil {
checkedSnippet = utils.OrDefault(loc.PhysicalLocation.Region.Snippet.Text, "")
}

snippetContent = dtos.SnippetContent{
StartLine: utils.OrDefault(loc.PhysicalLocation.Region.StartLine, 0),
EndLine: utils.OrDefault(loc.PhysicalLocation.Region.EndLine, 0),
StartColumn: utils.OrDefault(loc.PhysicalLocation.Region.StartColumn, 0),
EndColumn: utils.OrDefault(loc.PhysicalLocation.Region.EndColumn, 0),
Snippet: checkedSnippet,
}
}

hash = firstPartyVulnerability.CalculateHash()
Expand Down
Loading