Skip to content

Commit 80fbf02

Browse files
committed
docs: clarify custom SAST config, predence, rule-path semantics
Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent 21a1b95 commit 80fbf02

2 files changed

Lines changed: 44 additions & 20 deletions

File tree

docs/github-action.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,12 @@ jobs:
603603

604604
### Custom Rule Configuration
605605

606+
Use custom rules from your repository by setting `use_custom_sast_rules` and
607+
`custom_sast_rule_path`. This path is resolved relative to `GITHUB_WORKSPACE`
608+
in GitHub Actions.
609+
606610
```yaml
607-
name: Security Scan with Custom Rules
611+
name: Security Scan with Custom SAST Rules
608612
on:
609613
pull_request:
610614
types: [opened, synchronize, reopened]
@@ -625,21 +629,25 @@ jobs:
625629
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
626630
with:
627631
github_token: ${{ secrets.GITHUB_TOKEN }}
628-
629-
# Enable Python SAST
632+
633+
# Enable SAST languages you expect to run.
630634
python_sast_enabled: 'true'
631-
632-
# Enable specific Python rules
633-
python_enabled_rules: 'sql-injection,xss,hardcoded-credentials'
634-
635-
# Disable noisy rules
636-
python_disabled_rules: 'unused-import,line-too-long'
637-
638-
# JavaScript with custom rules
639635
javascript_sast_enabled: 'true'
640-
javascript_enabled_rules: 'eval-usage,prototype-pollution'
636+
637+
# Enable custom rules from repository path.
638+
use_custom_sast_rules: 'true'
639+
custom_sast_rule_path: '.socket/rules'
640+
641+
# Optional: to avoid allowlist exclusions, run all rules for enabled languages.
642+
all_rules_enabled: 'true'
641643
```
642644

645+
Important behavior:
646+
- `socket_security_api_key` + `socket_org` enables dashboard config loading.
647+
- Dashboard/API settings override overlapping `with:` values.
648+
- `<language>_enabled_rules` is an allowlist and can suppress custom rule IDs.
649+
- `all_rules_enabled: 'true'` disables allowlist filtering for enabled languages.
650+
643651
## Configuration Reference
644652
645653
### All Available Inputs
@@ -667,6 +675,8 @@ See [`action.yml`](../action.yml) for the complete list of inputs.
667675
**Rule Configuration (per language):**
668676
- `<language>_enabled_rules` — Comma-separated rules to enable
669677
- `<language>_disabled_rules` — Comma-separated rules to disable
678+
- `use_custom_sast_rules` — Enable custom SAST rule discovery from repo files
679+
- `custom_sast_rule_path` — Relative path to custom SAST rule directory
670680

671681
**Security Scanning:**
672682
- `secret_scanning_enabled` — Enable secret scanning

docs/parameters.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ Use custom SAST rules instead of bundled rules (falls back to bundled rules for
194194
socket-basics --python --use-custom-sast-rules
195195
```
196196

197+
When this is enabled, custom rules are loaded from YAML files under
198+
`--custom-sast-rule-path`. Each rule must include a `languages` list so Socket
199+
Basics can map it to the correct OpenGrep language rule file.
200+
197201
### `--custom-sast-rule-path CUSTOM_SAST_RULE_PATH`
198202
Relative path to custom SAST rules directory (relative to workspace if set, otherwise cwd).
199203

@@ -206,6 +210,11 @@ Relative path to custom SAST rules directory (relative to workspace if set, othe
206210
socket-basics --python --use-custom-sast-rules --custom-sast-rule-path "my_custom_rules"
207211
```
208212

213+
Custom rule file notes:
214+
- `.yml` and `.yaml` files are discovered recursively.
215+
- Files ending in `.test.yml` or `.test.yaml` are ignored.
216+
- Rules without `languages` are skipped.
217+
209218
### Language-Specific Rule Configuration
210219

211220
For each language, you can enable or disable specific rules:
@@ -519,7 +528,9 @@ All notification integrations support environment variables as alternatives to C
519528

520529
| Variable | Description |
521530
|----------|-------------|
522-
| `INPUT_OPENGREP_RULES_DIR` | Custom directory containing SAST rules |
531+
| `INPUT_OPENGREP_RULES_DIR` | Override directory for bundled OpenGrep rule files (`*.yml`) |
532+
| `INPUT_USE_CUSTOM_SAST_RULES` | Enable repository custom SAST rules |
533+
| `INPUT_CUSTOM_SAST_RULE_PATH` | Relative directory path for repository custom SAST rules |
523534

524535
## Configuration File
525536

@@ -536,6 +547,8 @@ You can provide configuration via a JSON file using `--config`:
536547

537548
"python_sast_enabled": true,
538549
"javascript_sast_enabled": true,
550+
"use_custom_sast_rules": true,
551+
"custom_sast_rule_path": ".socket/rules",
539552
"go_sast_enabled": true,
540553

541554
"secrets_enabled": true,
@@ -559,17 +572,18 @@ You can provide configuration via a JSON file using `--config`:
559572
Configuration is merged in the following order (later sources override earlier ones):
560573

561574
1. Default values
562-
2. JSON configuration file (via `--config`)
563-
3. Environment variables
564-
4. Command-line arguments
575+
2. Environment variables
576+
3. Socket Basics API configuration (when available and no `--config` file is used)
577+
4. JSON configuration file (via `--config`)
578+
5. Command-line arguments
565579

566580
**Example:**
567581
```bash
568-
# JSON file sets python_sast_enabled: true
569-
# Environment has PYTHON_SAST_ENABLED=false
582+
# Environment sets python_sast_enabled=true
583+
# Dashboard/API sets python_sast_enabled=false
570584
# CLI has --javascript
571-
# Result: JavaScript enabled, Python disabled (env override), other settings from JSON
572-
socket-basics --config config.json --javascript
585+
# Result: JavaScript enabled, Python follows dashboard/API value, other settings from env/API
586+
socket-basics --javascript
573587
```
574588

575589
## Common Usage Patterns

0 commit comments

Comments
 (0)