Skip to content

Commit 06431ca

Browse files
kanwalpreetdclaude
andcommitted
Add Socket Basics security scanning workflow
Runs SAST through OpenGrep, secret scanning through TruffleHog, and Dockerfile misconfiguration scanning through Trivy, submitting results to Socket.dev. .github/workflows/socket-basics.yml scheduled weekly + manual dispatch .socket-basics.json scanner configuration .semgrepignore SAST path exclusions .trivyignore Dockerfile lint rules with no security dimension (only present where the repo has a Dockerfile) Separate from socket-scan.yml, which covers dependency CVEs and Tier 1 reachability. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 2b72363 commit 06431ca

3 files changed

Lines changed: 206 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Socket Basics security scan for stellar-cli.
2+
# Upstream: https://github.com/SocketDev/socket-basics
3+
# Scanner settings live in .socket-basics.json; SAST path exclusions live in
4+
# .semgrepignore.
5+
#
6+
# This workflow does SAST through OpenGrep and secret scanning through
7+
# TruffleHog, and submits results to Socket.dev
8+
9+
name: Socket Basics security scan
10+
11+
on:
12+
workflow_dispatch:
13+
schedule:
14+
- cron: "26 14 * * 6"
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
socket-basics:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
24+
with:
25+
# Remove the GitHub token from the workspace after checkout, so it is
26+
# not mounted into the Socket Basics container, which doesn't need it.
27+
persist-credentials: false
28+
29+
- name: Run Socket Basics
30+
env:
31+
SOCKET_SECURITY_API_TOKEN: ${{ secrets.SOCKET_SECURITY_API_TOKEN }}
32+
SOCKET_ORG: stellar
33+
run: |
34+
set +e
35+
# Socket Basics is pinned by digest since rule tuning is calibrated
36+
# to the exact ruleset contained in this image. Automatic updates
37+
# could introduce new rules and a sudden increase in false
38+
# positives, as these tools are generally noisy without tuning.
39+
docker run --rm \
40+
-v "$PWD:/github/workspace" \
41+
-w /github/workspace \
42+
-e SOCKET_SECURITY_API_TOKEN \
43+
-e SOCKET_ORG \
44+
-e GITHUB_REPOSITORY \
45+
-e GITHUB_REF_NAME \
46+
-e GITHUB_SHA \
47+
ghcr.io/socketdev/socket-basics@sha256:d463bae84f21d0240d5e197acb81e95144a966a20ab7cd05cca3a70e1796a4bb \
48+
--config .socket-basics.json 2>&1 | tee /tmp/socket-basics.log
49+
rc=${PIPESTATUS[0]}
50+
51+
# Examine components count in .socket.facts.json to establish if the
52+
# scan ran successfully, and count alerts whose action is error or
53+
# warn in .socket.facts.json to decide on the warning annotation.
54+
components=$(python3 -c 'import json;d=json.load(open(".socket.facts.json"));print(len(d.get("components") or []))' 2>/dev/null || echo 0)
55+
findings=$(python3 -c 'import json;d=json.load(open(".socket.facts.json"));print(sum(1 for c in (d.get("components") or []) for a in (c.get("alerts") or []) if a.get("action") in ("error","warn")))' 2>/dev/null || echo 0)
56+
57+
if [ "${components:-0}" -eq 0 ]; then
58+
# ${rc:-1} would not fail here: rc is the string "0", which :- does not substitute.
59+
echo "::error::Socket Basics did not complete: no results in .socket.facts.json (docker exit ${rc:-unknown})"
60+
if [ "${rc:-0}" -eq 0 ]; then rc=1; fi
61+
exit "$rc"
62+
fi
63+
64+
# Submission is detected by matching the scanner's error text. This is
65+
# brittle -- a reworded message would stop being detected -- but it is
66+
# the only approach available today: socket-basics catches submission
67+
# exceptions, logs them and returns normally, so its exit code is
68+
# unaffected (that code means "high/critical found", nothing else),
69+
# and .socket.facts.json is written BEFORE submission and never
70+
# records the outcome. The image is pinned by digest, so the wording
71+
# cannot change until someone bumps the pin -- RE-CHECK THIS STRING
72+
# WHENEVER THE DIGEST IS BUMPED.
73+
if grep -q "Failed to submit socket facts file" /tmp/socket-basics.log; then
74+
echo "::error::Socket Basics scan completed but results were not submitted to Socket"
75+
exit 1
76+
fi
77+
78+
if [ "${findings:-0}" -gt 0 ]; then
79+
echo "::warning::Socket Basics found ${findings} high/critical finding(s)"
80+
fi
81+
exit 0

