From 06e5e81704430b25c319025c29e69bd9df691c2f Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sat, 4 May 2024 19:59:23 -0700 Subject: [PATCH] Add new fields to GH repos + handle null bools Add new fields + handle a few merge options that are bools with null values if not set Signed-off-by: Tim Smith --- providers/github/resources/github.lr | 6 ++ .../github/resources/github.lr.manifest.yaml | 6 ++ providers/github/resources/github_repo.go | 73 ++++++++++--------- 3 files changed, 50 insertions(+), 35 deletions(-) diff --git a/providers/github/resources/github.lr b/providers/github/resources/github.lr index 67bb1f8e6e..9373b1b5eb 100644 --- a/providers/github/resources/github.lr +++ b/providers/github/resources/github.lr @@ -354,6 +354,12 @@ private github.repository @defaults("fullName") { supportFile() github.file // Repository security file securityFile() github.file + // Whether the update branch button is enabled + allowUpdateBranch bool + // Whether commit signatures are required for commits + webCommitSignoffRequired bool + // Whether deleting pull request branches after merging a pull request is enabled + deleteBranchOnMerge bool } // GitHub license diff --git a/providers/github/resources/github.lr.manifest.yaml b/providers/github/resources/github.lr.manifest.yaml index af798f362b..c27d809da8 100755 --- a/providers/github/resources/github.lr.manifest.yaml +++ b/providers/github/resources/github.lr.manifest.yaml @@ -334,6 +334,8 @@ resources: min_mondoo_version: 6.4.0 allowSquashMerge: min_mondoo_version: 6.4.0 + allowUpdateBranch: + min_mondoo_version: 9.0.0 archived: {} branches: min_mondoo_version: 6.4.0 @@ -358,6 +360,8 @@ resources: min_mondoo_version: 9.0.0 defaultBranchName: min_mondoo_version: 6.4.0 + deleteBranchOnMerge: + min_mondoo_version: 9.0.0 description: {} disabled: {} files: @@ -427,6 +431,8 @@ resources: visibility: {} watchersCount: min_mondoo_version: 7.14.0 + webCommitSignoffRequired: + min_mondoo_version: 9.0.0 webhooks: min_mondoo_version: 6.11.0 workflows: diff --git a/providers/github/resources/github_repo.go b/providers/github/resources/github_repo.go index 6e526f8862..be6ece7eaf 100644 --- a/providers/github/resources/github_repo.go +++ b/providers/github/resources/github_repo.go @@ -37,41 +37,44 @@ func newMqlGithubRepository(runtime *plugin.Runtime, repo *github.Repository) (* } res, err := CreateResource(runtime, "github.repository", map[string]*llx.RawData{ - "id": llx.IntData(id), - "name": llx.StringDataPtr(repo.Name), - "fullName": llx.StringDataPtr(repo.FullName), - "description": llx.StringDataPtr(repo.Description), - "homepage": llx.StringDataPtr(repo.Homepage), - "topics": llx.ArrayData(convert.SliceAnyToInterface[string](repo.Topics), types.String), - "language": llx.StringData(repo.GetLanguage()), - "createdAt": llx.TimeDataPtr(githubTimestamp(repo.CreatedAt)), - "updatedAt": llx.TimeDataPtr(githubTimestamp(repo.UpdatedAt)), - "pushedAt": llx.TimeDataPtr(githubTimestamp(repo.PushedAt)), - "archived": llx.BoolDataPtr(repo.Archived), - "disabled": llx.BoolDataPtr(repo.Disabled), - "private": llx.BoolDataPtr(repo.Private), - "isFork": llx.BoolDataPtr(repo.Fork), - "watchersCount": llx.IntData(int64(repo.GetWatchersCount())), - "forksCount": llx.IntData(int64(repo.GetForksCount())), - "openIssuesCount": llx.IntData(int64(repo.GetOpenIssues())), - "stargazersCount": llx.IntData(int64(repo.GetStargazersCount())), - "visibility": llx.StringDataPtr(repo.Visibility), - "allowAutoMerge": llx.BoolDataPtr(repo.AllowAutoMerge), - "allowForking": llx.BoolDataPtr(repo.AllowForking), - "allowMergeCommit": llx.BoolDataPtr(repo.AllowMergeCommit), - "allowRebaseMerge": llx.BoolDataPtr(repo.AllowRebaseMerge), - "allowSquashMerge": llx.BoolDataPtr(repo.AllowSquashMerge), - "hasIssues": llx.BoolData(repo.GetHasIssues()), - "hasProjects": llx.BoolData(repo.GetHasProjects()), - "hasWiki": llx.BoolData(repo.GetHasWiki()), - "hasPages": llx.BoolData(repo.GetHasPages()), - "hasDownloads": llx.BoolData(repo.GetHasDownloads()), - "hasDiscussions": llx.BoolData(repo.GetHasDiscussions()), - "isTemplate": llx.BoolData(repo.GetIsTemplate()), - "defaultBranchName": llx.StringDataPtr(repo.DefaultBranch), - "cloneUrl": llx.StringData(repo.GetCloneURL()), - "sshUrl": llx.StringData(repo.GetSSHURL()), - "owner": llx.ResourceData(owner, owner.MqlName()), + "id": llx.IntData(id), + "name": llx.StringDataPtr(repo.Name), + "fullName": llx.StringDataPtr(repo.FullName), + "description": llx.StringDataPtr(repo.Description), + "homepage": llx.StringDataPtr(repo.Homepage), + "topics": llx.ArrayData(convert.SliceAnyToInterface[string](repo.Topics), types.String), + "language": llx.StringData(repo.GetLanguage()), + "createdAt": llx.TimeDataPtr(githubTimestamp(repo.CreatedAt)), + "updatedAt": llx.TimeDataPtr(githubTimestamp(repo.UpdatedAt)), + "pushedAt": llx.TimeDataPtr(githubTimestamp(repo.PushedAt)), + "archived": llx.BoolDataPtr(repo.Archived), + "disabled": llx.BoolDataPtr(repo.Disabled), + "private": llx.BoolDataPtr(repo.Private), + "isFork": llx.BoolDataPtr(repo.Fork), + "watchersCount": llx.IntData(int64(repo.GetWatchersCount())), + "forksCount": llx.IntData(int64(repo.GetForksCount())), + "openIssuesCount": llx.IntData(int64(repo.GetOpenIssues())), + "stargazersCount": llx.IntData(int64(repo.GetStargazersCount())), + "visibility": llx.StringDataPtr(repo.Visibility), + "allowAutoMerge": llx.BoolData(convert.ToBool(repo.AllowAutoMerge)), + "allowForking": llx.BoolData(convert.ToBool(repo.AllowForking)), + "allowMergeCommit": llx.BoolData(convert.ToBool(repo.AllowMergeCommit)), + "allowRebaseMerge": llx.BoolData(convert.ToBool(repo.AllowRebaseMerge)), + "allowSquashMerge": llx.BoolData(convert.ToBool(repo.AllowSquashMerge)), + "allowUpdateBranch": llx.BoolData(convert.ToBool(repo.AllowUpdateBranch)), + "webCommitSignoffRequired": llx.BoolData(convert.ToBool(repo.WebCommitSignoffRequired)), + "deleteBranchOnMerge": llx.BoolData(convert.ToBool(repo.DeleteBranchOnMerge)), + "hasIssues": llx.BoolData(repo.GetHasIssues()), + "hasProjects": llx.BoolData(repo.GetHasProjects()), + "hasWiki": llx.BoolData(repo.GetHasWiki()), + "hasPages": llx.BoolData(repo.GetHasPages()), + "hasDownloads": llx.BoolData(repo.GetHasDownloads()), + "hasDiscussions": llx.BoolData(repo.GetHasDiscussions()), + "isTemplate": llx.BoolData(repo.GetIsTemplate()), + "defaultBranchName": llx.StringDataPtr(repo.DefaultBranch), + "cloneUrl": llx.StringData(repo.GetCloneURL()), + "sshUrl": llx.StringData(repo.GetSSHURL()), + "owner": llx.ResourceData(owner, owner.MqlName()), }) if err != nil { return nil, err