Skip to content

Commit

Permalink
fix: Add pagination to collaborators collector (#275)
Browse files Browse the repository at this point in the history
* fix: Fix typo in deletion protection policy

* fix: Add pagination to collaborators collector

---------

Co-authored-by: noamd-legit <[email protected]>
  • Loading branch information
JakubBiel and noamd-legit authored Dec 11, 2023
1 parent 0d52c90 commit 861ecbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/collectors/github/repository_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,15 @@ func (rc *repositoryCollector) withVulnerabilityAlerts(repo ghcollected.Reposito
}

func (rc *repositoryCollector) withRepoCollaborators(repo ghcollected.Repository, org string) ghcollected.Repository {
users, _, err := rc.Client.Client().Repositories.ListCollaborators(rc.Context, org, repo.Repository.Name, &github.ListCollaboratorsOptions{})
users, err := pagination.New[*github.User](rc.Client.Client().Repositories.ListCollaborators, &github.ListCollaboratorsOptions{}).Sync(rc.Context, org, repo.Repository.Name)
if err != nil {
perm := collectors.NewMissingPermission(permissions.RepoAdmin, collectors.FullRepoName(org, repo.Repository.Name),
"Cannot read repository collaborators", namespace.Repository)
rc.IssueMissingPermissions(perm)
return repo
}

repo.Collaborators = users
repo.Collaborators = users.Collected
return repo
}

Expand Down
2 changes: 1 addition & 1 deletion policies/github/repository.rego
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ missing_default_branch_protection_deletion := false {
missing_default_branch_protection_deletion := false {
some index
rule := input.rules_set[index]
rule.type == "deletions"
rule.type == "deletion"
}

# METADATA
Expand Down

0 comments on commit 861ecbb

Please sign in to comment.