‎.semgrepignore‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# This file excludes scan paths from Socket Basics SAST scanning (through OpenGrep).
2+
# It replaces the built-in ignore list for scanning with a more thorough list of paths.
3+
4+
# --- third-party / generated ---
5+
.git/
6+
node_modules/
7+
vendor/
8+
third_party/
9+
thirdparty/
10+
.devcontainer/
11+
dist/
12+
build/
13+
target/
14+
.venv/
15+
venv/
16+
__pycache__/
17+
.yarn/
18+
generated/
19+
*.min.js
20+
21+
# --- test / example / mock code ---
22+
__fixtures__/
23+
__mocks__/
24+
__snapshots__/
25+
__tests__/
26+
acceptance-test/
27+
acceptance-tests/
28+
acceptance_test/
29+
acceptance_tests/
30+
benches/
31+
browser-test/
32+
browser-tests/
33+
browser_test/
34+
browser_tests/
35+
e2e/
36+
e2e-test/
37+
e2e-tests/
38+
e2e_test/
39+
e2e_tests/
40+
example/
41+
examples/
42+
fixtures/
43+
functional-test/
44+
functional-tests/
45+
functional_test/
46+
functional_tests/
47+
integration-test/
48+
integration-tests/
49+
integration_test/
50+
integration_tests/
51+
integrationtest/
52+
integrationtests/
53+
mock/
54+
mock-dapp/
55+
mocks/
56+
perf-test/
57+
perf-tests/
58+
perf_test/
59+
perf_tests/
60+
performance-test/
61+
performance-tests/
62+
performance_test/
63+
performance_tests/
64+
regression-test/
65+
regression-tests/
66+
regression_test/
67+
regression_tests/
68+
smoke-test/
69+
smoke-tests/
70+
smoke_test/
71+
smoke_tests/
72+
spec/
73+
specs/
74+
test/
75+
test-data/
76+
test-fixtures/
77+
testFixtures/
78+
testdata/
79+
testfixtures/
80+
tests/
81+
unit-test/
82+
unit-tests/
83+
unit_test/
84+
unit_tests/
85+
*.test.js
86+
*.test.jsx
87+
*.test.ts
88+
*.test.tsx
89+
*.test.mjs
90+
*.spec.js
91+
*.spec.jsx
92+
*.spec.ts
93+
*.spec.tsx
94+
*_test.go
95+
*_test.py
96+
*_test.rb
97+
*_test.exs
98+
test_*.py
99+
*Test.java
100+
*Tests.java
101+
*Test.kt
102+
*Tests.kt
103+
*Test.scala
104+
*Test.cs
105+
*Tests.cs
106+
tests.rs
107+
test.rs
108+
109+
# --- repo-specific third-party (PER_REPO_VENDORED +
110+
# git submodules); the generic patterns above cannot know these ---
111+
soroban-test/
112+
ts-tests/

