Skip to content

Commit 2352e54

Browse files
authored
Doug/add node and socket back into container (#11)
* Added support for custom_rules and fixed the posting of the socket facts json file * Updated default javascript rules * Updated actions yaml and parameters with the new options * Fixed the call to the Socket SDK for submitting the socket facts file * Updated default JS ruleset * Fix exclude logic * Added the sast custom rules folder to default exclusion if used * Added exclusions for *.test.yml and *.test.yaml for sast custom rules * more fixes for excluding the custom rules folder
1 parent ef8a27e commit 2352e54

File tree

18 files changed

+1839
-383
lines changed

18 files changed

+1839
-383
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ file_generator.py
2828
*.md
2929
test_results
3030
local_tests/
31+
custom_rules/
3132

3233
# Common Python ignores
3334
__pycache__/
@@ -99,4 +100,5 @@ logs/
99100
# Ignore output logs and generated src files
100101
*.log
101102

102-
.python-version
103+
.python-version
104+
.socket.fact.json

Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
1111
# Install system dependencies
1212
RUN apt-get update && apt-get install -y curl git wget
1313

14+
# Install Node.js 22.x
15+
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
16+
apt-get install -y nodejs
17+
18+
# Install Socket CLI globally
19+
RUN npm install -g socket
20+
1421
# Install Trivy
1522
RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.67.2
1623

@@ -30,7 +37,7 @@ COPY uv.lock /socket-basics/uv.lock
3037
# Install Python dependencies using uv from the project root
3138
WORKDIR /socket-basics
3239
RUN pip install -e . && uv sync --frozen --no-dev
33-
ENV PATH="/socket-basics/.venv/bin:/root/.opengrep/cli/latest:$PATH"
40+
ENV PATH="/socket-basics/.venv/bin:/root/.opengrep/cli/latest:/usr/bin:$PATH"
3441

3542
# Use socket-basics as the default entrypoint
3643
ENTRYPOINT ["socket-basics"]

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2828

2929
- name: Run Socket Basics
30-
uses: SocketDev/[email protected].11
30+
uses: SocketDev/[email protected].20
3131
env:
3232
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
3333
with:
@@ -112,7 +112,7 @@ Configure scanning policies, notification channels, and rule sets for your entir
112112

113113
**Dashboard-Configured (Enterprise):**
114114
```yaml
115-
- uses: SocketDev/[email protected].11
115+
- uses: SocketDev/[email protected].20
116116
env:
117117
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
118118
with:
@@ -123,7 +123,7 @@ Configure scanning policies, notification channels, and rule sets for your entir
123123

124124
**CLI-Configured:**
125125
```yaml
126-
- uses: SocketDev/[email protected].11
126+
- uses: SocketDev/[email protected].20
127127
env:
128128
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
129129
with:
@@ -139,10 +139,10 @@ Configure scanning policies, notification channels, and rule sets for your entir
139139

140140
```bash
141141
# Build with version tag
142-
docker build -t socketdev/socket-basics:1.0.11 .
142+
docker build -t socketdev/socket-basics:1.0.20 .
143143
144144
# Run scan
145-
docker run --rm -v "$PWD:/workspace" socketdev/socket-basics:1.0.11 \
145+
docker run --rm -v "$PWD:/workspace" socketdev/socket-basics:1.0.20 \
146146
--workspace /workspace \
147147
--python-sast-enabled \
148148
--secret-scanning-enabled \

action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ runs:
88
env:
99
# Core GitHub variables (these are automatically available, but we explicitly pass GITHUB_TOKEN)
1010
GITHUB_TOKEN: ${{ inputs.github_token }}
11+
INPUT_WORKSPACE: ${{ inputs.workspace }}
1112
# Input mappings for all parameters
1213
INPUT_ALL_LANGUAGES_ENABLED: ${{ inputs.all_languages_enabled }}
1314
INPUT_ALL_RULES_ENABLED: ${{ inputs.all_rules_enabled }}
1415
INPUT_CONTAINER_IMAGES_TO_SCAN: ${{ inputs.container_images }}
16+
INPUT_CUSTOM_SAST_RULE_PATH: ${{ inputs.custom_sast_rule_path }}
1517
INPUT_CPP_DISABLED_RULES: ${{ inputs.cpp_disabled_rules }}
1618
INPUT_CPP_ENABLED_RULES: ${{ inputs.cpp_enabled_rules }}
1719
INPUT_CPP_SAST_ENABLED: ${{ inputs.cpp_sast_enabled }}
@@ -81,11 +83,16 @@ runs:
8183
INPUT_TRUFFLEHOG_EXCLUDE_DIR: ${{ inputs.trufflehog_exclude_dir }}
8284
INPUT_TRUFFLEHOG_NOTIFICATION_METHOD: ${{ inputs.notification_method }}
8385
INPUT_TRUFFLEHOG_SHOW_UNVERIFIED: ${{ inputs.trufflehog_show_unverified }}
86+
INPUT_USE_CUSTOM_SAST_RULES: ${{ inputs.use_custom_sast_rules }}
8487
INPUT_WEBHOOK_URL: ${{ inputs.webhook_url }}
8588
SOCKET_ADDITIONAL_PARAMS: ${{ inputs.socket_additional_params }}
8689
SOCKET_TIER_1_ENABLED: ${{ inputs.socket_tier_1_enabled }}
8790

8891
inputs:
92+
workspace:
93+
description: "Workspace directory to scan (defaults to GITHUB_WORKSPACE)"
94+
required: false
95+
default: ""
8996
socket_org:
9097
description: "Socket organization slug (required for Enterprise features)"
9198
required: false
@@ -126,6 +133,10 @@ inputs:
126133
description: "Comma-separated list of container images to scan (auto-enables image scanning)"
127134
required: false
128135
default: ""
136+
custom_sast_rule_path:
137+
description: "Relative path to custom SAST rules directory (relative to workspace if set, otherwise cwd)"
138+
required: false
139+
default: "custom_rules"
129140
cpp_disabled_rules:
130141
description: "Comma-separated list of C++ SAST rules to disable"
131142
required: false
@@ -386,6 +397,10 @@ inputs:
386397
description: "Show unverified secrets in TruffleHog results"
387398
required: false
388399
default: "false"
400+
use_custom_sast_rules:
401+
description: "Use custom SAST rules instead of bundled rules (falls back to bundled rules for languages without custom rules)"
402+
required: false
403+
default: "false"
389404
webhook_url:
390405
description: "Generic webhook URL for WebhookNotifier"
391406
required: false

docs/github-action.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3939

4040
- name: Run Socket Basics
41-
uses: SocketDev/[email protected].11
41+
uses: SocketDev/[email protected].20
4242
env:
4343
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
4444
with:
@@ -78,7 +78,7 @@ Include these in your workflow's `jobs.<job_id>.permissions` section.
7878

7979
**SAST (Static Analysis):**
8080
```yaml
81-
- uses: SocketDev/[email protected].11
81+
- uses: SocketDev/[email protected].20
8282
with:
8383
github_token: ${{ secrets.GITHUB_TOKEN }}
8484
# Enable SAST for specific languages
@@ -92,7 +92,7 @@ Include these in your workflow's `jobs.<job_id>.permissions` section.
9292

9393
**Secret Scanning:**
9494
```yaml
95-
- uses: SocketDev/[email protected].11
95+
- uses: SocketDev/[email protected].20
9696
with:
9797
github_token: ${{ secrets.GITHUB_TOKEN }}
9898
secret_scanning_enabled: 'true'
@@ -104,7 +104,7 @@ Include these in your workflow's `jobs.<job_id>.permissions` section.
104104

105105
**Container Scanning:**
106106
```yaml
107-
- uses: SocketDev/[email protected].11
107+
- uses: SocketDev/[email protected].20
108108
with:
109109
github_token: ${{ secrets.GITHUB_TOKEN }}
110110
# Scan Docker images (auto-enables container scanning)
@@ -115,7 +115,7 @@ Include these in your workflow's `jobs.<job_id>.permissions` section.
115115

116116
**Socket Tier 1 Reachability:**
117117
```yaml
118-
- uses: SocketDev/[email protected].11
118+
- uses: SocketDev/[email protected].20
119119
with:
120120
github_token: ${{ secrets.GITHUB_TOKEN }}
121121
socket_tier_1_enabled: 'true'
@@ -124,7 +124,7 @@ Include these in your workflow's `jobs.<job_id>.permissions` section.
124124
### Output Configuration
125125

126126
```yaml
127-
- uses: SocketDev/[email protected].11
127+
- uses: SocketDev/[email protected].20
128128
with:
129129
github_token: ${{ secrets.GITHUB_TOKEN }}
130130
python_sast_enabled: 'true'
@@ -154,7 +154,7 @@ Configure Socket Basics centrally from the [Socket Dashboard](https://socket.dev
154154

155155
**Enable in workflow:**
156156
```yaml
157-
- uses: SocketDev/[email protected].11
157+
- uses: SocketDev/[email protected].20
158158
env:
159159
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
160160
with:
@@ -166,7 +166,7 @@ Configure Socket Basics centrally from the [Socket Dashboard](https://socket.dev
166166

167167
> **Note:** You can also pass credentials using environment variables instead of the `with:` section:
168168
> ```yaml
169-
> - uses: SocketDev/[email protected].11
169+
> - uses: SocketDev/[email protected].20
170170
> env:
171171
> SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_SECURITY_API_KEY }}
172172
> with:
@@ -184,7 +184,7 @@ All notification integrations require Socket Enterprise.
184184

