88 "time"
99
1010 "github.com/google/go-github/v69/github"
11- "github.com/slsa-framework/slsa-source-poc/sourcetool/pkg/slsa_types "
11+ "github.com/slsa-framework/slsa-source-poc/sourcetool/pkg/slsa "
1212)
1313
1414type actor struct {
@@ -69,7 +69,7 @@ type GhControlStatus struct {
6969 ActivityType string
7070 // The controls that are enabled according to the GitHub API.
7171 // May not include other controls like if we have provenance.
72- Controls slsa_types .Controls
72+ Controls slsa .Controls
7373}
7474
7575func (ghc * GitHubConnection ) ruleMeetsRequiresReview (rule * github.PullRequestBranchRule ) bool {
@@ -80,7 +80,7 @@ func (ghc *GitHubConnection) ruleMeetsRequiresReview(rule *github.PullRequestBra
8080}
8181
8282// Computes the continuity control returning nil if it's not enabled.
83- func (ghc * GitHubConnection ) computeContinuityControl (ctx context.Context , commit string , rules * github.BranchRules , activity * activity ) (* slsa_types .Control , error ) {
83+ func (ghc * GitHubConnection ) computeContinuityControl (ctx context.Context , commit string , rules * github.BranchRules , activity * activity ) (* slsa .Control , error ) {
8484 oldestDeletion , err := ghc .getOldestActiveRule (ctx , rules .Deletion )
8585 if err != nil {
8686 return nil , err
@@ -107,7 +107,7 @@ func (ghc *GitHubConnection) computeContinuityControl(ctx context.Context, commi
107107 return nil , fmt .Errorf ("commit %s created before (%v) the rule was enabled (%v), that shouldn't happen" , commit , activity .Timestamp , newestRule .UpdatedAt .Time )
108108 }
109109
110- return & slsa_types .Control {Name : slsa_types .ContinuityEnforced , Since : newestRule .UpdatedAt .Time }, nil
110+ return & slsa .Control {Name : slsa .ContinuityEnforced , Since : newestRule .UpdatedAt .Time }, nil
111111}
112112
113113func enforcesTagHygiene (ruleset * github.RepositoryRuleset ) bool {
@@ -123,7 +123,7 @@ func enforcesTagHygiene(ruleset *github.RepositoryRuleset) bool {
123123 return false
124124}
125125
126- func (ghc * GitHubConnection ) computeTagHygieneControl (ctx context.Context , commit string , allRulesets []* github.RepositoryRuleset , activityTime * time.Time ) (* slsa_types .Control , error ) {
126+ func (ghc * GitHubConnection ) computeTagHygieneControl (ctx context.Context , commit string , allRulesets []* github.RepositoryRuleset , activityTime * time.Time ) (* slsa .Control , error ) {
127127 var validRuleset * github.RepositoryRuleset
128128 for _ , ruleset := range allRulesets {
129129 if * ruleset .Target != github .RulesetTargetTag {
@@ -158,11 +158,11 @@ func (ghc *GitHubConnection) computeTagHygieneControl(ctx context.Context, commi
158158 return nil , nil
159159 }
160160
161- return & slsa_types .Control {Name : slsa_types .TagHygiene , Since : validRuleset .UpdatedAt .Time }, nil
161+ return & slsa .Control {Name : slsa .TagHygiene , Since : validRuleset .UpdatedAt .Time }, nil
162162}
163163
164164// Computes the review control returning nil if it's not enabled.
165- func (ghc * GitHubConnection ) computeReviewControl (ctx context.Context , rules []* github.PullRequestBranchRule ) (* slsa_types .Control , error ) {
165+ func (ghc * GitHubConnection ) computeReviewControl (ctx context.Context , rules []* github.PullRequestBranchRule ) (* slsa .Control , error ) {
166166 var oldestActive * github.RepositoryRuleset
167167 for _ , rule := range rules {
168168 if ghc .ruleMeetsRequiresReview (rule ) {
@@ -179,16 +179,16 @@ func (ghc *GitHubConnection) computeReviewControl(ctx context.Context, rules []*
179179 }
180180
181181 if oldestActive != nil {
182- return & slsa_types .Control {Name : slsa_types .ReviewEnforced , Since : oldestActive .UpdatedAt .Time }, nil
182+ return & slsa .Control {Name : slsa .ReviewEnforced , Since : oldestActive .UpdatedAt .Time }, nil
183183 }
184184
185185 return nil , nil
186186}
187187
188- func (ghc * GitHubConnection ) computeRequiredChecks (ctx context.Context , ghCheckRules []* github.RequiredStatusChecksBranchRule ) ([]* slsa_types .Control , error ) {
188+ func (ghc * GitHubConnection ) computeRequiredChecks (ctx context.Context , ghCheckRules []* github.RequiredStatusChecksBranchRule ) ([]* slsa .Control , error ) {
189189 // Only return the checks we're happy about.
190190 // For now that's only stuff from the GitHub Actions app.
191- requiredChecks := []* slsa_types .Control {}
191+ requiredChecks := []* slsa .Control {}
192192 for _ , ghCheckRule := range ghCheckRules {
193193 ruleset , _ , err := ghc .Client ().Repositories .GetRuleset (ctx , ghc .Owner (), ghc .Repo (), ghCheckRule .RulesetID , false )
194194 if err != nil {
@@ -204,7 +204,7 @@ func (ghc *GitHubConnection) computeRequiredChecks(ctx context.Context, ghCheckR
204204 // Ignore untrusted integration id.
205205 continue
206206 }
207- requiredChecks = append (requiredChecks , & slsa_types .Control {
207+ requiredChecks = append (requiredChecks , & slsa .Control {
208208 Name : CheckNameToControlName (check .Context ),
209209 Since : ruleset .UpdatedAt .Time ,
210210 })
@@ -242,7 +242,7 @@ func (ghc *GitHubConnection) GetBranchControls(ctx context.Context, commit, ref
242242 CommitPushTime : activity .Timestamp ,
243243 ActivityType : activity .ActivityType ,
244244 ActorLogin : activity .Actor .Login ,
245- Controls : slsa_types .Controls {}}
245+ Controls : slsa .Controls {}}
246246
247247 branch := GetBranchFromRef (ref )
248248 if branch == "" {
@@ -289,7 +289,7 @@ func (ghc *GitHubConnection) GetBranchControls(ctx context.Context, commit, ref
289289func (ghc * GitHubConnection ) GetTagControls (ctx context.Context , commit , ref string ) (* GhControlStatus , error ) {
290290 controlStatus := GhControlStatus {
291291 CommitPushTime : time .Now (),
292- Controls : slsa_types .Controls {}}
292+ Controls : slsa .Controls {}}
293293
294294 allRulesets , _ , err := ghc .Client ().Repositories .GetAllRulesets (ctx , ghc .Owner (), ghc .Repo (), true )
295295 if err != nil {
0 commit comments