‎.socket-basics.json‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"workspace": ".",
3+
"javascript_sast_enabled": true,
4+
"ruby_sast_enabled": true,
5+
"rust_sast_enabled": true,
6+
"rust_disabled_rules": "rust-env-injection,rust-panic-in-production,rust-sql-injection",
7+
"sast_ignore_overrides": "rust-hardcoded-secrets:cmd/crates/stellar-ledger/src/lib.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/commands/container/shared.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/commands/contract/upload.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/commands/keys/add.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/commands/keys/fund.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/commands/keys/public_key.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/commands/message/sign.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/commands/message/verify.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/commands/tx/new/clawback_claimable_balance.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/config/address.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/config/key.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/config/locator.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/config/secret.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/signer/mod.rs,rust-command-injection:cmd/soroban-cli/src/commands/doctor.rs,rust-integer-overflow:cmd/soroban-cli/src/commands/tx/fetch/fee.rs,rust-memory-safety:cmd/crates/soroban-spec-tools/src/contract.rs,rust-memory-safety:cmd/soroban-cli/src/assembled.rs,rust-memory-safety:cmd/soroban-cli/src/commands/contract/arg_parsing.rs,rust-memory-safety:cmd/soroban-cli/src/tx.rs,rust-path-traversal:cmd/crates/soroban-spec-typescript/src/boilerplate.rs,rust-path-traversal:cmd/crates/stellar-ledger/src/emulator_test_support/speculos.rs,rust-path-traversal:cmd/soroban-cli/src/cli.rs,rust-path-traversal:cmd/soroban-cli/src/commands/contract/build.rs,rust-path-traversal:cmd/soroban-cli/src/commands/contract/init.rs,rust-serde-security:cmd/soroban-cli/src/commands/contract/arg_parsing.rs,rust-serde-security:cmd/soroban-cli/src/commands/token/decimals.rs,rust-serde-security:cmd/soroban-cli/src/commands/token/name.rs,rust-serde-security:cmd/soroban-cli/src/commands/token/symbol.rs,rust-unsafe-usage:cmd/soroban-cli/src/commands/contract/invoke.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/config/network.rs,rust-hardcoded-secrets:cmd/soroban-cli/src/utils.rs",
8+
"secret_scanning_enabled": true,
9+
"console_tabular_enabled": true,
10+
"socket_tier_1_enabled": false,
11+
"trivy_vuln_enabled": false,
12+
"trufflehog_exclude_dir": "node_modules,dist,build,vendor,target,.git,__fixtures__,__mocks__,__snapshots__,__tests__,acceptance-test,acceptance-tests,acceptance_test,acceptance_tests,benches,browser-test,browser-tests,browser_test,browser_tests,e2e,e2e-test,e2e-tests,e2e_test,e2e_tests,example,examples,fixtures,functional-test,functional-tests,functional_test,functional_tests,integration-test,integration-tests,integration_test,integration_tests,integrationtest,integrationtests,mock,mock-dapp,mocks,perf-test,perf-tests,perf_test,perf_tests,performance-test,performance-tests,performance_test,performance_tests,regression-test,regression-tests,regression_test,regression_tests,smoke-test,smoke-tests,smoke_test,smoke_tests,spec,specs,test,test-data,test-fixtures,testFixtures,testdata,testfixtures,tests,unit-test,unit-tests,unit_test,unit_tests,*.test.js,*.test.jsx,*.test.ts,*.test.tsx,*.test.mjs,*.spec.js,*.spec.jsx,*.spec.ts,*.spec.tsx,*_test.go,*_test.py,*_test.rb,*_test.exs,test_*.py,*Test.java,*Tests.java,*Test.kt,*Tests.kt,*Test.scala,*Test.cs,*Tests.cs,tests.rs,test.rs,yarn.lock,package-lock.json,pnpm-lock.yaml,Cargo.lock,go.sum,poetry.lock,Gemfile.lock,composer.lock,cmd/soroban-cli/src/commands/network/ls.rs,cmd/soroban-cli/src/config/data.rs,cmd/soroban-cli/src/config/network.rs,cmd/soroban-cli/src/utils.rs,soroban-test,ts-tests"
13+
}

0 commit comments

Comments
 (0)