@@ -2,10 +2,8 @@ package main
22
33import (
44 "context"
5- "encoding/json"
65 "errors"
76 "fmt"
8- "os"
97 "slices"
108 "strings"
119
@@ -125,8 +123,6 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
125123 done = true
126124 continue
127125 }
128- l .Logger .Debug ("Processing repository:" , "repo_name" , repo .GetName ())
129-
130126 workflows , err := l .GatherConfiguredWorkflows (ctx , repo )
131127 if err != nil {
132128 l .Logger .Error ("Error gathering workflows" , "error" , err )
@@ -159,10 +155,8 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
159155 continue
160156 }
161157 name := b .GetName ()
162- l .Logger .Debug ("Found protected branch" , "branch" , name )
163158 branchNames = append (branchNames , name )
164159 protection , checks , err := l .GetBranchProtectionAndRequiredStatusCheck (ctx , repo , name )
165- l .Logger .Debug ("Fetched branch protection info" , "branch" , name , "protection" , protection , "checks" , checks )
166160 if err != nil {
167161 l .Logger .Trace ("Branch protection fetch failed" , "repo" , repo .GetFullName (), "branch" , name , "error" , err )
168162 continue
@@ -176,7 +170,6 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
176170 }
177171 // Fallback to default branch if none collected
178172 if len (requiredChecks ) == 0 {
179- l .Logger .Debug ("No protected branches with required status checks found, checking default branch" , "repo" , repo .GetFullName ())
180173 if def := repo .GetDefaultBranch (); def != "" {
181174 if protection , checks , err := l .GetBranchProtectionAndRequiredStatusCheck (ctx , repo , def ); err == nil {
182175 if protection != nil {
@@ -243,13 +236,6 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
243236 // Uncomment to check the data that is being passed through from
244237 // the client, as data formats are often slightly different than
245238 // the raw API endpoints
246- jsonData , _ := json .Marshal (data .OpenPullRequests )
247- // l.Logger.Debug("Data", "data", string(jsonData))
248- err = os .WriteFile (fmt .Sprintf ("./dist/%s.json" , repo .GetName ()), jsonData , 0o644 )
249- if err != nil {
250- l .Logger .Error ("failed to write file" , "error" , err )
251- }
252-
253239 evidences , err := l .EvaluatePolicies (ctx , data , req )
254240 if err != nil {
255241 l .Logger .Error ("Error evaluating policies" , "error" , err )
@@ -265,7 +251,6 @@ func (l *GithubReposPlugin) Eval(req *proto.EvalRequest, apiHelper runner.ApiHel
265251 }, err
266252 }
267253
268- l .Logger .Debug ("Successfully processed repository:" , "repo_name" , repo .GetName ())
269254 }
270255 }
271256
@@ -325,7 +310,7 @@ func (l *GithubReposPlugin) FetchRepositories(ctx context.Context, req *proto.Ev
325310 repochan <- repo
326311 }
327312
328- if resp .NextPage == 0 {
313+ if resp == nil || resp .NextPage == 0 {
329314 done = true
330315 } else {
331316 paginationOpts .Page = resp .NextPage
@@ -388,7 +373,7 @@ func (l *GithubReposPlugin) ListProtectedBranches(ctx context.Context, repo *git
388373 return nil , err
389374 }
390375 out = append (out , branches ... )
391- if resp .NextPage == 0 {
376+ if resp == nil || resp .NextPage == 0 {
392377 break
393378 }
394379 opts .Page = resp .NextPage
0 commit comments