Skip to content

Commit 5e05005

Browse files
Update Security-Notification.yml
Added test component
1 parent f38b91f commit 5e05005

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

.github/workflows/Security-Notification.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
name: Security Vulnerability Slack Notification
22

33
on:
4+
# The real trigger (fires on real alerts)
45
repository_vulnerability_alert:
56
types: [create]
7+
8+
# The manual trigger (for testing)
9+
workflow_dispatch:
10+
inputs:
11+
mock_package:
12+
description: 'Package Name'
13+
required: true
14+
default: 'axios (Test)'
15+
mock_severity:
16+
description: 'Severity'
17+
required: true
18+
default: 'critical'
19+
type: choice
20+
options:
21+
- critical
22+
- high
23+
- moderate
24+
- low
625

726
jobs:
827
notify-slack:
@@ -11,13 +30,15 @@ jobs:
1130
- name: Send Slack Notification
1231
env:
1332
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
14-
# Extract alert details from the event payload
15-
PACKAGE_NAME: ${{ github.event.alert.affected_package_name }}
16-
SEVERITY: ${{ github.event.alert.severity }}
17-
ALERT_URL: ${{ github.event.alert.html_url }}
18-
ECOSYSTEM: ${{ github.event.alert.affected_range }}
33+
# LOGIC: Use real data if available, otherwise use manual inputs (or defaults)
34+
PACKAGE_NAME: ${{ github.event.alert.affected_package_name || inputs.mock_package || 'Test-Package' }}
35+
SEVERITY: ${{ github.event.alert.severity || inputs.mock_severity || 'high' }}
36+
ALERT_URL: ${{ github.event.alert.html_url || github.server_url }}
1937
run: |
20-
# Map severity to an emoji for better visibility
38+
echo "Triggered by: ${{ github.event_name }}"
39+
echo "Package: $PACKAGE_NAME"
40+
41+
# Map severity to an emoji
2142
if [ "$SEVERITY" == "critical" ]; then
2243
EMOJI=":rotating_light:"
2344
elif [ "$SEVERITY" == "high" ]; then
@@ -26,7 +47,7 @@ jobs:
2647
EMOJI=":information_source:"
2748
fi
2849
29-
# Construct the JSON payload
50+
# JSON Payload
3051
PAYLOAD=$(cat <<EOF
3152
{
3253
"channel": "#docs-devdocs-notifications",
@@ -40,7 +61,7 @@ jobs:
4061
"type": "section",
4162
"text": {
4263
"type": "mrkdwn",
43-
"text": "$EMOJI *New Vulnerability Alert Detected*"
64+
"text": "$EMOJI *New Vulnerability Alert Detected* (Trigger: ${{ github.event_name }})"
4465
}
4566
},
4667
{
@@ -70,5 +91,4 @@ jobs:
7091
EOF
7192
)
7293
73-
# Send the request
7494
curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL"

0 commit comments

Comments
 (0)