@@ -135,7 +135,7 @@ type ResourceTag struct {
135135 Value string `json:"value"`
136136}
137137
138- func (shf * SecurityHubV2Finding ) SlackMessage (consoleURL , accessPortalURL , accessRoleName string ) (slack.MsgOption , slack.MsgOption ) {
138+ func (shf * SecurityHubV2Finding ) SlackMessage (consoleURL , accessPortalURL , accessRoleName , shRegion string ) (slack.MsgOption , slack.MsgOption ) {
139139 var blocks []slack.Block
140140
141141 severityEmoji := shf .GetSeverityEmoji ()
@@ -161,6 +161,12 @@ func (shf *SecurityHubV2Finding) SlackMessage(consoleURL, accessPortalURL, acces
161161 details := slack .NewSectionBlock (nil , detailFields , nil )
162162 blocks = append (blocks , details )
163163
164+ findingIDSection := slack .NewSectionBlock (
165+ slack .NewTextBlockObject ("mrkdwn" , fmt .Sprintf ("*Finding ID*\n `%s`" , shf .Metadata .UID ), false , false ),
166+ nil , nil ,
167+ )
168+ blocks = append (blocks , findingIDSection )
169+
164170 if len (shf .Resources ) > 0 {
165171 resource := shf .Resources [0 ]
166172 var resourceFields []* slack.TextBlockObject
@@ -192,7 +198,7 @@ func (shf *SecurityHubV2Finding) SlackMessage(consoleURL, accessPortalURL, acces
192198 blocks = append (blocks , remediationSection )
193199 }
194200
195- consoleUrl := shf .BuildConsoleUrl (consoleURL , accessPortalURL , accessRoleName )
201+ consoleUrl := shf .BuildConsoleUrl (consoleURL , accessPortalURL , accessRoleName , shRegion )
196202 buttonSection := slack .NewActionBlock (
197203 "actions" ,
198204 slack .NewButtonBlockElement (
@@ -270,13 +276,30 @@ func (shf *SecurityHubV2Finding) GetSeverityEmoji() string {
270276 }
271277}
272278
273- func (shf * SecurityHubV2Finding ) BuildConsoleUrl (consoleURL , accessPortalURL , accessRoleName string ) string {
274- encodedId := url .QueryEscape (shf .FindingInfo .UID )
275- region := shf .Cloud .Region
279+ func (shf * SecurityHubV2Finding ) BuildConsoleUrl (consoleURL , accessPortalURL , accessRoleName , shRegion string ) string {
280+ region := shRegion
281+ if region == "" {
282+ region = shf .Cloud .Region
283+ }
284+
285+ var view string
286+ findingType := shf .GetFindingCategory ()
287+
288+ switch findingType {
289+ case "Exposure" :
290+ view = "exposure"
291+ case "Posture Management" :
292+ view = "postureManagement"
293+ case "Threats" :
294+ view = "threats"
295+ case "Vulnerabilities" :
296+ view = "vulnerabilities"
297+ }
276298
299+ // https://883776786067-fwrss4sa.us-east-1.console.aws.amazon.com/securityhub/v2/home?region=us-east-1#/postureManagement?findingDetailId=b864b75ebfd1bf2a9c0353af5a446dd521ca0af231d56d671311494ecdcedbb8&detailPanelTabId=Resources
277300 dst := fmt .Sprintf (
278- "%s/securityhub/home?region=%s#/findings?search=Id%%3D%%255Coperator%%255C%%253AEQUALS%%255C%%253A %s" ,
279- consoleURL , region , encodedId ,
301+ "%s/securityhub/v2/ home?region=%s#/%s?findingDetailId= %s" ,
302+ consoleURL , region , view , shf . Metadata . UID ,
280303 )
281304
282305 if accessPortalURL != "" && accessRoleName != "" {
0 commit comments