-
Notifications
You must be signed in to change notification settings - Fork 16
add socket tier 1 reachability analysis #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c35bcc5
add socket tier 1 reachability analysis
kanwalpreetd 3e6c7a3
socket-scan: address review comments
kanwalpreetd ade7474
Merge branch 'main' into main
kanwalpreetd 0c6aa90
Merge branch 'main' into main
sydneynotthecity bcfee7e
socket-scan: drop the Coana version pin, warn on 0 analyzable projects
kanwalpreetd b620bb4
socket-scan: drop the resolved Coana-pin history from the header
kanwalpreetd 4966e65
socket-scan: detect Tier 1 from .socket.facts.json instead of log wor…
kanwalpreetd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # Socket reachability scan for stellar-horizon. | ||
| # For general Socket reachability documentation, see https://docs.socket.dev/docs/full-application-reachability | ||
| # Multi-eco: Go (root go.mod) + Rust (Cargo workspace and/or sub-Cargos). | ||
| # | ||
| # Schedule: Sun 17:36 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 + a "::warning::" annotation) — two distinct cases: | ||
| # (a) "0 reachability components" / "no .socket.facts.json" / "could not | ||
| # be parsed": Coana analyzed nothing, so there is no Tier 1 reachability. | ||
| # Determined from the retained .socket.facts.json, whose "components" | ||
| # array is empty when no analysis ran. CVE detection from the SBOM still | ||
| # applies. | ||
| # (b) "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. | ||
| # ============================================================================ | ||
|
|
||
| name: Socket reachability scan | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '36 17 * * 0' | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| socket-scan: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| - run: rustup update | ||
| - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | ||
| with: | ||
| go-version-file: go.mod | ||
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | ||
| with: | ||
| node-version: "24.18.0" | ||
|
|
||
| - name: Install Socket CLI | ||
| run: npm install -g socket | ||
|
|
||
| - 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 | ||
| # A stale .socket.facts.json is picked up as a pre-generated input and | ||
| # silently overrides fresh analysis, so clear any before scanning. A CI | ||
| # checkout is clean, but --reach-retain-facts-file makes this worth doing | ||
| # defensively. | ||
| rm -f .socket.facts.json | ||
| socket scan create --reach \ | ||
| --org=stellar \ | ||
| --no-interactive \ | ||
| --reach-continue-on-no-source-files \ | ||
| --reach-continue-on-analysis-errors \ | ||
| --reach-continue-on-install-errors \ | ||
| --reach-continue-on-missing-lock-files \ | ||
| --reach-retain-facts-file \ | ||
| . 2>&1 | tee /tmp/scan.log | ||
| rc=${PIPESTATUS[0]} | ||
| # Establish whether Tier 1 reachability actually ran by inspecting the | ||
| # retained .socket.facts.json. When Coana cannot analyze anything the | ||
| # report is still written but "components" is an empty array; a successful | ||
| # Tier 1 run populates it. Either way the scan exits 0 and CVE/SBOM | ||
| # detection still happens. | ||
| if [ $rc -eq 0 ]; then | ||
| if [ ! -f .socket.facts.json ]; then | ||
| echo "::warning::Socket scan completed but produced no .socket.facts.json - cannot confirm Tier 1 reachability ran. CVE detection from the SBOM still applies." | ||
| else | ||
| components=$(jq '(.components // []) | length' .socket.facts.json 2>/dev/null) | ||
| if ! [ "$components" -ge 0 ] 2>/dev/null; then | ||
| echo "::warning::Socket scan completed but .socket.facts.json could not be parsed - cannot confirm Tier 1 reachability ran. CVE detection from the SBOM still applies." | ||
| elif [ "$components" -eq 0 ]; then | ||
| echo "::warning::Socket reported 0 reachability components - no Tier 1 reachability ran. CVE detection from the SBOM still applies." | ||
| fi | ||
| fi | ||
| fi | ||
| if [ $rc -eq 0 ] && grep -qE "Reachability falls back to Tier 2|fallback to the results from the pre-computed|Reachability falls back to precomputed" /tmp/scan.log; then | ||
| echo "::warning::Socket scan completed with Tier 2 fallbacks - some vulnerabilities used precomputed reachability instead of full Tier 1" | ||
| fi | ||
|
kanwalpreetd marked this conversation as resolved.
|
||
| exit $rc | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.