Skip to content

Commit e69feb7

Browse files
committed
fix check:lint errors
1 parent c198a4d commit e69feb7

File tree

6 files changed

+50
-51
lines changed

6 files changed

+50
-51
lines changed

src/commands/action/core/github.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/github.py
2-
// eslint-disable no-await-in-loop
2+
/* eslint-disable no-await-in-loop */
33
import { Octokit } from '@octokit/rest'
4-
import { Comment } from './classes'
54

5+
import { Comment } from './classes'
66
import * as SCMComments from './scm_comments'
77

88
export class GitHub {
@@ -115,16 +115,16 @@ export class GitHub {
115115
for (const ignoreComment of comments.ignore) {
116116
if (
117117
ignoreComment.body?.includes('SocketSecurity ignore') &&
118-
!this.commentReactionExists({
118+
!(await this.commentReactionExists({
119119
commentId: ignoreComment.id
120-
})
120+
}))
121121
) {
122122
await this.postReaction({ commentId: ignoreComment.id })
123123
}
124124
}
125125
}
126126

127-
async updateComment({ id, body }: { id: number; body: string }) {
127+
async updateComment({ body, id }: { id: number; body: string }) {
128128
await this.octokit.issues.updateComment({
129129
owner: this.owner,
130130
repo: this.repo,
@@ -133,15 +133,15 @@ export class GitHub {
133133
})
134134
}
135135

136-
removeCommentAlerts({ comments }: { comments: SCMComments.SocketComments }) {
136+
async removeCommentAlerts({ comments }: { comments: SCMComments.SocketComments }) {
137137
const securityAlert = comments.security
138138
if (securityAlert !== undefined) {
139139
const newBody = SCMComments.processSecurityComment({
140140
security: comments.security,
141141
ignore: comments.ignore
142142
})
143-
this.handleIgnoreReactons({ comments })
144-
this.updateComment({ id: securityAlert.id, body: newBody })
143+
await this.handleIgnoreReactons({ comments })
144+
await this.updateComment({ id: securityAlert.id, body: newBody })
145145
}
146146
}
147147

@@ -155,11 +155,11 @@ export class GitHub {
155155
}
156156

157157
async addSocketComments({
158-
securityComment,
159-
overviewComment,
160158
comments,
159+
newOverviewComment,
161160
newSecurityComment,
162-
newOverviewComment
161+
overviewComment,
162+
securityComment
163163
}: {
164164
securityComment: string
165165
overviewComment: string

src/commands/action/core/index.ts

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
// https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/__init__.py
2-
// eslint-disable no-await-in-loop
3-
import { SocketSdk } from '@socketsecurity/sdk'
4-
import { Diff, FullScan, Issue, Package, Purl } from './classes'
5-
import type { components, operations } from '@socketsecurity/sdk/types/api.d.ts'
6-
import ndjson from 'ndjson'
2+
/* eslint-disable no-await-in-loop */
73
import { once } from 'node:events'
84
import fs from 'node:fs'
95
import path from 'node:path'
106

7+
import ndjson from 'ndjson'
8+
9+
import { SocketSdk } from '@socketsecurity/sdk'
10+
11+
import { Diff, FullScan, Issue, Package, Purl } from './classes'
12+
13+
import type { components, operations } from '@socketsecurity/sdk/types/api.d.ts'
14+
1115
export class Core {
1216
socket: SocketSdk
1317
owner: string
@@ -19,9 +23,9 @@ export class Core {
1923
> = {}
2024

2125
constructor({
22-
socket,
2326
owner,
24-
repo
27+
repo,
28+
socket
2529
}: Pick<Core, 'socket' | 'owner' | 'repo' | 'files'>) {
2630
this.socket = socket
2731
this.owner = owner
@@ -81,8 +85,8 @@ export class Core {
8185
}
8286

8387
getSourceData({
84-
pkg,
85-
packages
88+
packages,
89+
pkg
8690
}: {
8791
pkg: Package
8892
packages: Record<string, Package>
@@ -139,9 +143,9 @@ export class Core {
139143
}
140144

141145
async createIssueAlerts({
142-
pkg,
143146
alerts,
144-
packages
147+
packages,
148+
pkg
145149
}: {
146150
pkg: Package
147151
alerts: Record<string, Issue[]>
@@ -210,9 +214,9 @@ export class Core {
210214
}
211215

212216
compareIssueAlerts({
213-
newScanAlerts,
217+
alerts,
214218
headScanAlerts,
215-
alerts
219+
newScanAlerts
216220
}: {
217221
newScanAlerts: Record<string, Issue[]>
218222
headScanAlerts: Record<string, Issue[]>
@@ -257,10 +261,10 @@ export class Core {
257261
}
258262

259263
checkAlertCapabilities({
260-
pkg,
261264
capabilities,
265+
headPackage,
262266
packageId,
263-
headPackage
267+
pkg
264268
}: {
265269
pkg: Package
266270
capabilities: Record<string, string[]>
@@ -295,8 +299,8 @@ export class Core {
295299
}
296300

297301
compareCapabilities({
298-
newPackages,
299-
headPackages
302+
headPackages,
303+
newPackages
300304
}: {
301305
newPackages: Record<string, Package>
302306
headPackages: Record<string, Package>
@@ -351,8 +355,8 @@ export class Core {
351355
}
352356

353357
async compareSBOMs({
354-
newScan,
355-
headScan
358+
headScan,
359+
newScan
356360
}: {
357361
newScan: Awaited<ReturnType<Core['getSbomData']>>
358362
headScan: Awaited<ReturnType<Core['getSbomData']>>
@@ -366,7 +370,7 @@ export class Core {
366370
const consolidated = new Set()
367371

368372
for (const packageId in newPackages) {
369-
const { purl, pkg } = this.createPurl({
373+
const { pkg, purl } = this.createPurl({
370374
packageId,
371375
packages: newPackages
372376
})
@@ -389,7 +393,7 @@ export class Core {
389393
}
390394

391395
for (const packageId in headPackages) {
392-
const { purl, pkg } = this.createPurl({
396+
const { pkg, purl } = this.createPurl({
393397
packageId,
394398
packages: headPackages
395399
})

src/commands/action/core/messages.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,8 @@ import { Diff, Issue, Purl } from './classes'
44
export function createSecurityCommentJSON({ diff }: { diff: Diff }) {
55
let scanFailed = false
66

7-
if (diff.newAlerts.length === 0) {
8-
// FIXME: unreachable code
9-
for (const alert of diff.newAlerts) {
10-
if (alert.error) {
11-
scanFailed = true
12-
break
13-
}
14-
}
15-
}
7+
// Not porting this code because it's unreachable
8+
// https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/messages.py#L13-L18
169

1710
const output: {
1811
scanFailed: boolean
@@ -216,7 +209,7 @@ export function securityCommentTemplate(diff: Diff): string {
216209
md +=
217210
'To accept the risk, merge this PR and you will not be notified again.\n\n'
218211
md += '<!-- start-socket-alerts-table -->\n'
219-
const { ignoreCommands, nextSteps, mdTable } = createSecurityAlertTable(diff)
212+
const { ignoreCommands, mdTable, nextSteps } = createSecurityAlertTable(diff)
220213
md += mdTable
221214
md += '<!-- end-socket-alerts-table -->\n\n'
222215
md += createNextSteps(nextSteps)

src/commands/action/core/scm_comments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export function parseIgnoreCommand(line: string) {
6565

6666
// Ref: https://github.com/socketdev-demo/javascript-threats/pull/89#issuecomment-2456015512
6767
export function processSecurityComment({
68-
security: securityComment,
69-
ignore: ignoreComments
68+
ignore: ignoreComments,
69+
security: securityComment
7070
}: Pick<SocketComments, 'security' | 'ignore'>): string {
7171
const result: string[] = []
7272
let start = false

src/commands/action/index.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/socketcli.py
22
import { parseArgs } from 'util'
3-
import { CliSubcommand } from '../../utils/meow-with-subcommands'
3+
4+
import micromatch from 'micromatch'
45
import { simpleGit } from 'simple-git'
6+
57
import { SocketSdk } from '@socketsecurity/sdk'
6-
import micromatch from 'micromatch'
7-
import { getDefaultToken } from '../../utils/sdk'
8+
89
import { Core } from './core'
910
import { GitHub } from './core/github'
10-
import * as SCMComments from './core/scm_comments'
1111
import * as Messages from './core/messages'
12+
import * as SCMComments from './core/scm_comments'
13+
import { CliSubcommand } from '../../utils/meow-with-subcommands'
14+
import { getDefaultToken } from '../../utils/sdk'
1215

1316
const socket = new SocketSdk(getDefaultToken()!)
1417

@@ -58,7 +61,7 @@ export const action: CliSubcommand = {
5861
if (scm.checkEventType() === 'comment') {
5962
console.log('Comment initiated flow')
6063
const comments = await scm.getCommentsForPR()
61-
scm.removeCommentAlerts({ comments })
64+
await scm.removeCommentAlerts({ comments })
6265
} else if (scm.checkEventType() === 'diff') {
6366
console.log('Push initiated flow')
6467
const core = new Core({ owner: scm.owner, repo: scm.repo, files, socket })
@@ -92,7 +95,7 @@ export const action: CliSubcommand = {
9295
console.log('Updated overview comment with no dependencies')
9396
}
9497
}
95-
scm.addSocketComments({
98+
await scm.addSocketComments({
9699
securityComment,
97100
overviewComment,
98101
comments,

src/shadow/arborist/lib/arborist/reify.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import process from 'node:process'
44
import semver from 'semver'
55

66
import { getManifestData } from '@socketsecurity/registry'
7-
// eslint-disable-next-line import-x/no-unresolved
87
import { arrayUnique } from '@socketsecurity/registry/lib/arrays'
98
import { hasOwn } from '@socketsecurity/registry/lib/objects'
109
import {

0 commit comments

Comments
 (0)