Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/socket-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Socket reachability scan for js-xdr.
# For general Socket reachability documentation, see https://docs.socket.dev/docs/full-application-reachability
# Multi-ecosystem: Node (pnpm-lock.yaml) + Ruby (Gemfile).
#
# Schedule: Sat 14:24 UTC weekly. Use workflow_dispatch to run on demand.
#
# ============================================================================
# Socket scan — reading the job status. (The scan step below produces this: an
# exit code + an optional ::warning:: annotation, which GitHub Actions renders
# as the job's state.)
# ============================================================================
# GREEN (exit 0, no warning): scan completed and every analyzed vulnerability
# got full Tier 1 reachability (precise, your-code-aware). Nothing to do.
# YELLOW (exit 0 + "::warning:: Socket scan completed with Tier 2 fallbacks"):
# scan completed, but Tier 1 could NOT be computed for some/all
# vulnerabilities, which fell back to Tier 2 (precomputed) reachability.
# You still get CVE detection + Tier 2 results, just reduced precision
# for the affected CVEs. The job is NOT failing.
# RED (non-zero exit): scan did not complete. Do not assume any part
# succeeded — could be reachability hard-failing, a missing language
# toolchain, the runner out of memory, a network/API error, or even the
# underlying CVE/SBOM detection failing. Check the logs and fix before
# relying on results.
# ----------------------------------------------------------------------------
# THIS REPO STARTS YELLOW — a KNOWN upstream Coana bug, NOT your code or this
# scan setup:
# Coana's gem analyzer can't locate installed gems ("No load paths found");
# the 3 gem CVEs fall back to Tier 2. (The npm portion gets full Tier 1.)
# Reported to Socket; may be fixed upstream over time. Do NOT let this baseline
# yellow train the team to ignore yellow — a *new* yellow (a different Tier 2
# fallback that appears later) is a real signal worth investigating. After the
# initial rollout, the team may resolve the baseline yellow at its discretion
# (once Coana ships a fix, or by adjusting the scan) so GREEN becomes the
# normal state and any future yellow stands out.
Comment on lines +25 to +34
# ============================================================================

name: Socket reachability scan

on:
schedule:
- cron: '24 14 * * 6'
workflow_dispatch:

permissions:
contents: read

env:
# Force JS-based GitHub actions (actions/checkout, actions/setup-*, etc.) to
# use Node 24 instead of the soon-to-be-deprecated Node 20. Safe to remove
# after 2026-06-16 (when Node 24 becomes the default and this becomes a no-op).
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true

jobs:
socket-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: "20.20.2"
Comment on lines +58 to +60
- name: Enable Corepack (yarn/pnpm per repo packageManager)
run: corepack enable
Comment on lines +61 to +62

- name: Install Socket CLI
run: npm install -g socket

Comment on lines +64 to +66
- name: Run Socket reachability scan
env:
SOCKET_SECURITY_API_TOKEN: ${{ secrets.SOCKET_SECURITY_API_TOKEN }}
run: |
# Stream the scan output through tee so the run log captures it AND
# we can grep it for Tier-2-fallback markers; capture the scan's
# exit code via ${PIPESTATUS[0]} (tee always exits 0). If the scan
# succeeded but logged a Tier 2 fallback, emit a ::warning::
# annotation that GitHub Actions renders as a yellow run-level
# warning without failing the job.
set +e
socket scan create --reach \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Wait for the Socket report before marking success

For scheduled/manual runs this command can mark the job green before Socket has actually generated or evaluated the scan report: the Socket CLI docs/scan create --help state that socket scan create returns after creating the scan, while --report is what waits for and reads the generated report. As written, server-side vulnerability/policy failures or report-generation failures can happen after this step exits 0, so the workflow status no longer matches the documented GREEN/RED meaning; add --report if the job is intended to verify the completed scan.

Useful? React with 👍 / 👎.

--org=stellar \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Associate scans with the js-xdr repository

This fresh Actions runner has no checked-in socket.json, and the Socket CLI docs say scans default to socket-default-repository / socket-default-branch unless --repo and --branch are supplied. In this workflow, scheduled scans for js-xdr will therefore be filed under the default placeholder repo/branch (and can collide with other repos using the same org token) instead of updating the intended Socket repository/alerts page; pass the repository and branch/default-branch explicitly.

Useful? React with 👍 / 👎.

--no-interactive \
--reach-continue-on-no-source-files \
--reach-continue-on-analysis-errors \
--reach-continue-on-install-errors \
--reach-continue-on-missing-lock-files \
. 2>&1 | tee /tmp/scan.log
rc=${PIPESTATUS[0]}
if [ $rc -eq 0 ] && grep -qE "Reachability falls back to Tier 2|fallback to the results from the pre-computed" /tmp/scan.log; then
echo "::warning::Socket scan completed with Tier 2 fallbacks - some vulnerabilities used precomputed reachability instead of full Tier 1"
fi
exit $rc
Loading