@@ -18,6 +18,7 @@ import (
1818 "github.com/checkmarx/ast-cli/internal/params"
1919 "github.com/checkmarx/ast-cli/internal/wrappers"
2020 "github.com/checkmarx/ast-cli/internal/wrappers/mock"
21+ assertion "github.com/stretchr/testify/assert"
2122 "golang.org/x/text/cases"
2223 "golang.org/x/text/language"
2324 "gotest.tools/assert"
@@ -894,6 +895,15 @@ func assertTypePresentSarif(t *testing.T, resultType string, expectedResultTypeC
894895 fmt .Sprintf ("Expected %s result count to be %d, but found %d results" , resultType , expectedResultTypeCount , actualResultTypeCount ))
895896}
896897
898+ func assertURINonEmpty (t * testing.T ) {
899+ reportBytes , err := os .ReadFile (fileName + "." + printer .FormatSarif )
900+ assert .NilError (t , err , "Error reading SARIF file" )
901+ var scanResults * wrappers.SarifResultsCollection
902+ err = json .Unmarshal (reportBytes , & scanResults )
903+ assert .NilError (t , err , "Error unmarshalling SARIF results" )
904+ assertion .Contains (t , scanResults .Runs [0 ].Results [10 ].Locations [0 ].PhysicalLocation .ArtifactLocation .URI , "This alert has no associated file" )
905+ }
906+
897907func assertRulePresentSarif (t * testing.T , ruleID string , scanResultsCollection * wrappers.SarifResultsCollection ) {
898908 for i := range scanResultsCollection .Runs [0 ].Tool .Driver .Rules {
899909 rule := scanResultsCollection .Runs [0 ].Tool .Driver .Rules [i ]
@@ -1383,7 +1393,7 @@ func TestRunGetResultsByScanIdSonarFormat_SCSFlagEnabled_SCSPresentInReport(t *t
13831393 mock .SetScsMockVarsToDefault ()
13841394}
13851395
1386- func TestRunGetResultsByScanIdSarifFormat_SCSFlagEnabled_SCSPresentInReport (t * testing.T ) {
1396+ func TestRunGetResultsByScanIdSarifFormat_SCSFlagEnabled_SCSNonEmpty_URI_PresentInReport (t * testing.T ) {
13871397 clearFlags ()
13881398 mock .HasScs = true
13891399 mock .ScsScanPartial = false
@@ -1392,7 +1402,7 @@ func TestRunGetResultsByScanIdSarifFormat_SCSFlagEnabled_SCSPresentInReport(t *t
13921402 execCmdNilAssertion (t , "results" , "show" , "--scan-id" , "MOCK" , "--report-format" , "sarif" )
13931403 assertTypePresentSarif (t , params .SCSScorecardType , 1 )
13941404 assertTypePresentSarif (t , params .SCSSecretDetectionType , 2 )
1395-
1405+ assertURINonEmpty ( t )
13961406 removeFileBySuffix (t , printer .FormatSarif )
13971407 mock .SetScsMockVarsToDefault ()
13981408}
0 commit comments