185185
**Slack Notifications:**
186186
```yaml
187-
- uses: SocketDev/[email protected].11
187+
- uses: SocketDev/[email protected].20
188188
with:
189189
github_token: ${{ secrets.GITHUB_TOKEN }}
190190
socket_org: ${{ secrets.SOCKET_ORG }}
@@ -196,7 +196,7 @@ All notification integrations require Socket Enterprise.
196196

197197
**Jira Issue Creation:**
198198
```yaml
199-
- uses: SocketDev/[email protected].11
199+
- uses: SocketDev/[email protected].20
200200
with:
201201
github_token: ${{ secrets.GITHUB_TOKEN }}
202202
socket_org: ${{ secrets.SOCKET_ORG }}
@@ -211,7 +211,7 @@ All notification integrations require Socket Enterprise.
211211

212212
**Microsoft Teams:**
213213
```yaml
214-
- uses: SocketDev/[email protected].11
214+
- uses: SocketDev/[email protected].20
215215
with:
216216
github_token: ${{ secrets.GITHUB_TOKEN }}
217217
socket_org: ${{ secrets.SOCKET_ORG }}
@@ -223,7 +223,7 @@ All notification integrations require Socket Enterprise.
223223

224224
**Generic Webhook:**
225225
```yaml
226-
- uses: SocketDev/[email protected].11
226+
- uses: SocketDev/[email protected].20
227227
with:
228228
github_token: ${{ secrets.GITHUB_TOKEN }}
229229
socket_org: ${{ secrets.SOCKET_ORG }}
@@ -235,7 +235,7 @@ All notification integrations require Socket Enterprise.
235235

