Skip to content

Commit 7a688f4

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 457f20b commit 7a688f4

4 files changed

Lines changed: 251 additions & 0 deletions

File tree

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

‎.semgrepignore‎

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
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+
lib/
112+
src/xdr/
113+
test-lcm/
114+
test-tx-meta-baseline/
115+
adding-tests/
116+
running-tests/
117+
serialize-tests/
118+
lib/libsodium/
119+
lib/xdrpp/
120+
lib/libmedida/
121+
lib/cereal/
122+
lib/asio/
123+
lib/fmt/
124+
lib/tracy/
125+
lib/spdlog/
126+
src/protocol-curr/xdr/
127+
src/rust/soroban/p21/
128+
src/rust/soroban/p22/
129+
src/rust/soroban/p23/
130+
src/rust/soroban/p24/
131+
src/rust/soroban/p25/
132+
src/rust/soroban/p26/
133+
src/rust/soroban/p27/
134+
src/rust/soroban/p28/
135+
lib/gperftools/

‎.socket-basics.json‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"workspace": ".",
3+
"c_sast_enabled": true,
4+
"cpp_sast_enabled": true,
5+
"python_sast_enabled": true,
6+
"rust_sast_enabled": true,
7+
"cpp_disabled_rules": "cpp-exception-safety,cpp-unsafe-cast",
8+
"sast_ignore_overrides": "python-insecure-random:scripts/overlay_survey/simulation.py,c-format-string-vulnerability:src/main/main.cpp,c-format-string-vulnerability:src/util/Backtrace.cpp,c-weak-random:src/util/Math.cpp,c-memory-management:src/main/main.cpp,python-bare-except:scripts/stellar-core-debug-info,python-weak-random:scripts/OverlaySurvey.py,python-weak-random:scripts/overlay_survey/simulation.py,rust-env-injection:src/rust/src/soroban_test_extra_protocol.rs,rust-memory-safety:src/rust/src/quorum_checker.rs,rust-panic-in-production:src/rust/src/soroban_fuzz.rs,rust-panic-in-production:src/rust/src/soroban_proto_all.rs,rust-panic-in-production:src/rust/src/soroban_proto_any.rs,rust-panic-in-production:src/rust/src/soroban_test_wasm.rs,rust-sql-injection:src/rust/src/b64.rs,rust-sql-injection:src/rust/src/common.rs,rust-sql-injection:src/rust/src/soroban_proto_any.rs,rust-sql-injection:src/rust/src/soroban_test_extra_protocol.rs,rust-unsafe-usage:src/rust/src/bridge.rs,rust-unsafe-usage:src/rust/src/ed25519_verify.rs,rust-unsafe-usage:src/rust/src/sha256.rs,rust-unsafe-usage:src/rust/src/tcmalloc.rs",
9+
"secret_scanning_enabled": true,
10+
"console_tabular_enabled": true,
11+
"dockerfiles": ".devcontainer/Dockerfile,docker/Dockerfile,docker/Dockerfile.testing",
12+
"socket_tier_1_enabled": false,
13+
"trivy_vuln_enabled": false,
14+
"trufflehog_exclude_dir": "build,.venv,venv,__pycache__,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,lib,src/xdr,test-lcm,test-tx-meta-baseline,adding-tests,running-tests,serialize-tests,lib/libsodium,lib/xdrpp,lib/libmedida,lib/cereal,lib/asio,lib/fmt,lib/tracy,lib/spdlog,src/protocol-curr/xdr,src/rust/soroban/p21,src/rust/soroban/p22,src/rust/soroban/p23,src/rust/soroban/p24,src/rust/soroban/p25,src/rust/soroban/p26,src/rust/soroban/p27,src/rust/soroban/p28,lib/gperftools"
15+
}

‎.trivyignore‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# This file excludes non-security rules from Socket Basics Dockerfile scanning (through Trivy).
2+
#
3+
# Trivy reads this file from the working directory. socket-basics has no config
4+
# key that can disable a Trivy rule, so this is the only lever.
5+
#
6+
# Rules that ARE kept: DS-0002 (no USER - runs as root), DS-0001 (:latest tag),
7+
# DS-0017 (package-manager update alone, which can install from a stale index).
8+
9+
# Excluded rules:
10+
11+
# 'apt-get' missing '--no-install-recommends'
12+
DS-0029
13+
14+
# 'RUN cd ...' instead of WORKDIR
15+
DS-0013
16+
17+
# Deprecated MAINTAINER instruction
18+
DS-0022
19+
20+
# 'apk add' missing '--no-cache'
21+
DS-0025
22+
23+
# WORKDIR path not absolute
24+
DS-0009
25+
26+
# 'apt-get' missing '-y'
27+
DS-0021

0 commit comments

Comments
 (0)