Skip to content

Commit 88da48d

Browse files
authored
chore(deps): upgrade ossf/si-tooling/v2 to v2.2.0 (#237)
1 parent 963507b commit 88da48d

File tree

16 files changed

+195
-168
lines changed

16 files changed

+195
-168
lines changed

data/rest-data.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,28 @@ func (r *RestData) loadSecurityInsights() {
239239
r.Config.Logger.Error(fmt.Sprintf("failed to read security insights file: %s", err.Error()))
240240
r.InsightsError = true
241241
}
242-
return
242+
}
243+
r.ensureInsightsInitialized()
244+
}
245+
246+
func (r *RestData) ensureInsightsInitialized() {
247+
if r.Insights.Repository == nil {
248+
r.Insights.Repository = &si.Repository{}
249+
}
250+
if r.Insights.Project == nil {
251+
r.Insights.Project = &si.Project{}
252+
}
253+
if r.Insights.Repository.Documentation == nil {
254+
r.Insights.Repository.Documentation = &si.RepositoryDocumentation{}
255+
}
256+
if r.Insights.Repository.ReleaseDetails == nil {
257+
r.Insights.Repository.ReleaseDetails = &si.ReleaseDetails{}
258+
}
259+
if r.Insights.Project.Documentation == nil {
260+
r.Insights.Project.Documentation = &si.ProjectDocumentation{}
261+
}
262+
if r.Insights.Project.VulnerabilityReporting.Contact == nil {
263+
r.Insights.Project.VulnerabilityReporting.Contact = &si.Contact{}
243264
}
244265
}
245266

data/rest_data_mock.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func NewPayloadWithHTTPMock(base Payload, body []byte, statusCode int, httpErr e
2929
if base.RestData == nil {
3030
base.RestData = &RestData{}
3131
}
32+
base.ensureInsightsInitialized()
3233
base.HttpClient = mock
3334
return base
3435
}

data/security-posture.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ func buildSecurityPosture(repository *github.Repository, rd RestData) (SecurityP
3838
}
3939

