Skip to content

Commit 508d030

Browse files
authored
Merge pull request #32 from 0xPb1/feat/mention
add mention for slack bot workflow trigger
2 parents 94da275 + 40518f5 commit 508d030

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

connection.yml.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ notify:
33
suppress_duplicates: True
44
slack:
55
webhook_url: https://hooks.slack.com/services/T0XXXXXXXXXXX/BXXXXXXXX/1CIyXXXXXXXXXXXXXXX
6+
mention: "<@U013BDEFABC>"
67
jira:
78
username: "[email protected]"
89
server_url: "https://amce.atlassian.net"

hawk_scanner/main.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def group_results(args, results):
4747
return grouped_results
4848

4949

50-
def format_slack_message(group, result, records_mini):
50+
def format_slack_message(group, result, records_mini, mention):
5151
template_map = {
5252
's3': """
5353
*** PII Or Secret Found ***
@@ -171,7 +171,7 @@ def format_slack_message(group, result, records_mini):
171171
Exposed Values: {exposed_values}
172172
"""
173173
}
174-
return template_map.get(group, "").format(
174+
return f"{mention} " + template_map.get(group, "").format(
175175
vulnerable_profile=result['profile'],
176176
bucket=result.get('bucket', ''),
177177
file_path=result.get('file_path', ''),
@@ -258,7 +258,9 @@ def main():
258258
add_columns_to_table(group, table)
259259
for i, result in enumerate(group_data, 1):
260260
records_mini = ', '.join(result['matches']) if len(result['matches']) < 25 else ', '.join(result['matches'][:25]) + f" + {len(result['matches']) - 25} more"
261-
slack_message = format_slack_message(group, result, records_mini)
261+
connection = system.get_connection(args)
262+
mention = connection.get('notify', {}).get('slack', {}).get('mention', '')
263+
slack_message = format_slack_message(group, result, records_mini, mention)
262264
if slack_message:
263265
system.create_jira_ticket(args, result, slack_message)
264266
system.SlackNotify(slack_message, args)

readme.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,29 @@ sources:
387387
```
388388

389389
You can add or remove profiles from the connection.yml file as needed. You can also configure only one or two data sources if you don't need to scan all of them.
390+
391+
## Slack Bot Mentions and Workflow Integration
392+
393+
Hawk-eye now supports customizable Slack mentions in alert messages, allowing you to trigger internal Slack bot workflows (such as archiving the channel, etc) automatically.
394+
395+
### How to Configure Slack Mentions
396+
397+
In your `connection.yml`, under the `notify.slack` section, add a `mention` key. This value should be the Slack user ID of your bot in the format `<@USERID>`. Using the display name (e.g., `@DataScanBot`) will not trigger a real mention—Slack requires the user ID format.
398+
399+
**Example:**
400+
```yaml
401+
notify:
402+
slack:
403+
webhook_url: https://hooks.slack.com/services/...
404+
mention: "<@U12345678>" # Replace with your bot's actual user ID
405+
```
406+
407+
When Hawk-eye sends a Slack alert, the message will begin with this mention, ensuring your bot is properly notified and any associated workflows are triggered.
408+
409+
**Tip:** To find your bot's user ID, click on the bot's profile in Slack and look for the ID in the URL (e.g., `/team/U12345678`).
410+
411+
```
412+
390413
</div>
391414

392415
## Adding New Commands

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = "0.3.38"
1+
VERSION = "0.3.39"
22

33
from setuptools import setup, find_packages
44

0 commit comments

Comments
 (0)