Skip to content

Commit

Permalink
⭐️ Optimized fields for github provider (#4672)
Browse files Browse the repository at this point in the history
* Add fields to fetch suport md file and code of conduct

It should be more efficient to fetch a single file than to try to list
all the files and then try to have cnquery filter for it.

* Add field for admin collaborators

This should list fewer collaborators than trying to list all of them.
Useful for queries that only care about admins

* Add field for security.md file

* Tim's comments about adding File suffix

* Update providers/github/resources/github.lr

Co-authored-by: Letha <[email protected]>

---------

Co-authored-by: Tim Smith <[email protected]>
Co-authored-by: Letha <[email protected]>
  • Loading branch information
3 people authored Sep 23, 2024
1 parent 331a6c4 commit d135687
Show file tree
Hide file tree
Showing 4 changed files with 355 additions and 3 deletions.
12 changes: 11 additions & 1 deletion providers/github/resources/github.lr
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ private github.repository @defaults("fullName") {
commits() []github.commit
// List of contributors for the repository
contributors() []github.user
// List of collaborators for the repository
// List of all collaborators for the repository
collaborators() []github.collaborator
// List of admin collaborators for the repository
adminCollaborators() []github.collaborator
// List of files in the repository
files() []github.file
// List of releases for the repository
Expand All @@ -344,6 +346,12 @@ private github.repository @defaults("fullName") {
closedIssues() []github.issue
// Repository license
license() github.license
// Repository code of conduct
codeOfConductFile() github.file
// Repository support file
supportFile() github.file
// Repository security file
securityFile() github.file
}

// GitHub license
Expand Down Expand Up @@ -380,6 +388,8 @@ private github.file @defaults("name type") {
content() string
// File download URL
downloadUrl string
// Whether the file exists in the repository
exists bool
}

// GitHub release
Expand Down
110 changes: 109 additions & 1 deletion providers/github/resources/github.lr.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions providers/github/resources/github.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ resources:
content: {}
downloadUrl:
min_mondoo_version: 9.0.0
exists:
min_mondoo_version: 9.0.0
files: {}
isBinary: {}
name:
Expand Down Expand Up @@ -316,6 +318,8 @@ resources:
fields:
MergeRequests:
min_mondoo_version: 9.0.0
adminCollaborators:
min_mondoo_version: 9.0.0
allMergeRequests:
min_mondoo_version: 9.0.0
allowAutoMerge:
Expand All @@ -337,6 +341,10 @@ resources:
min_mondoo_version: 7.14.0
closedMergeRequests:
min_mondoo_version: 9.0.0
codeOfConduct:
min_mondoo_version: 9.0.0
codeOfConductFile:
min_mondoo_version: 9.0.0
collaborators:
min_mondoo_version: 6.11.0
commits:
Expand Down Expand Up @@ -393,14 +401,24 @@ resources:
private: {}
pushedAt:
min_mondoo_version: 7.14.0
readme:
min_mondoo_version: 9.0.0
releases:
min_mondoo_version: 6.4.0
security:
min_mondoo_version: 9.0.0
securityFile:
min_mondoo_version: 9.0.0
sshUrl:
min_mondoo_version: 7.14.0
stargazers:
min_mondoo_version: 7.14.0
stargazersCount:
min_mondoo_version: 7.14.0
support:
min_mondoo_version: 9.0.0
supportFile:
min_mondoo_version: 9.0.0
topics:
min_mondoo_version: 7.14.0
updatedAt: {}
Expand All @@ -413,6 +431,19 @@ resources:
min_mondoo_version: 6.11.0
is_private: true
min_mondoo_version: 5.31.0
github.repository.file:
fields:
content: {}
downloadUrl: {}
files: {}
isBinary: {}
name: {}
ownerName: {}
path: {}
repoName: {}
sha: {}
type: {}
min_mondoo_version: 9.0.0
github.review:
fields:
authorAssociation: {}
Expand Down
Loading

0 comments on commit d135687

Please sign in to comment.