Skip to content

Commit 3d920e0

Browse files
authored
feat: add SKIP_SOCKET_SUBMISSION and SKIP_SOCKET_REACH environment variables for CLI integration (#29)
Add support for environment variables to allow external tools (like the Node.js Socket CLI) to skip specific operations and collect data for unified API submission. SKIP_SOCKET_SUBMISSION: - Skip Socket API submission while still generating .socket.facts.json - Socket Basics completes all scanning and generates the facts file - Allows external tools to collect and submit in a unified API call SKIP_SOCKET_REACH: - Skip Socket Tier 1 reachability analysis - Allows external tools to skip redundant reachability scans - Useful when reachability analysis is performed separately Benefits: - Single scan ID for all findings (supply chain + SAST + secrets + containers + reachability) - Unified dashboard view - Better performance via parallel execution - No duplicate API submissions - Flexible workflow integration Implementation: - Added SKIP_SOCKET_SUBMISSION check in submit_socket_facts() - Added SKIP_SOCKET_REACH check in SocketTier1Scanner.scan() - Returns early when environment variables are set - Documented in README under Integration Environment Variables
1 parent 3913dbf commit 3d920e0

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ All configuration can be managed through:
8989

9090
See [Configuration Documentation](docs/configuration.md) for details on all available options.
9191

92+
#### Integration Environment Variables
93+
94+
Socket Basics supports special environment variables for integration with other tools:
95+
96+
- **`SKIP_SOCKET_REACH=1`** — Skip Socket Tier 1 reachability analysis. This allows external tools (like the Node.js Socket CLI) to skip redundant reachability scans when the analysis will be performed separately or is not needed for a particular workflow.
97+
98+
- **`SKIP_SOCKET_SUBMISSION=1`** — Skip submission to Socket API while still generating `.socket.facts.json`. This allows external tools (like the Node.js Socket CLI) to collect the facts file and submit it along with other data in a unified API call. When this is set, Socket Basics will complete all scanning and generate the facts file, but will not make the API submission call.
99+
92100
## 🎯 What Socket Basics Does
93101

94102
1. **Scans** your codebase using multiple security tools in parallel

socket_basics/core/connector/socket_tier1/scanner.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ def _parse_additional_params(self) -> List[str]:
100100
return shlex.split(raw)
101101

102102
def scan(self) -> Dict[str, Any]:
103+
# Check if Socket Tier 1 reachability scan should be skipped (for Node.js Socket CLI integration).
104+
# When SKIP_SOCKET_REACH=1, Socket Basics skips the reachability analysis. This allows the Node.js
105+
# Socket CLI to skip redundant scans when reachability analysis will be performed separately.
106+
if os.getenv('SKIP_SOCKET_REACH') == '1':
107+
logger.info("Skipping Socket Tier 1 reachability scan (SKIP_SOCKET_REACH=1)")
108+
return {}
109+
103110
# Verify auth
104111
auth_env = self._get_auth_env()
105112
if not auth_env.get('SOCKET_ORG') or not auth_env.get('SOCKET_SECURITY_API_KEY'):

socket_basics/socket_basics.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,25 @@ def load_notification_manager(self, notifications_cfg: Dict[str, Any] | None = N
199199

200200
def submit_socket_facts(self, socket_facts_path: Path, results: Dict[str, Any]) -> Dict[str, Any]:
201201
"""Submit the socket facts file to Socket API and return full scan results.
202-
202+
203203
Args:
204204
socket_facts_path: Path to the .socket.facts.json file
205205
results: Current scan results dict to update with full scan info
206-
206+
207207
Returns:
208208
Updated results dict with full scan information (id, html_url)
209209
"""
210+
# Check if Socket submission should be skipped (for Node.js Socket CLI integration).
211+
# When SKIP_SOCKET_SUBMISSION=1, socket-basics generates the .socket.facts.json
212+
# file but does not submit it to the Socket API. This allows the Node.js Socket CLI to
213+
# collect the facts and submit them in a unified API call along with manifest data.
214+
if os.getenv('SKIP_SOCKET_SUBMISSION') == '1':
215+
logger.info("Skipping Socket API submission (SKIP_SOCKET_SUBMISSION=1)")
216+
logger.debug(f"Socket facts file will be available at: {socket_facts_path}")
217+
# Include the facts file path in results for downstream tools.
218+
results['socket_facts_path'] = str(socket_facts_path)
219+
return results
220+
210221
try:
211222
# Check if socket facts file is empty or has no components
212223
if not socket_facts_path.exists():

0 commit comments

Comments
 (0)