@preventive/triage 1.0.0-alpha.86 → 1.0.0-alpha.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/bundle-compare-diff.js +3 -2
- package/common/dependency-reviews.d.ts +1 -0
- package/common/dependency-reviews.js +3 -0
- package/common/github-issue-labels.d.ts +3 -1
- package/common/github-issue-labels.js +37 -6
- package/common/managed/roles.ts +7 -0
- package/common/managed/routes.js +7 -6
- package/out/activity.js +2 -2
- package/out/{chunk-ULI2BIWN.js → chunk-3TJCEPHF.js} +1 -1
- package/out/chunk-5LY6QSPD.js +265 -0
- package/out/chunk-7PXMWWTQ.js +1 -0
- package/out/{chunk-ZQQALNFP.js → chunk-BZJU5EEV.js} +1 -1
- package/out/{chunk-YU3IUQY6.js → chunk-PSS7UX5T.js} +1 -1
- package/out/chunk-Q2NFBTNH.js +1 -0
- package/out/{chunk-CE2FMDK3.js → chunk-TKPNRQNN.js} +1 -1
- package/out/{chunk-GM6GP6TA.js → chunk-WKXQOUNH.js} +2 -2
- package/out/{chunk-XHYX3Q34.js → chunk-XRAAYXPR.js} +1 -1
- package/out/{chunk-R7HUX4PF.js → chunk-ZKJ7COEH.js} +1 -1
- package/out/chunk-ZPIUN4FW.js +55 -0
- package/out/client-managed-import.js +1 -1
- package/out/client-managed.js +28 -28
- package/out/compare.js +13 -13
- package/out/dialogs.js +38 -38
- package/out/graph.js +1 -1
- package/out/index.html +8 -8
- package/out/scan.js +2 -2
- package/out/view.css +1 -1
- package/out/view.js +8 -8
- package/package.json +2 -2
- package/risk/files/script.js +19 -9
- package/server-e2e/config.ts +3 -1
- package/server-managed/dependabot-access.ts +41 -17
- package/server-managed/dependabot-alerts.ts +19 -2
- package/server-managed/github-issues.ts +26 -14
- package/server-managed/github-users.ts +23 -0
- package/server-managed/http.ts +271 -123
- package/server-managed/npm-patch.ts +3 -1
- package/server-managed/repository-browser.ts +3 -2
- package/server-managed/repository-risk-assess.ts +10 -0
- package/out/chunk-2F7GGMMR.js +0 -266
- package/out/chunk-V4U7URJF.js +0 -54
- package/out/chunk-WOCJFOXN.js +0 -1
- package/out/chunk-ZQHKSKD7.js +0 -1
- /package/out/{chunk-6WMQVUT2.js → chunk-3YPZ7UBC.js} +0 -0
|
@@ -149,12 +149,13 @@ const RENAME_LIMIT = 250
|
|
|
149
149
|
// The files of `onlyBase` renamed to one of `onlyOther`, both by path as the
|
|
150
150
|
// other bundle lays them out, within a package: `Map<base path, other path>`,
|
|
151
151
|
// as @preventive/compare's compareTrees finds them, by content as git diff -M
|
|
152
|
-
// does
|
|
152
|
+
// does, where their paths say so, and a script or style sheet by its text as
|
|
153
|
+
// a build reformats it (renamesByForm). Whether a renamed file changed is
|
|
153
154
|
// sameContent's to say, not this reading's. A path no UTF-8 holds is left out.
|
|
154
155
|
function renamesOf(onlyBase, onlyOther, base, other, pkgOf) {
|
|
155
156
|
const entries = (rows, files, side) => rows.filter(({ path }) => path !== '' && path.isWellFormed())
|
|
156
157
|
.map(({ path }, at) => ({ name: path, data: treeData(files.get(path), `${side}${at}`) }))
|
|
157
|
-
const options = { paths: 'keys', renameGroup: pkgOf, renameLimit: RENAME_LIMIT, lines: false }
|
|
158
|
+
const options = { paths: 'keys', renameGroup: pkgOf, renameLimit: RENAME_LIMIT, renamesByForm: true, lines: false }
|
|
158
159
|
const changes = compareTrees(entries(onlyBase, base, 'a'), entries(onlyOther, other, 'b'), options)
|
|
159
160
|
return new Map(changes.filter(({ status }) => status === 'renamed').map(change => [change.old.path, change.new.path]))
|
|
160
161
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { npmMalwareAdvisory } from '../risk/npm/malware.js'
|
|
2
2
|
|
|
3
|
+
// Drafts published in one request at most (POST /api/npm/reviews/publish).
|
|
4
|
+
export const MAX_PUBLISHED_REVIEWS = 200
|
|
5
|
+
|
|
3
6
|
export const REVIEW_VERDICTS = {
|
|
4
7
|
accept: 'Accept',
|
|
5
8
|
'accept-with-nits': 'Accept with nits (non-blocking)',
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function issueAdvisoryUrl(finding: unknown): string | null
|
|
2
|
+
export function issueLabelChoices(finding: unknown, configured?: string): string[][]
|
|
3
|
+
export function newIssueLabels(finding: unknown, configured?: string): string[]
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { isHttpUrl } from '@preventive/report'
|
|
2
|
+
|
|
3
|
+
// The link of the advisory a finding's issue is on, which the issue opens on
|
|
4
|
+
// in place of the finding's source (`Advisory: <url>`, ui/view/issue-draft.js);
|
|
5
|
+
// null for a finding on none.
|
|
6
|
+
export function issueAdvisoryUrl(finding) {
|
|
7
|
+
const url = finding?.advisory?.url
|
|
8
|
+
return isHttpUrl(url) ? url : null
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// The labels a finding's new issue asks for, each a list of names of which
|
|
12
|
+
// it gets the first its repository has: `deepview`; `security` for a
|
|
13
|
+
// security finding; `dependencies`, else `deps`, for one on an advisory;
|
|
14
|
+
// then each of `configured` (GITHUB_NEW_ISSUE_LABELS, comma-separated).
|
|
15
|
+
// Names are trimmed, empty ones dropped, and a label asked for again, in any
|
|
16
|
+
// case, asked for once. Shared by GitHub's prefilled form and managed API
|
|
17
|
+
// issue creation (server-managed/github-issues.ts).
|
|
18
|
+
export function issueLabelChoices(finding, configured = '') {
|
|
3
19
|
const seen = new Set()
|
|
4
|
-
return ['deepview', ...(isSecurity ? ['security'] : []),
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
20
|
+
return [['deepview'], ...(finding?.isSecurity === true ? [['security']] : []),
|
|
21
|
+
...(issueAdvisoryUrl(finding) ? [['dependencies', 'deps']] : []), ...configured.split(',').map(name => [name])]
|
|
22
|
+
.map(names => names.map(name => name.trim()).filter(Boolean))
|
|
23
|
+
.filter(names => {
|
|
24
|
+
const key = names.join('\0').toLowerCase()
|
|
25
|
+
if (names.length === 0 || seen.has(key)) return false
|
|
8
26
|
seen.add(key)
|
|
9
27
|
return true
|
|
10
28
|
})
|
|
11
29
|
}
|
|
30
|
+
|
|
31
|
+
// Every name those ask for, once, for GitHub's prefilled form, which sets
|
|
32
|
+
// only the labels the repository has: unable to tell which, it is handed
|
|
33
|
+
// both `dependencies` and `deps`.
|
|
34
|
+
export function newIssueLabels(finding, configured = '') {
|
|
35
|
+
const seen = new Set()
|
|
36
|
+
return issueLabelChoices(finding, configured).flat().filter(name => {
|
|
37
|
+
const key = name.toLowerCase()
|
|
38
|
+
if (seen.has(key)) return false
|
|
39
|
+
seen.add(key)
|
|
40
|
+
return true
|
|
41
|
+
})
|
|
42
|
+
}
|
package/common/managed/roles.ts
CHANGED
|
@@ -39,3 +39,10 @@ export function canReadRepositoryCode(session: { role: Role; publicShare?: boole
|
|
|
39
39
|
export function canScanTeamRisk(session: { role: Role; publicShare?: boolean } | null | undefined): boolean {
|
|
40
40
|
return session != null && !session.publicShare && roleAtLeast(session.role, 'manage')
|
|
41
41
|
}
|
|
42
|
+
|
|
43
|
+
// Who scans one repository's risk, on its Risk tab: admins alone, as the
|
|
44
|
+
// server scans one repository for them alone (server-managed/http.ts
|
|
45
|
+
// mayReadRisk), signed in. A public link scans none.
|
|
46
|
+
export function canScanRepositoryRisk(session: { role: Role; publicShare?: boolean } | null | undefined): boolean {
|
|
47
|
+
return session != null && !session.publicShare && session.role === 'admin'
|
|
48
|
+
}
|
package/common/managed/routes.js
CHANGED
|
@@ -166,8 +166,8 @@ function parseNpmRoute(path, hash, search) {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// The code viewer: a directory of a repository at a commit, on its Code,
|
|
169
|
-
// Search, Treemap, Compare, Commits, Issues, Pull requests, Agents, Pulse
|
|
170
|
-
// or
|
|
169
|
+
// Search, Treemap, Compare, Commits, Issues, Pull requests, Agents, Pulse,
|
|
170
|
+
// Replay or Risk tab, `/repo/<repo id>/<commit>[/<tab>…][?path=<directory>]`,
|
|
171
171
|
// the repository's root where it names no directory. Code, the tab a bare
|
|
172
172
|
// link opens, names its file by number and its lines in the fragment, as a
|
|
173
173
|
// bundle's Code does: `/code/<file>#L4`. Compare names the commit compared
|
|
@@ -178,10 +178,11 @@ function parseNpmRoute(path, hash, search) {
|
|
|
178
178
|
// branch's head, or on the revision a route held in memory names (`ref`),
|
|
179
179
|
// and its route then names the commit it opened. Links from before it moved
|
|
180
180
|
// name it under `/manage/code/`, and open the same.
|
|
181
|
-
export const REPOSITORY_CODE_TABS = new Set(['code', 'search', 'treemap', 'compare', 'commits', 'issues', 'pulls', 'agents', 'pulse', 'replay'])
|
|
181
|
+
export const REPOSITORY_CODE_TABS = new Set(['code', 'search', 'treemap', 'compare', 'commits', 'issues', 'pulls', 'agents', 'pulse', 'replay', 'risk'])
|
|
182
182
|
// The tabs reading none of the directory's files, which a directory at a
|
|
183
|
-
// commit shows alone
|
|
184
|
-
|
|
183
|
+
// commit shows alone: its Activity views, and its Risk, which scans the
|
|
184
|
+
// repository as its default branch has it.
|
|
185
|
+
export const REPOSITORY_FILELESS_TABS = new Set(['commits', 'issues', 'pulls', 'agents', 'pulse', 'replay', 'risk'])
|
|
185
186
|
// The Activity views' sub-tabs past their first: Issues' and Pull requests'
|
|
186
187
|
// closed ones (open, the first), Pulse's periods (a month, the first),
|
|
187
188
|
// Replay's commits played (the last 300, the first), and one agent's
|
|
@@ -219,7 +220,7 @@ function repositoryCodePath(route) {
|
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
function parseRepositoryCodeRoute(url) {
|
|
222
|
-
const match = /^\/(?:repo|manage\/code)\/([1-9]\d*)(?:\/([a-f\d]{40})(?:\/(code|search|treemap|compare|commits|history|issues|pulls|agents|pulse|replay)(?:\/([^/]+)(?:\/([a-z]+))?)?)?)?$/u
|
|
223
|
+
const match = /^\/(?:repo|manage\/code)\/([1-9]\d*)(?:\/([a-f\d]{40})(?:\/(code|search|treemap|compare|commits|history|issues|pulls|agents|pulse|replay|risk)(?:\/([^/]+)(?:\/([a-z]+))?)?)?)?$/u
|
|
223
224
|
.exec(url.pathname.replace(/\/$/u, ''))
|
|
224
225
|
if (!match) return undefined
|
|
225
226
|
const repoId = Number(match[1])
|