@preventive/triage 1.0.0-alpha.32 → 1.0.0-alpha.34
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/client/linked-findings.js +5 -4
- package/common/bundle-metadata.js +4 -3
- package/common/bundle-source-links.d.ts +2 -1
- package/common/bundle-source-links.js +133 -6
- package/common/bundle-sources.d.ts +2 -0
- package/common/bundle-sources.js +2 -4
- package/common/managed/repository-alias.ts +65 -0
- package/common/managed/routes.js +20 -1
- package/common/managed/triage.ts +2 -2
- package/out/client-managed-import.js +51 -46
- package/out/client-managed.js +252 -72
- package/out/client-sync.js +14 -14
- package/out/graph.js +11 -11
- package/out/index.html +1 -0
- package/out/terminal.js +169 -169
- package/out/view.css +1 -1
- package/out/view.js +417 -201
- package/package.json +23 -17
- package/server-managed/activity.ts +15 -1
- package/server-managed/brotli.ts +3 -3
- package/server-managed/bundle-advisories.ts +8 -3
- package/server-managed/bundle-advisory-inventory.ts +27 -25
- package/server-managed/bundle-build-worker.js +45 -9
- package/server-managed/bundle-build.ts +35 -11
- package/server-managed/bundle-cache.ts +1 -1
- package/server-managed/bundle.ts +17 -1
- package/server-managed/config.ts +7 -2
- package/server-managed/db-methods.ts +170 -49
- package/server-managed/db-neon.ts +59 -4
- package/server-managed/db-schema.ts +12 -3
- package/server-managed/db.ts +9 -1
- package/server-managed/github-issue-links.ts +127 -0
- package/server-managed/github-issues.ts +1 -1
- package/server-managed/http-response.ts +7 -1
- package/server-managed/http.ts +248 -80
- package/server-managed/index.ts +4 -0
- package/server-managed/link-reports.ts +158 -0
- package/server-managed/managed-issues.ts +31 -3
- package/server-managed/management.ts +17 -4
- package/server-managed/object-storage-disk.ts +7 -3
- package/server-managed/object-storage-vercel.ts +6 -2
- package/server-managed/object-storage.ts +3 -2
- package/server-managed/public-workspace.ts +5 -2
- package/server-managed/report-sources.ts +6 -5
- package/server-managed/report-store.ts +47 -0
- package/server-managed/repository-aliases.ts +91 -0
- package/server-managed/revisions.ts +2 -2
- package/server-managed/sql.ts +3 -2
- package/server-managed/storage-encryption.ts +72 -6
- package/server-managed/storage-maintenance.ts +64 -49
- package/server-managed/storage-payload.ts +11 -10
- package/server-managed/storage-stores.ts +3 -1
- package/server-managed/storage.ts +17 -0
- package/server-managed/team-feed.ts +3 -3
- package/server-managed/team-reports.ts +24 -15
- package/server-managed/upstream-cache.ts +73 -0
- package/server-managed/workspace-shares.ts +16 -12
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { linkRevision } from './link-reports.ts'
|
|
1
2
|
import type { ManagedSql } from './sql.ts'
|
|
2
|
-
import type { ManagedBundle, TeamReportAccessSnapshot, UserTeam } from './db.ts'
|
|
3
|
+
import type { BundleBuildConditions, ManagedBundle, TeamReportAccessSnapshot, UserTeam } from './db.ts'
|
|
3
4
|
import { type TeamUserPermissions, parseTeamUserPermissions } from '../common/managed/permissions.ts'
|
|
4
5
|
|
|
5
6
|
export const WORKSPACE_SHARE_SCHEMA = `
|
|
@@ -47,7 +48,7 @@ export interface WorkspaceShareStore {
|
|
|
47
48
|
function shareQueries(db: ManagedSql) {
|
|
48
49
|
const manager = db.prepare(`SELECT 1 FROM managed_session s
|
|
49
50
|
JOIN managed_user u ON u.id = s.user_id
|
|
50
|
-
JOIN managed_team t ON t.id = ?
|
|
51
|
+
JOIN managed_team t ON t.id = ? AND t.hidden = 0
|
|
51
52
|
WHERE s.id = ? AND s.expires_at > ? AND (u.role = 'admin' OR (u.role = 'manage'
|
|
52
53
|
AND EXISTS (SELECT 1 FROM managed_team_user tu WHERE tu.user_id = u.id AND tu.team_id = t.id)))`)
|
|
53
54
|
const insert = db.prepare(`INSERT INTO managed_workspace_share (token_hash, team_id, created_by, created_at, dependencies, security)
|
|
@@ -62,12 +63,12 @@ function shareQueries(db: ManagedSql) {
|
|
|
62
63
|
WHERE s.id = ? AND s.expires_at > ? AND u.role IN ('manage', 'admin')`)
|
|
63
64
|
const all = db.prepare(`SELECT s.token_hash AS id, s.created_at AS createdAt, u.login AS createdBy, s.dependencies, s.security,
|
|
64
65
|
t.id AS teamId, t.slug AS teamSlug, t.name AS teamName FROM managed_workspace_share s
|
|
65
|
-
JOIN managed_user u ON u.id = s.created_by JOIN managed_team t ON t.id = s.team_id
|
|
66
|
+
JOIN managed_user u ON u.id = s.created_by JOIN managed_team t ON t.id = s.team_id AND t.hidden = 0
|
|
66
67
|
WHERE ? = 'admin' OR EXISTS (SELECT 1 FROM managed_team_user tu WHERE tu.user_id = ? AND tu.team_id = s.team_id)
|
|
67
68
|
ORDER BY t.name, t.id, s.created_at DESC, s.token_hash`)
|
|
68
69
|
const shareGrant = `FROM managed_workspace_share s
|
|
69
70
|
JOIN managed_user u ON u.id = s.created_by
|
|
70
|
-
JOIN managed_team t ON t.id = s.team_id
|
|
71
|
+
JOIN managed_team t ON t.id = s.team_id AND t.hidden = 0
|
|
71
72
|
WHERE s.token_hash = ? AND (u.role = 'admin' OR (u.role = 'manage'
|
|
72
73
|
AND EXISTS (SELECT 1 FROM managed_team_user tu WHERE tu.user_id = u.id AND tu.team_id = s.team_id)))`
|
|
73
74
|
const share = db.prepare(`SELECT t.id, t.slug, t.name, s.dependencies, s.security ${shareGrant}`)
|
|
@@ -88,10 +89,10 @@ function shareQueries(db: ManagedSql) {
|
|
|
88
89
|
// A raw bundle is visible only when its declared root is inside the team scope.
|
|
89
90
|
// Root bundles remain hidden from directory-only grants.
|
|
90
91
|
const bundles = db.prepare(`SELECT DISTINCT b.id, b.slug, b.integrity, b.filename, b.kind, b.byte_size AS byteSize,
|
|
91
|
-
b.uploaded_by AS uploadedBy, b.repo_id AS repoId, b.repo_directory AS repoDirectory, b.uploaded_at AS uploadedAt, sr.full_name AS repoFullName
|
|
92
|
+
b.uploaded_by AS uploadedBy, b.repo_id AS repoId, b.repo_directory AS repoDirectory, b.uploaded_at AS uploadedAt, b.provenance, b.build_conditions AS buildConditions, sr.full_name AS repoFullName
|
|
92
93
|
FROM managed_team_repo tr JOIN managed_bundle b ON b.repo_id = tr.repo_id
|
|
93
94
|
JOIN managed_selected_repo sr ON sr.repo_id = b.repo_id
|
|
94
|
-
WHERE tr.team_id = ? AND (tr.path = '' OR b.repo_directory = tr.path
|
|
95
|
+
WHERE tr.team_id = ? AND b.visible = 1 AND (tr.path = '' OR b.repo_directory = tr.path
|
|
95
96
|
OR substr(b.repo_directory, 1, length(tr.path) + 1) = tr.path || '/') ORDER BY b.id`)
|
|
96
97
|
return { manager, insert, remove, update, list, session, all, share, feed, repositories, reports, bundles }
|
|
97
98
|
}
|
|
@@ -141,21 +142,24 @@ export function workspaceShareMethods(db: ManagedSql): WorkspaceShareStore {
|
|
|
141
142
|
const { dependencies, security, ...team } = grant
|
|
142
143
|
const permissions = { dependencies: dependencies === 1, security: security === 1 }
|
|
143
144
|
const rows = await q.reports.all(team.id) as { id: string; slug: string; filename: string; analyzer: string | null; byteSize: number; sha256: string; directory: string; github: string }[]
|
|
144
|
-
const
|
|
145
|
+
const links = await linkRevision(db)
|
|
146
|
+
const bundleRows = (await q.bundles.all(team.id) as (Omit<ManagedBundle, 'buildConditions'> & { buildConditions: string | null; repoFullName: string })[])
|
|
147
|
+
.map(row => ({ ...row, buildConditions: row.buildConditions == null ? null : JSON.parse(row.buildConditions) as BundleBuildConditions }))
|
|
145
148
|
return {
|
|
146
149
|
user: { id: `share:${tokenHash}`, login: 'public', name: 'Public workspace', avatarUrl: null, role: 'view' },
|
|
147
150
|
teamId: team.id,
|
|
151
|
+
linkRevision: links,
|
|
148
152
|
permissions,
|
|
149
153
|
repositories: await q.repositories.all(team.id) as WorkspaceShareSnapshot['repositories'],
|
|
150
154
|
reports: rows.map(row => ({ id: row.id, filename: row.filename, byteSize: row.byteSize, sha256: row.sha256,
|
|
151
155
|
repo: { github: row.github, directory: row.directory }, permissions })),
|
|
152
|
-
team: { ...team,
|
|
153
|
-
reports: rows.map(row => ({ id: row.id, slug: row.slug, filename: row.filename, analyzer: row.analyzer, repoFullName: row.github, repoDirectory: row.directory,
|
|
154
|
-
cacheKey: JSON.stringify([row.sha256, row.github, row.directory, row.filename, permissions]) })),
|
|
156
|
+
team: { ...team, permissions, cacheKey: links,
|
|
157
|
+
reports: rows.map(row => ({ id: row.id, slug: row.slug, filename: row.filename, visible: true, analyzer: row.analyzer, repoFullName: row.github, repoDirectory: row.directory,
|
|
158
|
+
cacheKey: JSON.stringify([row.sha256, row.github, row.directory, row.filename, permissions, links]) })),
|
|
155
159
|
bundles: bundleRows.map(row => ({ id: row.id, slug: row.slug, integrity: row.integrity,
|
|
156
|
-
filename: row.filename, kind: row.kind, byteSize: row.byteSize, repoId: row.repoId!, repoDirectory: row.repoDirectory, repoFullName: row.repoFullName })),
|
|
160
|
+
filename: row.filename, visible: true, kind: row.kind, byteSize: row.byteSize, repoId: row.repoId!, repoDirectory: row.repoDirectory, repoFullName: row.repoFullName, provenance: row.provenance })),
|
|
157
161
|
},
|
|
158
|
-
bundles: bundleRows,
|
|
162
|
+
bundles: bundleRows.map(row => ({ ...row, visible: true })),
|
|
159
163
|
}
|
|
160
164
|
},
|
|
161
165
|
}
|