236236
**SIEM Integration:**
237237
```yaml
238-
- uses: SocketDev/[email protected].11
238+
- uses: SocketDev/[email protected].20
239239
with:
240240
github_token: ${{ secrets.GITHUB_TOKEN }}
241241
socket_org: ${{ secrets.SOCKET_ORG }}
@@ -271,7 +271,7 @@ jobs:
271271
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
272272
273273
- name: Run Socket Basics
274-
uses: SocketDev/[email protected].11
274+
uses: SocketDev/[email protected].20
275275
env:
276276
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
277277
with:
@@ -317,7 +317,7 @@ jobs:
317317
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
318318
319319
- name: Run Full Security Scan
320-
uses: SocketDev/[email protected].11
320+
uses: SocketDev/[email protected].20
321321
env:
322322
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
323323
with:
@@ -368,10 +368,10 @@ jobs:
368368
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
369369
370370
- name: Build Docker Image
371-
run: docker build -t myapp:1.0.11:${{ github.sha }} .
371+
run: docker build -t myapp:1.0.20:${{ github.sha }} .
372372
373373
- name: Scan Container
374-
uses: SocketDev/[email protected].11
374+
uses: SocketDev/[email protected].20
375375
env:
376376
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
377377
with:
@@ -404,7 +404,7 @@ jobs:
404404
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
405405
406406
- name: Run Socket Basics
407-
uses: SocketDev/[email protected].11
407+
uses: SocketDev/[email protected].20
408408
env:
409409
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
410410
with:
@@ -497,7 +497,7 @@ env:
497497
```yaml
498498
steps:
499499
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - Must be first
500-
- uses: SocketDev/[email protected].11
500+
- uses: SocketDev/[email protected].20
501501
```
502502

503503
### PR Comments Not Appearing

0 commit comments

Comments
 (0)