Skip to content

Commit

Permalink
Add new properties to gitlab.project (#1816)
Browse files Browse the repository at this point in the history
Add a pile of new properties we need to improve the security policy +
asset overview data.

```
gitlab.group.projects.first: {
  webURL: "https://gitlab.com/lunaelectric/rover"
  issuesEnabled: true
  wikiEnabled: true
  requirementsEnabled: false
  path: "rover"
  createdAt: 2023-09-20 15:56:18.042 -0700 PDT
  containerRegistryEnabled: true
  name: "Rover"
  visibility: "private"
  id: 50575105
  defaultBranch: "main"
  description: ""
  archived: false
  serviceDeskEnabled: true
  emailsDisabled: false
  mirror: false
  allowMergeOnSkippedPipeline: false
  autoDevopsEnabled: false
  onlyAllowMergeIfAllDiscussionsAreResolved: false
  onlyAllowMergeIfPipelineSucceeds: false
  fullName: "Lunalectric / Rover"
  packagesEnabled: true
  mergeRequestsEnabled: true
  snippetsEnabled: true
}
```

Highlights:

- Update the defaults to use the new fullName property which includes
the namespace (group in our context)
- Include super handy things for asset inventory like the URL, create
date, and status of features, if its a mirror/archived, and the default
branch name.
- Include some rules for merges

---------

Signed-off-by: Tim Smith <[email protected]>
Co-authored-by: Letha <[email protected]>
  • Loading branch information
tas50 and misterpantz authored Sep 21, 2023
1 parent c884837 commit ebe8c80
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 12 deletions.
4 changes: 2 additions & 2 deletions providers/gitlab/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/rs/zerolog v1.30.0
github.com/stretchr/testify v1.8.4
github.com/xanzy/go-gitlab v0.91.1
go.mondoo.com/cnquery v0.0.0-20230915180754-c5f61bc705cf
go.mondoo.com/cnquery v0.0.0-20230920205842-55a158611de3
)

require (
Expand Down Expand Up @@ -59,7 +59,7 @@ require (
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect
google.golang.org/grpc v1.58.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions providers/gitlab/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb h1:Isk1sSH7bovx8Rti2wZK0UZF6oraBDK74uoyLEEVFN0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230913181813-007df8e322eb/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down
29 changes: 24 additions & 5 deletions providers/gitlab/resources/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,30 @@ func (g *mqlGitlabGroup) projects() ([]interface{}, error) {
prj := grp.Projects[i]

mqlProject, err := CreateResource(g.MqlRuntime, "gitlab.project", map[string]*llx.RawData{
"id": llx.IntData(int64(prj.ID)),
"name": llx.StringData(prj.Name),
"path": llx.StringData(prj.Path),
"description": llx.StringData(prj.Description),
"visibility": llx.StringData(string(prj.Visibility)),
"allowMergeOnSkippedPipeline": llx.BoolData(prj.AllowMergeOnSkippedPipeline),
"archived": llx.BoolData(prj.Archived),
"autoDevopsEnabled": llx.BoolData(prj.AutoDevopsEnabled),
"containerRegistryEnabled": llx.BoolData(prj.ContainerRegistryEnabled),
"createdAt": llx.TimeDataPtr(prj.CreatedAt),
"defaultBranch": llx.StringData(prj.DefaultBranch),
"description": llx.StringData(prj.Description),
"emailsDisabled": llx.BoolData(!prj.EmailsEnabled),
"fullName": llx.StringData(prj.NameWithNamespace),
"id": llx.IntData(int64(prj.ID)),
"issuesEnabled": llx.BoolData(prj.IssuesEnabled),
"mergeRequestsEnabled": llx.BoolData(prj.MergeRequestsEnabled),
"mirror": llx.BoolData(prj.Mirror),
"name": llx.StringData(prj.Name),
"onlyAllowMergeIfAllDiscussionsAreResolved": llx.BoolData(prj.OnlyAllowMergeIfAllDiscussionsAreResolved),
"onlyAllowMergeIfPipelineSucceeds": llx.BoolData(prj.OnlyAllowMergeIfPipelineSucceeds),
"packagesEnabled": llx.BoolData(prj.PackagesEnabled),
"path": llx.StringData(prj.Path),
"requirementsEnabled": llx.BoolData(prj.RequirementsEnabled),
"serviceDeskEnabled": llx.BoolData(prj.ServiceDeskEnabled),
"snippetsEnabled": llx.BoolData(prj.SnippetsEnabled),
"visibility": llx.StringData(string(prj.Visibility)),
"webURL": llx.StringData(prj.WebURL),
"wikiEnabled": llx.BoolData(prj.WikiEnabled),
})
if err != nil {
return nil, err
Expand Down
44 changes: 41 additions & 3 deletions providers/gitlab/resources/gitlab.lr
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ gitlab.group @defaults("name") {
path string
// Group description
description string
// URL of the project
// URL of the group
webURL string
// Group visibility. Can be private, internal, or public.
// The group's visibility level. Can be private, internal, or public.
visibility string
// Require all users in this group to setup Two-factor authentication.
requireTwoFactorAuthentication bool
Expand All @@ -31,15 +31,53 @@ gitlab.group @defaults("name") {
}

// GitLab Project
gitlab.project @defaults("name visibility") {
gitlab.project @defaults("fullName visibility webURL") {
// Project ID
id int
// Project name
name string
// The full name of the project, including the namespace
fullName string
// Project path
path string
// Create date of the project
createdAt time
// Project description
description string
// default git branch
defaultBranch string
// The project's visibility level. Can be private, internal, or public.
visibility string
// Is the project archived?
archived bool
// Is the project a mirror?
mirror bool
// URL of the project
webURL string
// Disable project email notifications
emailsDisabled bool
// Allow merging merge requests when a pipeline is skipped
allowMergeOnSkippedPipeline bool
// Only allow merging merge requests if the pipelines succeed
onlyAllowMergeIfPipelineSucceeds bool
// Allow merging merge requests if all discussions are resolved
onlyAllowMergeIfAllDiscussionsAreResolved bool
// Is the issues feature enabled?
issuesEnabled bool
// Is the merge request feature enabled?
mergeRequestsEnabled bool
// Is the wiki feature enabled?
wikiEnabled bool
// Is the snippets feature enabled?
snippetsEnabled bool
// Is the container registry feature enabled?
containerRegistryEnabled bool
// Is the Service Desk feature enabled?
serviceDeskEnabled bool
// Is the packages feature enabled?
packagesEnabled bool
// Is the Auto DevOps feature enabled?
autoDevopsEnabled bool
// Is the requirements feature enabled?
requirementsEnabled bool
}
Loading

0 comments on commit ebe8c80

Please sign in to comment.