diff --git a/resources/packs/googleworkspace/connected_apps.go b/resources/packs/googleworkspace/connected_apps.go new file mode 100644 index 0000000000..5d6df85081 --- /dev/null +++ b/resources/packs/googleworkspace/connected_apps.go @@ -0,0 +1,119 @@ +package googleworkspace + +import ( + "go.mondoo.com/cnquery/resources/packs/core" + "go.mondoo.com/cnquery/stringx" +) + +type connectedApp struct { + clientID string + scopes []string + name string + users []*mqlGoogleworkspaceUser + tokens []*mqlGoogleworkspaceToken +} + +func (g *mqlGoogleworkspace) GetConnectedApps() ([]interface{}, error) { + // get all users + users, err := g.Users() + if err != nil { + return nil, err + } + + connectedApps := map[string]*connectedApp{} + for _, user := range users { + usr := user.(*mqlGoogleworkspaceUser) + // get all token from user + tokens, err := usr.GetTokens() + if err != nil { + return nil, err + } + + for _, token := range tokens { + tk := token.(*mqlGoogleworkspaceToken) + + clientID, err := tk.ClientId() + if err != nil { + return nil, err + } + + cApp, ok := connectedApps[clientID] + if !ok { + cApp = &connectedApp{ + clientID: clientID, + users: []*mqlGoogleworkspaceUser{}, + tokens: []*mqlGoogleworkspaceToken{}, + } + } + + // assign name + displayText, err := tk.DisplayText() + if err != nil { + return nil, err + } + cApp.name = displayText + + // merge scopes + scopes, err := tk.Scopes() + if err != nil { + return nil, err + } + stringScopes := []string{} + for _, scope := range scopes { + stringScopes = append(stringScopes, scope.(string)) + } + cApp.scopes = stringx.DedupStringArray(append(cApp.scopes, stringScopes...)) + + cApp.tokens = append(cApp.tokens, tk) + cApp.users = append(cApp.users, usr) + + connectedApps[clientID] = cApp + } + } + + // group token by client id + runtime := g.MotorRuntime + res := make([]interface{}, len(connectedApps)) + i := 0 + for k := range connectedApps { + connectedApp := connectedApps[k] + + mqlUsers := make([]interface{}, len(connectedApp.users)) + if connectedApp.users != nil && len(connectedApp.users) > 0 { + for i := range connectedApp.users { + mqlUsers[i] = connectedApp.users[i] + } + } + + mqlTokens := make([]interface{}, len(connectedApp.tokens)) + if connectedApp.tokens != nil && len(connectedApp.tokens) > 0 { + for i := range connectedApp.tokens { + mqlTokens[i] = connectedApp.tokens[i] + } + } + + mqlApp, err := runtime.CreateResource("googleworkspace.connectedApp", + "clientId", connectedApp.clientID, + "name", connectedApp.name, + "scopes", core.StrSliceToInterface(connectedApp.scopes), + "users", mqlUsers, + "tokens", mqlTokens, + ) + if err != nil { + return nil, err + } + res[i] = mqlApp + i++ + } + + return res, err +} + +func (g *mqlGoogleworkspaceConnectedApp) id() (string, error) { + clientId, err := g.ClientId() + if err != nil { + return "", err + } + + return "googleworkspace.connectedApp/" + clientId, nil +} diff --git a/resources/packs/googleworkspace/googleworkspace.lr b/resources/packs/googleworkspace/googleworkspace.lr index 3d55182cd9..5daf83a8ab 100644 --- a/resources/packs/googleworkspace/googleworkspace.lr +++ b/resources/packs/googleworkspace/googleworkspace.lr @@ -12,6 +12,8 @@ googleworkspace { groups() []googleworkspace.group // Retrieves a list of all roles for the Google Workspace account roles() []googleworkspace.role + // Retrieves a list of all apps for the Google Workspace account + connectedApps() []googleworkspace.connectedApp } // Google Workspace organizational unit @@ -96,6 +98,20 @@ private googleworkspace.token @defaults("displayText") { userKey string } +// Google Workspace Third-party Connected Apps +private googleworkspace.connectedApp @defaults("name clientId") { + // The unique ID of the application + clientId string + // The application's name + name string + // Aggregated scopes across all tokens issued to the application + scopes []string + // Google Workspace User that use the 3rd-party application + users []googleworkspace.user + // Returns the user-issued tokens to 3rd party applications + tokens []googleworkspace.token +} + // Google Workspace Group private googleworkspace.group @defaults("email") { // The unique ID of a group diff --git a/resources/packs/googleworkspace/googleworkspace.lr.go b/resources/packs/googleworkspace/googleworkspace.lr.go index f64930b011..f9edcc818a 100644 --- a/resources/packs/googleworkspace/googleworkspace.lr.go +++ b/resources/packs/googleworkspace/googleworkspace.lr.go @@ -17,6 +17,7 @@ func Init(registry *resources.Registry) { registry.AddFactory("googleworkspace.domain", newGoogleworkspaceDomain) registry.AddFactory("googleworkspace.user", newGoogleworkspaceUser) registry.AddFactory("googleworkspace.token", newGoogleworkspaceToken) + registry.AddFactory("googleworkspace.connectedApp", newGoogleworkspaceConnectedApp) registry.AddFactory("googleworkspace.group", newGoogleworkspaceGroup) registry.AddFactory("googleworkspace.member", newGoogleworkspaceMember) registry.AddFactory("googleworkspace.role", newGoogleworkspaceRole) @@ -38,6 +39,7 @@ type Googleworkspace interface { Domains() ([]interface{}, error) Groups() ([]interface{}, error) Roles() ([]interface{}, error) + ConnectedApps() ([]interface{}, error) } // mqlGoogleworkspace for the googleworkspace resource @@ -86,6 +88,10 @@ func newGoogleworkspace(runtime *resources.Runtime, args *resources.Args) (inter if _, ok := val.([]interface{}); !ok { return nil, errors.New("Failed to initialize \"googleworkspace\", its \"roles\" argument has the wrong type (expected type \"[]interface{}\")") } + case "connectedApps": + if _, ok := val.([]interface{}); !ok { + return nil, errors.New("Failed to initialize \"googleworkspace\", its \"connectedApps\" argument has the wrong type (expected type \"[]interface{}\")") + } case "__id": idVal, ok := val.(string) if !ok { @@ -132,6 +138,8 @@ func (s *mqlGoogleworkspace) Register(name string) error { return nil case "roles": return nil + case "connectedApps": + return nil default: return errors.New("Cannot find field '" + name + "' in \"googleworkspace\" resource") } @@ -151,6 +159,8 @@ func (s *mqlGoogleworkspace) Field(name string) (interface{}, error) { return s.Groups() case "roles": return s.Roles() + case "connectedApps": + return s.ConnectedApps() default: return nil, fmt.Errorf("Cannot find field '" + name + "' in \"googleworkspace\" resource") } @@ -271,6 +281,29 @@ func (s *mqlGoogleworkspace) Roles() ([]interface{}, error) { return tres, nil } +// ConnectedApps accessor autogenerated +func (s *mqlGoogleworkspace) ConnectedApps() ([]interface{}, error) { + res, ok := s.Cache.Load("connectedApps") + if !ok || !res.Valid { + if err := s.ComputeConnectedApps(); err != nil { + return nil, err + } + res, ok = s.Cache.Load("connectedApps") + if !ok { + return nil, errors.New("\"googleworkspace\" calculated \"connectedApps\" but didn't find its value in cache.") + } + s.MotorRuntime.Trigger(s, "connectedApps") + } + if res.Error != nil { + return nil, res.Error + } + tres, ok := res.Data.([]interface{}) + if !ok { + return nil, fmt.Errorf("\"googleworkspace\" failed to cast field \"connectedApps\" to the right type ([]interface{}): %#v", res) + } + return tres, nil +} + // Compute accessor autogenerated func (s *mqlGoogleworkspace) MqlCompute(name string) error { log.Trace().Str("field", name).Msg("[googleworkspace].MqlCompute") @@ -285,6 +318,8 @@ func (s *mqlGoogleworkspace) MqlCompute(name string) error { return s.ComputeGroups() case "roles": return s.ComputeRoles() + case "connectedApps": + return s.ComputeConnectedApps() default: return errors.New("Cannot find field '" + name + "' in \"googleworkspace\" resource") } @@ -360,6 +395,20 @@ func (s *mqlGoogleworkspace) ComputeRoles() error { return nil } +// ComputeConnectedApps computer autogenerated +func (s *mqlGoogleworkspace) ComputeConnectedApps() error { + var err error + if _, ok := s.Cache.Load("connectedApps"); ok { + return nil + } + vres, err := s.GetConnectedApps() + if _, ok := err.(resources.NotReadyError); ok { + return err + } + s.Cache.Store("connectedApps", &resources.CacheEntry{Data: vres, Valid: true, Error: err, Timestamp: time.Now().Unix()}) + return nil +} + // GoogleworkspaceOrgUnit resource interface type GoogleworkspaceOrgUnit interface { MqlResource() (*resources.Resource) @@ -1758,6 +1807,249 @@ func (s *mqlGoogleworkspaceToken) MqlCompute(name string) error { } } +// GoogleworkspaceConnectedApp resource interface +type GoogleworkspaceConnectedApp interface { + MqlResource() (*resources.Resource) + MqlCompute(string) error + Field(string) (interface{}, error) + Register(string) error + Validate() error + ClientId() (string, error) + Name() (string, error) + Scopes() ([]interface{}, error) + Users() ([]interface{}, error) + Tokens() ([]interface{}, error) +} + +// mqlGoogleworkspaceConnectedApp for the googleworkspace.connectedApp resource +type mqlGoogleworkspaceConnectedApp struct { + *resources.Resource +} + +// MqlResource to retrieve the underlying resource info +func (s *mqlGoogleworkspaceConnectedApp) MqlResource() *resources.Resource { + return s.Resource +} + +// create a new instance of the googleworkspace.connectedApp resource +func newGoogleworkspaceConnectedApp(runtime *resources.Runtime, args *resources.Args) (interface{}, error) { + // User hooks + var err error + res := mqlGoogleworkspaceConnectedApp{runtime.NewResource("googleworkspace.connectedApp")} + // assign all named fields + var id string + + now := time.Now().Unix() + for name, val := range *args { + if val == nil { + res.Cache.Store(name, &resources.CacheEntry{Data: val, Valid: true, Timestamp: now}) + continue + } + + switch name { + case "clientId": + if _, ok := val.(string); !ok { + return nil, errors.New("Failed to initialize \"googleworkspace.connectedApp\", its \"clientId\" argument has the wrong type (expected type \"string\")") + } + case "name": + if _, ok := val.(string); !ok { + return nil, errors.New("Failed to initialize \"googleworkspace.connectedApp\", its \"name\" argument has the wrong type (expected type \"string\")") + } + case "scopes": + if _, ok := val.([]interface{}); !ok { + return nil, errors.New("Failed to initialize \"googleworkspace.connectedApp\", its \"scopes\" argument has the wrong type (expected type \"[]interface{}\")") + } + case "users": + if _, ok := val.([]interface{}); !ok { + return nil, errors.New("Failed to initialize \"googleworkspace.connectedApp\", its \"users\" argument has the wrong type (expected type \"[]interface{}\")") + } + case "tokens": + if _, ok := val.([]interface{}); !ok { + return nil, errors.New("Failed to initialize \"googleworkspace.connectedApp\", its \"tokens\" argument has the wrong type (expected type \"[]interface{}\")") + } + case "__id": + idVal, ok := val.(string) + if !ok { + return nil, errors.New("Failed to initialize \"googleworkspace.connectedApp\", its \"__id\" argument has the wrong type (expected type \"string\")") + } + id = idVal + default: + return nil, errors.New("Initialized googleworkspace.connectedApp with unknown argument " + name) + } + res.Cache.Store(name, &resources.CacheEntry{Data: val, Valid: true, Timestamp: now}) + } + + // Get the ID + if id == "" { + res.Resource.Id, err = res.id() + if err != nil { + return nil, err + } + } else { + res.Resource.Id = id + } + + return &res, nil +} + +func (s *mqlGoogleworkspaceConnectedApp) Validate() error { + // required arguments + if _, ok := s.Cache.Load("clientId"); !ok { + return errors.New("Initialized \"googleworkspace.connectedApp\" resource without a \"clientId\". This field is required.") + } + if _, ok := s.Cache.Load("name"); !ok { + return errors.New("Initialized \"googleworkspace.connectedApp\" resource without a \"name\". This field is required.") + } + if _, ok := s.Cache.Load("scopes"); !ok { + return errors.New("Initialized \"googleworkspace.connectedApp\" resource without a \"scopes\". This field is required.") + } + if _, ok := s.Cache.Load("users"); !ok { + return errors.New("Initialized \"googleworkspace.connectedApp\" resource without a \"users\". This field is required.") + } + if _, ok := s.Cache.Load("tokens"); !ok { + return errors.New("Initialized \"googleworkspace.connectedApp\" resource without a \"tokens\". This field is required.") + } + + return nil +} + +// Register accessor autogenerated +func (s *mqlGoogleworkspaceConnectedApp) Register(name string) error { + log.Trace().Str("field", name).Msg("[googleworkspace.connectedApp].Register") + switch name { + case "clientId": + return nil + case "name": + return nil + case "scopes": + return nil + case "users": + return nil + case "tokens": + return nil + default: + return errors.New("Cannot find field '" + name + "' in \"googleworkspace.connectedApp\" resource") + } +} + +// Field accessor autogenerated +func (s *mqlGoogleworkspaceConnectedApp) Field(name string) (interface{}, error) { + log.Trace().Str("field", name).Msg("[googleworkspace.connectedApp].Field") + switch name { + case "clientId": + return s.ClientId() + case "name": + return s.Name() + case "scopes": + return s.Scopes() + case "users": + return s.Users() + case "tokens": + return s.Tokens() + default: + return nil, fmt.Errorf("Cannot find field '" + name + "' in \"googleworkspace.connectedApp\" resource") + } +} + +// ClientId accessor autogenerated +func (s *mqlGoogleworkspaceConnectedApp) ClientId() (string, error) { + res, ok := s.Cache.Load("clientId") + if !ok || !res.Valid { + return "", errors.New("\"googleworkspace.connectedApp\" failed: no value provided for static field \"clientId\"") + } + if res.Error != nil { + return "", res.Error + } + tres, ok := res.Data.(string) + if !ok { + return "", fmt.Errorf("\"googleworkspace.connectedApp\" failed to cast field \"clientId\" to the right type (string): %#v", res) + } + return tres, nil +} + +// Name accessor autogenerated +func (s *mqlGoogleworkspaceConnectedApp) Name() (string, error) { + res, ok := s.Cache.Load("name") + if !ok || !res.Valid { + return "", errors.New("\"googleworkspace.connectedApp\" failed: no value provided for static field \"name\"") + } + if res.Error != nil { + return "", res.Error + } + tres, ok := res.Data.(string) + if !ok { + return "", fmt.Errorf("\"googleworkspace.connectedApp\" failed to cast field \"name\" to the right type (string): %#v", res) + } + return tres, nil +} + +// Scopes accessor autogenerated +func (s *mqlGoogleworkspaceConnectedApp) Scopes() ([]interface{}, error) { + res, ok := s.Cache.Load("scopes") + if !ok || !res.Valid { + return nil, errors.New("\"googleworkspace.connectedApp\" failed: no value provided for static field \"scopes\"") + } + if res.Error != nil { + return nil, res.Error + } + tres, ok := res.Data.([]interface{}) + if !ok { + return nil, fmt.Errorf("\"googleworkspace.connectedApp\" failed to cast field \"scopes\" to the right type ([]interface{}): %#v", res) + } + return tres, nil +} + +// Users accessor autogenerated +func (s *mqlGoogleworkspaceConnectedApp) Users() ([]interface{}, error) { + res, ok := s.Cache.Load("users") + if !ok || !res.Valid { + return nil, errors.New("\"googleworkspace.connectedApp\" failed: no value provided for static field \"users\"") + } + if res.Error != nil { + return nil, res.Error + } + tres, ok := res.Data.([]interface{}) + if !ok { + return nil, fmt.Errorf("\"googleworkspace.connectedApp\" failed to cast field \"users\" to the right type ([]interface{}): %#v", res) + } + return tres, nil +} + +// Tokens accessor autogenerated +func (s *mqlGoogleworkspaceConnectedApp) Tokens() ([]interface{}, error) { + res, ok := s.Cache.Load("tokens") + if !ok || !res.Valid { + return nil, errors.New("\"googleworkspace.connectedApp\" failed: no value provided for static field \"tokens\"") + } + if res.Error != nil { + return nil, res.Error + } + tres, ok := res.Data.([]interface{}) + if !ok { + return nil, fmt.Errorf("\"googleworkspace.connectedApp\" failed to cast field \"tokens\" to the right type ([]interface{}): %#v", res) + } + return tres, nil +} + +// Compute accessor autogenerated +func (s *mqlGoogleworkspaceConnectedApp) MqlCompute(name string) error { + log.Trace().Str("field", name).Msg("[googleworkspace.connectedApp].MqlCompute") + switch name { + case "clientId": + return nil + case "name": + return nil + case "scopes": + return nil + case "users": + return nil + case "tokens": + return nil + default: + return errors.New("Cannot find field '" + name + "' in \"googleworkspace.connectedApp\" resource") + } +} + // GoogleworkspaceGroup resource interface type GoogleworkspaceGroup interface { MqlResource() (*resources.Resource) diff --git a/resources/packs/googleworkspace/googleworkspace.lr.manifest.yaml b/resources/packs/googleworkspace/googleworkspace.lr.manifest.yaml index 49f830de68..9de3144859 100755 --- a/resources/packs/googleworkspace/googleworkspace.lr.manifest.yaml +++ b/resources/packs/googleworkspace/googleworkspace.lr.manifest.yaml @@ -1,12 +1,26 @@ resources: googleworkspace: fields: + connectedApps: {} domains: {} groups: {} orgUnits: {} roles: {} users: {} min_mondoo_version: latest + googleworkspace.connectedApp: + fields: + access: {} + clientId: {} + id: {} + name: {} + scopes: {} + tokens: {} + type: {} + users: {} + verified: {} + is_private: true + min_mondoo_version: latest googleworkspace.domain: fields: creationTime: {} diff --git a/resources/packs/googleworkspace/info/googleworkspace.lr.json b/resources/packs/googleworkspace/info/googleworkspace.lr.json index c89f5b6b27..4f9b0b3abe 100644 --- a/resources/packs/googleworkspace/info/googleworkspace.lr.json +++ b/resources/packs/googleworkspace/info/googleworkspace.lr.json @@ -1 +1 @@ -{"resources":{"googleworkspace":{"id":"googleworkspace","name":"googleworkspace","fields":{"domains":{"name":"domains","type":"\u0019\u001bgoogleworkspace.domain","title":"Retrieves a list of domains for the Google Workspace account"},"groups":{"name":"groups","type":"\u0019\u001bgoogleworkspace.group","title":"Retrieves a list of all groups for the Google Workspace account"},"orgUnits":{"name":"orgUnits","type":"\u0019\u001bgoogleworkspace.orgUnit","title":"Retrieves a list of all organizational units for the Google Workspace account"},"roles":{"name":"roles","type":"\u0019\u001bgoogleworkspace.role","title":"Retrieves a list of all roles for the Google Workspace account"},"users":{"name":"users","type":"\u0019\u001bgoogleworkspace.user","title":"Retrieves a list of all users for the Google Workspace account"}},"title":"Google Workspace"},"googleworkspace.domain":{"id":"googleworkspace.domain","name":"googleworkspace.domain","fields":{"creationTime":{"name":"creationTime","type":"\t","is_mandatory":true,"title":"Creation time of the domain"},"domainName":{"name":"domainName","type":"\u0007","is_mandatory":true,"title":"The domain name of the customer"},"isPrimary":{"name":"isPrimary","type":"\u0004","is_mandatory":true,"title":"Indicates if the domain is a primary domain"},"verified":{"name":"verified","type":"\u0004","is_mandatory":true,"title":"Indicates the verification state of a domain"}},"title":"Google Workspace domain","private":true,"defaults":"domainName"},"googleworkspace.group":{"id":"googleworkspace.group","name":"googleworkspace.group","fields":{"adminCreated":{"name":"adminCreated","type":"\u0004","is_mandatory":true,"title":"Indicates if this group was created by an administrator rather than a user"},"aliases":{"name":"aliases","type":"\u0019\u0007","is_mandatory":true,"title":"A list of a group's alias email addresses"},"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"Purpose of the group"},"directMembersCount":{"name":"directMembersCount","type":"\u0005","is_mandatory":true,"title":"The number of users that are direct members of the group"},"email":{"name":"email","type":"\u0007","is_mandatory":true,"title":"The group's email address"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"The unique ID of a group"},"members":{"name":"members","type":"\u0019\u001bgoogleworkspace.member","title":"Retrieve members of the group"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"The group's display name"},"securitySettings":{"name":"securitySettings","type":"\n","title":"Group security settings"},"settings":{"name":"settings","type":"\n","title":"Group settings"}},"title":"Google Workspace Group","private":true,"defaults":"email"},"googleworkspace.member":{"id":"googleworkspace.member","name":"googleworkspace.member","fields":{"email":{"name":"email","type":"\u0007","is_mandatory":true,"title":"The member's email address"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"The unique ID of the group member"},"status":{"name":"status","type":"\u0007","is_mandatory":true,"title":"Status of member"},"type":{"name":"type","type":"\u0007","is_mandatory":true,"title":"The type of group member"},"user":{"name":"user","type":"\u001bgoogleworkspace.user","title":"Linked user account"}},"title":"Google Workspace Group Member","private":true,"defaults":"email"},"googleworkspace.orgUnit":{"id":"googleworkspace.orgUnit","name":"googleworkspace.orgUnit","fields":{"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"Description of the organizational unit"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"The unique ID of the organizational unit"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"The organizational unit's path name"}},"title":"Google Workspace organizational unit","private":true,"defaults":"name"},"googleworkspace.report.activity":{"id":"googleworkspace.report.activity","name":"googleworkspace.report.activity","fields":{"actor":{"name":"actor","type":"\n","is_mandatory":true},"events":{"name":"events","type":"\u0019\n","is_mandatory":true},"id":{"name":"id","type":"\u0005","is_mandatory":true},"ipAddress":{"name":"ipAddress","type":"\u0007","is_mandatory":true},"ownerDomain":{"name":"ownerDomain","type":"\u0007","is_mandatory":true}},"title":"Google Workspace App Reports Activity","private":true},"googleworkspace.report.apps":{"id":"googleworkspace.report.apps","name":"googleworkspace.report.apps","fields":{"drive":{"name":"drive","type":"\u0019\u001bgoogleworkspace.report.activity"}},"title":"Google Workspace Apps Reports","private":true},"googleworkspace.report.usage":{"id":"googleworkspace.report.usage","name":"googleworkspace.report.usage","fields":{"account":{"name":"account","type":"\n","title":"Account Settings"},"appUsage":{"name":"appUsage","type":"\n","title":"App Usage"},"customerId":{"name":"customerId","type":"\u0007","is_mandatory":true,"title":"The unique identifier of the customer's account"},"date":{"name":"date","type":"\t","is_mandatory":true,"title":"Date of the report"},"entityId":{"name":"entityId","type":"\u0007","is_mandatory":true,"title":"Google Workspace entity ID"},"parameters":{"name":"parameters","type":"\u0019\n","is_mandatory":true,"title":"Parameter value pairs"},"profileId":{"name":"profileId","type":"\u0007","is_mandatory":true,"title":"Google Workspace profile identifier"},"security":{"name":"security","type":"\n","title":"Security Settings"},"type":{"name":"type","type":"\u0007","is_mandatory":true,"title":"Entity type"},"userEmail":{"name":"userEmail","type":"\u0007","is_mandatory":true,"title":"Email of user"}},"title":"Google Workspace Usage Report","private":true},"googleworkspace.report.users":{"id":"googleworkspace.report.users","name":"googleworkspace.report.users","fields":{"list":{"name":"list","type":"\u0019\u001bgoogleworkspace.report.usage"}},"list_type":"\u001bgoogleworkspace.report.usage","title":"Google Workspace User Usage Reports","private":true},"googleworkspace.role":{"id":"googleworkspace.role","name":"googleworkspace.role","fields":{"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"A short description of the role"},"id":{"name":"id","type":"\u0005","is_mandatory":true,"title":"ID of the role"},"isSuperAdminRole":{"name":"isSuperAdminRole","type":"\u0004","is_mandatory":true,"title":"Indicates if the role is a super admin role"},"isSystemRole":{"name":"isSystemRole","type":"\u0004","is_mandatory":true,"title":"Indicates if this is a pre-defined system role"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Name of the role"},"privileges":{"name":"privileges","type":"\u0019\n","is_mandatory":true,"title":"The set of privileges"}},"title":"Google Workspace Role","private":true,"defaults":"name"},"googleworkspace.token":{"id":"googleworkspace.token","name":"googleworkspace.token","fields":{"anonymous":{"name":"anonymous","type":"\u0004","is_mandatory":true,"title":"Indicates if the application is registered with Google"},"clientId":{"name":"clientId","type":"\u0007","is_mandatory":true,"title":"The Client ID of the application"},"displayText":{"name":"displayText","type":"\u0007","is_mandatory":true,"title":"The displayable name of the application token"},"nativeApp":{"name":"nativeApp","type":"\u0004","is_mandatory":true,"title":"Indicates if the token is issued to an installed application"},"scopes":{"name":"scopes","type":"\u0019\u0007","is_mandatory":true,"title":"A list of granted authorization scopes the application"},"userKey":{"name":"userKey","type":"\u0007","is_mandatory":true,"title":"The unique ID of the user that issued the token"}},"title":"Google Workspace Token","private":true,"defaults":"displayText"},"googleworkspace.user":{"id":"googleworkspace.user","name":"googleworkspace.user","fields":{"agreedToTerms":{"name":"agreedToTerms","type":"\u0004","is_mandatory":true,"title":"User accepted the Terms of Service agreement"},"aliases":{"name":"aliases","type":"\u0019\u0007","is_mandatory":true,"title":"A list of the user's alias email addresses"},"archived":{"name":"archived","type":"\u0004","is_mandatory":true,"title":"Indicates if user is archived"},"creationTime":{"name":"creationTime","type":"\t","is_mandatory":true,"title":"User's account creation time"},"familyName":{"name":"familyName","type":"\u0007","is_mandatory":true,"title":"The user's last name"},"fullName":{"name":"fullName","type":"\u0007","is_mandatory":true,"title":"The user's full name"},"givenName":{"name":"givenName","type":"\u0007","is_mandatory":true,"title":"The user's first names"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"The unique ID for the user"},"isAdmin":{"name":"isAdmin","type":"\u0004","is_mandatory":true,"title":"Indicates a user with super administrator privileges"},"isEnforcedIn2Sv":{"name":"isEnforcedIn2Sv","type":"\u0004","is_mandatory":true,"title":"Is 2-step verification enforced"},"isEnrolledIn2Sv":{"name":"isEnrolledIn2Sv","type":"\u0004","is_mandatory":true,"title":"Is enrolled in 2-step verification"},"isMailboxSetup":{"name":"isMailboxSetup","type":"\u0004","is_mandatory":true,"title":"Indicates if the user's Google mailbox is created"},"lastLoginTime":{"name":"lastLoginTime","type":"\t","is_mandatory":true,"title":"User's last login time"},"primaryEmail":{"name":"primaryEmail","type":"\u0007","is_mandatory":true,"title":"The user's primary email address"},"recoveryEmail":{"name":"recoveryEmail","type":"\u0007","is_mandatory":true,"title":"Recovery email of the user"},"recoveryPhone":{"name":"recoveryPhone","type":"\u0007","is_mandatory":true,"title":"Recovery phone of the user"},"suspended":{"name":"suspended","type":"\u0004","is_mandatory":true,"title":"Indicates if user is suspended"},"suspensionReason":{"name":"suspensionReason","type":"\u0007","is_mandatory":true,"title":"The reason a user account is suspended"},"tokens":{"name":"tokens","type":"\u0019\u001bgoogleworkspace.token","title":"Returns the user-issued tokens to 3rd party applications"},"usageReport":{"name":"usageReport","type":"\u001bgoogleworkspace.report.usage","title":"Retrieves latest report for the user"}},"title":"Google Workspace User Accounts","private":true,"defaults":"primaryEmail"}}} \ No newline at end of file +{"resources":{"googleworkspace":{"id":"googleworkspace","name":"googleworkspace","fields":{"connectedApps":{"name":"connectedApps","type":"\u0019\u001bgoogleworkspace.connectedApp","title":"Retrieves a list of all apps for the Google Workspace account"},"domains":{"name":"domains","type":"\u0019\u001bgoogleworkspace.domain","title":"Retrieves a list of domains for the Google Workspace account"},"groups":{"name":"groups","type":"\u0019\u001bgoogleworkspace.group","title":"Retrieves a list of all groups for the Google Workspace account"},"orgUnits":{"name":"orgUnits","type":"\u0019\u001bgoogleworkspace.orgUnit","title":"Retrieves a list of all organizational units for the Google Workspace account"},"roles":{"name":"roles","type":"\u0019\u001bgoogleworkspace.role","title":"Retrieves a list of all roles for the Google Workspace account"},"users":{"name":"users","type":"\u0019\u001bgoogleworkspace.user","title":"Retrieves a list of all users for the Google Workspace account"}},"title":"Google Workspace"},"googleworkspace.connectedApp":{"id":"googleworkspace.connectedApp","name":"googleworkspace.connectedApp","fields":{"clientId":{"name":"clientId","type":"\u0007","is_mandatory":true,"title":"The unique ID of the application"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"The application's name"},"scopes":{"name":"scopes","type":"\u0019\u0007","is_mandatory":true,"title":"Aggregated scopes across all tokens issued to the application"},"tokens":{"name":"tokens","type":"\u0019\u001bgoogleworkspace.token","is_mandatory":true,"title":"Returns the user-issued tokens to 3rd party applications"},"users":{"name":"users","type":"\u0019\u001bgoogleworkspace.user","is_mandatory":true,"title":"Google Workspace User that use the 3rd-party application"}},"title":"Google Workspace Third-party Connected Apps","private":true,"defaults":"name clientId"},"googleworkspace.domain":{"id":"googleworkspace.domain","name":"googleworkspace.domain","fields":{"creationTime":{"name":"creationTime","type":"\t","is_mandatory":true,"title":"Creation time of the domain"},"domainName":{"name":"domainName","type":"\u0007","is_mandatory":true,"title":"The domain name of the customer"},"isPrimary":{"name":"isPrimary","type":"\u0004","is_mandatory":true,"title":"Indicates if the domain is a primary domain"},"verified":{"name":"verified","type":"\u0004","is_mandatory":true,"title":"Indicates the verification state of a domain"}},"title":"Google Workspace domain","private":true,"defaults":"domainName"},"googleworkspace.group":{"id":"googleworkspace.group","name":"googleworkspace.group","fields":{"adminCreated":{"name":"adminCreated","type":"\u0004","is_mandatory":true,"title":"Indicates if this group was created by an administrator rather than a user"},"aliases":{"name":"aliases","type":"\u0019\u0007","is_mandatory":true,"title":"A list of a group's alias email addresses"},"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"Purpose of the group"},"directMembersCount":{"name":"directMembersCount","type":"\u0005","is_mandatory":true,"title":"The number of users that are direct members of the group"},"email":{"name":"email","type":"\u0007","is_mandatory":true,"title":"The group's email address"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"The unique ID of a group"},"members":{"name":"members","type":"\u0019\u001bgoogleworkspace.member","title":"Retrieve members of the group"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"The group's display name"},"securitySettings":{"name":"securitySettings","type":"\n","title":"Group security settings"},"settings":{"name":"settings","type":"\n","title":"Group settings"}},"title":"Google Workspace Group","private":true,"defaults":"email"},"googleworkspace.member":{"id":"googleworkspace.member","name":"googleworkspace.member","fields":{"email":{"name":"email","type":"\u0007","is_mandatory":true,"title":"The member's email address"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"The unique ID of the group member"},"status":{"name":"status","type":"\u0007","is_mandatory":true,"title":"Status of member"},"type":{"name":"type","type":"\u0007","is_mandatory":true,"title":"The type of group member"},"user":{"name":"user","type":"\u001bgoogleworkspace.user","title":"Linked user account"}},"title":"Google Workspace Group Member","private":true,"defaults":"email"},"googleworkspace.orgUnit":{"id":"googleworkspace.orgUnit","name":"googleworkspace.orgUnit","fields":{"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"Description of the organizational unit"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"The unique ID of the organizational unit"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"The organizational unit's path name"}},"title":"Google Workspace organizational unit","private":true,"defaults":"name"},"googleworkspace.report.activity":{"id":"googleworkspace.report.activity","name":"googleworkspace.report.activity","fields":{"actor":{"name":"actor","type":"\n","is_mandatory":true},"events":{"name":"events","type":"\u0019\n","is_mandatory":true},"id":{"name":"id","type":"\u0005","is_mandatory":true},"ipAddress":{"name":"ipAddress","type":"\u0007","is_mandatory":true},"ownerDomain":{"name":"ownerDomain","type":"\u0007","is_mandatory":true}},"title":"Google Workspace App Reports Activity","private":true},"googleworkspace.report.apps":{"id":"googleworkspace.report.apps","name":"googleworkspace.report.apps","fields":{"drive":{"name":"drive","type":"\u0019\u001bgoogleworkspace.report.activity"}},"title":"Google Workspace Apps Reports","private":true},"googleworkspace.report.usage":{"id":"googleworkspace.report.usage","name":"googleworkspace.report.usage","fields":{"account":{"name":"account","type":"\n","title":"Account Settings"},"appUsage":{"name":"appUsage","type":"\n","title":"App Usage"},"customerId":{"name":"customerId","type":"\u0007","is_mandatory":true,"title":"The unique identifier of the customer's account"},"date":{"name":"date","type":"\t","is_mandatory":true,"title":"Date of the report"},"entityId":{"name":"entityId","type":"\u0007","is_mandatory":true,"title":"Google Workspace entity ID"},"parameters":{"name":"parameters","type":"\u0019\n","is_mandatory":true,"title":"Parameter value pairs"},"profileId":{"name":"profileId","type":"\u0007","is_mandatory":true,"title":"Google Workspace profile identifier"},"security":{"name":"security","type":"\n","title":"Security Settings"},"type":{"name":"type","type":"\u0007","is_mandatory":true,"title":"Entity type"},"userEmail":{"name":"userEmail","type":"\u0007","is_mandatory":true,"title":"Email of user"}},"title":"Google Workspace Usage Report","private":true},"googleworkspace.report.users":{"id":"googleworkspace.report.users","name":"googleworkspace.report.users","fields":{"list":{"name":"list","type":"\u0019\u001bgoogleworkspace.report.usage"}},"list_type":"\u001bgoogleworkspace.report.usage","title":"Google Workspace User Usage Reports","private":true},"googleworkspace.role":{"id":"googleworkspace.role","name":"googleworkspace.role","fields":{"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"A short description of the role"},"id":{"name":"id","type":"\u0005","is_mandatory":true,"title":"ID of the role"},"isSuperAdminRole":{"name":"isSuperAdminRole","type":"\u0004","is_mandatory":true,"title":"Indicates if the role is a super admin role"},"isSystemRole":{"name":"isSystemRole","type":"\u0004","is_mandatory":true,"title":"Indicates if this is a pre-defined system role"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Name of the role"},"privileges":{"name":"privileges","type":"\u0019\n","is_mandatory":true,"title":"The set of privileges"}},"title":"Google Workspace Role","private":true,"defaults":"name"},"googleworkspace.token":{"id":"googleworkspace.token","name":"googleworkspace.token","fields":{"anonymous":{"name":"anonymous","type":"\u0004","is_mandatory":true,"title":"Indicates if the application is registered with Google"},"clientId":{"name":"clientId","type":"\u0007","is_mandatory":true,"title":"The Client ID of the application"},"displayText":{"name":"displayText","type":"\u0007","is_mandatory":true,"title":"The displayable name of the application token"},"nativeApp":{"name":"nativeApp","type":"\u0004","is_mandatory":true,"title":"Indicates if the token is issued to an installed application"},"scopes":{"name":"scopes","type":"\u0019\u0007","is_mandatory":true,"title":"A list of granted authorization scopes the application"},"userKey":{"name":"userKey","type":"\u0007","is_mandatory":true,"title":"The unique ID of the user that issued the token"}},"title":"Google Workspace Token","private":true,"defaults":"displayText"},"googleworkspace.user":{"id":"googleworkspace.user","name":"googleworkspace.user","fields":{"agreedToTerms":{"name":"agreedToTerms","type":"\u0004","is_mandatory":true,"title":"User accepted the Terms of Service agreement"},"aliases":{"name":"aliases","type":"\u0019\u0007","is_mandatory":true,"title":"A list of the user's alias email addresses"},"archived":{"name":"archived","type":"\u0004","is_mandatory":true,"title":"Indicates if user is archived"},"creationTime":{"name":"creationTime","type":"\t","is_mandatory":true,"title":"User's account creation time"},"familyName":{"name":"familyName","type":"\u0007","is_mandatory":true,"title":"The user's last name"},"fullName":{"name":"fullName","type":"\u0007","is_mandatory":true,"title":"The user's full name"},"givenName":{"name":"givenName","type":"\u0007","is_mandatory":true,"title":"The user's first names"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"The unique ID for the user"},"isAdmin":{"name":"isAdmin","type":"\u0004","is_mandatory":true,"title":"Indicates a user with super administrator privileges"},"isEnforcedIn2Sv":{"name":"isEnforcedIn2Sv","type":"\u0004","is_mandatory":true,"title":"Is 2-step verification enforced"},"isEnrolledIn2Sv":{"name":"isEnrolledIn2Sv","type":"\u0004","is_mandatory":true,"title":"Is enrolled in 2-step verification"},"isMailboxSetup":{"name":"isMailboxSetup","type":"\u0004","is_mandatory":true,"title":"Indicates if the user's Google mailbox is created"},"lastLoginTime":{"name":"lastLoginTime","type":"\t","is_mandatory":true,"title":"User's last login time"},"primaryEmail":{"name":"primaryEmail","type":"\u0007","is_mandatory":true,"title":"The user's primary email address"},"recoveryEmail":{"name":"recoveryEmail","type":"\u0007","is_mandatory":true,"title":"Recovery email of the user"},"recoveryPhone":{"name":"recoveryPhone","type":"\u0007","is_mandatory":true,"title":"Recovery phone of the user"},"suspended":{"name":"suspended","type":"\u0004","is_mandatory":true,"title":"Indicates if user is suspended"},"suspensionReason":{"name":"suspensionReason","type":"\u0007","is_mandatory":true,"title":"The reason a user account is suspended"},"tokens":{"name":"tokens","type":"\u0019\u001bgoogleworkspace.token","title":"Returns the user-issued tokens to 3rd party applications"},"usageReport":{"name":"usageReport","type":"\u001bgoogleworkspace.report.usage","title":"Retrieves latest report for the user"}},"title":"Google Workspace User Accounts","private":true,"defaults":"primaryEmail"}}} \ No newline at end of file diff --git a/resources/packs/googleworkspace/info/googleworkspace.lr.manifest.json b/resources/packs/googleworkspace/info/googleworkspace.lr.manifest.json index 493ac9a88b..6c858bc529 100644 --- a/resources/packs/googleworkspace/info/googleworkspace.lr.manifest.json +++ b/resources/packs/googleworkspace/info/googleworkspace.lr.manifest.json @@ -1 +1 @@ -{"resources":{"googleworkspace":{"fields":{"domains":{},"groups":{},"orgUnits":{},"roles":{},"users":{}},"min_mondoo_version":"latest"},"googleworkspace.domain":{"fields":{"creationTime":{},"domainName":{},"isPrimary":{},"verified":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.group":{"fields":{"adminCreated":{},"aliases":{},"description":{},"directMembersCount":{},"email":{},"id":{},"members":{},"name":{},"securitySettings":{},"settings":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.member":{"fields":{"email":{},"id":{},"status":{},"type":{},"user":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.orgUnit":{"fields":{"description":{},"id":{},"name":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.report.activity":{"fields":{"actor":{},"events":{},"id":{},"ipAddress":{},"ownerDomain":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.report.apps":{"fields":{"drive":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.report.usage":{"fields":{"account":{},"appUsage":{},"customerId":{},"date":{},"entityId":{},"parameters":{},"profileId":{},"security":{},"type":{},"userEmail":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.report.users":{"fields":{"list":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.role":{"fields":{"description":{},"id":{},"isSuperAdminRole":{},"isSystemRole":{},"name":{},"privileges":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.token":{"fields":{"anonymous":{},"clientId":{},"displayText":{},"nativeApp":{},"scopes":{},"userKey":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.user":{"fields":{"agreedToTerms":{},"aliases":{},"archived":{},"creationTime":{},"familyName":{},"fullName":{},"givenName":{},"id":{},"isAdmin":{},"isEnforcedIn2Sv":{},"isEnrolledIn2Sv":{},"isMailboxSetup":{},"lastLoginTime":{},"primaryEmail":{},"recoveryEmail":{},"recoveryPhone":{},"suspended":{},"suspensionReason":{},"tokens":{},"usageReport":{}},"is_private":true,"min_mondoo_version":"latest"}}} \ No newline at end of file +{"resources":{"googleworkspace":{"fields":{"connectedApps":{},"domains":{},"groups":{},"orgUnits":{},"roles":{},"users":{}},"min_mondoo_version":"latest"},"googleworkspace.connectedApp":{"fields":{"access":{},"clientId":{},"id":{},"name":{},"scopes":{},"tokens":{},"type":{},"users":{},"verified":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.domain":{"fields":{"creationTime":{},"domainName":{},"isPrimary":{},"verified":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.group":{"fields":{"adminCreated":{},"aliases":{},"description":{},"directMembersCount":{},"email":{},"id":{},"members":{},"name":{},"securitySettings":{},"settings":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.member":{"fields":{"email":{},"id":{},"status":{},"type":{},"user":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.orgUnit":{"fields":{"description":{},"id":{},"name":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.report.activity":{"fields":{"actor":{},"events":{},"id":{},"ipAddress":{},"ownerDomain":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.report.apps":{"fields":{"drive":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.report.usage":{"fields":{"account":{},"appUsage":{},"customerId":{},"date":{},"entityId":{},"parameters":{},"profileId":{},"security":{},"type":{},"userEmail":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.report.users":{"fields":{"list":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.role":{"fields":{"description":{},"id":{},"isSuperAdminRole":{},"isSystemRole":{},"name":{},"privileges":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.token":{"fields":{"anonymous":{},"clientId":{},"displayText":{},"nativeApp":{},"scopes":{},"userKey":{}},"is_private":true,"min_mondoo_version":"latest"},"googleworkspace.user":{"fields":{"agreedToTerms":{},"aliases":{},"archived":{},"creationTime":{},"familyName":{},"fullName":{},"givenName":{},"id":{},"isAdmin":{},"isEnforcedIn2Sv":{},"isEnrolledIn2Sv":{},"isMailboxSetup":{},"lastLoginTime":{},"primaryEmail":{},"recoveryEmail":{},"recoveryPhone":{},"suspended":{},"suspensionReason":{},"tokens":{},"usageReport":{}},"is_private":true,"min_mondoo_version":"latest"}}} \ No newline at end of file diff --git a/resources/packs/os/services/manager.go b/resources/packs/os/services/manager.go index 394292a09a..c70bda38d7 100644 --- a/resources/packs/os/services/manager.go +++ b/resources/packs/os/services/manager.go @@ -140,6 +140,8 @@ func ResolveManager(motor *motor.Motor) (OSServiceManager, error) { osm = &AlpineOpenrcServiceManager{provider: osProvider} case pf.Name == "cos": osm = ResolveSystemdServiceManager(osProvider) + case pf.Name == "kali": // debian based with versions from 2015 onwards being systemd based + osm = ResolveSystemdServiceManager(osProvider) } if osm == nil {