From 1ac06f265e9ddf9cc7c774a14e490378f359c6ce Mon Sep 17 00:00:00 2001 From: Ivan Milchev Date: Mon, 27 Mar 2023 22:09:28 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20Slack=20user=202FA=20type=20p?= =?UTF-8?q?roperty=20(#1107)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ```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 https://github.com/slack-go/slack/pull/1183 Signed-off-by: Ivan Milchev --- go.mod | 2 ++ go.sum | 4 +-- resources/packs/slack/info/slack.lr.json | 2 +- .../packs/slack/info/slack.lr.manifest.json | 2 +- resources/packs/slack/slack.lr | 2 ++ resources/packs/slack/slack.lr.go | 30 +++++++++++++++++++ resources/packs/slack/slack.lr.manifest.yaml | 1 + resources/packs/slack/users.go | 6 ++++ 8 files changed, 45 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index e6945131b1..d37c070cee 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index a0b824bb62..a3f845d7a0 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/resources/packs/slack/info/slack.lr.json b/resources/packs/slack/info/slack.lr.json index e4d472cff8..224b4b7288 100644 --- a/resources/packs/slack/info/slack.lr.json +++ b/resources/packs/slack/info/slack.lr.json @@ -1 +1 @@ -{"resources":{"slack":{"id":"slack","name":"slack","fields":{"accessLogs":{"name":"accessLogs","type":"\u0019\u001bslack.login","title":"Slack Access Logs"},"conversations":{"name":"conversations","type":"\u0019\u001bslack.conversation","title":"List of channels in a Slack team"},"userGroups":{"name":"userGroups","type":"\u0019\u001bslack.userGroup","title":"List of Slack user groups"}},"title":"Slack"},"slack.conversation":{"id":"slack.conversation","name":"slack.conversation","fields":{"created":{"name":"created","type":"\t","is_mandatory":true,"title":"Timestamp of when the conversation was"},"creator":{"name":"creator","type":"\u001bslack.user","is_mandatory":true,"title":"User the member that created this conversation"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Conversation ID"},"isArchived":{"name":"isArchived","type":"\u0004","is_mandatory":true,"title":"Indicates that the conversation is archived"},"isChannel":{"name":"isChannel","type":"\u0004","is_mandatory":true,"title":"Indicates whether a conversation is a channel"},"isExtShared":{"name":"isExtShared","type":"\u0004","is_mandatory":true,"title":"Indicates whether a conversation is part of a Shared Channel with a remote organization"},"isGroup":{"name":"isGroup","type":"\u0004","is_mandatory":true,"title":"Indicates a private channel created before March 2021"},"isIM":{"name":"isIM","type":"\u0004","is_mandatory":true,"title":"Indicates whether this is a direct message"},"isMpim":{"name":"isMpim","type":"\u0004","is_mandatory":true,"title":"Indicates whether this private conversation between multiple users"},"isOpen":{"name":"isOpen","type":"\u0004","is_mandatory":true,"title":"Indicates that the conversation is open"},"isOrgShared":{"name":"isOrgShared","type":"\u0004","is_mandatory":true,"title":"Indicates whether this shared channel is shared between Enterprise Grid workspaces"},"isPendingExtShared":{"name":"isPendingExtShared","type":"\u0004","is_mandatory":true,"title":"Indicates whether a conversation is going to be shared with a remote organization"},"isPrivate":{"name":"isPrivate","type":"\u0004","is_mandatory":true,"title":"Conversation is privileged between two or more members"},"isShared":{"name":"isShared","type":"\u0004","is_mandatory":true,"title":"Indicates whether conversation is in some way shared between multiple workspaces"},"locale":{"name":"locale","type":"\u0007","is_mandatory":true,"title":"IETF language code that represents chosen language"},"members":{"name":"members","type":"\u0019\u001bslack.user","title":"Members of the conversation"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Name of the channel-like thing"},"priority":{"name":"priority","type":"\u0006","is_mandatory":true,"title":"Priority of the conversation"},"purpose":{"name":"purpose","type":"\n","is_mandatory":true,"title":"Information about the channel purpose"},"topic":{"name":"topic","type":"\n","is_mandatory":true,"title":"Information about the channel topic"}},"title":"Slack Conversation","defaults":"id name"},"slack.enterpriseUser":{"id":"slack.enterpriseUser","name":"slack.enterpriseUser","fields":{"enterpriseId":{"name":"enterpriseId","type":"\u0007","is_mandatory":true,"title":"Unique ID for the Enterprise Grid organization"},"enterpriseName":{"name":"enterpriseName","type":"\u0007","is_mandatory":true,"title":"Name for the Enterprise Grid organization."},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Enterprise user ID"},"isAdmin":{"name":"isAdmin","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is an Admin of the Enterprise Grid organization"},"isOwner":{"name":"isOwner","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is an Owner of the Enterprise Grid organization"}},"title":"Slack Enterprise Grid User"},"slack.login":{"id":"slack.login","name":"slack.login","fields":{"count":{"name":"count","type":"\u0005","is_mandatory":true,"title":"Total number of access log entries for that combination"},"country":{"name":"country","type":"\u0007","is_mandatory":true,"title":"Best guesses on where the access originated, based on the IP address"},"dateFirst":{"name":"dateFirst","type":"\t","is_mandatory":true,"title":"First access log entry for user, IP address, and user agent combination"},"dateLast":{"name":"dateLast","type":"\t","is_mandatory":true,"title":"Most recent log entry for user, IP address, and user agent combination"},"ip":{"name":"ip","type":"\u0007","is_mandatory":true,"title":"IP address of the device used"},"isp":{"name":"isp","type":"\u0007","is_mandatory":true,"title":"Best guess at the internet service provider"},"region":{"name":"region","type":"\u0007","is_mandatory":true,"title":"Best guesses on where the access originated, based on the IP address"},"userAgent":{"name":"userAgent","type":"\u0007","is_mandatory":true,"title":"User agent string from the browser or client application"},"userID":{"name":"userID","type":"\u0007","is_mandatory":true,"title":"User ID"},"username":{"name":"username","type":"\u0007","is_mandatory":true,"title":"User's handle"}},"title":"Slack access log entry","defaults":"userID"},"slack.team":{"id":"slack.team","name":"slack.team","fields":{"domain":{"name":"domain","type":"\u0007","is_mandatory":true,"title":"Domain of the team"},"emailDomain":{"name":"emailDomain","type":"\u0007","is_mandatory":true,"title":"Email domain of the team"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"ID of the team"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Name of the team"}},"title":"Slack Team","defaults":"id domain"},"slack.user":{"id":"slack.user","name":"slack.user","fields":{"color":{"name":"color","type":"\u0007","is_mandatory":true,"title":"Special username color."},"deleted":{"name":"deleted","type":"\u0004","is_mandatory":true,"title":"Indicates if the user has been deactivated"},"enterpriseUser":{"name":"enterpriseUser","type":"\u001bslack.enterpriseUser","is_mandatory":true,"title":"related Slack Enterprise Grid user"},"has2FA":{"name":"has2FA","type":"\u0004","is_mandatory":true,"title":"Indicates whether two-factor authentication is enabled for this user"},"hasFiles":{"name":"hasFiles","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user own files"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Identifier for workspace user"},"isAdmin":{"name":"isAdmin","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is an Admin of the current workspace"},"isAppUser":{"name":"isAppUser","type":"\u0004","is_mandatory":true},"isBot":{"name":"isBot","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is actually a bot user"},"isInvitedUser":{"name":"isInvitedUser","type":"\u0004","is_mandatory":true,"title":"Indicates whether a user has been invited but has not yet signed in"},"isOwner":{"name":"isOwner","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is an Owner of the current workspace"},"isPrimaryOwner":{"name":"isPrimaryOwner","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is the Primary Owner of the current workspace"},"isRestricted":{"name":"isRestricted","type":"\u0004","is_mandatory":true,"title":"Indicates whether or not the user is a guest user"},"isStranger":{"name":"isStranger","type":"\u0004","is_mandatory":true,"title":"Indicates if the user belongs to a different workspace"},"isUltraRestricted":{"name":"isUltraRestricted","type":"\u0004","is_mandatory":true,"title":"Indicates whether or not the user is a single-channel guest"},"locale":{"name":"locale","type":"\u0007","is_mandatory":true,"title":"IETF language code that represents this user's chosen display language"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"User name"},"presence":{"name":"presence","type":"\u0007","is_mandatory":true,"title":"Presence of the user"},"profile":{"name":"profile","type":"\n","is_mandatory":true,"title":"User profile"},"realName":{"name":"realName","type":"\u0007","is_mandatory":true,"title":"User's first and last name"},"teamId":{"name":"teamId","type":"\u0007","is_mandatory":true,"title":"Slack workspace ID"},"timeZone":{"name":"timeZone","type":"\u0007","is_mandatory":true,"title":"Geographic timezone-related region"},"timeZoneLabel":{"name":"timeZoneLabel","type":"\u0007","is_mandatory":true,"title":"Commonly used name of the timezone"},"timeZoneOffset":{"name":"timeZoneOffset","type":"\u0005","is_mandatory":true,"title":"Number of seconds to offset UTC time"}},"title":"Slack User","defaults":"id"},"slack.userGroup":{"id":"slack.userGroup","name":"slack.userGroup","fields":{"created":{"name":"created","type":"\t","is_mandatory":true,"title":"Timestamp when the group was created"},"createdBy":{"name":"createdBy","type":"\u001bslack.user","is_mandatory":true,"title":"User that created the group"},"deleted":{"name":"deleted","type":"\t","is_mandatory":true,"title":"Timestamp when the group was deleted"},"deletedBy":{"name":"deletedBy","type":"\u001bslack.user","is_mandatory":true,"title":"User that deleted the group"},"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"Purpose of the group"},"handle":{"name":"handle","type":"\u0007","is_mandatory":true,"title":"Value used to notify group members"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Group ID"},"isExternal":{"name":"isExternal","type":"\u0004","is_mandatory":true,"title":"Indicates whether the group is external"},"members":{"name":"members","type":"\u0019\u001bslack.user","title":"Members of the group"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Friendly name of the group"},"teamId":{"name":"teamId","type":"\u0007","is_mandatory":true,"title":"Slack workspace ID"},"updated":{"name":"updated","type":"\t","is_mandatory":true,"title":"Timestamp when the group was updated"},"updatedBy":{"name":"updatedBy","type":"\u001bslack.user","is_mandatory":true,"title":"User that updated the group"},"userCount":{"name":"userCount","type":"\u0005","is_mandatory":true,"title":"Total number of users in a group"}},"title":"Slack User Groups","defaults":"handle"},"slack.users":{"id":"slack.users","name":"slack.users","fields":{"admins":{"name":"admins","type":"\u0019\u001bslack.user","title":"Filter admins of workspace"},"bots":{"name":"bots","type":"\u0019\u001bslack.user","title":"Filter bot users"},"list":{"name":"list","type":"\u0019\u001bslack.user"},"members":{"name":"members","type":"\u0019\u001bslack.user","title":"Filter members of workspace"},"owners":{"name":"owners","type":"\u0019\u001bslack.user","title":"Filter owner of workspace"}},"list_type":"\u001bslack.user","title":"Slack Users"}}} \ No newline at end of file +{"resources":{"slack":{"id":"slack","name":"slack","fields":{"accessLogs":{"name":"accessLogs","type":"\u0019\u001bslack.login","title":"Slack Access Logs"},"conversations":{"name":"conversations","type":"\u0019\u001bslack.conversation","title":"List of channels in a Slack team"},"userGroups":{"name":"userGroups","type":"\u0019\u001bslack.userGroup","title":"List of Slack user groups"}},"title":"Slack"},"slack.conversation":{"id":"slack.conversation","name":"slack.conversation","fields":{"created":{"name":"created","type":"\t","is_mandatory":true,"title":"Timestamp of when the conversation was"},"creator":{"name":"creator","type":"\u001bslack.user","is_mandatory":true,"title":"User the member that created this conversation"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Conversation ID"},"isArchived":{"name":"isArchived","type":"\u0004","is_mandatory":true,"title":"Indicates that the conversation is archived"},"isChannel":{"name":"isChannel","type":"\u0004","is_mandatory":true,"title":"Indicates whether a conversation is a channel"},"isExtShared":{"name":"isExtShared","type":"\u0004","is_mandatory":true,"title":"Indicates whether a conversation is part of a Shared Channel with a remote organization"},"isGroup":{"name":"isGroup","type":"\u0004","is_mandatory":true,"title":"Indicates a private channel created before March 2021"},"isIM":{"name":"isIM","type":"\u0004","is_mandatory":true,"title":"Indicates whether this is a direct message"},"isMpim":{"name":"isMpim","type":"\u0004","is_mandatory":true,"title":"Indicates whether this private conversation between multiple users"},"isOpen":{"name":"isOpen","type":"\u0004","is_mandatory":true,"title":"Indicates that the conversation is open"},"isOrgShared":{"name":"isOrgShared","type":"\u0004","is_mandatory":true,"title":"Indicates whether this shared channel is shared between Enterprise Grid workspaces"},"isPendingExtShared":{"name":"isPendingExtShared","type":"\u0004","is_mandatory":true,"title":"Indicates whether a conversation is going to be shared with a remote organization"},"isPrivate":{"name":"isPrivate","type":"\u0004","is_mandatory":true,"title":"Conversation is privileged between two or more members"},"isShared":{"name":"isShared","type":"\u0004","is_mandatory":true,"title":"Indicates whether conversation is in some way shared between multiple workspaces"},"locale":{"name":"locale","type":"\u0007","is_mandatory":true,"title":"IETF language code that represents chosen language"},"members":{"name":"members","type":"\u0019\u001bslack.user","title":"Members of the conversation"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Name of the channel-like thing"},"priority":{"name":"priority","type":"\u0006","is_mandatory":true,"title":"Priority of the conversation"},"purpose":{"name":"purpose","type":"\n","is_mandatory":true,"title":"Information about the channel purpose"},"topic":{"name":"topic","type":"\n","is_mandatory":true,"title":"Information about the channel topic"}},"title":"Slack Conversation","defaults":"id name"},"slack.enterpriseUser":{"id":"slack.enterpriseUser","name":"slack.enterpriseUser","fields":{"enterpriseId":{"name":"enterpriseId","type":"\u0007","is_mandatory":true,"title":"Unique ID for the Enterprise Grid organization"},"enterpriseName":{"name":"enterpriseName","type":"\u0007","is_mandatory":true,"title":"Name for the Enterprise Grid organization."},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Enterprise user ID"},"isAdmin":{"name":"isAdmin","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is an Admin of the Enterprise Grid organization"},"isOwner":{"name":"isOwner","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is an Owner of the Enterprise Grid organization"}},"title":"Slack Enterprise Grid User"},"slack.login":{"id":"slack.login","name":"slack.login","fields":{"count":{"name":"count","type":"\u0005","is_mandatory":true,"title":"Total number of access log entries for that combination"},"country":{"name":"country","type":"\u0007","is_mandatory":true,"title":"Best guesses on where the access originated, based on the IP address"},"dateFirst":{"name":"dateFirst","type":"\t","is_mandatory":true,"title":"First access log entry for user, IP address, and user agent combination"},"dateLast":{"name":"dateLast","type":"\t","is_mandatory":true,"title":"Most recent log entry for user, IP address, and user agent combination"},"ip":{"name":"ip","type":"\u0007","is_mandatory":true,"title":"IP address of the device used"},"isp":{"name":"isp","type":"\u0007","is_mandatory":true,"title":"Best guess at the internet service provider"},"region":{"name":"region","type":"\u0007","is_mandatory":true,"title":"Best guesses on where the access originated, based on the IP address"},"userAgent":{"name":"userAgent","type":"\u0007","is_mandatory":true,"title":"User agent string from the browser or client application"},"userID":{"name":"userID","type":"\u0007","is_mandatory":true,"title":"User ID"},"username":{"name":"username","type":"\u0007","is_mandatory":true,"title":"User's handle"}},"title":"Slack access log entry","defaults":"userID"},"slack.team":{"id":"slack.team","name":"slack.team","fields":{"domain":{"name":"domain","type":"\u0007","is_mandatory":true,"title":"Domain of the team"},"emailDomain":{"name":"emailDomain","type":"\u0007","is_mandatory":true,"title":"Email domain of the team"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"ID of the team"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Name of the team"}},"title":"Slack Team","defaults":"id domain"},"slack.user":{"id":"slack.user","name":"slack.user","fields":{"color":{"name":"color","type":"\u0007","is_mandatory":true,"title":"Special username color."},"deleted":{"name":"deleted","type":"\u0004","is_mandatory":true,"title":"Indicates if the user has been deactivated"},"enterpriseUser":{"name":"enterpriseUser","type":"\u001bslack.enterpriseUser","is_mandatory":true,"title":"related Slack Enterprise Grid user"},"has2FA":{"name":"has2FA","type":"\u0004","is_mandatory":true,"title":"Indicates whether two-factor authentication is enabled for this user"},"hasFiles":{"name":"hasFiles","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user own files"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Identifier for workspace user"},"isAdmin":{"name":"isAdmin","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is an Admin of the current workspace"},"isAppUser":{"name":"isAppUser","type":"\u0004","is_mandatory":true},"isBot":{"name":"isBot","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is actually a bot user"},"isInvitedUser":{"name":"isInvitedUser","type":"\u0004","is_mandatory":true,"title":"Indicates whether a user has been invited but has not yet signed in"},"isOwner":{"name":"isOwner","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is an Owner of the current workspace"},"isPrimaryOwner":{"name":"isPrimaryOwner","type":"\u0004","is_mandatory":true,"title":"Indicates whether the user is the Primary Owner of the current workspace"},"isRestricted":{"name":"isRestricted","type":"\u0004","is_mandatory":true,"title":"Indicates whether or not the user is a guest user"},"isStranger":{"name":"isStranger","type":"\u0004","is_mandatory":true,"title":"Indicates if the user belongs to a different workspace"},"isUltraRestricted":{"name":"isUltraRestricted","type":"\u0004","is_mandatory":true,"title":"Indicates whether or not the user is a single-channel guest"},"locale":{"name":"locale","type":"\u0007","is_mandatory":true,"title":"IETF language code that represents this user's chosen display language"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"User name"},"presence":{"name":"presence","type":"\u0007","is_mandatory":true,"title":"Presence of the user"},"profile":{"name":"profile","type":"\n","is_mandatory":true,"title":"User profile"},"realName":{"name":"realName","type":"\u0007","is_mandatory":true,"title":"User's first and last name"},"teamId":{"name":"teamId","type":"\u0007","is_mandatory":true,"title":"Slack workspace ID"},"timeZone":{"name":"timeZone","type":"\u0007","is_mandatory":true,"title":"Geographic timezone-related region"},"timeZoneLabel":{"name":"timeZoneLabel","type":"\u0007","is_mandatory":true,"title":"Commonly used name of the timezone"},"timeZoneOffset":{"name":"timeZoneOffset","type":"\u0005","is_mandatory":true,"title":"Number of seconds to offset UTC time"},"twoFactorType":{"name":"twoFactorType","type":"\u0007","is_mandatory":true,"title":"Indicates the type of two-factor authentication in use"}},"title":"Slack User","defaults":"id"},"slack.userGroup":{"id":"slack.userGroup","name":"slack.userGroup","fields":{"created":{"name":"created","type":"\t","is_mandatory":true,"title":"Timestamp when the group was created"},"createdBy":{"name":"createdBy","type":"\u001bslack.user","is_mandatory":true,"title":"User that created the group"},"deleted":{"name":"deleted","type":"\t","is_mandatory":true,"title":"Timestamp when the group was deleted"},"deletedBy":{"name":"deletedBy","type":"\u001bslack.user","is_mandatory":true,"title":"User that deleted the group"},"description":{"name":"description","type":"\u0007","is_mandatory":true,"title":"Purpose of the group"},"handle":{"name":"handle","type":"\u0007","is_mandatory":true,"title":"Value used to notify group members"},"id":{"name":"id","type":"\u0007","is_mandatory":true,"title":"Group ID"},"isExternal":{"name":"isExternal","type":"\u0004","is_mandatory":true,"title":"Indicates whether the group is external"},"members":{"name":"members","type":"\u0019\u001bslack.user","title":"Members of the group"},"name":{"name":"name","type":"\u0007","is_mandatory":true,"title":"Friendly name of the group"},"teamId":{"name":"teamId","type":"\u0007","is_mandatory":true,"title":"Slack workspace ID"},"updated":{"name":"updated","type":"\t","is_mandatory":true,"title":"Timestamp when the group was updated"},"updatedBy":{"name":"updatedBy","type":"\u001bslack.user","is_mandatory":true,"title":"User that updated the group"},"userCount":{"name":"userCount","type":"\u0005","is_mandatory":true,"title":"Total number of users in a group"}},"title":"Slack User Groups","defaults":"handle"},"slack.users":{"id":"slack.users","name":"slack.users","fields":{"admins":{"name":"admins","type":"\u0019\u001bslack.user","title":"Filter admins of workspace"},"bots":{"name":"bots","type":"\u0019\u001bslack.user","title":"Filter bot users"},"list":{"name":"list","type":"\u0019\u001bslack.user"},"members":{"name":"members","type":"\u0019\u001bslack.user","title":"Filter members of workspace"},"owners":{"name":"owners","type":"\u0019\u001bslack.user","title":"Filter owner of workspace"}},"list_type":"\u001bslack.user","title":"Slack Users"}}} \ No newline at end of file diff --git a/resources/packs/slack/info/slack.lr.manifest.json b/resources/packs/slack/info/slack.lr.manifest.json index 7a569078d8..29aeef7ea3 100644 --- a/resources/packs/slack/info/slack.lr.manifest.json +++ b/resources/packs/slack/info/slack.lr.manifest.json @@ -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"}}} \ No newline at end of file +{"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"}}} \ No newline at end of file diff --git a/resources/packs/slack/slack.lr b/resources/packs/slack/slack.lr index 8fc9b80b3f..885750129d 100644 --- a/resources/packs/slack/slack.lr +++ b/resources/packs/slack/slack.lr @@ -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 diff --git a/resources/packs/slack/slack.lr.go b/resources/packs/slack/slack.lr.go index 84d2f86614..9bcca9c1b6 100644 --- a/resources/packs/slack/slack.lr.go +++ b/resources/packs/slack/slack.lr.go @@ -842,6 +842,7 @@ type SlackUser interface { IsAppUser() (bool, error) IsInvitedUser() (bool, error) Has2FA() (bool, error) + TwoFactorType() (string, error) HasFiles() (bool, error) Presence() (string, error) Locale() (string, error) @@ -960,6 +961,10 @@ func newSlackUser(runtime *resources.Runtime, args *resources.Args) (interface{} if _, ok := val.(bool); !ok { return nil, errors.New("Failed to initialize \"slack.user\", its \"has2FA\" argument has the wrong type (expected type \"bool\")") } + case "twoFactorType": + if _, ok := val.(string); !ok { + return nil, errors.New("Failed to initialize \"slack.user\", its \"twoFactorType\" argument has the wrong type (expected type \"string\")") + } case "hasFiles": if _, ok := val.(bool); !ok { return nil, errors.New("Failed to initialize \"slack.user\", its \"hasFiles\" argument has the wrong type (expected type \"bool\")") @@ -1064,6 +1069,9 @@ func (s *mqlSlackUser) Validate() error { if _, ok := s.Cache.Load("has2FA"); !ok { return errors.New("Initialized \"slack.user\" resource without a \"has2FA\". This field is required.") } + if _, ok := s.Cache.Load("twoFactorType"); !ok { + return errors.New("Initialized \"slack.user\" resource without a \"twoFactorType\". This field is required.") + } if _, ok := s.Cache.Load("hasFiles"); !ok { return errors.New("Initialized \"slack.user\" resource without a \"hasFiles\". This field is required.") } @@ -1125,6 +1133,8 @@ func (s *mqlSlackUser) Register(name string) error { return nil case "has2FA": return nil + case "twoFactorType": + return nil case "hasFiles": return nil case "presence": @@ -1182,6 +1192,8 @@ func (s *mqlSlackUser) Field(name string) (interface{}, error) { return s.IsInvitedUser() case "has2FA": return s.Has2FA() + case "twoFactorType": + return s.TwoFactorType() case "hasFiles": return s.HasFiles() case "presence": @@ -1501,6 +1513,22 @@ func (s *mqlSlackUser) Has2FA() (bool, error) { return tres, nil } +// TwoFactorType accessor autogenerated +func (s *mqlSlackUser) TwoFactorType() (string, error) { + res, ok := s.Cache.Load("twoFactorType") + if !ok || !res.Valid { + return "", errors.New("\"slack.user\" failed: no value provided for static field \"twoFactorType\"") + } + if res.Error != nil { + return "", res.Error + } + tres, ok := res.Data.(string) + if !ok { + return "", fmt.Errorf("\"slack.user\" failed to cast field \"twoFactorType\" to the right type (string): %#v", res) + } + return tres, nil +} + // HasFiles accessor autogenerated func (s *mqlSlackUser) HasFiles() (bool, error) { res, ok := s.Cache.Load("hasFiles") @@ -1623,6 +1651,8 @@ func (s *mqlSlackUser) MqlCompute(name string) error { return nil case "has2FA": return nil + case "twoFactorType": + return nil case "hasFiles": return nil case "presence": diff --git a/resources/packs/slack/slack.lr.manifest.yaml b/resources/packs/slack/slack.lr.manifest.yaml index 68736ef8a9..074b53cbc5 100755 --- a/resources/packs/slack/slack.lr.manifest.yaml +++ b/resources/packs/slack/slack.lr.manifest.yaml @@ -82,6 +82,7 @@ resources: timeZone: {} timeZoneLabel: {} timeZoneOffset: {} + twoFactorType: {} min_mondoo_version: latest slack.userGroup: fields: diff --git a/resources/packs/slack/users.go b/resources/packs/slack/users.go index a9c72a48b1..9bfe745940 100644 --- a/resources/packs/slack/users.go +++ b/resources/packs/slack/users.go @@ -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, @@ -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,