@@ -174,49 +174,95 @@ func releaseHasUniqueIdentifier(payloadData interface{}, _ map[string]*layer4.Ch
174174 return layer4 .Passed , "All releases found have a unique name"
175175}
176176
177- func getLinks (data data.Payload ) []string {
177+ func getLinksFromProjectDocumentation (data data.Payload ) (urls []string ) {
178+ doc := data .Insights .Project .Documentation
179+ if doc == nil {
180+ return urls
181+ }
182+ if doc .DetailedGuide != nil {
183+ urls = append (urls , doc .DetailedGuide .String ())
184+ }
185+ if doc .CodeOfConduct != nil {
186+ urls = append (urls , doc .CodeOfConduct .String ())
187+ }
188+ if doc .QuickstartGuide != nil {
189+ urls = append (urls , doc .QuickstartGuide .String ())
190+ }
191+ if doc .ReleaseProcess != nil {
192+ urls = append (urls , doc .ReleaseProcess .String ())
193+ }
194+ if doc .SignatureVerification != nil {
195+ urls = append (urls , doc .SignatureVerification .String ())
196+ }
197+ return urls
198+ }
199+
200+ func getLinks (data data.Payload ) (links []string ) {
178201 si := data .Insights
179- links := []string {
180- si .Header .URL ,
181- si .Header .ProjectSISource ,
182- si .Project .Homepage ,
183- si .Project .Roadmap ,
184- si .Project .Funding ,
185- si .Project .Documentation .DetailedGuide ,
186- si .Project .Documentation .CodeOfConduct ,
187- si .Project .Documentation .QuickstartGuide ,
188- si .Project .Documentation .ReleaseProcess ,
189- si .Project .Documentation .SignatureVerification ,
190- si .Project .Vulnerability .BugBountyProgram ,
191- si .Project .Vulnerability .SecurityPolicy ,
192- si .Repository .URL ,
193- si .Repository .License .URL ,
194- si .Repository .Security .Assessments .Self .Evidence ,
202+
203+ if len (si .Header .URL .String ()) > 0 {
204+ links = append (links , si .Header .URL .String ())
195205 }
196- if data .RepositoryMetadata .OrganizationBlogURL () != nil {
197- links = append (links , * data .RepositoryMetadata .OrganizationBlogURL ())
206+
207+ if si .Header .ProjectSISource != nil && len (si .Header .ProjectSISource .String ()) > 0 {
208+ links = append (links , si .Header .ProjectSISource .String ())
198209 }
199- for _ , repo := range si .Project .Repositories {
200- links = append (links , repo .URL )
210+
211+ if si .Project != nil {
212+ for _ , repo := range si .Project .Repositories {
213+ links = append (links , repo .Url .String ())
214+ }
215+ links = append (links , getLinksFromProjectDocumentation (data )... )
216+ if si .Project .HomePage != nil {
217+ links = append (links , si .Project .HomePage .String ())
218+ }
219+ if si .Project .Roadmap != nil {
220+ links = append (links , si .Project .Roadmap .String ())
221+ }
222+ if si .Project .Funding != nil {
223+ links = append (links , si .Project .Funding .String ())
224+ }
225+
226+ if si .Project .VulnerabilityReporting .BugBountyProgram != nil {
227+ links = append (links , si .Project .VulnerabilityReporting .BugBountyProgram .String ())
228+ }
229+ if si .Project .VulnerabilityReporting .SecurityPolicy != nil {
230+ links = append (links , si .Project .VulnerabilityReporting .SecurityPolicy .String ())
231+ }
201232 }
233+ if si .Repository != nil {
234+ if len (si .Repository .Url .String ()) > 0 {
235+ links = append (links , si .Repository .Url .String ())
236+ }
237+ if len (si .Repository .License .Url .String ()) > 0 {
238+ links = append (links , si .Repository .License .Url .String ())
239+ }
202240
203- for _ , repo := range si .Repository .Security .Assessments .ThirdParty {
204- links = append (links , repo .Evidence )
241+ for _ , tool := range si .Repository .SecurityPosture .Tools {
242+ links = append (links , tool .Results .Adhoc .Location .String ())
243+ links = append (links , tool .Results .CI .Location .String ())
244+ links = append (links , tool .Results .Release .Location .String ())
245+ }
246+ for _ , repo := range si .Repository .SecurityPosture .Assessments .ThirdPartyAssessment {
247+ links = append (links , repo .Evidence .String ())
248+ }
249+ if si .Repository .SecurityPosture .Assessments .Self .Evidence != nil {
250+ links = append (links , si .Repository .SecurityPosture .Assessments .Self .Evidence .String ())
251+ }
205252 }
206253
207- for _ , tool := range si .Repository .Security .Tools {
208- links = append (links , tool .Results .Adhoc .Location )
209- links = append (links , tool .Results .CI .Location )
210- links = append (links , tool .Results .Release .Location )
254+ if data .RepositoryMetadata != nil && data .RepositoryMetadata .OrganizationBlogURL () != nil {
255+ links = append (links , * data .RepositoryMetadata .OrganizationBlogURL ())
211256 }
257+
212258 return links
213259}
214260
215261func insecureURI (uri string ) bool {
216- if ! strings .HasPrefix (uri , "https://" ) ||
217- ! strings .HasPrefix (uri , "ssh:" ) ||
218- ! strings .HasPrefix (uri , "git:" ) ||
219- ! strings .HasPrefix (uri , "git@" ) {
262+ if strings .HasPrefix (uri , "https://" ) ||
263+ strings .HasPrefix (uri , "ssh:" ) ||
264+ strings .HasPrefix (uri , "git:" ) ||
265+ strings .HasPrefix (uri , "git@" ) {
220266 return false
221267 }
222268 return true
@@ -260,7 +306,7 @@ func insightsHasSlsaAttestation(payloadData interface{}, _ map[string]*layer4.Ch
260306 return layer4 .Unknown , message
261307 }
262308
263- attestations := data .Insights .Repository .Release .Attestations
309+ attestations := data .Insights .Repository .ReleaseDetails .Attestations
264310
265311 for _ , attestation := range attestations {
266312 if attestation .PredicateURI == "https://slsa.dev/provenance/v1" {
@@ -275,17 +321,15 @@ func distributionPointsUseHTTPS(payloadData interface{}, _ map[string]*layer4.Ch
275321 if message != "" {
276322 return layer4 .Unknown , message
277323 }
278-
279- distributionPoints := data .Insights .Repository .Release .DistributionPoints
280-
281- if len (distributionPoints ) == 0 {
324+ if data .Insights .Repository .ReleaseDetails == nil || (data .Insights .Repository .ReleaseDetails != nil && len (data .Insights .Repository .ReleaseDetails .DistributionPoints ) == 0 ) {
282325 return layer4 .NotApplicable , "No official distribution points found in Security Insights data"
283326 }
327+ distributionPoints := data .Insights .Repository .ReleaseDetails .DistributionPoints
284328
285329 var badURIs []string
286330 for _ , point := range distributionPoints {
287- if insecureURI (point .URI ) {
288- badURIs = append (badURIs , point .URI )
331+ if insecureURI (point .Uri ) {
332+ badURIs = append (badURIs , point .Uri )
289333 }
290334 }
291335 if len (badURIs ) > 0 {
0 commit comments