Skip to content

Commit 7ef5701

Browse files
committed
Updated README with new Slack bot directions
1 parent ec3e000 commit 7ef5701

File tree

3 files changed

+80
-10
lines changed

3 files changed

+80
-10
lines changed

README.md

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,43 +221,113 @@ Example `SOCKET_JIRA_CONFIG_JSON` value
221221
222222
| Environment Variable | Required | Default | Description |
223223
|:-------------------------|:---------|:--------|:-----------------------------------|
224-
| SOCKET_SLACK_CONFIG_JSON | False | None | Slack webhook configuration (enables plugin when set). Alternatively, use --slack-webhook CLI flag. |
224+
| SOCKET_SLACK_CONFIG_JSON | False | None | Slack configuration (enables plugin when set). Supports webhook or bot mode. Alternatively, use --slack-webhook CLI flag for simple webhook mode. |
225+
| SOCKET_SLACK_BOT_TOKEN | False | None | Slack Bot User OAuth Token (starts with `xoxb-`). Required when using bot mode. |
225226
226-
Example `SOCKET_SLACK_CONFIG_JSON` value (simple webhook):
227+
**Slack supports two modes:**
228+
229+
1. **Webhook Mode** (default): Posts to incoming webhooks
230+
2. **Bot Mode**: Posts via Slack API with bot token authentication
231+
232+
###### Webhook Mode Examples
233+
234+
Simple webhook:
227235
228236
````json
229-
{"url": "https://REPLACE_ME_WEBHOOK"}
237+
{"url": "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"}
230238
````
231239
232-
Example with advanced filtering (reachability-only alerts):
240+
Multiple webhooks with advanced filtering:
233241
234242
````json
235243
{
244+
"mode": "webhook",
236245
"url": [
237246
{
238247
"name": "prod_alerts",
239248
"url": "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
249+
},
250+
{
251+
"name": "critical_only",
252+
"url": "https://hooks.slack.com/services/YOUR/OTHER/WEBHOOK/URL"
240253
}
241254
],
242255
"url_configs": {
243256
"prod_alerts": {
244257
"reachability_alerts_only": true,
245-
"always_send_reachability": true
258+
"severities": ["high", "critical"]
259+
},
260+
"critical_only": {
261+
"severities": ["critical"]
246262
}
247263
}
248264
}
249265
````
250266
251-
**Advanced Configuration Options:**
267+
###### Bot Mode Examples
268+
269+
**Setting up a Slack Bot:**
270+
1. Go to https://api.slack.com/apps and create a new app
271+
2. Under "OAuth & Permissions", add the `chat:write` bot scope
272+
3. Install the app to your workspace and copy the "Bot User OAuth Token"
273+
4. Invite the bot to your channels: `/invite @YourBotName`
274+
275+
Basic bot configuration:
276+
277+
````json
278+
{
279+
"mode": "bot",
280+
"bot_configs": [
281+
{
282+
"name": "security_alerts",
283+
"channels": ["security-alerts", "dev-team"]
284+
}
285+
]
286+
}
287+
````
288+
289+
Bot with filtering (reachability-only alerts):
290+
291+
````json
292+
{
293+
"mode": "bot",
294+
"bot_configs": [
295+
{
296+
"name": "critical_reachable",
297+
"channels": ["security-critical"],
298+
"severities": ["critical", "high"],
299+
"reachability_alerts_only": true
300+
},
301+
{
302+
"name": "all_alerts",
303+
"channels": ["security-all"],
304+
"repos": ["myorg/backend", "myorg/frontend"]
305+
}
306+
]
307+
}
308+
````
309+
310+
Set the bot token:
311+
```bash
312+
export SOCKET_SLACK_BOT_TOKEN="xoxb-your-bot-token-here"
313+
```
252314
253-
The `url_configs` object allows per-webhook filtering:
315+
**Configuration Options:**
254316
317+
Webhook mode (`url_configs`):
255318
- `reachability_alerts_only` (boolean, default: false): When `--reach` is enabled, only send blocking alerts (error=true) from diff scans
256-
- `always_send_reachability` (boolean, default: true): Send reachability alerts even on non-diff scans when `--reach` is enabled. Set to false to only send reachability alerts when there are diff alerts.
257319
- `repos` (array): Only send alerts for specific repositories (e.g., `["owner/repo1", "owner/repo2"]`)
258320
- `alert_types` (array): Only send specific alert types (e.g., `["malware", "typosquat"]`)
259321
- `severities` (array): Only send alerts with specific severities (e.g., `["high", "critical"]`)
260322
323+
Bot mode (`bot_configs` array items):
324+
- `name` (string, required): Friendly name for this configuration
325+
- `channels` (array, required): Channel names (without #) where alerts will be posted
326+
- `severities` (array, optional): Only send alerts with specific severities (e.g., `["high", "critical"]`)
327+
- `repos` (array, optional): Only send alerts for specific repositories
328+
- `alert_types` (array, optional): Only send specific alert types
329+
- `reachability_alerts_only` (boolean, default: false): Only send reachable vulnerabilities when using `--reach`
330+
261331
## Automatic Git Detection
262332
263333
The CLI now automatically detects repository information from your git environment, significantly simplifying usage in CI/CD pipelines:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.2.61"
9+
version = "2.2.62"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.2.61'
2+
__version__ = '2.2.62'
33
USER_AGENT = f'SocketPythonCLI/{__version__}'

0 commit comments

Comments
 (0)