Skip to content

Commit

Permalink
🧹 Replace llx.StringData and llx.BoolData with llx.StringDataPtr and …
Browse files Browse the repository at this point in the history
…llx.BoolDataPtr in ms365.

Signed-off-by: Preslav <[email protected]>
  • Loading branch information
preslavgerchev committed Feb 17, 2024
1 parent ef84431 commit 33a0b29
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 69 deletions.
10 changes: 5 additions & 5 deletions providers/ms365/resources/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ func (a *mqlMicrosoft) applications() ([]interface{}, error) {
for _, app := range apps {
mqlResource, err := CreateResource(a.MqlRuntime, "microsoft.application",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(app.GetId())),
"appId": llx.StringData(convert.ToString(app.GetAppId())),
"id": llx.StringDataPtr(app.GetId()),
"appId": llx.StringDataPtr(app.GetAppId()),
"createdDateTime": llx.TimeDataPtr(app.GetCreatedDateTime()),
"displayName": llx.StringData(convert.ToString(app.GetDisplayName())),
"publisherDomain": llx.StringData(convert.ToString(app.GetPublisherDomain())),
"signInAudience": llx.StringData(convert.ToString(app.GetSignInAudience())),
"displayName": llx.StringDataPtr(app.GetDisplayName()),
"publisherDomain": llx.StringDataPtr(app.GetPublisherDomain()),
"signInAudience": llx.StringDataPtr(app.GetSignInAudience()),
"identifierUris": llx.ArrayData(convert.SliceAnyToInterface(app.GetIdentifierUris()), types.String),
})
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions providers/ms365/resources/devicemanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ func (a *mqlMicrosoftDevicemanagement) deviceConfigurations() ([]interface{}, er
properties := getConfigurationProperties(configuration)
mqlResource, err := CreateResource(a.MqlRuntime, "microsoft.devicemanagement.deviceconfiguration",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(configuration.GetId())),
"id": llx.StringDataPtr(configuration.GetId()),
"lastModifiedDateTime": llx.TimeDataPtr(configuration.GetLastModifiedDateTime()),
"createdDateTime": llx.TimeDataPtr(configuration.GetCreatedDateTime()),
"description": llx.StringData(convert.ToString(configuration.GetDescription())),
"displayName": llx.StringData(convert.ToString(configuration.GetDisplayName())),
"description": llx.StringDataPtr(configuration.GetDescription()),
"displayName": llx.StringDataPtr(configuration.GetDisplayName()),
"version": llx.IntData(convert.ToInt64From32(configuration.GetVersion())),
"properties": llx.DictData(properties),
})
Expand Down Expand Up @@ -85,10 +85,10 @@ func (a *mqlMicrosoftDevicemanagement) deviceCompliancePolicies() ([]interface{}
properties := getComplianceProperties(compliancePolicy)
mqlResource, err := CreateResource(a.MqlRuntime, "microsoft.devicemanagement.devicecompliancepolicy",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(compliancePolicy.GetId())),
"id": llx.StringDataPtr(compliancePolicy.GetId()),
"createdDateTime": llx.TimeDataPtr(compliancePolicy.GetCreatedDateTime()),
"description": llx.StringData(convert.ToString(compliancePolicy.GetDescription())),
"displayName": llx.StringData(convert.ToString(compliancePolicy.GetDisplayName())),
"description": llx.StringDataPtr(compliancePolicy.GetDescription()),
"displayName": llx.StringDataPtr(compliancePolicy.GetDisplayName()),
"lastModifiedDateTime": llx.TimeDataPtr(compliancePolicy.GetLastModifiedDateTime()),
"version": llx.IntData(convert.ToInt64From32(compliancePolicy.GetVersion())),
"assignments": llx.ArrayData(assignments, types.Any),
Expand Down
26 changes: 13 additions & 13 deletions providers/ms365/resources/domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ func (a *mqlMicrosoft) domains() ([]interface{}, error) {
}
mqlResource, err := CreateResource(a.MqlRuntime, "microsoft.domain",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(domain.GetId())),
"authenticationType": llx.StringData(convert.ToString(domain.GetAuthenticationType())),
"availabilityStatus": llx.StringData(convert.ToString(domain.GetAvailabilityStatus())),
"isAdminManaged": llx.BoolData(convert.ToBool(domain.GetIsAdminManaged())),
"isDefault": llx.BoolData(convert.ToBool(domain.GetIsDefault())),
"isInitial": llx.BoolData(convert.ToBool(domain.GetIsInitial())),
"isRoot": llx.BoolData(convert.ToBool(domain.GetIsRoot())),
"isVerified": llx.BoolData(convert.ToBool(domain.GetIsVerified())),
"id": llx.StringDataPtr(domain.GetId()),
"authenticationType": llx.StringDataPtr(domain.GetAuthenticationType()),
"availabilityStatus": llx.StringDataPtr(domain.GetAvailabilityStatus()),
"isAdminManaged": llx.BoolDataPtr(domain.GetIsAdminManaged()),
"isDefault": llx.BoolDataPtr(domain.GetIsDefault()),
"isInitial": llx.BoolDataPtr(domain.GetIsInitial()),
"isRoot": llx.BoolDataPtr(domain.GetIsRoot()),
"isVerified": llx.BoolDataPtr(domain.GetIsVerified()),
"passwordNotificationWindowInDays": llx.IntData(convert.ToInt64From32(domain.GetPasswordNotificationWindowInDays())),
"passwordValidityPeriodInDays": llx.IntData(convert.ToInt64From32(domain.GetPasswordValidityPeriodInDays())),
"supportedServices": llx.ArrayData(supportedServices, types.String),
Expand Down Expand Up @@ -84,11 +84,11 @@ func (a *mqlMicrosoftDomain) serviceConfigurationRecords() ([]interface{}, error
properties := getDomainsDnsRecordProperties(record)
mqlResource, err := CreateResource(a.MqlRuntime, "microsoft.domaindnsrecord",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(record.GetId())),
"isOptional": llx.BoolData(convert.ToBool(record.GetIsOptional())),
"label": llx.StringData(convert.ToString(record.GetLabel())),
"recordType": llx.StringData(convert.ToString(record.GetRecordType())),
"supportedService": llx.StringData(convert.ToString(record.GetSupportedService())),
"id": llx.StringDataPtr(record.GetId()),
"isOptional": llx.BoolDataPtr(record.GetIsOptional()),
"label": llx.StringDataPtr(record.GetLabel()),
"recordType": llx.StringDataPtr(record.GetRecordType()),
"supportedService": llx.StringDataPtr(record.GetSupportedService()),
"ttl": llx.IntData(convert.ToInt64From32(record.GetTtl())),
"properties": llx.DictData(properties),
})
Expand Down
13 changes: 6 additions & 7 deletions providers/ms365/resources/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/microsoftgraph/msgraph-sdk-go/groups"
"go.mondoo.com/cnquery/v10/llx"
"go.mondoo.com/cnquery/v10/providers-sdk/v1/util/convert"
"go.mondoo.com/cnquery/v10/providers/ms365/connection"
)

