Skip to content

Commit 8195cc5

Browse files
committed
Filter to only error action when using SOCKET_CLI_ACCEPT_RISKS
1 parent e25ff62 commit 8195cc5

File tree

5 files changed

+11
-1
lines changed

5 files changed

+11
-1
lines changed

src/shadow/npm/arborist/lib/arborist/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,11 @@ export class SafeArborist extends Arborist {
119119
options['yes'] ||
120120
acceptAllRisks
121121
? {
122+
actions: ['error'],
122123
blocked: true,
123124
critical: false,
124125
cve: false,
126+
existing: true,
125127
unfixable: false
126128
}
127129
: {

src/utils/alert/artifact.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import constants from '../../constants'
33
import type { Remap } from '@socketsecurity/registry/lib/objects'
44
import type { components, operations } from '@socketsecurity/sdk/types/api'
55

6+
export type ALERT_ACTION = 'error' | 'monitor' | 'warn' | 'ignore'
7+
68
export type ALERT_TYPE = keyof NonNullable<
79
operations['getOrgSecurityPolicy']['responses']['200']['content']['application/json']['securityPolicyRules']
810
>

src/utils/arborist-helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ export async function getAlertsMapFromArborist(
207207

208208
const include = {
209209
__proto__: null,
210+
actions: undefined,
210211
blocked: true,
211212
critical: true,
212213
cve: true,
@@ -262,7 +263,8 @@ export async function getAlertsMapFromArborist(
262263
{
263264
alerts: 'true',
264265
compact: 'true',
265-
fixable: include.unfixable ? 'false' : 'true'
266+
...(include.actions ? { actions: include.actions.join(',') } : {}),
267+
...(include.unfixable ? {} : { fixable: 'true' })
266268
},
267269
{
268270
components: pkgIds.map(id => ({ purl: `pkg:npm/${id}` }))

src/utils/pnpm-lock-yaml.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export async function getAlertsMapFromPnpmLockfile(
2828

2929
const include = {
3030
__proto__: null,
31+
actions: undefined,
3132
blocked: true,
3233
critical: true,
3334
cve: true,

src/utils/socket-package-alert.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import constants from '../constants'
1717
import { findSocketYmlSync } from './config'
1818

1919
import type {
20+
ALERT_ACTION,
2021
ALERT_TYPE,
2122
CompactSocketArtifact,
2223
CompactSocketArtifactAlert
@@ -159,6 +160,7 @@ function getSeverityLabel(severity: `${ALERT_SEVERITY}`): string {
159160
}
160161

161162
export type AlertIncludeFilter = {
163+
actions?: ALERT_ACTION[] | undefined
162164
blocked?: boolean | undefined
163165
critical?: boolean | undefined
164166
cve?: boolean | undefined
@@ -194,6 +196,7 @@ export async function addArtifactToAlertsMap<T extends AlertsByPkgId>(
194196

195197
const include = {
196198
__proto__: null,
199+
actions: undefined,
197200
blocked: true,
198201
critical: true,
199202
cve: true,

0 commit comments

Comments
 (0)