4040
func insightsClaimsSecretsTooling(insights si.SecurityInsights) bool {
41-
if insights.Repository.Security.Tools == nil {
41+
if insights.Repository.SecurityPosture.Tools == nil {
4242
return false
4343
}
44-
for _, tool := range insights.Repository.Security.Tools {
44+
for _, tool := range insights.Repository.SecurityPosture.Tools {
4545
if tool.Type == "secret-scanning" {
4646
return true
4747
}

data/security-posture_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ func TestBuildSecurityPosture_SecretScanningEnabled(t *testing.T) {
3939
},
4040
},
4141
}
42-
rd := RestData{}
42+
rd := RestData{
43+
Insights: si.SecurityInsights{
44+
Repository: &si.Repository{},
45+
},
46+
}
4347
sp, err := buildSecurityPosture(repo, rd)
4448
assert.NoError(t, err)
4549
assert.True(t, sp.PreventsPushingSecrets())
@@ -56,9 +60,9 @@ func TestBuildSecurityPosture_SecretScanningDisabledButInsightsTooling(t *testin
5660
}
5761
rd := RestData{
5862
Insights: si.SecurityInsights{
59-
Repository: si.Repository{
60-
Security: si.SecurityInfo{
61-
Tools: []si.Tool{
63+
Repository: &si.Repository{
64+
SecurityPosture: si.SecurityPosture{
65+
Tools: []si.SecurityTool{
6266
{Type: "secret-scanning"},
6367
},
6468
},
@@ -73,9 +77,9 @@ func TestBuildSecurityPosture_SecretScanningDisabledButInsightsTooling(t *testin
7377

7478
func TestInsightsClaimsSecretsTooling(t *testing.T) {
7579
insights := si.SecurityInsights{
76-
Repository: si.Repository{
77-
Security: si.SecurityInfo{
78-
Tools: []si.Tool{
80+
Repository: &si.Repository{
81+
SecurityPosture: si.SecurityPosture{
82+
Tools: []si.SecurityTool{
7983
{Type: "secret-scanning"},
8084
{Type: "other-tool"},
8185
},
@@ -84,11 +88,11 @@ func TestInsightsClaimsSecretsTooling(t *testing.T) {
8488
}
8589
assert.True(t, insightsClaimsSecretsTooling(insights))
8690

87-
insights.Repository.Security.Tools = []si.Tool{
91+
insights.Repository.SecurityPosture.Tools = []si.SecurityTool{
8892
{Type: "other-tool"},
8993
}
9094
assert.False(t, insightsClaimsSecretsTooling(insights))
9195

92-
insights.Repository.Security.Tools = nil
96+
insights.Repository.SecurityPosture.Tools = nil
9397
assert.False(t, insightsClaimsSecretsTooling(insights))
9498
}

evaluation_plans/osps/build_release/steps.go

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
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

187188
func 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

225238
func 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 {

evaluation_plans/osps/docs/steps.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func HasUserGuides(payloadData any) (result gemara.Result, message string, confi
2626
return gemara.Unknown, message, confidence
2727
}
2828

29-
if data.Insights.Project.Documentation.DetailedGuide == "" {
29+
if data.Insights.Project.Documentation.DetailedGuide == nil {
3030
return gemara.Failed, "User guide was NOT specified in Security Insights data", confidence
3131
}
3232

@@ -39,7 +39,7 @@ func AcceptsVulnReports(payloadData any) (result gemara.Result, message string,
3939
return gemara.Unknown, message, confidence
4040
}
4141

42-
if data.Insights.Project.Vulnerability.ReportsAccepted {
42+
if data.Insights.Project.VulnerabilityReporting.ReportsAccepted {
4343
return gemara.Passed, "Repository accepts vulnerability reports", confidence
4444
}
4545

@@ -52,7 +52,7 @@ func HasSignatureVerificationGuide(payloadData any) (result gemara.Result, messa
5252
return gemara.Unknown, message, confidence
5353
}
5454

55-
if data.Insights.Project.Documentation.SignatureVerification == "" {
55+
if data.Insights.Project.Documentation.SignatureVerification == nil {
5656
return gemara.Failed, "Signature verification guide was NOT specified in Security Insights data", confidence
5757
}
5858

@@ -65,7 +65,7 @@ func HasDependencyManagementPolicy(payloadData any) (result gemara.Result, messa
6565
return gemara.Unknown, message, confidence
6666
}
6767

68-
if data.Insights.Repository.Documentation.DependencyManagement == "" {
68+
if data.Insights.Repository.Documentation.DependencyManagementPolicy == nil {
6969
return gemara.Failed, "Dependency management policy was NOT specified in Security Insights data", confidence
7070
}
7171

@@ -78,7 +78,7 @@ func HasIdentityVerificationGuide(payloadData any) (result gemara.Result, messag
7878
return gemara.Unknown, message, confidence
7979
}
8080

81-
if data.Insights.Project.Documentation.SignatureVerification == "" {
81+
if data.Insights.Project.Documentation.SignatureVerification == nil {
8282
return gemara.Failed, "Identity verification guide was NOT specified in Security Insights data (checked signature-verification field)", confidence
8383
}
8484

evaluation_plans/osps/governance/steps.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func HasRolesAndResponsibilities(payloadData any) (result gemara.Result, message
3737
return gemara.Unknown, message, confidence
3838
}
3939

40-
if data.Insights.Repository.Documentation.Governance == "" {
40+
if data.Insights.Repository.Documentation.Governance == nil {
4141
return gemara.Failed, "Roles and responsibilities were NOT specified in Security Insights data", confidence
4242
}
4343

@@ -50,11 +50,11 @@ func HasContributionGuide(payloadData any) (result gemara.Result, message string
5050
return gemara.Unknown, message, confidence
5151
}
5252

53-
if data.Insights.Project.Documentation.CodeOfConduct != "" && data.Insights.Repository.Documentation.Contributing != "" {
53+
if data.Insights.Project.Documentation.CodeOfConduct != nil && data.Insights.Repository.Documentation.ContributingGuide != nil {
5454
return gemara.Passed, "Contributing guide specified in Security Insights data (Bonus: code of conduct location also specified)", confidence
5555
}
5656

57-
if data.Repository.ContributingGuidelines.Body != "" && data.Insights.Project.Documentation.CodeOfConduct != "" {
57+
if data.Repository.ContributingGuidelines.Body != "" && data.Insights.Project.Documentation.CodeOfConduct != nil {
5858
return gemara.Passed, "Contributing guide was found via GitHub API (Bonus: code of conduct was specified in Security Insights data)", confidence
5959
}
6060

@@ -73,7 +73,7 @@ func HasContributionReviewPolicy(payloadData any) (result gemara.Result, message
7373
if !data.IsCodeRepo {
7474
return gemara.NotApplicable, "Repository contains no code - skipping code contribution policy check", confidence
7575
}
76-
if data.Insights.Repository.Documentation.ReviewPolicy != "" {
76+
if data.Insights.Repository.Documentation.ReviewPolicy != nil {
7777
return gemara.Passed, "Code review guide was specified in Security Insights data", confidence
7878
}
7979

evaluation_plans/osps/quality/steps_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ func Test_InsightsListsRepositories(t *testing.T) {
2020
payload: data.Payload{
2121
RestData: &data.RestData{
2222
Insights: si.SecurityInsights{
23-
Project: si.Project{
24-
Repositories: []si.Repo{
25-
si.Repo{
26-
URL: "https://github.com/org/repo",
23+
Project: &si.Project{
24+
Repositories: []si.ProjectRepository{
25+
{
26+
Url: "https://github.com/org/repo",
2727
},
2828
},
2929
},
@@ -38,8 +38,8 @@ func Test_InsightsListsRepositories(t *testing.T) {
3838
payload: data.Payload{
3939
RestData: &data.RestData{
4040
Insights: si.SecurityInsights{
41-
Project: si.Project{
42-
Repositories: []si.Repo{},
41+
Project: &si.Project{
42+
Repositories: []si.ProjectRepository{},
4343
},
4444
},
4545
},
@@ -51,7 +51,9 @@ func Test_InsightsListsRepositories(t *testing.T) {
5151
name: "insights is nil",
5252
payload: data.Payload{
5353
RestData: &data.RestData{
54-
Insights: si.SecurityInsights{},
54+
Insights: si.SecurityInsights{
55+
Project: &si.Project{},
56+
},
5557
},
5658
},
5759
wantResult: gemara.Failed,

evaluation_plans/osps/sec_assessment/steps.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func HasDesignDocumentation(payloadData any) (result gemara.Result, message stri
6565
}
6666

6767
// Fallback: check if DetailedGuide is specified in Security Insights
68-
if data.RestData != nil && data.Insights.Project.Documentation.DetailedGuide != "" {
68+
if data.RestData != nil && data.Insights.Project.Documentation.DetailedGuide != nil {
6969
return gemara.NeedsReview, "No design documentation file found, but detailed guide specified in Security Insights - manual review needed to confirm design documentation with actions and actors", confidence
7070
}
7171

0 commit comments

Comments
 (0)