Expand Down Expand Up @@ -39,12 +38,12 @@ func (a *mqlMicrosoft) groups() ([]interface{}, error) {
for _, grp := range grps {
graphGrp, err := CreateResource(a.MqlRuntime, "microsoft.group",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(grp.GetId())),
"displayName": llx.StringData(convert.ToString(grp.GetDisplayName())),
"mail": llx.StringData(convert.ToString(grp.GetMail())),
"mailEnabled": llx.BoolData(convert.ToBool(grp.GetMailEnabled())),
"mailNickname": llx.StringData(convert.ToString(grp.GetMailNickname())),
"securityEnabled": llx.BoolData(convert.ToBool(grp.GetSecurityEnabled())),
"id": llx.StringDataPtr(grp.GetId()),
"displayName": llx.StringDataPtr(grp.GetDisplayName()),
"mail": llx.StringDataPtr(grp.GetMail()),
"mailEnabled": llx.BoolDataPtr(grp.GetMailEnabled()),
"mailNickname": llx.StringDataPtr(grp.GetMailNickname()),
"securityEnabled": llx.BoolDataPtr(grp.GetSecurityEnabled()),
"visibility": llx.StringDataPtr(grp.GetVisibility()),
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions providers/ms365/resources/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ func (a *mqlMicrosoft) organizations() ([]interface{}, error) {
}
mqlResource, err := CreateResource(a.MqlRuntime, "microsoft.organization",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(org.GetId())),
"id": llx.StringDataPtr(org.GetId()),
"assignedPlans": llx.ArrayData(assignedPlans, types.Any),
"createdDateTime": llx.TimeDataPtr(org.GetCreatedDateTime()),
"displayName": llx.StringData(convert.ToString(org.GetDisplayName())),
"displayName": llx.StringDataPtr(org.GetDisplayName()),
"verifiedDomains": llx.ArrayData(verifiedDomains, types.Any),
"onPremisesSyncEnabled": llx.BoolDataPtr(org.GetOnPremisesSyncEnabled()),
})
Expand Down
20 changes: 10 additions & 10 deletions providers/ms365/resources/rolemanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ func (a *mqlMicrosoftRolemanagement) roleDefinitions() ([]interface{}, error) {
}
mqlResource, err := CreateResource(a.MqlRuntime, "microsoft.rolemanagement.roledefinition",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(role.GetId())),
"description": llx.StringData(convert.ToString(role.GetDescription())),
"displayName": llx.StringData(convert.ToString(role.GetDisplayName())),
"isBuiltIn": llx.BoolData(convert.ToBool(role.GetIsBuiltIn())),
"isEnabled": llx.BoolData(convert.ToBool(role.GetIsEnabled())),
"id": llx.StringDataPtr(role.GetId()),
"description": llx.StringDataPtr(role.GetDescription()),
"displayName": llx.StringDataPtr(role.GetDisplayName()),
"isBuiltIn": llx.BoolDataPtr(role.GetIsBuiltIn()),
"isEnabled": llx.BoolDataPtr(role.GetIsEnabled()),
"rolePermissions": llx.ArrayData(rolePermissions, types.Any),
"templateId": llx.StringData(convert.ToString(role.GetTemplateId())),
"version": llx.StringData(convert.ToString(role.GetVersion())),
"templateId": llx.StringDataPtr(role.GetTemplateId()),
"version": llx.StringDataPtr(role.GetVersion()),
})
if err != nil {
return nil, err
Expand Down Expand Up @@ -89,9 +89,9 @@ func (a *mqlMicrosoftRolemanagementRoledefinition) assignments() ([]interface{},
}
mqlResource, err := CreateResource(a.MqlRuntime, "microsoft.rolemanagement.roleassignment",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(roleAssignment.GetId())),
"roleDefinitionId": llx.StringData(convert.ToString(roleAssignment.GetRoleDefinitionId())),
"principalId": llx.StringData(convert.ToString(roleAssignment.GetPrincipalId())),
"id": llx.StringDataPtr(roleAssignment.GetId()),
"roleDefinitionId": llx.StringDataPtr(roleAssignment.GetRoleDefinitionId()),
"principalId": llx.StringDataPtr(roleAssignment.GetPrincipalId()),
"principal": llx.DictData(principal),
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions providers/ms365/resources/securescores.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ func msSecureScoreToMql(runtime *plugin.Runtime, score models.SecureScoreable) (
}
mqlResource, err := CreateResource(runtime, "microsoft.security.securityscore",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(score.GetId())),
"id": llx.StringDataPtr(score.GetId()),
"activeUserCount": llx.IntData(convert.ToInt64From32(score.GetActiveUserCount())),
"averageComparativeScores": llx.ArrayData(averageComparativeScores, types.Any),
"azureTenantId": llx.StringData(convert.ToString(score.GetAzureTenantId())),
"azureTenantId": llx.StringDataPtr(score.GetAzureTenantId()),
"controlScores": llx.ArrayData(controlScores, types.Any),
"createdDateTime": llx.TimeDataPtr(score.GetCreatedDateTime()),
"currentScore": llx.FloatData(convert.ToFloat64(score.GetCurrentScore())),
Expand Down
44 changes: 20 additions & 24 deletions providers/ms365/resources/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,29 @@ func (a *mqlMicrosoft) users() ([]interface{}, error) {
res := []interface{}{}
users := resp.GetValue()
for _, u := range users {
mails := []interface{}{}
for _, mail := range u.GetOtherMails() {
mails = append(mails, mail)
}
graphUser, err := CreateResource(a.MqlRuntime, "microsoft.user",
map[string]*llx.RawData{
"id": llx.StringData(convert.ToString(u.GetId())),
"accountEnabled": llx.BoolData(convert.ToBool(u.GetAccountEnabled())),
"city": llx.StringData(convert.ToString(u.GetCity())),
"companyName": llx.StringData(convert.ToString(u.GetCompanyName())),
"country": llx.StringData(convert.ToString(u.GetCountry())),
"id": llx.StringDataPtr(u.GetId()),
"accountEnabled": llx.BoolDataPtr(u.GetAccountEnabled()),
"city": llx.StringDataPtr(u.GetCity()),
"companyName": llx.StringDataPtr(u.GetCompanyName()),
"country": llx.StringDataPtr(u.GetCountry()),
"createdDateTime": llx.TimeDataPtr(u.GetCreatedDateTime()),
"department": llx.StringData(convert.ToString(u.GetDepartment())),
"displayName": llx.StringData(convert.ToString(u.GetDisplayName())),
"employeeId": llx.StringData(convert.ToString(u.GetEmployeeId())),
"givenName": llx.StringData(convert.ToString(u.GetGivenName())),
"jobTitle": llx.StringData(convert.ToString(u.GetJobTitle())),
"mail": llx.StringData(convert.ToString(u.GetMail())),
"mobilePhone": llx.StringData(convert.ToString(u.GetMobilePhone())),
"otherMails": llx.ArrayData(mails, types.String),
"officeLocation": llx.StringData(convert.ToString(u.GetOfficeLocation())),
"postalCode": llx.StringData(convert.ToString(u.GetPostalCode())),
"state": llx.StringData(convert.ToString(u.GetState())),
"streetAddress": llx.StringData(convert.ToString(u.GetStreetAddress())),
"surname": llx.StringData(convert.ToString(u.GetSurname())),
"userPrincipalName": llx.StringData(convert.ToString(u.GetUserPrincipalName())),
"userType": llx.StringData(convert.ToString(u.GetUserType())),
"department": llx.StringDataPtr(u.GetDepartment()),
"displayName": llx.StringDataPtr(u.GetDisplayName()),
"employeeId": llx.StringDataPtr(u.GetEmployeeId()),
"givenName": llx.StringDataPtr(u.GetGivenName()),
"jobTitle": llx.StringDataPtr(u.GetJobTitle()),
"mail": llx.StringDataPtr(u.GetMail()),
"mobilePhone": llx.StringDataPtr(u.GetMobilePhone()),
"otherMails": llx.ArrayData(llx.TArr2Raw(u.GetOtherMails()), types.String),
"officeLocation": llx.StringDataPtr(u.GetOfficeLocation()),
"postalCode": llx.StringDataPtr(u.GetPostalCode()),
"state": llx.StringDataPtr(u.GetState()),
"streetAddress": llx.StringDataPtr(u.GetStreetAddress()),
"surname": llx.StringDataPtr(u.GetSurname()),
"userPrincipalName": llx.StringDataPtr(u.GetUserPrincipalName()),
"userType": llx.StringDataPtr(u.GetUserType()),
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 33a0b29

Please sign in to comment.