Skip to content

Commit

Permalink
✨ add Slack user 2FA type property (#1107)
Browse files Browse the repository at this point in the history
```typescript
cnquery> slack.users.where( has2FA == true ){ has2FA twoFactorType }
slack.users.where.list: [
  0: {
    twoFactorType: "app"
    has2FA: true
  }
]
```

Note that this PR switches the slack library to a fork. That's required
until the PR I submitted for the upstream repo is merged
slack-go/slack#1183

Signed-off-by: Ivan Milchev <ivan@mondoo.com>
  • Loading branch information
imilchev committed Mar 27, 2023
1 parent 2e7bde9 commit 1ac06f2
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 4 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module go.mondoo.com/cnquery

go 1.19

replace github.com/slack-go/slack v0.12.1 => github.com/imilchev/slack v0.0.0-20230324120548-5380d7dd00a5

require (
cloud.google.com/go/accessapproval v1.5.0
cloud.google.com/go/bigquery v1.44.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU=
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/imilchev/slack v0.0.0-20230324120548-5380d7dd00a5 h1:aNFjgSeqhIzc+g0SyzXxypHI87MzN32fCd2kI6OD/1o=
github.com/imilchev/slack v0.0.0-20230324120548-5380d7dd00a5/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
Expand Down Expand Up @@ -1231,8 +1233,6 @@ github.com/sivchari/nosnakecase v1.7.0 h1:7QkpWIRMe8x25gckkFd2A5Pi6Ymo0qgr4JrhGt
github.com/sivchari/nosnakecase v1.7.0/go.mod h1:CwDzrzPea40/GB6uynrNLiorAlgFRvRbFSgJx2Gs+QY=
github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak=
github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg=
github.com/slack-go/slack v0.12.1 h1:X97b9g2hnITDtNsNe5GkGx6O2/Sz/uC20ejRZN6QxOw=
github.com/slack-go/slack v0.12.1/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
Expand Down
2 changes: 1 addition & 1 deletion resources/packs/slack/info/slack.lr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/packs/slack/info/slack.lr.manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"resources":{"slack":{"fields":{"accessLogs":{},"conversations":{},"userGroups":{}},"min_mondoo_version":"latest"},"slack.conversation":{"fields":{"created":{},"creator":{},"id":{},"isArchived":{},"isChannel":{},"isExtShared":{},"isGroup":{},"isIM":{},"isMpim":{},"isOpen":{},"isOrgShared":{},"isPendingExtShared":{},"isPrivate":{},"isShared":{},"locale":{},"members":{},"name":{},"priority":{},"purpose":{},"topic":{}},"min_mondoo_version":"latest"},"slack.enterpriseUser":{"fields":{"enterpriseId":{},"enterpriseName":{},"id":{},"isAdmin":{},"isOwner":{}},"min_mondoo_version":"latest"},"slack.login":{"fields":{"count":{},"country":{},"dateFirst":{},"dateLast":{},"ip":{},"isp":{},"region":{},"userAgent":{},"userID":{},"username":{}},"min_mondoo_version":"latest"},"slack.team":{"fields":{"domain":{},"emailDomain":{},"id":{},"name":{}},"min_mondoo_version":"latest"},"slack.user":{"fields":{"color":{},"deleted":{},"enterpriseUser":{},"has2FA":{},"hasFiles":{},"id":{},"isAdmin":{},"isAppUser":{},"isBot":{},"isInvitedUser":{},"isOwner":{},"isPrimaryOwner":{},"isRestricted":{},"isStranger":{},"isUltraRestricted":{},"locale":{},"name":{},"presence":{},"profile":{},"realName":{},"teamId":{},"timeZone":{},"timeZoneLabel":{},"timeZoneOffset":{}},"min_mondoo_version":"latest"},"slack.userGroup":{"fields":{"created":{},"createdBy":{},"deleted":{},"deletedBy":{},"description":{},"handle":{},"id":{},"isExternal":{},"members":{},"name":{},"teamId":{},"updated":{},"updatedBy":{},"userCount":{}},"min_mondoo_version":"latest"},"slack.users":{"fields":{"admins":{},"bots":{},"list":{},"members":{},"owner":{},"owners":{}},"min_mondoo_version":"latest"}}}
{"resources":{"slack":{"fields":{"accessLogs":{},"conversations":{},"userGroups":{}},"min_mondoo_version":"latest"},"slack.conversation":{"fields":{"created":{},"creator":{},"id":{},"isArchived":{},"isChannel":{},"isExtShared":{},"isGroup":{},"isIM":{},"isMpim":{},"isOpen":{},"isOrgShared":{},"isPendingExtShared":{},"isPrivate":{},"isShared":{},"locale":{},"members":{},"name":{},"priority":{},"purpose":{},"topic":{}},"min_mondoo_version":"latest"},"slack.enterpriseUser":{"fields":{"enterpriseId":{},"enterpriseName":{},"id":{},"isAdmin":{},"isOwner":{}},"min_mondoo_version":"latest"},"slack.login":{"fields":{"count":{},"country":{},"dateFirst":{},"dateLast":{},"ip":{},"isp":{},"region":{},"userAgent":{},"userID":{},"username":{}},"min_mondoo_version":"latest"},"slack.team":{"fields":{"domain":{},"emailDomain":{},"id":{},"name":{}},"min_mondoo_version":"latest"},"slack.user":{"fields":{"color":{},"deleted":{},"enterpriseUser":{},"has2FA":{},"hasFiles":{},"id":{},"isAdmin":{},"isAppUser":{},"isBot":{},"isInvitedUser":{},"isOwner":{},"isPrimaryOwner":{},"isRestricted":{},"isStranger":{},"isUltraRestricted":{},"locale":{},"name":{},"presence":{},"profile":{},"realName":{},"teamId":{},"timeZone":{},"timeZoneLabel":{},"timeZoneOffset":{},"twoFactorType":{}},"min_mondoo_version":"latest"},"slack.userGroup":{"fields":{"created":{},"createdBy":{},"deleted":{},"deletedBy":{},"description":{},"handle":{},"id":{},"isExternal":{},"members":{},"name":{},"teamId":{},"updated":{},"updatedBy":{},"userCount":{}},"min_mondoo_version":"latest"},"slack.users":{"fields":{"admins":{},"bots":{},"list":{},"members":{},"owner":{},"owners":{}},"min_mondoo_version":"latest"}}}
2 changes: 2 additions & 0 deletions resources/packs/slack/slack.lr
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ slack.user @defaults("id") {
isInvitedUser bool
// Indicates whether two-factor authentication is enabled for this user
has2FA bool
// Indicates the type of two-factor authentication in use
twoFactorType string
// Indicates whether the user own files
hasFiles bool
// Presence of the user
Expand Down
30 changes: 30 additions & 0 deletions resources/packs/slack/slack.lr.go

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

1 change: 1 addition & 0 deletions resources/packs/slack/slack.lr.manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ resources:
timeZone: {}
timeZoneLabel: {}
timeZoneOffset: {}
twoFactorType: {}
min_mondoo_version: latest
slack.userGroup:
fields:
Expand Down
6 changes: 6 additions & 0 deletions resources/packs/slack/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ func newMqlSlackUser(runtime *resources.Runtime, user slack.User) (interface{},
}
}

twoFactoryType := ""
if user.TwoFactorType != nil {
twoFactoryType = *user.TwoFactorType
}

return runtime.CreateResource("slack.user",
"id", user.ID,
"teamId", user.TeamID,
Expand All @@ -202,6 +207,7 @@ func newMqlSlackUser(runtime *resources.Runtime, user slack.User) (interface{},
"isAppUser", user.IsAppUser,
"isInvitedUser", user.IsInvitedUser,
"has2FA", user.Has2FA,
"twoFactorType", twoFactoryType,
"hasFiles", user.HasFiles,
"presence", user.Presence,
"locale", user.Locale,
Expand Down

0 comments on commit 1ac06f2

Please sign in to comment.