@@ -97,6 +97,7 @@ log "Workspaces: $WORKSPACES"
9797# Build an associative array: GHSA_ID -> "workspace1 workspace2 ..."
9898declare -A GHSA_WORKSPACES
9999declare -A GHSA_SEVERITY
100+ GHSA_COUNT=0
100101
101102for workspace in $WORKSPACES ; do
102103 log " ========================================="
@@ -105,11 +106,10 @@ for workspace in $WORKSPACES; do
105106
106107 output_file=" /tmp/socket-fix-${workspace} -discovery.json"
107108
108- # CI= unsets the CI env var so socket CLI runs in interactive mode (avoids CI-only behavior)
109- if ! CI= socket fix --all --no-apply-fixes --output-file " $output_file " " $workspace /" 2>&1 ; then
110- warn " socket fix dry run failed in $workspace , skipping"
111- continue
112- fi
109+ # CI= unsets the CI env var so socket CLI runs in interactive mode (avoids CI-only behavior).
110+ # Don't skip the workspace on non-zero exit — socket may still have written partial results.
111+ CI= socket fix --all --no-apply-fixes --output-file " $output_file " " $workspace /" 2>&1 || \
112+ warn " socket fix dry run returned non-zero in $workspace , attempting to parse output anyway"
113113
114114 # Extract GHSA IDs from the structured JSON output (keys of the "fixes" object)
115115 ghsa_ids=$( jq -r ' .fixes | keys[]' " $output_file " 2> /dev/null | sort -u || true)
@@ -127,6 +127,7 @@ for workspace in $WORKSPACES; do
127127 warn " Could not determine severity for $ghsa_id , treating as unknown"
128128 fi
129129 GHSA_SEVERITY[$ghsa_id ]=" $sev "
130+ GHSA_COUNT=$(( GHSA_COUNT + 1 ))
130131 fi
131132
132133 # Track which workspaces this GHSA affects
@@ -142,26 +143,28 @@ done
142143QUALIFYING_GHSAS=()
143144SKIPPED_GHSAS=()
144145
145- for ghsa_id in " ${! GHSA_SEVERITY[@]} " ; do
146- sev=" ${GHSA_SEVERITY[$ghsa_id]} "
147- sev_num=$( severity_to_num " $sev " )
146+ if [[ $GHSA_COUNT -gt 0 ]]; then
147+ for ghsa_id in " ${! GHSA_SEVERITY[@]} " ; do
148+ sev=" ${GHSA_SEVERITY[$ghsa_id]} "
149+ sev_num=$( severity_to_num " $sev " )
148150
149- if [[ " $sev_num " -ge " $MIN_SEVERITY " ]]; then
150- QUALIFYING_GHSAS+=(" $ghsa_id " )
151- else
152- SKIPPED_GHSAS+=(" $ghsa_id ($sev )" )
153- fi
154- done
151+ if [[ " $sev_num " -ge " $MIN_SEVERITY " ]]; then
152+ QUALIFYING_GHSAS+=(" $ghsa_id " )
153+ else
154+ SKIPPED_GHSAS+=(" $ghsa_id ($sev )" )
155+ fi
156+ done
157+ fi
155158
156159# --- Summary of discovered vulnerabilities ---
157160log " ========================================="
158161log " Discovery complete"
159162log " ========================================="
160- log " Total GHSAs found: ${ # GHSA_SEVERITY[@]} "
163+ log " Total GHSAs found: $GHSA_COUNT "
161164log " Qualifying (>= $SEVERITY ): ${# QUALIFYING_GHSAS[@]} "
162165log " Skipped (below threshold): ${# SKIPPED_GHSAS[@]} "
163166
164- if [[ ${ # GHSA_SEVERITY[@]} -gt 0 ]]; then
167+ if [[ $GHSA_COUNT -gt 0 ]]; then
165168 log " "
166169 log " Vulnerability report:"
167170 for ghsa_id in " ${! GHSA_SEVERITY[@]} " ; do
@@ -185,7 +188,7 @@ if [[ "$DRY_RUN" == true ]]; then
185188 gh_output " skipped" " ${SKIPPED_GHSAS[*]:- } "
186189 gh_output " qualifying_ids" " ${QUALIFYING_GHSAS[*]:- } "
187190 gh_output " remaining_count" " ${# QUALIFYING_GHSAS[@]} "
188- gh_output " total_found" " ${ # GHSA_SEVERITY[@]} "
191+ gh_output " total_found" " $GHSA_COUNT "
189192 gh_output " qualifying_count" " ${# QUALIFYING_GHSAS[@]} "
190193 exit 0
191194fi
@@ -198,7 +201,7 @@ if [[ ${#QUALIFYING_GHSAS[@]} -eq 0 ]]; then
198201 gh_output " skipped" " ${SKIPPED_GHSAS[*]:- } "
199202 gh_output " qualifying_ids" " "
200203 gh_output " remaining_count" " 0"
201- gh_output " total_found" " ${ # GHSA_SEVERITY[@]} "
204+ gh_output " total_found" " $GHSA_COUNT "
202205 gh_output " qualifying_count" " 0"
203206 exit 0
204207fi
@@ -264,5 +267,5 @@ gh_output "failed" "${FAILED[*]:-}"
264267gh_output " skipped" " ${SKIPPED_GHSAS[*]:- } "
265268gh_output " qualifying_ids" " ${QUALIFYING_GHSAS[*]:- } "
266269gh_output " remaining_count" " ${# FAILED[@]} "
267- gh_output " total_found" " ${ # GHSA_SEVERITY[@]} "
270+ gh_output " total_found" " $GHSA_COUNT "
268271gh_output " qualifying_count" " ${# QUALIFYING_GHSAS[@]} "
0 commit comments