77 "strings"
88
99 "github.com/gemaraproj/go-gemara"
10+ "github.com/ossf/si-tooling/v2/si"
1011 "github.com/rhysd/actionlint"
1112
1213 "github.com/revanite-io/pvtr-github-repo/data"
@@ -185,48 +186,60 @@ func ReleaseHasUniqueIdentifier(payloadData any) (result gemara.Result, message
185186}
186187
187188func getLinks (data data.Payload ) []string {
188- si := data .Insights
189- links := []string {
190- si .Header .URL ,
191- si .Header .ProjectSISource ,
192- si .Project .Homepage ,
193- si .Project .Roadmap ,
194- si .Project .Funding ,
195- si .Project .Documentation .DetailedGuide ,
196- si .Project .Documentation .CodeOfConduct ,
197- si .Project .Documentation .QuickstartGuide ,
198- si .Project .Documentation .ReleaseProcess ,
199- si .Project .Documentation .SignatureVerification ,
200- si .Project .Vulnerability .BugBountyProgram ,
201- si .Project .Vulnerability .SecurityPolicy ,
202- si .Repository .URL ,
203- si .Repository .License .URL ,
204- si .Repository .Security .Assessments .Self .Evidence ,
189+ ins := data .Insights
190+ var links []string
191+
192+ addURL := func (u si.URL ) { links = append (links , string (u )) }
193+ addURLPtr := func (u * si.URL ) {
194+ if u != nil {
195+ links = append (links , string (* u ))
196+ }
205197 }
198+
199+ addURL (ins .Header .URL )
200+ addURLPtr (ins .Header .ProjectSISource )
201+ addURLPtr (ins .Project .HomePage )
202+ addURLPtr (ins .Project .Roadmap )
203+ addURLPtr (ins .Project .Funding )
204+ addURLPtr (ins .Project .Documentation .DetailedGuide )
205+ addURLPtr (ins .Project .Documentation .CodeOfConduct )
206+ addURLPtr (ins .Project .Documentation .QuickstartGuide )
207+ addURLPtr (ins .Project .Documentation .ReleaseProcess )
208+ addURLPtr (ins .Project .Documentation .SignatureVerification )
209+ addURLPtr (ins .Project .VulnerabilityReporting .BugBountyProgram )
210+ addURLPtr (ins .Project .VulnerabilityReporting .Policy )
211+ addURL (ins .Repository .Url )
212+ addURL (ins .Repository .License .Url )
213+ addURLPtr (ins .Repository .SecurityPosture .Assessments .Self .Evidence )
214+
206215 if data .RepositoryMetadata .OrganizationBlogURL () != nil {
207216 links = append (links , * data .RepositoryMetadata .OrganizationBlogURL ())
208217 }
209- for _ , repo := range si .Project .Repositories {
210- links = append ( links , repo .URL )
218+ for _ , repo := range ins .Project .Repositories {
219+ addURL ( repo .Url )
211220 }
212-
213- for _ , repo := range si .Repository .Security .Assessments .ThirdParty {
214- links = append (links , repo .Evidence )
221+ for _ , assessment := range ins .Repository .SecurityPosture .Assessments .ThirdPartyAssessment {
222+ addURLPtr (assessment .Evidence )
215223 }
216-
217- for _ , tool := range si .Repository .Security .Tools {
218- links = append (links , tool .Results .Adhoc .Location )
219- links = append (links , tool .Results .CI .Location )
220- links = append (links , tool .Results .Release .Location )
224+ for _ , tool := range ins .Repository .SecurityPosture .Tools {
225+ if tool .Results .Adhoc != nil {
226+ addURL (tool .Results .Adhoc .Location )
227+ }
228+ if tool .Results .CI != nil {
229+ addURL (tool .Results .CI .Location )
230+ }
231+ if tool .Results .Release != nil {
232+ addURL (tool .Results .Release .Location )
233+ }
221234 }
222235 return links
223236}
224237
225238func insecureURI (uri string ) bool {
226- if ! strings .HasPrefix (uri , "https://" ) ||
227- ! strings .HasPrefix (uri , "ssh:" ) ||
228- ! strings .HasPrefix (uri , "git:" ) ||
229- ! strings .HasPrefix (uri , "git@" ) {
239+ if strings .HasPrefix (uri , "https://" ) ||
240+ strings .HasPrefix (uri , "ssh:" ) ||
241+ strings .HasPrefix (uri , "git:" ) ||
242+ strings .HasPrefix (uri , "git@" ) {
230243 return false
231244 }
232245 return true
@@ -270,7 +283,7 @@ func InsightsHasSlsaAttestation(payloadData any) (result gemara.Result, message
270283 return gemara .Unknown , message , confidence
271284 }
272285
273- attestations := data .Insights .Repository .Release .Attestations
286+ attestations := data .Insights .Repository .ReleaseDetails .Attestations
274287
275288 for _ , attestation := range attestations {
276289 if attestation .PredicateURI == "https://slsa.dev/provenance/v1" {
@@ -286,16 +299,16 @@ func DistributionPointsUseHTTPS(payloadData any) (result gemara.Result, message
286299 return gemara .Unknown , message , confidence
287300 }
288301
289- distributionPoints := data .Insights .Repository .Release .DistributionPoints
302+ distributionPoints := data .Insights .Repository .ReleaseDetails .DistributionPoints
290303
291304 if len (distributionPoints ) == 0 {
292305 return gemara .NotApplicable , "No official distribution points found in Security Insights data" , confidence
293306 }
294307
295308 var badURIs []string
296309 for _ , point := range distributionPoints {
297- if insecureURI (point .URI ) {
298- badURIs = append (badURIs , point .URI )
310+ if insecureURI (point .Uri ) {
311+ badURIs = append (badURIs , point .Uri )
299312 }
300313 }
301314 if len (badURIs ) > 0 {
0 commit comments