From bb751948fa7dcac6427faaf996eea8108111b19e Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Fri, 13 Jun 2025 07:46:42 -0500 Subject: [PATCH 1/4] Fix fix command when server rejects request --- src/utils/alerts-map.mts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/utils/alerts-map.mts b/src/utils/alerts-map.mts index 3f01d5c20..db6624647 100644 --- a/src/utils/alerts-map.mts +++ b/src/utils/alerts-map.mts @@ -1,8 +1,11 @@ import { arrayUnique } from '@socketsecurity/registry/lib/arrays' +import { debugFn } from '@socketsecurity/registry/lib/debug' +import { logger } from '@socketsecurity/registry/lib/logger' import { extractPurlsFromPnpmLockfile } from './pnpm.mts' import { getPublicToken, setupSdk } from './sdk.mts' import { addArtifactToAlertsMap } from './socket-package-alert.mts' +import constants from '../constants.mts' import type { CompactSocketArtifact } from './alert/artifact.mts' import type { @@ -12,6 +15,7 @@ import type { import type { LockfileObject } from '@pnpm/lockfile.fs' import type { Spinner } from '@socketsecurity/registry/lib/spinner' + export type GetAlertsMapFromPnpmLockfileOptions = { consolidate?: boolean | undefined include?: AlertIncludeFilter | undefined @@ -117,6 +121,19 @@ export async function getAlertsMapFromPurls( throw new Error( `Socket API server error (${statusCode}): ${statusMessage}`, ) + } else { + if (batchResult.status >= 300 && batchResult.status !== 400) { + const { spinner } = constants + spinner.stop() + debugFn('Received a result=false:', batchResult) + logger.fail( + `Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`, + batchResult.error, + batchResult.cause ? `( ${batchResult.cause} )` : '', + ) + break + } + debugFn('Received a result=false:', batchResult) } remaining -= 1 if (spinner && remaining > 0) { From 2ebc2a742036ad577747205458b0bbeec806bc64 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 13 Jun 2025 09:19:32 -0400 Subject: [PATCH 2/4] Update src/utils/alerts-map.mts Signed-off-by: John-David Dalton --- src/utils/alerts-map.mts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/alerts-map.mts b/src/utils/alerts-map.mts index db6624647..1927e4081 100644 --- a/src/utils/alerts-map.mts +++ b/src/utils/alerts-map.mts @@ -15,7 +15,6 @@ import type { import type { LockfileObject } from '@pnpm/lockfile.fs' import type { Spinner } from '@socketsecurity/registry/lib/spinner' - export type GetAlertsMapFromPnpmLockfileOptions = { consolidate?: boolean | undefined include?: AlertIncludeFilter | undefined From 27899120c85ef5e83a01650ae67ef15d6043fce6 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 13 Jun 2025 09:23:54 -0400 Subject: [PATCH 3/4] Update src/utils/alerts-map.mts Signed-off-by: John-David Dalton --- src/utils/alerts-map.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/alerts-map.mts b/src/utils/alerts-map.mts index 1927e4081..c688abbd1 100644 --- a/src/utils/alerts-map.mts +++ b/src/utils/alerts-map.mts @@ -121,7 +121,7 @@ export async function getAlertsMapFromPurls( `Socket API server error (${statusCode}): ${statusMessage}`, ) } else { - if (batchResult.status >= 300 && batchResult.status !== 400) { + if (batchResult.status >= 300) { const { spinner } = constants spinner.stop() debugFn('Received a result=false:', batchResult) From dff82d26cf4ce737e43d0cde3440bf39d0ec0abd Mon Sep 17 00:00:00 2001 From: Peter van der Zee Date: Fri, 13 Jun 2025 08:25:09 -0500 Subject: [PATCH 4/4] Remove condition --- src/utils/alerts-map.mts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/utils/alerts-map.mts b/src/utils/alerts-map.mts index c688abbd1..89e8b7b1a 100644 --- a/src/utils/alerts-map.mts +++ b/src/utils/alerts-map.mts @@ -121,18 +121,15 @@ export async function getAlertsMapFromPurls( `Socket API server error (${statusCode}): ${statusMessage}`, ) } else { - if (batchResult.status >= 300) { - const { spinner } = constants - spinner.stop() - debugFn('Received a result=false:', batchResult) - logger.fail( - `Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`, - batchResult.error, - batchResult.cause ? `( ${batchResult.cause} )` : '', - ) - break - } + const { spinner } = constants + spinner.stop() debugFn('Received a result=false:', batchResult) + logger.fail( + `Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`, + batchResult.error, + batchResult.cause ? `( ${batchResult.cause} )` : '', + ) + break } remaining -= 1 if (spinner && remaining > 0) {