@preventive/triage 1.0.0-alpha.9 → 1.0.0-alpha.90
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/LICENSE-APACHE +202 -0
- package/README.md +16 -0
- package/api/reap.ts +16 -78
- package/cli.js +6 -0
- package/client/dependency-paths.d.ts +3 -0
- package/client/dependency-paths.js +36 -0
- package/client/finding-link.js +305 -0
- package/client/linked-findings.d.ts +1 -0
- package/client/linked-findings.js +115 -0
- package/common/bundle-commit.d.ts +1 -0
- package/common/bundle-commit.js +4 -0
- package/common/bundle-compare-diff.d.ts +6 -0
- package/common/bundle-compare-diff.js +378 -0
- package/common/bundle-compare-inputs.d.ts +3 -0
- package/common/bundle-compare-inputs.js +141 -0
- package/common/bundle-compare-versions.js +172 -0
- package/common/bundle-comparison.d.ts +8 -0
- package/common/bundle-comparison.js +69 -0
- package/common/bundle-imports.js +20 -0
- package/common/bundle-metadata.d.ts +15 -0
- package/common/bundle-metadata.js +226 -0
- package/common/bundle-pkg-of.d.ts +1 -0
- package/common/bundle-pkg-of.js +90 -0
- package/common/bundle-reasons.d.ts +6 -0
- package/common/bundle-reasons.js +58 -0
- package/common/bundle-source-links.d.ts +6 -0
- package/common/bundle-source-links.js +216 -0
- package/common/bundle-sourcemap.d.ts +10 -0
- package/common/bundle-sourcemap.js +100 -0
- package/common/bundle-sources.d.ts +10 -0
- package/common/bundle-sources.js +374 -0
- package/common/bundle-stats.js +41 -0
- package/common/bundle-tabs.js +1 -0
- package/common/code-language.js +80 -0
- package/common/default-scan-models.ts +37 -0
- package/common/dependency-reviews.d.ts +19 -0
- package/common/dependency-reviews.js +67 -0
- package/common/finding-duplicates.js +63 -0
- package/common/finding-filters.js +313 -0
- package/common/finding-id.js +47 -0
- package/common/finding-repo.d.ts +5 -0
- package/common/finding-repo.js +67 -0
- package/common/github-issue-labels.d.ts +3 -0
- package/common/github-issue-labels.js +42 -0
- package/common/github-pr.ts +56 -0
- package/common/gzip.js +59 -0
- package/common/line-diff.d.ts +15 -0
- package/common/line-diff.js +188 -0
- package/common/linked-workspace-groups.js +63 -0
- package/common/managed/agent-tasks.ts +292 -0
- package/common/managed/comments.ts +43 -0
- package/common/managed/dependency-routes.js +25 -0
- package/common/managed/directory-packages.ts +28 -0
- package/common/managed/finding-detail.d.ts +5 -0
- package/common/managed/finding-detail.js +75 -0
- package/common/managed/finding-values.d.ts +2 -0
- package/common/managed/finding-values.js +138 -0
- package/common/managed/github-agents.ts +114 -0
- package/common/managed/github-logins.ts +49 -0
- package/common/managed/lite-name.d.ts +2 -0
- package/common/managed/lite-name.js +20 -0
- package/common/managed/npm-packages.d.ts +9 -0
- package/common/managed/npm-packages.js +63 -0
- package/common/managed/permissions.ts +31 -0
- package/common/managed/report-content.ts +72 -0
- package/common/managed/report-filter.ts +120 -0
- package/common/managed/repository-alias.ts +65 -0
- package/common/managed/review-view-routes.js +23 -0
- package/common/managed/risk-routes.js +30 -0
- package/common/managed/roles.ts +48 -0
- package/common/managed/routes.d.ts +2 -0
- package/common/managed/routes.js +386 -0
- package/common/managed/scan-models.ts +6 -0
- package/common/managed/stasis-config.ts +7 -0
- package/common/managed/team-app.d.ts +19 -0
- package/common/managed/team-app.js +129 -0
- package/common/managed/team-filters.js +26 -0
- package/common/managed/triage.ts +83 -0
- package/common/managed/upload-seal.ts +126 -0
- package/common/npm-token.d.ts +2 -0
- package/common/npm-token.js +14 -0
- package/common/pretty-json.js +123 -0
- package/common/pretty-kinds.js +20 -0
- package/common/pretty-print.d.ts +7 -0
- package/common/pretty-print.js +41 -0
- package/common/pretty-sourcemap.js +70 -0
- package/common/repo-commit.d.ts +4 -0
- package/common/repo-commit.js +30 -0
- package/common/revalidation-conflicts.js +48 -0
- package/common/revalidation-input-groups.js +56 -0
- package/common/scan-server.ts +13 -0
- package/common/security-links.d.ts +5 -0
- package/common/security-links.js +33 -0
- package/common/server-info.ts +46 -0
- package/common/sourcemap-listing.js +78 -0
- package/common/sourcemap-mappings.js +136 -0
- package/common/sourcemap-unlist.js +85 -0
- package/common/stasis-files.d.ts +5 -0
- package/common/stasis-files.js +20 -0
- package/common/stasis-tgz.d.ts +6 -0
- package/common/stasis-tgz.js +27 -0
- package/common/utf8.d.ts +3 -0
- package/common/utf8.js +45 -0
- package/common/whitespace-insensitive.js +19 -0
- package/common/workspace-app.js +91 -0
- package/common/workspace-groups.js +176 -0
- package/out/activity.js +2 -0
- package/out/brotli-fallback.js +3 -3
- package/out/chunk-2XUEZHIP.js +28 -0
- package/out/chunk-3DOSBILK.js +4 -0
- package/out/chunk-55YIWY3H.js +5 -0
- package/out/chunk-5AVGKFMR.js +1 -0
- package/out/chunk-5PWEAEA5.js +1 -0
- package/out/chunk-6VOB5WXX.js +2 -0
- package/out/chunk-6Y6PZ2BU.js +9 -0
- package/out/chunk-74JZTGTO.js +11 -0
- package/out/chunk-7BKKYVWR.js +7 -0
- package/out/chunk-7C7DWL7I.js +1 -0
- package/out/chunk-7HP2VYIC.js +2 -0
- package/out/chunk-7YFJUT2P.js +1 -0
- package/out/chunk-A4BBBHQU.js +1 -0
- package/out/chunk-B64CTMVU.js +4 -0
- package/out/chunk-BEKYZCPX.js +14 -0
- package/out/chunk-BZJU5EEV.js +1 -0
- package/out/chunk-C4Z6ZBXV.js +10 -0
- package/out/chunk-CJVMNJDZ.js +3 -0
- package/out/chunk-CU3FPB3P.js +1 -0
- package/out/chunk-DEVAORP2.js +1 -0
- package/out/chunk-DUASGS2O.js +8 -0
- package/out/chunk-EEJA7JBI.js +13 -0
- package/out/chunk-ESXA7KID.js +1 -0
- package/out/chunk-FSU2PLJL.js +1 -0
- package/out/chunk-GO7FT4OD.js +1 -0
- package/out/chunk-GX5UXWT4.js +1 -0
- package/out/chunk-HGWFRZNC.js +267 -0
- package/out/chunk-IYPY47MC.js +1 -0
- package/out/chunk-JZAROLQT.js +40 -0
- package/out/chunk-K4XJHM2T.js +1 -0
- package/out/chunk-KP2XM324.js +6 -0
- package/out/chunk-LRWB6QVO.js +1 -0
- package/out/chunk-LVSLM7HB.js +1 -0
- package/out/chunk-LVW7WWV4.js +1 -0
- package/out/chunk-N57OWFKY.js +15 -0
- package/out/chunk-NRPC74AM.js +1 -0
- package/out/chunk-OOJM4CTU.js +1 -0
- package/out/chunk-PKLVXUEI.js +11 -0
- package/out/chunk-PLGH63UC.js +2 -0
- package/out/chunk-PNHBZGDD.js +1 -0
- package/out/chunk-PWFUOLZK.js +17 -0
- package/out/chunk-PXK7EU4V.js +1 -0
- package/out/chunk-QD3IBSF4.js +7 -0
- package/out/chunk-QI66YA4F.js +1 -0
- package/out/chunk-QRKFPLA4.js +80 -0
- package/out/chunk-R3NZFXVR.js +1 -0
- package/out/chunk-R5O6FAW4.js +2 -0
- package/out/chunk-RAM3GDAD.js +1 -0
- package/out/chunk-RPNO56H2.js +1 -0
- package/out/chunk-SMNFBOLO.js +10 -0
- package/out/chunk-SSPDMA6D.js +1 -0
- package/out/chunk-SZTCJVZJ.js +55 -0
- package/out/chunk-SZWPYLPC.js +1 -0
- package/out/chunk-TKPNRQNN.js +3 -0
- package/out/chunk-TUII34K2.js +1 -0
- package/out/chunk-UJP4PQJA.js +1 -0
- package/out/chunk-UJSJMXEG.js +1 -0
- package/out/chunk-UR4WYMIP.js +1 -0
- package/out/chunk-UTYWTUTC.js +1 -0
- package/out/chunk-VHEXSGGP.js +1 -0
- package/out/chunk-VYYUMYVW.js +9 -0
- package/out/chunk-WBK5ZN4K.js +3 -0
- package/out/chunk-WCDYSIKG.js +1 -0
- package/out/chunk-XM4RLC4A.js +2 -0
- package/out/chunk-XRAAYXPR.js +1 -0
- package/out/chunk-ZQHLECTI.js +1 -0
- package/out/client-managed-import.js +4 -0
- package/out/client-managed.js +35 -0
- package/out/client-sync.js +11 -17
- package/out/compare.js +26 -0
- package/out/dialogs.js +40 -0
- package/out/github-issue-authorized.html +3 -0
- package/out/github-issue-authorized.js +1 -0
- package/out/graph.js +19 -5
- package/out/index.html +105 -25
- package/out/prism.js +14 -10
- package/out/scan.js +2 -0
- package/out/stasis.svg +20 -0
- package/out/terminal.js +367 -39
- package/out/view.css +1 -1
- package/out/view.js +19 -148
- package/package.json +416 -64
- package/risk/actions/findings.js +161 -0
- package/risk/actions/resolve.js +287 -0
- package/risk/actions/scripts/commands.js +182 -0
- package/risk/actions/scripts/grade.js +113 -0
- package/risk/actions/scripts/packages.js +123 -0
- package/risk/actions/scripts/shell.js +169 -0
- package/risk/actions/uses.js +94 -0
- package/risk/actions/workflow.js +183 -0
- package/risk/files/characters.js +354 -0
- package/risk/files/hosts.js +206 -0
- package/risk/files/readability.js +185 -0
- package/risk/files/runs-code.js +568 -0
- package/risk/files/script.js +420 -0
- package/risk/files/source-map-link.js +43 -0
- package/risk/files/stamps.js +47 -0
- package/risk/index.d.ts +309 -0
- package/risk/index.js +12 -0
- package/risk/npm/assess.js +303 -0
- package/risk/npm/combined.js +68 -0
- package/risk/npm/compare.js +236 -0
- package/risk/npm/dependencies.js +172 -0
- package/risk/npm/diff.js +79 -0
- package/risk/npm/downloads.js +84 -0
- package/risk/npm/files.js +445 -0
- package/risk/npm/held.js +67 -0
- package/risk/npm/install-scripts.js +34 -0
- package/risk/npm/malware.js +38 -0
- package/risk/npm/manifest.js +65 -0
- package/risk/npm/new-dependency.js +60 -0
- package/risk/npm/old-version.js +108 -0
- package/risk/npm/registry.js +401 -0
- package/risk/npm/release.js +85 -0
- package/risk/npm/score.js +59 -0
- package/risk/npm/specs.js +124 -0
- package/risk/npm/tarball.js +169 -0
- package/server-common/database-config.ts +16 -0
- package/server-common/initialize.ts +18 -0
- package/server-common/npm-advisories.ts +101 -0
- package/{server → server-common}/origin.ts +5 -5
- package/server-common/reap.ts +48 -0
- package/server-common/scan-config.ts +19 -0
- package/server-common/standalone.ts +29 -0
- package/server-common/storage-crypto.ts +182 -0
- package/server-common/storage-log.ts +38 -0
- package/server-common/vercel-blob.ts +103 -0
- package/server-e2e/app.ts +487 -0
- package/{server → server-e2e}/bus-receiver.ts +2 -1
- package/{server → server-e2e}/cli.js +9 -4
- package/{server → server-e2e}/config.ts +52 -42
- package/{server → server-e2e}/db-neon.ts +2 -2
- package/{server → server-e2e}/db-revision-sql.ts +1 -1
- package/{server → server-e2e}/db-stmt.ts +2 -2
- package/{server → server-e2e}/db.ts +7 -7
- package/{server → server-e2e}/http.ts +44 -13
- package/{server → server-e2e}/hub.ts +40 -9
- package/server-e2e/index.ts +17 -0
- package/server-e2e/lifecycle.ts +95 -0
- package/{server → server-e2e}/neon-driver.ts +2 -2
- package/{server → server-e2e}/npm-proxy.ts +12 -145
- package/{server → server-e2e}/objstore/blob-vercel.ts +10 -114
- package/{server → server-e2e}/objstore/blob.ts +1 -1
- package/{server → server-e2e}/objstore/fetch-mint-guard.ts +2 -2
- package/{server → server-e2e}/objstore/handlers.ts +9 -8
- package/{server → server-e2e}/objstore/init.ts +19 -27
- package/{server → server-e2e}/objstore/reaper.ts +1 -1
- package/{server → server-e2e}/objstore/rest-deny.ts +1 -1
- package/{server → server-e2e}/objstore/rest-mint.ts +3 -3
- package/{server → server-e2e}/objstore/rest.ts +3 -3
- package/{server → server-e2e}/objstore/store-neon.ts +6 -10
- package/{server → server-e2e}/objstore/store.ts +7 -7
- package/{server → server-e2e}/objstore/tokens.ts +2 -2
- package/{server → server-e2e}/pubsub.ts +12 -9
- package/{server → server-e2e}/sign.ts +4 -4
- package/{server → server-e2e}/sse-server.ts +3 -3
- package/{server → server-e2e}/static.ts +18 -17
- package/{server → server-e2e}/sync-handlers.ts +56 -30
- package/{server → server-e2e}/ws-server.ts +20 -9
- package/server-managed/activity.ts +269 -0
- package/server-managed/agent-merges.ts +109 -0
- package/server-managed/app-agents.ts +23 -0
- package/server-managed/avatar-store.ts +21 -0
- package/server-managed/blob-store.ts +26 -0
- package/server-managed/brotli.ts +10 -0
- package/server-managed/bundle-advisories.ts +176 -0
- package/server-managed/bundle-advisory-inventory.ts +85 -0
- package/server-managed/bundle-build-diagnostics.d.ts +10 -0
- package/server-managed/bundle-build-diagnostics.js +23 -0
- package/server-managed/bundle-build-leases.ts +41 -0
- package/server-managed/bundle-build-worker.js +387 -0
- package/server-managed/bundle-build.ts +328 -0
- package/server-managed/bundle-cache.ts +261 -0
- package/server-managed/bundle-catalog.ts +29 -0
- package/server-managed/bundle-commits.ts +133 -0
- package/server-managed/bundle-dependency-reviews.ts +91 -0
- package/server-managed/bundle-store.ts +24 -0
- package/server-managed/bundle-summary-cache.ts +139 -0
- package/server-managed/bundle-validation.ts +33 -0
- package/server-managed/bundle.ts +151 -0
- package/server-managed/cache-storage.ts +20 -0
- package/server-managed/cli.js +21 -0
- package/server-managed/combined.ts +43 -0
- package/server-managed/comments.ts +138 -0
- package/server-managed/commit-coauthors.ts +105 -0
- package/server-managed/commit-lockfiles.ts +78 -0
- package/server-managed/comparison.ts +51 -0
- package/server-managed/config.ts +163 -0
- package/server-managed/content-access.ts +15 -0
- package/server-managed/crypto.ts +25 -0
- package/server-managed/db-methods.ts +1950 -0
- package/server-managed/db-neon.ts +401 -0
- package/server-managed/db-schema.ts +271 -0
- package/server-managed/db-table-names.ts +22 -0
- package/server-managed/db.ts +150 -0
- package/server-managed/dependabot-access.ts +85 -0
- package/server-managed/dependabot-alerts.ts +197 -0
- package/server-managed/dependency-review-comments.ts +158 -0
- package/server-managed/dependency-reviews.ts +369 -0
- package/server-managed/github-accounts.ts +59 -0
- package/server-managed/github-actions.ts +71 -0
- package/server-managed/github-app.ts +347 -0
- package/server-managed/github-errors.ts +92 -0
- package/server-managed/github-graphql.ts +42 -0
- package/server-managed/github-issue-links.ts +264 -0
- package/server-managed/github-issue-oauth.ts +30 -0
- package/server-managed/github-issues.ts +169 -0
- package/server-managed/github-link-oauth.ts +56 -0
- package/server-managed/github-links.ts +204 -0
- package/server-managed/github-metadata.ts +218 -0
- package/server-managed/github-oauth.ts +264 -0
- package/server-managed/github-pulls.ts +290 -0
- package/server-managed/github-requests.ts +181 -0
- package/server-managed/github-users.ts +53 -0
- package/server-managed/github-values.ts +26 -0
- package/server-managed/history-windows.ts +172 -0
- package/server-managed/http-response.ts +76 -0
- package/server-managed/http.ts +6722 -0
- package/server-managed/import-triage.ts +51 -0
- package/server-managed/index.ts +204 -0
- package/server-managed/kept-briefly.ts +37 -0
- package/server-managed/kept.ts +28 -0
- package/server-managed/known-listings.ts +112 -0
- package/server-managed/link-reports.ts +149 -0
- package/server-managed/listed-activity.ts +39 -0
- package/server-managed/locked-packages.ts +234 -0
- package/server-managed/lockfile-scope.ts +58 -0
- package/server-managed/lru.ts +30 -0
- package/server-managed/managed-issues.ts +92 -0
- package/server-managed/management-catalog.ts +45 -0
- package/server-managed/management.ts +116 -0
- package/server-managed/npm-delta-worker.js +203 -0
- package/server-managed/npm-delta.ts +277 -0
- package/server-managed/npm-insights.ts +455 -0
- package/server-managed/npm-kept.ts +274 -0
- package/server-managed/npm-loads.ts +259 -0
- package/server-managed/npm-manifest.ts +117 -0
- package/server-managed/npm-packages.ts +477 -0
- package/server-managed/npm-patch-paths.ts +86 -0
- package/server-managed/npm-patch.ts +457 -0
- package/server-managed/npm-provenance.ts +127 -0
- package/server-managed/npm-risk.ts +310 -0
- package/server-managed/object-storage-disk.ts +147 -0
- package/server-managed/object-storage-vercel.ts +71 -0
- package/server-managed/object-storage.ts +82 -0
- package/server-managed/package-entry-points.ts +127 -0
- package/server-managed/pretty-copies.ts +22 -0
- package/server-managed/pretty-format.d.ts +4 -0
- package/server-managed/pretty-format.js +27 -0
- package/server-managed/pretty-print.ts +444 -0
- package/server-managed/public-workspace.ts +242 -0
- package/server-managed/pull-comment-reviews.ts +161 -0
- package/server-managed/pull-dependencies.ts +370 -0
- package/server-managed/pull-dependency-reviews.ts +458 -0
- package/server-managed/pull-reviews.ts +202 -0
- package/server-managed/pulse-walk.ts +164 -0
- package/server-managed/queue.ts +54 -0
- package/server-managed/release-commits.ts +85 -0
- package/server-managed/rename-diff-worker.js +30 -0
- package/server-managed/rename-diff.ts +237 -0
- package/server-managed/repo-path.ts +21 -0
- package/server-managed/report-migration.ts +32 -0
- package/server-managed/report-opening.ts +77 -0
- package/server-managed/report-query.ts +10 -0
- package/server-managed/report-response.ts +16 -0
- package/server-managed/report-sources.ts +185 -0
- package/server-managed/report-store.ts +77 -0
- package/server-managed/repository-actions.ts +220 -0
- package/server-managed/repository-agents.ts +422 -0
- package/server-managed/repository-aliases.ts +119 -0
- package/server-managed/repository-browser.ts +362 -0
- package/server-managed/repository-changes.ts +280 -0
- package/server-managed/repository-code.ts +222 -0
- package/server-managed/repository-dependency-reviews.ts +220 -0
- package/server-managed/repository-discovery.ts +83 -0
- package/server-managed/repository-history.ts +444 -0
- package/server-managed/repository-issues.ts +293 -0
- package/server-managed/repository-policy.ts +27 -0
- package/server-managed/repository-pulls.ts +207 -0
- package/server-managed/repository-pulse.ts +409 -0
- package/server-managed/repository-risk-assess.ts +179 -0
- package/server-managed/repository-risk-audit.ts +145 -0
- package/server-managed/repository-risk-caches.ts +56 -0
- package/server-managed/repository-risk-kept.ts +86 -0
- package/server-managed/repository-risk-read.ts +296 -0
- package/server-managed/repository-risk-stasis.ts +61 -0
- package/server-managed/repository-risk-turn.ts +97 -0
- package/server-managed/repository-risk.ts +528 -0
- package/server-managed/repository-squashes.ts +160 -0
- package/server-managed/repository-stamp.ts +41 -0
- package/server-managed/request-timing.ts +63 -0
- package/server-managed/reviewed-dependencies.ts +170 -0
- package/server-managed/revisions.ts +35 -0
- package/server-managed/scan-downloads.ts +121 -0
- package/server-managed/session.ts +132 -0
- package/server-managed/slugs.ts +38 -0
- package/server-managed/solidity-entry-points.ts +71 -0
- package/server-managed/sql-postgres.ts +34 -0
- package/server-managed/sql.ts +107 -0
- package/server-managed/stasis-config.ts +147 -0
- package/server-managed/stasis-dependencies.ts +280 -0
- package/server-managed/static.ts +28 -0
- package/server-managed/storage-command.ts +16 -0
- package/server-managed/storage-db.ts +183 -0
- package/server-managed/storage-encryption.ts +288 -0
- package/server-managed/storage-maintenance.ts +259 -0
- package/server-managed/storage-payload.ts +121 -0
- package/server-managed/storage-stores.ts +91 -0
- package/server-managed/storage.ts +82 -0
- package/server-managed/team-app-summaries.ts +57 -0
- package/server-managed/team-app.ts +162 -0
- package/server-managed/team-catalog.ts +7 -0
- package/server-managed/team-feed.ts +180 -0
- package/server-managed/team-icons.ts +50 -0
- package/server-managed/team-npm-scopes.ts +103 -0
- package/server-managed/team-progress.ts +77 -0
- package/server-managed/team-reports.ts +369 -0
- package/server-managed/triage-response.ts +16 -0
- package/server-managed/type-only-proof.js +181 -0
- package/server-managed/type-only-worker.js +31 -0
- package/server-managed/type-only.ts +135 -0
- package/server-managed/uploads.ts +106 -0
- package/server-managed/upstream-cache.ts +275 -0
- package/server-managed/view-as.ts +58 -0
- package/server-managed/worker-turns.ts +76 -0
- package/server-managed/workspace-shares.ts +170 -0
- package/server.ts +70 -0
- package/strip-types-loader.js +13 -10
- package/server/index.ts +0 -480
- package/server/lifecycle.ts +0 -208
- /package/{LICENSE → LICENSE-MIT} +0 -0
- /package/{server → server-e2e}/auth.ts +0 -0
- /package/{server → server-e2e}/config.example.json +0 -0
- /package/{server → server-e2e}/objstore/blob-fs.ts +0 -0
- /package/{server → server-e2e}/objstore/fs.ts +0 -0
- /package/{server → server-e2e}/objstore/sign.ts +0 -0
- /package/{server → server-e2e}/peer.ts +0 -0
- /package/{server → server-e2e}/sse-session.ts +0 -0
- /package/{server → server-e2e}/util.ts +0 -0
- /package/{server → server-e2e}/validation.ts +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as e,b as t,c as n,d as r,e as i,f as a}from"./chunk-WCDYSIKG.js";import{a as o}from"./chunk-QI66YA4F.js";import{C as s,H as c,K as l,L as u,Q as d,m as f}from"./chunk-LVW7WWV4.js";import"./chunk-ZQHLECTI.js";import{d as p,h as m,i as h,j as g,k as ee,p as te,r as ne,s as _}from"./chunk-7HP2VYIC.js";import"./chunk-PXK7EU4V.js";import"./chunk-OOJM4CTU.js";var re=e=>/^[A-Za-z\d][\w.-]*$/u.test(e)&&/[A-Za-z]/u.test(e);function ie(e){let t=e.split(`-`);for(;t.at(-1)===``;)t.pop();return t}var v=()=>{},ae={3:[[/aix(\d+)?/u,`aix`],[/cygwin/u,`cygwin`,v],[/darwin(\d+)?/u,`darwin`],[/^macruby$/u,`macruby`,v],[/freebsd(\d+)?/u,`freebsd`],[/^(?:java|jruby)$/u,`java`,v],[/^java([\d.]*)/u,`java`],[/^dalvik(\d+)?$/u,`dalvik`],[/^dotnet$/u,`dotnet`,v],[/^dotnet([\d.]*)/u,`dotnet`],[/linux-?(\w+)?/u,`linux`],[/mingw32/u,`mingw32`,v],[/mingw-?(\w+)?/u,`mingw`],[/(mswin\d+)(_(\d+))?/u,void 0,e=>e[3]],[/netbsdelf/u,`netbsdelf`,v],[/openbsd(\d+\.\d+)?/u,`openbsd`],[/solaris(\d+\.\d+)?/u,`solaris`],[/wasi/u,`wasi`,v],[/^(\w+_platform)(\d+)?/u,void 0,e=>e[2]]],4:[[/aix-?(\d+)?/u,`aix`],[/cygwin/u,`cygwin`,v],[/darwin-?(\d+)?/u,`darwin`],[/^macruby$/u,`macruby`,v],[/^macruby-?(\d+(?:\.\d+)*)?/u,`macruby`],[/freebsd-?(\d+)?/u,`freebsd`],[/^(?:java|jruby)$/u,`java`,v],[/^java-?(\d+(?:\.\d+)*)?/u,`java`],[/^dalvik-?(\d+)?$/u,`dalvik`],[/^dotnet$/u,`dotnet`,v],[/^dotnet-?(\d+(?:\.\d+)*)?/u,`dotnet`],[/linux-?(\w+)?/u,`linux`],[/mingw32/u,`mingw32`,v],[/mingw-?(\w+)?/u,`mingw`],[/(mswin\d+)(?:[_-](\d+))?/u,void 0,e=>e[2]],[/netbsdelf/u,`netbsdelf`,v],[/openbsd-?(\d+\.\d+)?/u,`openbsd`],[/solaris-?(\d+\.\d+)?/u,`solaris`],[/wasi/u,`wasi`,v],[/^(\w+_platform)-?(\d+)?/u,void 0,e=>e[2]]]};function oe(e,t){if(e===void 0)return[`unknown`,void 0,void 0];for(let[n,r,i=e=>e[1]]of ae[t]){let t=n.exec(e);if(t===null)continue;let a=r??t[1];return[a,i(t),/^mswin\d*32$/u.test(a)?`x86`:void 0]}return[`unknown`,void 0,void 0]}function y(e){let t=ie(e);if(t.length>2&&!/\d$/u.test(t.at(-1))){let e=t.pop();t[t.length-1]+=`-${e}`}let n=t.shift();return t.length===2&&/^\d+(?:\.\d+)?$/u.test(t[1])?{cpu:n,os:t[0],version:t[1]}:{cpu:n,os:t[0]}}function b(e){let t=e.length;for(;e[t-1]===`-`;)t--;let n=e.slice(0,t),r=n.indexOf(`-`);return r===-1?{cpu:n||void 0}:{cpu:n.slice(0,r),os:n.slice(r+1)}}function x(e,t){let{cpu:n,os:r,version:i}=t===3?y(e):b(e),a=n!==void 0&&/i\d86/u.test(n)?`x86`:n;if(i!==void 0)return[a,r,i];let[o,s,c]=oe(r??n,t);return[r===void 0?c:a,o,s]}function S(e,t){let n=x(e,t);return n.filter(e=>e!==void 0).join(t===4&&n[0]===void 0?``:`-`)}var C=e=>e!==`ruby`&&e!==`current`&&/^[\w.-]+$/u.test(e)&&S(e,3)===e&&S(e,4)===e;function w(e){let t=e?.replace(/^gnu/u,``).replace(/eabi(?:hf)?$/u,``);return t===``?void 0:t}var T=Symbol(`all`),E=Symbol(`arm`);function se(e){let t=new Map;for(let n of e){if(n===`ruby`)continue;let[e,r,i]=x(n,3),a=t.get(r)??t.set(r,new Map).get(r);for(let t of[e,T,...e?.startsWith(`arm`)?[E]:[]]){let e=a.get(t)??a.set(t,{versions:new Set,libcs:new Set}).get(t);e.versions.add(i),e.libcs.add(w(i))}}return t}function ce(e,t,n){return e===void 0?!1:n===void 0||e.versions.has(void 0)||e.versions.has(n)?!0:t===`linux`&&(e.libcs.has(w(n))||[`musl`,`musleabi`,`musleabihf`].some(t=>e.versions.has(`${t}${n}`)))}function le(e,t){if(t===`java`||t===`mswin64`)return[void 0,t];if(t===`mswin32`&&e===`x86`)return[e,t];if(t===`mingw32`)return[e===`universal`||e===`x64`?e:e===`x86_64`?`x64`:`x86`,t]}function D(e,t,n,r){let i=e.get(n),a=t===void 0||t===`universal`?[T]:[t,void 0,`universal`,...t===`arm`?[E]:[]];return i!==void 0&&a.some(e=>ce(i.get(e),n,r))?!0:n.startsWith(`mingw`)&&[`mingw`,`mingw32`].some(n=>e.get(n)?.has(t===`universal`?T:`universal`))}function ue(e,t){let[n,r,i]=x(t,3),a=le(n,r);return D(e,n,r,i)||a!==void 0&&D(e,...a,void 0)}var de={GIT:{order:[`remote`,`revision`,`ref`,`branch`,`tag`,`submodules`,`glob`],required:2},PATH:{order:[`remote`,`glob`],required:1},GEM:{order:[`remote`],required:0}},fe=`{,*,*/*}.gemspec`;function pe({type:e,number:t,options:n}){let{order:r,required:i}=de[e],a=Object.create(null),o=0;for(let{key:t,value:i,number:s}of n){let n=r.indexOf(t);if(n===-1)throw g(`${m(t)} is not an option Bundler writes for a ${e} source`,s);if(t in a)throw g(e===`GEM`?`a second remote: Bundler fetches each gem of the source from either, and the lockfile does not say which`:`a second ${t}`,s);if(n<o)throw g(`${t} after ${r[o-1]}, where Bundler writes it before`,s);if(i.trim()!==i)throw g(`${m(i)} has a space at an end, which no ${t} Bundler writes has`,s);o=n+1,a[t]=i}let s=r.slice(0,i).find(e=>!(e in a));if(s!==void 0)throw g(`a ${e} source without its ${s}`,t);return a}var O=/\\|(?:^|[/{,])\.\.(?=$|[/},])|(?:^|[{,])(?:\/|[A-Za-z]:)/u;function k(e,t){if(e===fe)throw new p(`${m(e)}, which Bundler reads by where none is written, and does not write`,t);if(e!==void 0&&O.test(e))throw new p(`${m(e)} reaches out of the source, which Bundler globs its gemspecs from`,t);return e}function A(e,t){let{remote:n}=e;if(n.endsWith(`/`))throw new p(`${m(n)} ends in "/", which Bundler 2.4 and later drop as they read it, and 2.2 and 2.3 keep`,h(t,`remote`));u(n,h(t,`remote`));let{revision:r,ref:i}=e;if(!c(r))throw new p(`${m(r)} is not a full commit hash`,h(t,`revision`));if(i!==void 0&&/\s/u.test(i))throw new p(`${m(i)} is not a reference git reads`,h(t,`ref`));if(i?.startsWith(`-`))throw new p(`${m(i)} starts with "-", which git reads as an option`,h(t,`ref`));if(i!==void 0&&c(i)&&i!==r)throw new p(`the commit ${i}, and the revision another`,h(t,`ref`));if(e.submodules!==void 0&&e.submodules!==`true`)throw new p(`expected "true", found ${m(e.submodules)}`,h(t,`submodules`));return{type:`git`,remote:n,revision:r,ref:i,branch:f(e,`branch`,t,l),tag:f(e,`tag`,t,l),submodules:e.submodules===`true`,glob:k(e.glob,h(t,`glob`))}}function j(e,t){let n=h(t,`path`);if(e.remote.startsWith(`/`))throw new p(`${m(e.remote)} is an absolute path, which is the path on one machine alone`,n);if(e.remote.startsWith(`~`))throw new p(`${m(e.remote)} is a path from a home directory, which Bundler writes from the lockfile's`,n);return{type:`path`,path:s(e.remote,n),glob:k(e.glob,h(t,`glob`))}}function M(e){let t=URL.parse(e);return t!==null&&t.href===e&&(t.protocol===`file:`?t.host===``:t.protocol===`s3:`&&t.host!==``)}function N(e,t){let{remote:n}=e;if(n===void 0)return{type:`gem`,remote:n};if(!d(n)&&!M(n))throw new p(`${m(n)} is not an http(s) URL, or a file: or s3: URL in normal form`,h(t,`remote`));if(!n.endsWith(`/`))throw new p(`${m(n)} does not end in "/", as Bundler writes a source`,h(t,`remote`));return{type:`gem`,remote:n}}var P={GIT:A,PATH:j,GEM:N};function F(e){if(e.type===`gem`)return;if(e.type===`path`)return`source at \`${e.path}\``;let t=/^([A-Za-z][\w+.-]*):\/\/([^/]*)/u.exec(e.remote);return t!==null&&(/[A-Z]/u.test(t[1])||t[2].includes(`@`))?void 0:`${e.remote} (`}var I=e=>`the ${e.type} source ${m(e.remote??e.path)}`;function L(e,t){let n;for(let[r,i]of e.entries()){let e=F(i);if(e!==void 0){if(n!==void 0&&o(e,n.key)<0)throw g(`${I(i)} after ${I(n.source)}, where Bundler sorts them the other way`,t[r].number);n={key:e,source:i}}}}function R(e,t){let n=e.findIndex(e=>e.type===`gem`);if(n===-1)throw new p(`no GEM source, which Bundler always writes`);let r=e[n].remote===void 0,i=e.findIndex((e,t)=>t>n&&e.type===`gem`&&e.remote===void 0);if(i!==-1)throw g(r?`a second GEM source of no remote, where Bundler writes one, the Gemfile's own`:`a GEM source of no remote after one of a remote, where Bundler writes it first`,t[i].number);return r?n:-1}function z(e){let t=e.map((e,t)=>P[e.type](pe(e),`sources[${t}]`));return L(t,e),{sources:t,local:R(t,e)}}var B=/<<<<<<<|=======|>>>>>>>|\|{7}/u,me=new Set([`GIT`,`PATH`,`GEM`]),V={PLATFORMS:[2],DEPENDENCIES:[2],CHECKSUMS:[2],"RUBY VERSION":[2,3],"BUNDLED WITH":[2,3]},H=Object.keys(V);function U(e,t,n){let r=te(e);if(!t.includes(r))throw g(`expected ${t.join(` or `)} spaces of indentation, found ${r}`,n);return e.slice(r)}var he=/^([^\s()]+) \(([^\s()]+)\)(?: (\S+))?$/u;function W(e,t,n){let r=he.exec(e);if(r===null||!n&&r[3]!==void 0)throw g(`expected a gem as "name (version)", found ${m(e)}`,t);let[,i,a,o]=r,s=a.indexOf(`-`);return{name:i,version:s===-1?a:a.slice(0,s),platform:s===-1?void 0:a.slice(s+1),checksum:o,number:t}}var ge=/^([^\s()!]+)(?: \(([^()]+)\))?(!)?$/u;function G(e,t,n){let r=ge.exec(e);if(r===null||!n&&r[3]!==void 0)throw g(`expected a dependency as "name" or "name (requirement)", found ${m(e)}`,t);return{name:r[1],requirements:r[2]?.split(`, `)??[],pinned:r[3]!==void 0}}var _e=/^ {2}([a-z]+): (.+)$/u;function ve(e){let{line:t,number:n}=e,r=[];for(_(e);;_(e)){let t=_e.exec(e.line??``);if(t===null)break;r.push({key:t[1],value:t[2],number:e.number})}if(e.line!==` specs:`)throw g(`expected an option, "key: value", or "specs:", two spaces in, found ${e.line===void 0?`the end of the file`:m(e.line)}`,e.number);let i=[];for(_(e);e.line?.startsWith(` `);_(e)){let t=U(e.line,[4,6],e.number);if(e.line.length-t.length===4)i.push({...W(t,e.number,!1),dependencies:[]});else{if(i.length===0)throw g(`a dependency before any spec`,e.number);i.at(-1).dependencies.push(G(t,e.number,!1))}}return{type:t,number:n,options:r,specs:i}}function ye(e,t){let n=[];for(_(e);e.line?.startsWith(` `);_(e)){let r=U(e.line,t,e.number);n.push({text:r,indent:e.line.length-r.length,number:e.number})}return n}function be(e){let[t,n]=[`RUBY VERSION`,`BUNDLED WITH`].map(t=>e.get(t)?.lines[0]);if(t!==void 0&&n!==void 0&&t.indent!==n.indent)throw g(`${t.indent} spaces of indentation, and ${n.indent} under BUNDLED WITH`,t.number)}function xe(e){let t=B.exec(e)?.[0];if(t!==void 0)throw new p(`${m(t)}, which Bundler reads as a merge conflict`);if(e===``)throw new p(`an empty lockfile, which Bundler reads as none`);if(!e.endsWith(`
|
|
2
|
+
`))throw new p(`no line end after the last line, where Bundler ends every line`);let n=ne(e,ee),r=[],i=new Map,a;for(_(n);n.line!==void 0;){let{line:e,number:t}=n;if(e===``||e.startsWith(` `))throw g(e===``?`a blank line, where Bundler writes one between sections alone`:`expected a section, at column 0`,t);if(e===`PLUGIN SOURCE`)throw g(`a plugin source, which only its plugin can read, and which is not read here`,t);if(me.has(e)){if(a!==void 0)throw g(`a ${e} source after ${a}, where Bundler writes the sources first`,t);if(e!==`GEM`&&r.at(-1)?.type===`GEM`)throw g(`a ${e} source after a GEM one, where Bundler writes the GEM sources last`,t);r.push(ve(n))}else{let r=H.indexOf(e);if(r===-1)throw g(`${m(e)} is not a section Bundler writes`,t);if(i.has(e))throw g(`a second ${e}`,t);if(r<H.indexOf(a))throw g(`${e} after ${a}, where Bundler writes it before`,t);a=e,i.set(e,{number:t,lines:ye(n,V[e])})}if(n.line===void 0)break;if(n.line!==``)throw g(`expected a blank line before ${m(n.line)}`,n.number);if(_(n),n.line===void 0)throw g(`a blank line at the end, where Bundler writes none`,n.number)}return be(i),{sources:r,sections:i}}function K(e,t){if(!re(e))throw new p(`${m(e)} is not a gem name`,t);return e}var q=({name:e,version:t,platform:n=`ruby`})=>n===`ruby`?`${e}-${t}`:`${e}-${t}-${n}`;function J({name:t,version:n,platform:r},i){if(K(t,i),!e(n))throw new p(`${m(n)} is not a version as RubyGems writes one`,i);if(r===`ruby`)throw new p(`the platform ruby, which Bundler leaves out of a gem of no platform`,i);if(r!==void 0&&!C(r))throw new p(`${m(r)} is not a platform as RubyGems writes one`,i);return{name:t,version:n,platform:r??`ruby`}}function Se(e,r){for(let[t,i]of e.entries()){if(n(i)===void 0)throw new p(`${m(i)} is not a requirement as Bundler writes one, "op version"`,r);if(t>0&&i>e[t-1])throw new p(`${m(i)} after ${m(e[t-1])}, where Bundler sorts them backwards`,r)}let[i]=e;if(e.length===1&&i.startsWith(`>= `)&&t(i.slice(3),`0`)===0)throw new p(`${m(i)}, which Bundler leaves out, as any version`,r);return e}function Y(e,t,n,r=e=>e){let i=Object.create(null),a;for(let o of e){let e=h(t,o.name);if(K(o.name,e),a!==void 0&&o.name<=a)throw new p(`${o.name===a?`listed twice`:`after ${m(a)}`}, where Bundler sorts ${n} by name`,e);a=o.name,i[o.name]=r(Se(o.requirements,e),o)}return i}function Ce(e,t){let n=Object.create(null);for(let[r,{specs:i}]of e.entries()){let e;for(let a of i){let i=q(a),o=h(`specs`,i),{name:s,version:c,platform:l}=J(a,o);if(s===`bundler`)throw new p(`Bundler itself, which Bundler leaves out of the sources`,o);if(i in n)throw new p(`listed twice, of which Bundler keeps the last alone, at line ${a.number+1}`,o);if(e!==void 0&&i<e)throw new p(`after ${m(e)}, where Bundler sorts a source's gems by full name`,o);if(e=i,r===t)throw new p(`from sources[${r}], which has no remote: Bundler takes it from the gems installed where it runs`,o);n[i]={name:s,version:c,platform:l,source:r,dependencies:Y(a.dependencies,h(o,`dependencies`),`a gem's dependencies`),checksum:void 0}}}return n}var we=/^sha256=[\da-f]{64}$/u;function X(e,t){if(!we.test(e))throw new p(`${m(e)} is not a checksum as Bundler writes one, "sha256=" and the hex digest`,t);return e}function Te(e,t,n){let r,i,a=new Set;for(let{text:o,number:s}of e){if(i!==void 0&&o<=i)throw g(`${m(o)} after ${m(i)}, where Bundler sorts the checksums, each once`,s);i=o;let e=W(o,s,!0);if(e.name===`bundler`&&e.platform===void 0&&r===void 0){let{version:t}=J(e,`bundlerChecksum`);if(e.checksum===void 0)throw g(`Bundler itself, without the checksum Bundler writes it with`,s);r={version:t,checksum:X(e.checksum,h(`bundlerChecksum`,`checksum`))};continue}let c=q(e),l=m(o.split(` `,2).join(` `));if(!(c in t))throw g(`${l} is no gem of the sources`,s);if(a.has(c))throw g(`${l} a second time, where Bundler lists each gem once`,s);a.add(c);let u=t[c];if(e.checksum===void 0)continue;let d=h(h(`specs`,c),`checksum`);if(n[u.source].type!==`gem`)throw new p(`a checksum of a gem from a ${n[u.source].type} source, which has no .gem to check`,d);u.checksum=X(e.checksum,d)}let o=Object.keys(t).find(e=>!a.has(e));if(o!==void 0)throw new p(`not in CHECKSUMS, where Bundler lists every gem`,h(`specs`,o));return r}function Z(e,t){let n=e.get(t);if(n===void 0)throw new p(`no ${t}, which Bundler always writes`);return n}function Ee(e){let t=e.lines.map(({text:e})=>e);if(t.length===0)throw g(`no platform under PLATFORMS`,e.number);for(let[e,n]of t.entries()){let r=`platforms[${e}]`;if(n!==`ruby`&&!C(n))throw new p(`${m(n)} is not a platform as RubyGems writes one`,r);if(e>0&&n<=t[e-1])throw new p(`${m(n)} after ${m(t[e-1])}, where Bundler sorts the platforms, each once`,r)}return t}function De(e,t){let n=se(t);for(let[t,{platform:r}]of Object.entries(e))if(r!==`ruby`&&!ue(n,r))throw new p(`of the platform ${m(r)}, which no platform of PLATFORMS takes, where Bundler locks a gem for one`,h(`specs`,t))}function Oe(e){return Y(e.lines.map(({text:e,number:t})=>G(e,t,!0)),`dependencies`,`the dependencies`,(e,{pinned:t})=>({requirements:e,pinned:t}))}var ke=/^ruby \d+\.\d+\.\d+(?:\.[\dA-Za-z]+)*(?:p(?:-1|0|[1-9]\d*))?(?: \((?!ruby )[\w.-]+ [\w.-]+\))?$/u;function Ae(e,t){if(e.lines.length!==1)throw g(`expected one line under ${t}, found ${e.lines.length}`,e.number);return e.lines[0].text}var je=/^(?:2\.[2-7]|4\.0)\./u;function Q(t){let[n,r]=[`RUBY VERSION`,`BUNDLED WITH`].map(e=>t.has(e)?Ae(t.get(e),e):void 0);if(n!==void 0&&!ke.test(n))throw new p(`${m(n)} is not a Ruby as Bundler writes one, "ruby 3.3.6p108"`,`rubyVersion`);if(r!==void 0&&!e(r))throw new p(`${m(r)} is not a version as RubyGems writes one`,`bundledWith`);if(r!==void 0&&!je.test(r))throw new p(`${m(r)} is not a version of Bundler from 2.2 to 4.0, which this reader reads`,`bundledWith`);return{rubyVersion:n,bundledWith:r}}function Me(e){let t=Object.create(null),n=new Map;for(let[r,i]of Object.entries(e)){let a=t[i.name]??=[],[o]=a;if(o!==void 0&&e[o].source!==i.source)throw new p(`from sources[${i.source}], and ${m(o)} from sources[${e[o].source}], where Bundler takes a gem from one source`,h(`specs`,r));let s=n.get(`${i.name} ${i.platform}`);if(s!==void 0)throw new p(`for the platform of ${m(s)}, where Bundler locks one version of a gem for each`,h(`specs`,r));n.set(`${i.name} ${i.platform}`,r),a.push(r)}return t}function Ne({specs:e,gems:t,dependencies:n,sources:r,local:i}){let a;for(let[o,{pinned:s}]of Object.entries(n)){if(s||t[o]===void 0)continue;let n=h(`dependencies`,o),c=e[t[o][0]].source,{type:l}=r[c];if(l===`git`)throw new p(`from a git source, without the "!" Bundler writes of it`,n);if(l===`gem`&&i!==-1)throw new p(`from sources[${c}], where Bundler takes what the Gemfile names no source of from its default, sources[${i}], of no remote`,n);if(a??={name:o,index:c},c!==a.index)throw new p(`from sources[${c}], and ${m(a.name)} from sources[${a.index}], where Bundler takes what the Gemfile names no source of from its default alone`,n)}}function $(e,t,{specs:i,gems:o,versions:s},c){let l=s.get(e);if(!(l===void 0||t.every(e=>a(l,n(e)))))for(let a of o[e]){let e=t.find(e=>!r(i[a].version,n(e)));if(e!==void 0)throw new p(`${m(e)} is not met by ${m(a)}`,c)}}function Pe({specs:e,gems:t,dependencies:n}){let r={specs:e,gems:t,versions:new Map(Object.entries(t).map(([t,n])=>[t,i(n.map(t=>e[t].version))]))},a=new Set,o=[],s=e=>{e in t&&!a.has(e)&&o.push(e),a.add(e)};for(let[e,{requirements:t}]of Object.entries(n))$(e,t,r,h(`dependencies`,e)),s(e);for(;o.length>0;)for(let n of t[o.pop()]){let i=h(h(`specs`,n),`dependencies`);for(let[a,o]of Object.entries(e[n].dependencies)){let e=h(i,a);if(a!==`bundler`&&!(a in t))throw new p(`names no gem of the sources`,e);$(a,o,r,e),s(a)}}let c=Object.keys(t).find(e=>!a.has(e));if(c!==void 0)throw new p(`nothing depends on it, and Bundler locks what it resolves alone`,h(`specs`,t[c][0]))}function Fe(e){if(typeof e!=`string`)throw TypeError(`expected a string`);let{sources:t,sections:n}=xe(e),{sources:r,local:i}=z(t),a=Ce(t,i),o=Ee(Z(n,`PLATFORMS`));De(a,o);let s=Oe(Z(n,`DEPENDENCIES`)),c=Me(a);Ne({sources:r,local:i,specs:a,gems:c,dependencies:s}),Pe({specs:a,gems:c,dependencies:s});let l=n.get(`CHECKSUMS`),u=l===void 0?void 0:Te(l.lines,a,r);return{sources:r,specs:a,gems:c,platforms:o,dependencies:s,checksums:l!==void 0,bundlerChecksum:u,...Q(n)}}export{p as LockfileError,Fe as parseGemfileLock};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e}from"./chunk-NRPC74AM.js";import{a as t,d as n,f as r,h as i}from"./chunk-7C7DWL7I.js";import{d as a}from"./chunk-PNHBZGDD.js";import{a as o,b as s}from"./chunk-TKPNRQNN.js";import{c}from"./chunk-BZJU5EEV.js";import{C as l,D as u,G as d,J as f,K as p,L as m,O as h,q as g}from"./chunk-QRKFPLA4.js";import{a as _}from"./chunk-TUII34K2.js";function v(e,t){let n=s([{groups:[e],tree:t.tree,treeDependencies:t.treeDependencies}]);for(let r of e)l(r,t),r.isApp??=g(r,r.source??t.source),r._depsDirectory=n}function y(e,t){return!(e.isApp??g(e,e._source??e.source))&&o(e.file,e._depsDirectory??t??s([{groups:[[e]]}]))}function ee(e,n,r){let i=t(n);return i===`ignored`&&y(e,r)?void 0:i}function b(e,n,a,o){let s=n.id??String(n._id),c=n._reportName??``;y(n,o)&&(a===`ignored`||a===`untriaged`)?(t(e.get(s))!==`ignored`&&r(e,s,{triage:void 0}),i(e,s,c,a===`ignored`,!0)):(r(e,s,{triage:a===`untriaged`?void 0:a}),a!==`ignored`&&a!==`untriaged`&&i(e,s,c,!1))}function x(e,a){let o=new Set;for(let t of e.values()){let e=t?.ignoredReports;if(!e?.length)continue;let r=new Set(e).size!==e.length;for(let i of e)(r||!n(t,i))&&o.add(i)}if(o.size===0)return!1;let c=!1;for(let l of a){let a=(l.groups??[]).flat();if(!a.some(e=>o.has(e._reportName??l.name??l.fileName??``)))continue;let u=s([l]),d=e=>({...e,_source:e._source??e.source??l.source}),f=new Set(a.filter(e=>y(d(e),u)).map(e=>e.id??String(e._id)));for(let o of a){let a=o.id??String(o._id),s=o._reportName??l.name??l.fileName??``,p=e.get(a);p?.ignoredReports?.includes(s)&&(n(p,s)||y(d(o),u)||(t(p)||(c=r(e,a,{triage:`ignored`})||c),f.has(a)||(c=i(e,a,s,!1)||c)))}for(let t of a){if(!y(d(t),u))continue;let n=t.id??String(t._id),r=t._reportName??l.name??l.fileName??``;e.get(n)?.ignoredReports?.includes(r)&&(c=i(e,n,r,!0,!0)||c)}}return c}async function S(e,t){let r=new Set(Object.values(e??{}).flatMap(e=>Array.isArray(e?.ignoredReports)?e.ignoredReports.filter(t=>typeof t==`string`&&!n(e,t)):[])),i=[];for(let e of r){let n;try{let r=await t(e);if(typeof r!=`string`)continue;n=await h(r)}catch{continue}n&&i.push({...n.data,name:e,groups:[n.findings]})}return i}async function C(e,t){if(e!=null&&(typeof e!=`object`||Array.isArray(e)))return{entries:e,changed:!1};let n=new Map(Object.entries(e??{})),r=x(n,await S(e,t));return{entries:Object.fromEntries(n),changed:r}}var w=`links`;function T(e){if(typeof e==`string`)return e.length>0?e:null;if(!e||typeof e!=`object`||Array.isArray(e))return null;let{id:t}=e;return typeof t==`string`&&t.length>0?t:null}function E(e){if(typeof e==`string`&&!/^\s*\[/u.test(e))return null;let t;try{t=JSON.parse(e)}catch{return null}if(!Array.isArray(t)||t.length===0)return null;let n=[],r=0;for(let e of t){if(!Array.isArray(e))return null;let t=new Set;for(let n of e){let e=T(n);if(e===null)return null;c(e)?t.add(e):r++}t.size>1&&n.push([...t])}return{groups:n,skipped:r}}function D(e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t.size}function te(e,t){for(let n of e)for(let e of n){let r=t.get(e);r||t.set(e,r=new Set);for(let t of n)t!==e&&r.add(t)}return t}var O=1,k=16,A=12,j=1+k+A+16,M=1+k+A;async function N(e,t){let n=await crypto.subtle.importKey(`raw`,_(e),`PBKDF2`,!1,[`deriveKey`]);return crypto.subtle.deriveKey({name:`PBKDF2`,hash:`SHA-256`,salt:t,iterations:3e6},n,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`])}function P(e){return!(e instanceof Uint8Array)||e.length<j?!1:e[0]===O}async function F(e,t){if(!(e instanceof Uint8Array))throw TypeError(`encryptWithPassword: plaintext Uint8Array required`);if(typeof t!=`string`||!t)throw TypeError(`encryptWithPassword: password required`);let n=new Uint8Array(M+e.length+16);n[0]=O,crypto.getRandomValues(n.subarray(1,1+k)),crypto.getRandomValues(n.subarray(1+k,M));let r=n.subarray(1,1+k),i=n.subarray(1+k,M),a=await N(t,r),o=new Uint8Array(await crypto.subtle.encrypt({name:`AES-GCM`,iv:i,additionalData:n.subarray(0,M)},a,e));return n.set(o,M),n}async function ne(e,t){if(typeof t!=`string`||!t)throw TypeError(`tryDecryptWithPassword: password required`);if(!(e instanceof Uint8Array)||e.length<j||e[0]!==O)return{ok:!1,reason:`malformed`};let n=e.subarray(1,1+k),r=e.subarray(1+k,M),i=e.subarray(M),a=await N(t,n),o;try{o=new Uint8Array(await crypto.subtle.decrypt({name:`AES-GCM`,iv:r,additionalData:e.subarray(0,M)},a,i))}catch{return{ok:!1,reason:`wrong-password`}}return{ok:!0,plaintext:o}}async function I(e,t,n){if(!n||typeof n.malformedMsg!=`string`||typeof n.wrongPasswordMsg!=`string`)throw TypeError(`decryptWithPasswordOrThrow: { malformedMsg, wrongPasswordMsg } strings required`);let r=await ne(e,t);if(r.ok)return r.plaintext;throw r.reason===`wrong-password`?Error(n.wrongPasswordMsg):Error(n.malformedMsg)}var L=P,R=F;function z(e,t){return I(e,t,{malformedMsg:`malformed encrypted bundle`,wrongPasswordMsg:`wrong password or corrupt bundle`})}var B=1,V=1024,H=1024,U=200,W=0x6400000,G=Math.ceil(W*4/3)+16,K=512,q=64;function J(e){if(!e||typeof e!=`object`)return`payload is not an object`;if(e.version!==B)return`unsupported export version: ${e.version}`;if(!e.workspace||typeof e.workspace!=`object`)return`workspace metadata missing`;if(typeof e.workspace.id!=`string`)return`workspace.id must be a string`;if(typeof e.workspace.name!=`string`)return`workspace.name must be a string`;if(typeof e.workspace.privateKey!=`string`)return`workspace.privateKey must be a string`;if(e.workspace.createdAt!==void 0&&!Number.isFinite(e.workspace.createdAt))return`workspace.createdAt must be a finite number or omitted`;if(!Array.isArray(e.reports))return`reports field must be an array`;if(e.reports.length>H)return`reports count (${e.reports.length}) exceeds cap (${H})`;if(e.bundles!==void 0){if(!Array.isArray(e.bundles))return`bundles field must be an array when present`;if(e.bundles.length>V)return`bundles count (${e.bundles.length}) exceeds cap (${V})`;for(let t of e.bundles){if(typeof t!=`string`)return`bundles entries must be strings`;if(t.length>U)return`bundle integrity exceeds per-entry length cap (${U})`}}if(e.bundleBlobs!==void 0){if(!Array.isArray(e.bundleBlobs))return`bundleBlobs field must be an array when present`;if(e.bundleBlobs.length>q)return`bundleBlobs count (${e.bundleBlobs.length}) exceeds cap (${q})`;for(let t of e.bundleBlobs){if(!t||typeof t!=`object`||Array.isArray(t))return`bundleBlobs entries must be objects`;if(typeof t.integrity!=`string`||t.integrity.length===0)return`bundleBlobs.integrity must be a non-empty string`;if(t.integrity.length>U)return`bundleBlobs.integrity exceeds per-entry length cap (${U})`;if(typeof t.name!=`string`||t.name.length===0)return`bundleBlobs.name must be a non-empty string`;if(t.name.length>K)return`bundleBlobs.name exceeds per-entry length cap (${K})`;if(t.name.includes(`\0`))return`bundleBlobs.name cannot contain NUL`;if(typeof t.data!=`string`)return`bundleBlobs.data must be a base64 string`;if(t.data.length>G)return`bundleBlobs.data exceeds per-blob size cap (${W} bytes raw)`}}return null}async function Y(e){return new Uint8Array(await e.arrayBuffer())}async function X(e,t){if(L(e)){if(typeof t!=`string`||!t)throw TypeError(`parseWorkspaceBundleBytes: password required for encrypted bundle`);let n=await z(e,t);try{return Z(await a(n))}catch(e){throw Error(`wrong password or corrupt bundle`,{cause:e})}}let n;try{n=await a(e)}catch(e){throw Error(`gzip decompression failed: ${e.message}`,{cause:e})}return Z(n)}function Z(e){let t;try{t=JSON.parse(e)}catch(e){throw Error(`payload is not JSON: ${e.message}`,{cause:e})}let n=J(t);if(n===null)return t;let r=n.includes(`exceeds cap`);throw Error(r?n:`not a deepview workspace export: ${n}`)}function Q(e,t){let n=e.trimStart().startsWith(`[`)?E(e):null;if(n)return{data:{source:`links`,findings:[],links:n.groups},format:`links`,reason:null};let r=m(e);if(r.data!=null||p(e,t)!==`codex`)return r;try{return{data:{type:`security`,source:`codex-security`,findings:d(e).flatMap(e=>e.data.findings)},format:`codex`,reason:null}}catch(e){return{data:null,format:null,reason:e instanceof Error?e.message:`Invalid Codex CSV`}}}function re(e,t){let n=Q(e,t);return n.data==null?Promise.resolve(null):h(JSON.stringify(n.data))}function ie(e){let t=new Set;for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.file==`string`&&e.file&&t.add(e.file);for(let n of Array.isArray(e.evidence)?e.evidence:[])typeof n?.file==`string`&&n.file&&t.add(n.file)}return t}function $(e){let t=(f(e)??[]).flat().filter(e=>typeof e==`object`&&!!e),n=s([{groups:[t],tree:e?.tree}]);return{directory:n,own:t.filter(e=>!o(e.file,n))}}function ae(e){let t=new Map;for(let n of $(e).own){let e=u(n);e&&t.set(e.toLowerCase(),e)}return t.size===1?[...t.values()][0]:null}function oe(t){let{directory:n,own:r}=$(t);return e([...ie(r)].filter(e=>!o(e,n)))}var se=[`inprogress`,`fixed`,`invalid`,`deleted`,`ignored`];function ce(e){return typeof e==`string`&&se.includes(e)}function le(e){if(e===null)return null;if(typeof e!=`object`||Array.isArray(e))return`invalid`;let t=e,n={},r=t.color;if(r!=null){if(typeof r!=`string`||r.length>50)return`invalid`;r!==``&&(n.color=r)}let i=t.triage;if(i!=null){if(!ce(i))return`invalid`;n.triage=i}for(let e of[`comment`,`fix`]){let r=t[e];if(r!=null){if(typeof r!=`string`||r.length>1e4)return`invalid`;r!==``&&(n[e]=r)}}let a=t.flagged;if(a!=null){if(typeof a!=`boolean`)return`invalid`;n.flagged=a}return n}export{v as a,y as b,ee as c,b as d,x as e,S as f,C as g,w as h,E as i,D as j,te as k,F as l,I as m,L as n,R as o,H as p,Y as q,X as r,Z as s,Q as t,re as u,ae as v,oe as w,le as x};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e,c as t,d as n,e as r,f as i,g as a,h as o,j as s,k as c,m as l,n as u}from"./chunk-PXK7EU4V.js";import{b as d}from"./chunk-OOJM4CTU.js";function f(e){if(Object.keys(e).length>0)throw TypeError(`Unexpected extra options`)}Object.getPrototypeOf(Uint8Array);var p=globalThis.atob,m=Uint8Array.prototype.toBase64,h=8192,g=m&&p;function _(e,t=0,n=e.length){t|=0,n|=0;let r=n-t;if(r===0)return``;if(g&&r>=256&&r<1e8&&e.toBase64===m&&e.BYTES_PER_ELEMENT===1)return p((t===0&&n===e.length?e:e.subarray(t,n)).toBase64());if(r>h){let r=``;for(let i=t;i<n;){let t=Math.min(n,i+h);r+=String.fromCharCode.apply(String,e.subarray(i,t)),i=t}return r}let i=t===0&&n===e.length?e:e.subarray(t,n);return String.fromCharCode.apply(String,i)}var v=t?e=>e.byteLength>=768&&!r?t.from(e.buffer,e.byteOffset,e.byteLength).latin1Slice(0,e.byteLength):a.decode(e):o?e=>o.decode(e):e=>_(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),y=t=>e(t,new Uint8Array(t.length)),b=n&&i?.encodeInto?(e,t)=>{let n=new Uint8Array(e.length+4),r=i.encodeInto(e,n);if(r.read!==e.length||r.written!==e.length)throw SyntaxError(t);return n.subarray(0,e.length)}:t?(e,n)=>{let r=t.from(e,`utf8`);if(r.length!==e.length)throw SyntaxError(n);return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}:(e,t)=>{let n=i.encode(e);if(n.length!==e.length)throw SyntaxError(t);return n},x={};d(x,{E_CHAR:()=>E,E_LAST:()=>k,E_LENGTH:()=>O,E_PADDING:()=>D,fromBase64:()=>M,toBase64:()=>A});var S=[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`],C=[...`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`],w={},T={},E=`Invalid character in base64 input`,D=`Invalid base64 padding`,O=`Invalid base64 length`,k=`Invalid last chunk`;function A(e,t,n){let r=e.length/3|0,i=r*3,o=``,s=0,c=t?C:S,l=t?T:w;if(!l.pairs){if(l.pairs=[],a){l.codepairs=new Uint16Array(4096);let e=l.codepairs,t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);for(let e=0;e<64;e++){let n=c[e].charCodeAt(0);for(let r=0;r<64;r++)t[e<<7|r<<1]=t[r<<7|(e<<1)+1]=n}}else{let e=l.pairs;for(let t=0;t<64;t++)for(let n=0;n<64;n++)e.push(`${c[t]}${c[n]}`)}}let{pairs:u,codepairs:d}=l;if(a){let t=new Uint16Array(r*2),n=0;for(let r=e.length-11;s<r;s+=12,n+=8){let r=e[s],i=e[s+1],a=e[s+2],o=e[s+3],c=e[s+4],l=e[s+5],u=e[s+6],f=e[s+7],p=e[s+8],m=e[s+9],h=e[s+10],g=e[s+11];t[n]=d[r<<4|i>>4],t[n+1]=d[(i&15)<<8|a],t[n+2]=d[o<<4|c>>4],t[n+3]=d[(c&15)<<8|l],t[n+4]=d[u<<4|f>>4],t[n+5]=d[(f&15)<<8|p],t[n+6]=d[m<<4|h>>4],t[n+7]=d[(h&15)<<8|g]}for(let r=e.length-2;s<r;s+=3,n+=2){let r=e[s],i=e[s+1],a=e[s+2];t[n]=d[r<<4|i>>4],t[n+1]=d[(i&15)<<8|a]}o=v(t)}else for(;s<i;s+=3){let t=e[s],n=e[s+1],r=e[s+2];o+=u[t<<4|n>>4],o+=u[(n&15)<<8|r]}let f=0,p=2,m=e.length;for(;s<m;s++){let t=e[s];o+=c[f|t>>p],p===6&&(p=0,o+=c[t&63]),f=t<<6-p&63,p+=2}return p!==2&&(o+=c[f]),n&&(o+=[``,`==`,`=`][m-i]),o}var j=i?128:65536;function M(e,t){let n=e.length;for(;e[n-1]===`=`;)n--;let r=e.length-n,a=n%4,o=n-a;if(a===1)throw SyntaxError(O);if(r>3||r!==0&&e.length%4!=0)throw SyntaxError(D);let s=t?C:S,c=t?T:w;c.fromMap||(c.fromMap=new Int8Array(j).fill(-1),s.forEach((e,t)=>c.fromMap[e.charCodeAt(0)]=t));let l=c.fromMap,u=new Uint8Array(Math.floor(n*3/4)),d=0,f=0;if(i){let t=b(e,E);for(;f<o;f+=4){let e=t[f],n=t[f+1],r=t[f+2],i=t[f+3],a=l[e]<<18|l[n]<<12|l[r]<<6|l[i];if(a<0)throw SyntaxError(E);u[d]=a>>16,u[d+1]=a>>8&255,u[d+2]=a&255,d+=3}}else for(;f<o;f+=4){let t=e.charCodeAt(f),n=e.charCodeAt(f+1),r=e.charCodeAt(f+2),i=e.charCodeAt(f+3),a=l[t]<<18|l[n]<<12|l[r]<<6|l[i];if(a<0)throw SyntaxError(E);u[d]=a>>16,u[d+1]=a>>8&255,u[d+2]=a&255,d+=3}if(a<2)return u;let p=l[e.charCodeAt(f++)]<<6|l[e.charCodeAt(f++)];if(p<0)throw SyntaxError(E);if(u[d++]=p>>4,a<3){if(p&15)throw SyntaxError(k);return u}let m=l[e.charCodeAt(f++)];if(m<0)throw SyntaxError(E);if(u[d++]=p<<4&255|m>>2,m&3)throw SyntaxError(k);return u}var{Buffer:N,atob:P,btoa:F}=globalThis,I=N&&!N.TYPED_ARRAY_SUPPORT,{toBase64:L}=Uint8Array.prototype,{E_CHAR:R,E_PADDING:z,E_LENGTH:B,E_LAST:V}=x,H=F&&n,U=P&&n,W=e=>e.constructor===N&&N.isBuffer(e),G=e=>W(e)?e:N.from(e.buffer,e.byteOffset,e.byteLength);function K(e,t){if(t)return e;let n=e.indexOf(`=`,e.length-3);return n===-1?e:e.slice(0,n)}function q(e,t){return t&&e.length%4!=0?e+`=`.repeat(4-e.length%4):e}var J=e=>L&&e.toBase64===L;function Y(e,{padding:t=!0}={}){return s(e),J(e)?t?e.toBase64():e.toBase64({omitPadding:!t}):I?K(G(e).base64Slice(0,e.byteLength),t):H?K(F(_(e)),t):A(e,!1,t)}function X(e,t){if(typeof t==`string`&&(t={format:t}),!t)return Z(e,!1,`both`,`uint8`,null);let{format:n=`uint8`,padding:r=`both`,...i}=t;return Z(e,!1,r,n,i)}function Z(e,t,n,r,i){if(typeof e!=`string`)throw TypeError(c);i!==null&&f(i);let a=n===`both`?e.endsWith(`=`):void 0;if(n===!0||a===!0){if(e.length%4!=0||e[e.length-3]===`=`)throw SyntaxError(z)}else if(n===!1||a===!1){if(e.length%4==1)throw SyntaxError(B);if(n===!1&&e.endsWith(`=`))throw SyntaxError(`Did not expect padding in base64 input`)}else throw TypeError(`Invalid padding option`);return ee(e,t,n,r)}var Q=/[\t\n\f\r ]/;function $(e,t){let n=e.indexOf(`=`,e.length-3),r=n>=0?e.length-n:0,i=e.length-r,a=i%4,o=t.length-(i-a)/4*3;return a===0&&o===0||a===2&&o===1||a===3&&o===2}var ee=Uint8Array.fromBase64?(e,t,n,r)=>{let i=t?`base64url`:`base64`,a;if(n===!0)a=Uint8Array.fromBase64(e,{alphabet:i,lastChunkHandling:`strict`});else try{let t=e.length%4>0?`${e}${`=`.repeat(4-e.length%4)}`:e;a=Uint8Array.fromBase64(t,{alphabet:i,lastChunkHandling:`strict`})}catch(t){throw Q.test(e)?SyntaxError(R):t}if(!$(e,a))throw SyntaxError(R);return l(a,r)}:I?(e,t,n,r)=>{let i=N.byteLength(e,`base64`),a=N.allocUnsafeSlow(i);if(a.base64Write(e)!==i)throw SyntaxError(z);let o=t?a.base64urlSlice(0,a.length):a.base64Slice(0,a.length);if(e!==o&&(n===!t||q(e,!0)!==q(o,t)))throw SyntaxError(z);return u(a,r)}:U?(e,t,n,r)=>{let i;if(t){if(/[\t\n\f\r +/]/.test(e))throw SyntaxError(R);e=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`)}try{i=y(P(e))}catch{throw SyntaxError(R)}if(!t&&!$(e,i))throw SyntaxError(R);if(i.length%3!=0&&Y(i.subarray(-(i.length%3)))!==(e.length%4==0?e.slice(-4):e.slice(-(e.length%4)).padEnd(4,`=`)))throw SyntaxError(V);return l(i,r)}:(e,t,n,r)=>l(M(e,t),r);export{f as a,v as b,b as c,Y as d,X as e};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as e}from"./chunk-6VOB5WXX.js";import{g as t,n,r,s as i,t as a,u as o,v as s,w as c,x as l}from"./chunk-XRAAYXPR.js";import{a as u}from"./chunk-NRPC74AM.js";import{e as d,i as f}from"./chunk-7C7DWL7I.js";import"./chunk-PNHBZGDD.js";import"./chunk-TKPNRQNN.js";import"./chunk-BZJU5EEV.js";import{D as p}from"./chunk-QRKFPLA4.js";import{a as m,c as h,g}from"./chunk-2XUEZHIP.js";import"./chunk-TUII34K2.js";import"./chunk-OOJM4CTU.js";var _=`h1{font-size:1.35rem;margin-bottom:.5rem}h2{font-size:1.1rem;margin-bottom:.5rem}.triage-import{display:flex;gap:1rem;align-items:center;margin:1.5rem 0 2rem}.triage-import .btn{flex-shrink:0}.triage-import p{margin:0}.workspace-drop{display:grid;gap:.8rem;padding:2rem;margin:1.5rem 0;border:1px dashed var(--border);border-radius:var(--ui-radius, 8px)}.workspace-drop.dragging{border-color:var(--accent);background:rgb(from var(--accent) r g b / .08)}.workspace-drop span,p,li span{color:var(--muted);line-height:1.5}.actions,.local-choice{display:flex;gap:.8rem;flex-wrap:wrap;align-items:center}.local-choice{margin-bottom:1.5rem}.import-preview{display:grid;gap:.8rem}input:not([type=radio]),select{padding:.55rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);color:var(--text);background:var(--bg);font:inherit}.import-preview input:not([type=radio]),.import-preview select{width:100%;box-sizing:border-box}fieldset{display:grid;gap:.8rem;padding:1rem;border:1px solid var(--border);border-radius:var(--ui-radius, 5px)}fieldset label{display:flex;gap:.5rem;align-items:center}li{padding:.4rem 0;overflow-wrap:anywhere}li span{display:block;font-size:.8rem}ul{padding-left:1.2rem}.primary{justify-self:start;color:var(--accent)}.error{color:var(--critical)}button:disabled{opacity:.5}input:focus-visible,select:focus-visible,button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
|
|
2
|
+
`;async function v(e,{session:t,confirmImport:n,...r}){if(t?.role!==`admin`||!t.csrfToken)throw Error(`An administrator session is required.`);if(e!=null&&(typeof e!=`object`||Array.isArray(e)))throw Error(`Invalid local triage.`);let i=Object.create(null);for(let[t,n]of Object.entries(e??{})){let{ignoredReports:e,scopedIgnoredReports:r,...a}=d(n)??{};Object.keys(a).length!==0&&(i[t]=a)}let a=Object.keys(i).length,o=new Set,s=[],c;if(a>0)do{r.signal?.throwIfAborted();let e=`/api/admin/reports/finding-ids`+(c?`?after=${encodeURIComponent(c)}`:``),{reports:t,nextCursor:n}=await r.api.send(e);r.signal?.throwIfAborted();for(let e of t){let t=e.findingIds.filter(e=>Object.hasOwn(i,e)&&!o.has(e));t.length>0&&s.push({id:e.id,ids:t});for(let e of t)o.add(e)}c=n}while(c);for(let e of o){if(!e||e.length>100)throw Error(`Triage finding IDs must be between 1 and 100 characters.`);if(l(i[e])===`invalid`)throw Error(`Triage for ${e} exceeds the managed server limits.`)}if(r.signal?.throwIfAborted(),n){let e=await n({matched:o.size,available:a});if(r.signal?.throwIfAborted(),!e)return null}let u=r.importedIds??new Set;for(let e of s)await S(i,{...r,importedIds:u,ids:e.ids,path:`/api/admin/reports/${encodeURIComponent(e.id)}/import-triage`});return o.size}function y(e,t){let n=[],r=Object.create(null);for(let[i,a]of Object.entries(e)){let e=t[i];if(!e)throw Error(`The server did not return the requested triage snapshot.`);let o=e.entry??{},s=r[i]={...o};delete s.comment;for(let[t,r]of Object.entries(a))if(t===`comment`){if(e.comments.some(e=>e.body===r))continue;e.comments.length>0?n.push({id:i,property:t,local:e.comments.map(e=>e.body).join(`
|
|
3
|
+
|
|
4
|
+
`),imported:r}):s.comment=r}else if(o[t]!==void 0&&o[t]!==r){let e=e=>t===`flagged`?e?`flagged`:`not flagged`:e;n.push({id:i,property:t,local:e(o[t]),imported:e(r)})}else s[t]=r}return{entries:r,conflicts:n}}async function b(e,t,n,r,i){i?.throwIfAborted();let{entries:a,conflicts:o}=y(e,t);if(o.length===0)return a;let s=await r(o,n,{title:`Triage conflicts on import`,intro:`disagree with stored triage on`,trailingNote:`Imported comments are added alongside existing comments. Other choices apply to these finding IDs across all teams.`,importedSideLabel:`Apply imported`});if(i?.throwIfAborted(),!s)throw Object.assign(Error(`Triage conflict resolution was cancelled.`),{cancelled:!0});for(let t of o){let n=s[`${t.id}:${t.property}`];if(![`local`,`imported`].includes(n))throw Error(`Resolve every triage conflict before importing.`);n===`imported`&&(a[t.id][t.property]=e[t.id][t.property])}return a}function x(e,t){let n=[],r={entries:{},expected:{}};for(let[i,a]of Object.entries(e)){let e={entries:{...r.entries,[i]:a},expected:{...r.expected,[i]:t[i].version}};if(new TextEncoder().encode(JSON.stringify(e)).length<=262144)r=e;else{if(Object.keys(r.entries).length===0)throw Error(`This triage entry is too large to import.`);n.push(r),r={entries:{[i]:a},expected:{[i]:t[i].version}}}}return Object.keys(r.entries).length>0&&n.push(r),n}async function S(e,{api:t,path:n,ids:r=Object.keys(e),importedIds:i=new Set,lookup:a=new Map,resolveConflicts:o,signal:s}){r=r.filter(t=>Object.hasOwn(e,t)&&!i.has(t));for(let c=0;c<r.length;c+=200){let l=r.slice(c,c+200);for(let r=0;r<5&&l.length>0;r++){s?.throwIfAborted();let{snapshots:r}=await t.send(n,{findingIds:l}),c=await b(Object.fromEntries(l.map(t=>[t,e[t]])),r,a,o,s);for(let e of x(c,r)){if(s?.throwIfAborted(),(await t.send(n,e)).conflict)break;Object.keys(e.entries).forEach(e=>i.add(e))}l=l.filter(e=>!i.has(e))}if(l.length>0)throw Error(`Stored triage keeps changing. Retry to resolve it against the latest values.`)}}var C=`You can retry the remaining steps.`;function w(e){return String(e?.detail??e?.message??e).replace(/\.$/u,``)}function T(e,t){return t?.aborted===!0||e?.name===`AbortError`||e?.cancelled===!0}function E(e){if(typeof e!=`string`)return{ok:!0,path:null};if(/\p{Cc}/u.test(e)||e.includes(`\\`)||e!==e.trim())return{ok:!1};let t=[];for(let n of e.split(`/`))if(n!==``&&n!==`.`){if(n===`..`||n!==n.trim())return{ok:!1};t.push(n)}let n=t.join(`/`);return n.length>500?{ok:!1}:{ok:!0,path:n===``?null:n}}async function D(e,t){let a=new Uint8Array(await e.arrayBuffer());return n(a)?t({tryPassword:e=>r(a,e)}):a[0]===31&&a[1]===139?r(a):i(new TextDecoder(`utf-8`,{fatal:!0}).decode(a))}function O(e,t,n,r,i=``){let a=e?u(e,t,r,i):null,o=n.find(t=>a?t.repoId===a.repoId:t.fullName.toLowerCase()===e?.toLowerCase());return{repoId:o?.repoId??null,directory:a?.directory??t,github:o?.fullName??e}}async function k(e,n,r=[]){let i=new Map,l=[];for(let t of e.reports){if(typeof t?.name!=`string`||!t.name||typeof t.content!=`string`)throw Error(`Every report must have a name and content.`);let u=a(t.content,t.name);if(!u.data)throw Error(`${t.name}: ${u.reason??`Unsupported report`}`);let d=p(u.data),f=d??p(t)??p({repo:{github:e.repoUrls?.[t.name]}})??s(u.data),m=d?``:c(u.data),h=E(u.data.repo?.directory);if(!h.ok)throw Error(`${t.name}: invalid repository directory`);let g=u.format===`links`?[]:(await o(t.content,t.name))?.findings??[];for(let e of g)e.id&&i.set(e.id,e);let _=h.path??``;l.push({...t,links:u.format===`links`,...O(f,_,n,r,m),declaredGithub:f,declaredDirectory:_,filePrefix:m,embedded:d,ids:[...new Set(g.map(e=>e.id).filter(Boolean))],uploaded:null})}let u=Object.create(null);if(e.triage!=null&&(typeof e.triage!=`object`||Array.isArray(e.triage)))throw Error(`Invalid workspace triage.`);let f=await t(e.triage,t=>e.reports.find(e=>e.name===t)?.content);for(let[e,t]of Object.entries(f.entries)){if(!i.has(e))continue;let n=d(t);if(!n)continue;let{ignoredReports:r,scopedIgnoredReports:a,...o}=n;Object.keys(o).length!==0&&(u[e]=o)}let m=[];for(let t of e.bundleBlobs??[]){let e=Uint8Array.fromBase64(t.data),n=`sha512-${new Uint8Array(await crypto.subtle.digest(`SHA-512`,e)).toBase64()}`;if(n!==t.integrity)throw Error(`${t.name}: bundle integrity mismatch`);m.push({name:t.name,integrity:n,bytes:e,uploaded:null})}return{name:e.workspace.name.slice(0,100),reports:l,bundles:m,triage:u,lookup:i,references:e.bundles??[],team:null,completed:new Set,importedIds:new Set}}function A(e,t,n){async function r(r,i,a={}){n?.throwIfAborted();let o=await e(r,{credentials:`same-origin`,signal:n,...i===void 0?{}:{method:`POST`,body:i instanceof File?i:JSON.stringify(i)},headers:{...i instanceof File?{}:{"content-type":`application/json`},"x-csrf-token":t.csrfToken,...a}});if(n?.throwIfAborted(),o.status===409)return{conflict:!0};if(!o.ok){let e=await o.json().then(e=>typeof e?.error==`string`?e.error:``,()=>``);n?.throwIfAborted();let t=`Import request failed (HTTP ${o.status}${e?`: ${e}`:``}).`;throw Object.assign(Error(`${t} ${C}`),{detail:t})}let s=await o.json();return n?.throwIfAborted(),s}return{send:r}}async function j(e,t,n,r,i,a){if(e.bundles.length===0&&e.references.length===0)return;let o=i??(await n.send(`/api/admin/bundles`)).bundles,s=new Set(e.bundles.map(e=>e.uploaded.id));if([...s].some(e=>!o.some(t=>t.id===e)))throw Error(`Could not verify the uploaded source bundles. Retry the import.`);let c=new Set(e.references);for(let i of o){if(!s.has(i.id)&&!c.has(i.integrity))continue;let o=!a.has(i.repoId),l=o?t:i.repoId;o&&await r(`bundle-repo:${i.id}:${l}`,()=>n.send(`/api/admin/bundles/set-repo`,{bundleId:i.id,repoId:l}));let u=o?``:i.repoDirectory??``;await r(`repo:${l}:${u}`,()=>n.send(`/api/admin/teams/set-repo`,{teamId:e.team.id,repoId:l,path:u}))}}async function M(e,t){e.uploaded||=await t.send(`/api/admin/deduplication`,new File([e.content],e.name),{"x-report-filename":encodeURIComponent(e.name)})}async function N(e,t){let n=(await t.send(`/api/admin/repositories/browsable`)).repos,r=e.reports.filter(e=>!e.links&&e.declaredGithub&&!e.uploaded);if(r.length>0){let{aliases:e=[]}=await t.send(`/api/admin/repositories/aliases`);for(let t of r)Object.assign(t,O(t.declaredGithub,t.declaredDirectory,n,e,t.filePrefix))}return new Set(n.map(e=>e.repoId))}async function P(e,{plan:t,api:n,step:r,activeRepos:i,defaultRepo:a,includeTriage:o,resolveConflicts:s,signal:c}){if(e.links){await M(e,n);return}let l=i.has(e.repoId)?e.repoId:a;if(!e.uploaded){let t=await n.send(`/api/admin/reports`,new File([e.content],e.name),{"x-report-filename":encodeURIComponent(e.name),"x-repo-id":String(l),"x-repo-directory":encodeURIComponent(e.directory)});if(t.conflict)throw Error(`Could not reuse the stored report ${e.name}. Retry the import.`);e.uploaded=t}let u=e.uploaded;i.has(u.repoId)||await r(`report-repo:${u.id}:${l}:${e.directory}`,async()=>{if((await n.send(`/api/admin/reports/set-repo`,{reportId:u.id,repoId:l,directory:e.directory})).conflict)throw Error(`Could not assign the stored report ${e.name} to its repository.`);u.repoId=l,u.repoDirectory=e.directory});let d=u.repoDirectory??``;await r(`repo:${u.repoId}:${d}`,()=>n.send(`/api/admin/teams/set-repo`,{teamId:t.team.id,repoId:u.repoId,path:d})),o&&await S(t.triage,{api:n,resolveConflicts:s,signal:c,ids:e.ids,importedIds:t.importedIds,lookup:t.lookup,path:`/api/admin/reports/${encodeURIComponent(e.uploaded.id)}/import-triage`}),await r(`publish:${e.uploaded.id}`,()=>n.send(`/api/admin/reports/set-visible`,{reportId:e.uploaded.id,visible:!0}))}async function F(e,{api:t,session:n,defaultRepo:r,includeTriage:i,resolveConflicts:a,signal:o,progress:s=()=>{}}){if(n?.role!==`admin`||!n.csrfToken)throw Error(`An administrator session is required.`);if(!e.name.trim()||e.name.trim().length>100)throw Error(`Enter a team name of up to 100 characters.`);if(i)for(let[t,n]of Object.entries(e.triage)){if(!t||t.length>100)throw Error(`Triage finding IDs must be between 1 and 100 characters. Choose Skip triage to import the files without it.`);if(l(n)===`invalid`)throw Error(`Triage for ${t} exceeds the managed server limits. Choose Skip triage to import the files without it.`)}o?.throwIfAborted();let c=null;if(e.bundles.length===0){let n=new Set(e.references);c=n.size>0?(await t.send(`/api/admin/bundles`)).bundles.filter(e=>n.has(e.integrity)):[]}if(e.reports.length===0&&e.bundles.length===0&&c.length===0)throw Error(e.references.length>0?`None of the referenced source bundles are available on the server. Export with bundle bytes included and try again.`:`This workspace contains no report or bundle files.`);let u=await N(e,t);for(let t of e.reports.filter(e=>!e.links)){if(t.embedded&&!u.has(t.repoId))throw Error(`Connect ${t.embedded} in Repositories before importing ${t.name}.`);if(!u.has(t.repoId)&&!u.has(r))throw Error(`Choose an active repository for ${t.name}.`)}if((e.bundles.length>0||c.some(e=>!u.has(e.repoId)))&&!u.has(r))throw Error(`Choose an active repository for the source bundles.`);let d=()=>o?.throwIfAborted(),f=async(t,n)=>{d(),e.completed.has(t)||(await n(),e.completed.add(t))};if(d(),!e.team){let n=await t.send(`/api/admin/teams`,{name:e.name.trim()});if(n.conflict)throw Error(`A team already has this name. Choose another name.`);e.team=n}await f(`member`,()=>t.send(`/api/admin/teams/set-member`,{teamId:e.team.id,userId:n.id,security:!0,dependencies:!0}));for(let n of e.bundles)d(),s(`Importing ${n.name}\u2026`),n.uploaded||=await t.send(`/api/admin/bundles`,new File([n.bytes],n.name),{"x-bundle-filename":encodeURIComponent(n.name)});await j(e,r,t,f,c,u);let p=[];for(let n of e.reports){d(),s(`Importing ${n.name}\u2026`);try{await P(n,{plan:e,api:t,step:f,activeRepos:u,defaultRepo:r,includeTriage:i,resolveConflicts:a,signal:o})}catch(e){if(T(e,o))throw e;p.push(`${n.name}: ${w(e)}`)}}if(p.length>0)throw Error(`Could not import ${p.length} of ${e.reports.length} files: ${p.join(`; `)}. ${C}`);return e.team}function I(e){let t=()=>e.isEncryptionEnabled()&&!e.isUnlocked();return{get locked(){return t()},unlock:t=>e.unlockEncryption(t),async read({signal:n}={}){let r=!1,i=e.onVaultStateChange(()=>{r=!0}),a=()=>{if(n?.throwIfAborted(),t()||r)throw Error(`Local data was locked or changed. Unlock it and import triage again.`)};try{a();let t=await e.readTriageBlob();return a(),t}finally{i()}}}}function L(e){let t=()=>e.isEncryptionEnabled()&&!e.isUnlocked();async function n(){let t=JSON.parse(await e.hydrateKey(`deepview.workspaces`)||`[]`);return(Array.isArray(t)?t:t.workspaces??[]).filter(e=>typeof e.id==`string`&&typeof e.name==`string`)}async function r(n,r){let i=!1,a=[e.onVaultStateChange,e.onFileMutated,e.onBundleMutated].map(e=>e(()=>{i=!0})),o=()=>{if(r?.throwIfAborted(),t()||i)throw Error(`Local data was locked or changed. Unlock it and select the workspace again.`)};try{o();let e=await n(o);return o(),e}finally{a.forEach(e=>e())}}return{get locked(){return t()},unlock:t=>e.unlockEncryption(t),list:({signal:e}={})=>r(async()=>(await n()).map(e=>({id:e.id,name:e.name})),e),read:(t,{signal:i}={})=>r(async r=>{let i=(await n()).find(e=>e.id===t);if(!i)throw Error(`This local workspace no longer exists.`);let a=JSON.stringify(i),o=JSON.parse(await e.hydrateKey(`deepview.repoUrls`)||`{}`),s=[];for(let t of i.reports??[]){r();let n=await e.withStoredItem(`report`,t,()=>e.readFile(t));r(),s.push({name:t,content:n,...o[t]?{repo:{github:o[t]}}:{}})}let c=await e.listBundles(),l=[];for(let t of i.bundles??[]){r();let n=c.find(e=>e.integrity===t);if(!n)continue;let i=await e.withStoredItem(`bundle`,t,()=>e.readBundle(t));r(),l.push({integrity:t,name:n.name,data:i.toBase64()})}let u=await e.readTriageBlob()??{};if(JSON.stringify((await n()).find(e=>e.id===t))!==a)throw Error(`The local workspace changed. Select it again.`);return{version:1,workspace:{id:t,name:i.name,privateKey:``},reports:s,bundles:i.bundles??[],bundleBlobs:l,triage:u,repoUrls:o}},i)}}var R=e=>e===`bundle`?`bundles`:`reports`,z=(e,t)=>JSON.stringify([e,t||``]),B=(e,t)=>new Set(t.map(t=>e===`bundle`?t.integrity:z(t.sha256,t.analyzer)));async function V(e){let t=new Uint8Array(await e.arrayBuffer()),n=a(new TextDecoder().decode(t),e.name);if(!n.data)throw Error(n.reason??`Not a recognized report`);let r=new Uint8Array(await crypto.subtle.digest(`SHA-256`,t)).toBase64({alphabet:`base64url`,omitPadding:!0});return{hash:r,key:z(r,typeof n.data.source==`string`?n.data.source:null)}}async function H(e,{source:t,deps:n,api:r,signal:i}){let a=JSON.parse(await n.hydrateKey(`deepview.workspaces`)||`[]`),o=(Array.isArray(a)?a:a.workspaces??[]).filter(e=>typeof e.id==`string`&&typeof e.name==`string`);i.throwIfAborted();let s=await t.list(e),c=B(e,(await r.send(`/api/admin/${R(e)}`))[R(e)]),l=o.map(e=>({id:e.id,name:e.name,items:[]})),u={id:null,name:`Not in a workspace`,items:[]},d=[];for(let r of s){i.throwIfAborted();let a={value:r.value,name:r.label,key:r.value,synced:!1,present:!1,error:``};if(e===`report`)try{Object.assign(a,await t.importItem(e,a.value,V,{signal:i})),a.syncHash=await n.reportSyncHash(a.value)}catch(e){i.throwIfAborted(),a.error=String(e?.message??e)}i.throwIfAborted(),a.present=c.has(a.key);let s=!1;o.forEach((t,r)=>{if(!t[R(e)]?.includes(a.value))return;let i=n.localContentSyncStatus(t.id,e,a.value,a.syncHash);a.synced||=i.synced,l[r].items.push({item:a,...i}),s=!0}),s||u.items.push({item:a,synced:!1,cached:!1}),d.push(a)}return{kind:e,items:d,groups:[...l,u].filter(e=>e.items.length>0)}}async function U(e,t,{source:n,api:r,signal:i,progress:a=()=>{},imported:o=new Set}){let{kind:s}=e,c=B(s,(await r.send(`/api/admin/${R(s)}`))[R(s)]),l=new Set(t),u=[],d=0;for(let t of e.items)if(i.throwIfAborted(),!(!l.has(t.value)||t.error||t.present)){if(c.has(t.key)){t.present=!0;continue}a(`Importing ${t.name}\u2026`),d++;try{await n.importItem(s,t.value,async e=>{let n=s===`report`?(await V(e)).key:await f(new Uint8Array(await e.arrayBuffer()));if(i.throwIfAborted(),n!==t.key)throw Error(`${t.name} changed. Choose files again before importing.`);if((await r.send(`/api/admin/${R(s)}`,e,{[`x-${s}-filename`]:encodeURIComponent(e.name)})).conflict)throw Error(`Could not import ${t.name}. Try again.`)},{signal:i})}catch(e){if(T(e,i))throw e;u.push(`${t.name}: ${w(e)}`);continue}c.add(t.key),t.present=!0,o.add(t.value)}if(u.length>0)throw Error(`Imported ${d-u.length} of ${d} ${s}s. Could not import ${u.join(`; `)}. Import again to retry them.`);return o.size}var W=(e,t)=>e===void 0?`managed-only`:t===void 0?`local-only`:`mismatch`;function G(e,t){let n=t.slice(),r=e.map(e=>{let t=n.indexOf(e);return t!==-1&&n.splice(t,1),{text:e,different:t===-1}}),i=e.slice(),a=t.map(e=>{let t=i.indexOf(e);return t!==-1&&i.splice(t,1),{text:e,different:t===-1}});return!r.some(e=>e.different)&&!a.some(e=>e.different)?null:{property:`comment`,local:r,managed:a,kind:r.some(e=>e.different)?a.some(e=>e.different)?`mismatch`:`local-only`:`managed-only`}}function K(e,t){let n=d(e)??{},r=d(t.entry)??{},i=[];for(let e of[`triage`,`color`,`fix`,`flagged`])n[e]!==r[e]&&i.push({property:e,local:n[e],managed:r[e],kind:W(n[e],r[e])});let a=G(n.comment?[n.comment]:[],t.comments.map(e=>e.body));return a&&i.push(a),n.ignoredReports?.length&&i.push({property:`ignoredReports`,local:[...new Set(n.ignoredReports)],managed:void 0,kind:`local-only`}),i}async function q(e,{lookup:t,triage:n,matched:r,findings:i,api:a,signal:o}){let s=[...new Set(e.findingIds)].filter(e=>t.has(e)&&!r.has(e));for(let c=0;c<s.length;c+=200){let l=s.slice(c,c+200);if(l.some(e=>e.length>100))throw Error(`A shared finding ID exceeds the managed triage limit.`);o.throwIfAborted();let{snapshots:u}=await a.send(`/api/admin/reports/${encodeURIComponent(e.id)}/import-triage`,{findingIds:l});o.throwIfAborted();for(let e of l){if(!u?.[e])throw Error(`The server did not return the requested triage snapshot.`);let a=K(n[e],u[e]);a.length>0&&i.push({id:e,finding:t.get(e),differences:a}),r.add(e)}}}async function J({source:e,readTriage:t,api:n,signal:r,progress:i=()=>{}}){let s=new Map,c=[];for(let t of await e.list(`report`)){r.throwIfAborted(),i(`Reading ${t.label}\u2026`);try{let n=await e.importItem(`report`,t.value,async e=>{let t=await e.text(),n=a(t,e.name);if(!n.data)throw Error(n.reason??`Not a recognized report`);return n.format===`links`?[]:(await o(t,e.name))?.findings??[]},{signal:r});r.throwIfAborted();for(let e of n)typeof e.id!=`string`||!e.id||(s.has(e.id)||s.set(e.id,{...e,reports:[]}),s.get(e.id).reports.push(t.label))}catch(e){r.throwIfAborted(),c.push({name:t.label,reason:String(e?.message??e)})}}let l=await t()??{};if(r.throwIfAborted(),typeof l!=`object`||Array.isArray(l))throw TypeError(`Invalid local triage.`);let u=[],d=new Set;if(s.size===0)return{matched:0,localFindings:0,findings:u,skipped:c};let f;do{r.throwIfAborted(),i(`Comparing local and managed triage…`);let e=await n.send(`/api/admin/reports/finding-ids`+(f?`?after=${encodeURIComponent(f)}`:``));r.throwIfAborted();for(let t of e.reports)await q(t,{lookup:s,triage:l,matched:d,findings:u,api:n,signal:r});f=e.nextCursor}while(f);return r.throwIfAborted(),{matched:d.size,localFindings:s.size,findings:u,skipped:c}}function Y(t,n){if(customElements.get(`managed-admin-import`))return;class r extends t{static view=`manage-import`;static styles=[m(e),m(_)];static properties={localDeps:{attribute:!1},_busy:{state:!0},_error:{state:!0},_message:{state:!0},_plan:{state:!0},_catalog:{state:!0},_localOpen:{state:!0},_workspaces:{state:!0},_localId:{state:!0},_triage:{state:!0},_repo:{state:!0},_drag:{state:!0}};constructor(){super(),this._busy=!1,this._error=``,this._message=``,this._plan=null,this._catalog=null,this._workspaces=[],this._localOpen=!1,this._localId=``,this._triage=``,this._repo=null,this._files=[],this._drag=!1,this._local=!1,this._over=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),this._drag=!0)},this._drop=e=>{e.dataTransfer?.types?.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),this._drag=!1,this._busy||(this._files.push(...e.dataTransfer.files),this._nextFile()))},this._localChanged=()=>{this._workspaces=[],this._localId=``,!this._unlocking&&(this._local&&(this._plan=null),(this._local||this._importingTriage||this._importingContent||this._comparingTriage)&&(this._operation?.abort(),this._message=``,this._error=this._comparingTriage?`Local data changed or was locked. Compare triage again to continue.`:this._importingContent?`Local data changed or was locked. Choose files again to continue.`:this._importingTriage?`Local data changed or was locked. Import triage again to continue.`:`Local data changed or was locked. Choose the workspace again.`))},this._blur=()=>{this._readingLocal&&this._localChanged()}}connectedCallback(){super.connectedCallback(),this.addEventListener(`dragover`,this._over),this.addEventListener(`drop`,this._drop),globalThis.addEventListener(`blur`,this._blur),globalThis.addEventListener(`storage`,this._localChanged),this._offVault=this.localDeps?.onVaultStateChange(this._localChanged),this._loadCatalog()}disconnectedCallback(){this._operation?.abort(),this._offVault?.(),this._plan=null,this._files=[],this.removeEventListener(`dragover`,this._over),this.removeEventListener(`drop`,this._drop),globalThis.removeEventListener(`blur`,this._blur),globalThis.removeEventListener(`storage`,this._localChanged),super.disconnectedCallback()}updated(e){e.has(`session`)&&(this._role!==`admin`||e.get(`session`)?.id!==this.session?.id)&&(this._operation?.abort(),this._plan=null,this._files=[])}async _action(e){if(this._busy||this._role!==`admin`)return;let t=this._operation=new AbortController,n=AbortSignal.any([t.signal,this.appState.sessionController.signal]);this._busy=!0,this._error=``;try{await e(n),n.throwIfAborted()}catch(e){n.aborted||(this._error=String(e?.message??e))}finally{this._operation===t&&(this._busy=!1)}}async _loadCatalog(){if(this._role===`admin`)try{await this._loadCollection(`workspace-import:catalog`,`import options`,async e=>{let t=A(n,this.session,e),[r,i,a,o]=await Promise.all([t.send(`/api/admin/reports`),t.send(`/api/admin/teams`),t.send(`/api/admin/bundles`),t.send(`/api/admin/repositories/aliases`)]);return{repos:r.repos,teams:i.teams,bundles:a.bundles,aliases:o.aliases}},e=>{this._catalog=e})}catch(e){this._error=String(e?.message??e)}}_browse(){let e=document.createElement(`input`);e.type=`file`,e.multiple=!0,e.accept=`.enc,.gz,.json`,e.addEventListener(`change`,()=>{this._files.push(...e.files),this._nextFile()},{once:!0}),e.click()}async _prepare(e,t){if(!e)return;if(this._catalog||await this._loadCatalog(),t.throwIfAborted(),!this._catalog)throw Error(`Could not load repositories. Try again.`);let n=await k(e,this._catalog.repos,this._catalog.aliases);t.throwIfAborted();let r=new Set(this._catalog.teams.map(e=>e.name)),i=n.name||`Imported workspace`,a=2;for(;r.has(n.name);){let e=` (${a++})`;n.name=i.slice(0,100-e.length)+e}let o=new Set(n.reports.map(e=>e.repoId).filter(e=>e!=null));this._repo=o.size===1?[...o][0]:null,this._triage=Object.keys(n.triage).length>0?``:`skip`,this._plan=n,this._message=``}async _nextFile(){if(this._files.length===0||this._busy)return;let e=this._files.shift();this._local=!1,this._plan=null,await this._action(async t=>{let n=await D(e,this.promptPassword);t.throwIfAborted(),await this._prepare(n,t)})}async _unlock(e,t){this._unlocking=!0;try{return!e.locked||await e.unlock({signal:t})}finally{this._unlocking=!1}}async _chooseLocal(){this._localOpen=!0,await this._action(async e=>{let t=L(this.localDeps);await this._unlock(t,e)&&(e.throwIfAborted(),this._workspaces=await t.list({signal:e}))})}async _readLocal(){if(!this._localId)return;let e=this._localId;this._local=!0,this._plan=null,await this._action(async t=>{let n=L(this.localDeps);if(await this._unlock(n,t)){this._readingLocal=!0;try{await this._prepare(await n.read(e,{signal:t}),t)}finally{this._readingLocal=!1}}})}async _import(){this._plan&&this._triage&&this._csrf&&(await this._action(async e=>{if(this._local&&L(this.localDeps).locked)throw Error(`Unlock local data and choose the workspace again.`);let t=this._plan,r=[`teams`,`reports`,`bundles`,`history`,`workspace-import`,`scan-sources`,`repo-impact`];try{let i=await this.appState.mutate(()=>F(t,{api:A(n,this.session,e),session:this.session,defaultRepo:this._repo,includeTriage:this._triage===`include`,resolveConflicts:this.resolveConflicts,signal:e,progress:e=>{this._message=e}}),r);this._catalog.teams.push(i),this._message=`Imported into ${i.name}.`,this._plan=null}finally{this.appState.invalidate(r),t.team&&this._emit(`managed-import-complete`)}}),!this._plan&&!this._error&&await this._nextFile())}async _importLocalTriage(){this._csrf&&await this._action(async e=>{this._importingTriage=!0,this._message=``;let t=new Set,r=[`reports`,`history`];try{let r=I(this.localDeps);if(!await this._unlock(r,e))return;this._readingLocal=!0;let i;try{i=await r.read({signal:e})}finally{this._readingLocal=!1}let a=await v(i,{api:A(n,this.session,e),session:this.session,resolveConflicts:this.resolveConflicts,signal:e,importedIds:t,confirmImport:async t=>(await this.confirmTriageImport({...t,signal:e}))?.confirmed===!0});if(e.throwIfAborted(),a===null)return;this._message=a?`Imported triage for ${a} finding${a===1?``:`s`}.`:`No local triage matches findings in managed reports.`}finally{this._importingTriage=!1,this.appState.invalidate(r),t.size>0&&this._emit(`managed-import-complete`)}})}async _compareLocalTriage(){this._csrf&&await this._action(async e=>{this._comparingTriage=!0,this._message=``;let t=this.localImportSource,r=t.subscribe(this._localChanged);try{if(!await this._unlock(t,e))return;e.throwIfAborted(),this._readingLocal=!0;let r=I(this.localDeps),i=await J({source:t,signal:e,readTriage:()=>r.read({signal:e}),api:A(n,this.session,e),progress:e=>{this._message=e}});e.throwIfAborted(),this._message=``,await this.showTriageComparison({comparison:i,signal:e})}finally{r(),this._readingLocal=!1,this._comparingTriage=!1,this._message=``}})}async _importLocalContent(e){this._csrf&&await this._action(async t=>{this._importingContent=!0,this._message=``;let r=this.localImportSource,i=[`reports`,`bundles`,`bundle-metadata`,`history`,`workspace-import`,`scan-sources`,`repo-impact`],a=new Set,o=r.subscribe(this._localChanged);try{if(!await this._unlock(r,t))return;t.throwIfAborted(),this._readingLocal=!0;let i=A(n,this.session,t),o=await H(e,{source:r,deps:this.localDeps,api:i,signal:t}),s=await this.confirmContentImport({plan:o,signal:t});if(t.throwIfAborted(),!s?.confirmed)return;let c=await U(o,s.selected,{source:r,api:i,signal:t,imported:a,progress:e=>{this._message=e}});this._message=`Imported ${c} ${e}${c===1?``:`s`}.`}finally{o(),this._readingLocal=!1,this._importingContent=!1,this.appState.invalidate(i),a.size>0&&this._emit(`managed-import-complete`)}})}render(){if(this._role!==`admin`)return g;let e=this._plan,t=e?Object.keys(e.triage).length:0,n=new Set([...e?.references??[],...e?.bundles.map(e=>e.integrity)??[]]),r=(this._catalog?.bundles??[]).filter(e=>n.has(e.integrity)),i=e?.references.filter(t=>!e.bundles.some(e=>e.integrity===t)).length??0;return h`<div class="wrap" @dragleave="${()=>{this._drag=!1}}">${this._nav()}<h1>Import</h1><section class="triage-import" aria-label="Import local files"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent(`bundle`)}">Import bundles</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalContent(`report`)}">Import reports</button></div><p>Choose files from this browser, grouped by workspace. Import files without teams or triage.</p></section><section class="triage-import" aria-label="Local triage"><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._importLocalTriage()}">Import triage</button> <button type="button" class="btn" ?disabled="${this._busy||!this._csrf}" @click="${()=>this._compareLocalTriage()}">Compare triage</button></div><p>Import saved triage and comments for findings already in managed reports.<br>Unmatched data stays in this browser.<br>Conflicting values prompt for resolution; per-report ignores are skipped.</p></section><h2>Import workspace</h2><p class="intro ui-hint">Create a new team from a workspace export or a workspace stored in this browser.</p><section class="${`workspace-drop ${this._drag?`dragging`:``}`}" aria-label="Workspace files"><strong>Drop workspace files here</strong><span>Encrypted exports, JSON, or compressed JSON. Encrypted files prompt for a password.</span><div class="actions"><button type="button" class="btn" ?disabled="${this._busy||!this._catalog}" @click="${()=>this._browse()}">Choose files</button> <button type="button" class="btn" ?disabled="${this._busy}" @click="${()=>this._chooseLocal()}">Choose local workspace</button></div></section>${this._localOpen?h`<section class="local-choice"><label for="local-workspace">Local workspace</label> <select id="local-workspace" .value="${this._localId}" ?disabled="${this._busy}" @change="${e=>{this._localId=e.target.value}}"><option value="">Choose a workspace…</option>${this._workspaces.map(e=>h`<option value="${e.id}">${e.name}</option>`)}</select> <button type="button" class="btn" ?disabled="${this._busy||!this._localId}" @click="${()=>this._readLocal()}">Select workspace</button> ${!this._busy&&this._workspaces.length===0?h`<p class="ui-hint">No unlocked local workspaces. Choose local workspace to unlock or refresh.</p>`:g}</section>`:g} ${e?h`<section class="import-preview" aria-label="Import options">${e.team?h`<p>Team ${e.team.name} has been created. Retry continues its remaining import steps.</p>`:g} <label for="import-team">New team name</label><input id="import-team" maxlength="100" .value="${e.name}" ?disabled="${this._busy||!!e.team}" @input="${t=>{e.name=t.target.value,this.requestUpdate()}}"><p>${e.reports.length} reports / links · ${n.size} source bundles · ${t} triaged findings</p><label for="import-repo">Repository for files and source bundles without an active repository</label> <select id="import-repo" .value="${String(this._repo??``)}" ?disabled="${this._busy||!!e.team}" @change="${e=>{this._repo=e.target.value?Number(e.target.value):null}}"><option value="" ?selected="${this._repo==null}">Choose a repository…</option>${(this._catalog?.repos??[]).map(e=>h`<option value="${String(e.repoId)}" ?selected="${this._repo===e.repoId}">${e.fullName}</option>`)}</select><p>Declared report repositories and directories are preserved. Stored reports without an active repository use the selected repository. The new team receives those repository paths; other published reports in the same paths are also visible to that team.</p><ul>${e.reports.map(e=>h`<li>${e.name}<span>${e.links?`Global deduplication — enabled for all teams`:e.github??`Uses selected repository`}${e.links||e.github==null||e.repoId!=null?``:e.embedded?` — connect this repository first`:` — not connected; uses selected repository`}</span></li>`)}</ul>${r.length>0?h`<p>Existing source bundles in active repositories keep their locations. The new team also receives access to those directories. Unassigned bundles and bundles in inactive repositories use the selected repository.</p><ul>${r.map(e=>h`<li>${e.filename}<span>${e.repoFullName?`${e.repoFullName}${e.repoDirectory?`/${e.repoDirectory}`:``}`:`Uses selected repository`}</span></li>`)}</ul>`:g} ${i?h`<p>${i} referenced source bundles have no bytes in this export. Reports can use matching bundles already on the server.</p>`:g} ${t?h`<fieldset ?disabled="${this._busy||!!e.team}"><legend>Import triage?</legend><label><input type="radio" name="import-triage" value="include" ?checked="${this._triage===`include`}" @change="${()=>{this._triage=`include`}}"> Include triage and comments</label> <label><input type="radio" name="import-triage" value="skip" ?checked="${this._triage===`skip`}" @change="${()=>{this._triage=`skip`}}"> Skip triage</label><p>Conflicting values prompt for resolution. Triage stays shared by finding ID across teams. Per-report local ignores are not imported.</p></fieldset>`:g} <button type="button" class="btn primary" ?disabled="${this._busy||!this._triage||!this._csrf}" @click="${()=>this._import()}">${this._busy?`Importing…`:e.team?`Retry remaining import`:`Import workspace`}</button></section>`:g} ${this._message?h`<p role="status">${this._message}</p>`:g} ${this._error?h`<p class="error" role="alert">${this._error}${this._catalog?g:h`<button class="btn" @click="${()=>this._loadCatalog()}">Retry</button>`}</p>`:g} ${this._files.length>0&&!this._busy?h`<button class="btn" @click="${()=>this._nextFile()}">Next workspace file (${this._files.length} waiting)</button>`:g}</div>`}}customElements.define(`managed-admin-import`,r)}export{Y as registerWorkspaceImport};
|