@lievclouds/dsh-cortex 0.3.9 → 0.4.2
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.
Potentially problematic release.
This version of @lievclouds/dsh-cortex might be problematic. Click here for more details.
- package/client.js +312 -307
- package/index.js +5 -2
- package/package.json +1 -1
- package/src/cortex-ui/dsh/api.ts +10 -1
- package/src/cortex-ui/dsh/entry.tsx +80 -1
- package/src/cortex-ui/renderer/components/asset/AssetDetail.tsx +4 -2
- package/src/cortex-ui/renderer/components/asset/AssetTable.tsx +21 -27
- package/src/cortex-ui/renderer/components/asset/TestParameterList.tsx +8 -6
- package/src/cortex-ui/renderer/components/retest/RepeaterPanel.tsx +3 -2
- package/src/cortex-ui/renderer/components/vuln/VulnDetail.tsx +7 -1
- package/src/cortex-ui/renderer/i18n/messages/vuln.ts +2 -0
- package/src/cortex-ui/renderer/lib/assets.ts +118 -0
- package/src/cortex-ui/renderer/lib/retestRequest.ts +17 -0
- package/src/cortex-ui/renderer/pages/DashboardPage.tsx +5 -1
- package/src/cortex-ui/shared/types.ts +3 -1
- package/src/cortex-ui/shared/web.ts +2 -0
- package/src/host/cortex/assets.js +14 -57
- package/src/host/cortex/data-tools.js +393 -0
- package/src/host/cortex/graph-adapter.js +26 -22
- package/src/host/cortex/normalize-asset.js +208 -0
- package/src/host/cortex/tools.js +340 -22
- package/src/host/cortex/vulns.js +32 -2
package/src/host/cortex/vulns.js
CHANGED
|
@@ -34,6 +34,9 @@ import {
|
|
|
34
34
|
} from '../http.js'
|
|
35
35
|
import * as dto from '../dto.js'
|
|
36
36
|
import { buildVulnReport, reportFilename } from '../reports.js'
|
|
37
|
+
import { mkdirSync, writeFileSync } from 'node:fs'
|
|
38
|
+
import { homedir } from 'node:os'
|
|
39
|
+
import { join } from 'node:path'
|
|
37
40
|
|
|
38
41
|
const SEVERITIES = ['Critical', 'High', 'Medium', 'Low', 'Info']
|
|
39
42
|
const STATUSES = ['Confirmed', 'Inconclusive', 'Retest_Passed']
|
|
@@ -497,7 +500,7 @@ export async function handleExport({ req, res, holder, bumpRev }) {
|
|
|
497
500
|
const body = await readJsonBody(req)
|
|
498
501
|
const ids = requireIdList(body, 'ids', MAX_EXPORT_IDS)
|
|
499
502
|
if (ids.length === 0) {
|
|
500
|
-
sendJson(res, 200, { cancelled: true, files: [] })
|
|
503
|
+
sendJson(res, 200, { cancelled: true, files: [], savedPaths: [] })
|
|
501
504
|
return
|
|
502
505
|
}
|
|
503
506
|
const db = holder.db
|
|
@@ -525,9 +528,36 @@ export async function handleExport({ req, res, holder, bumpRev }) {
|
|
|
525
528
|
content: buildVulnReport(detail, related),
|
|
526
529
|
})
|
|
527
530
|
}
|
|
531
|
+
// The DSH desktop WebView may block browser downloads, so the Host also
|
|
532
|
+
// writes the Markdown reports to ~/.cortex/exports/<timestamp>/ and returns
|
|
533
|
+
// the absolute paths. The renderer still attempts a normal download, but the
|
|
534
|
+
// toast can then point at a real file that always exists.
|
|
535
|
+
const savedPaths = []
|
|
536
|
+
if (files.length > 0) {
|
|
537
|
+
try {
|
|
538
|
+
const exportRoot = process.env.CORTEX_EXPORT_DIR || join(homedir(), '.cortex', 'exports')
|
|
539
|
+
const stamp = new Date()
|
|
540
|
+
.toISOString()
|
|
541
|
+
.replace(/[-:]/g, '')
|
|
542
|
+
.replace(/\..+$/, '')
|
|
543
|
+
.replace('T', '-')
|
|
544
|
+
const exportDir = join(exportRoot, stamp)
|
|
545
|
+
mkdirSync(exportDir, { recursive: true })
|
|
546
|
+
for (let index = 0; index < files.length; index += 1) {
|
|
547
|
+
const file = files[index]
|
|
548
|
+
const safeName = String(file.filename).replace(/[<>:"/\\|?*\u0000-\u001f]/g, '_').slice(0, 120) || file.id
|
|
549
|
+
const target = join(exportDir, `${String(index + 1).padStart(2, '0')}-${safeName.endsWith('.md') ? safeName : `${safeName}.md`}`)
|
|
550
|
+
writeFileSync(target, file.content, 'utf8')
|
|
551
|
+
savedPaths.push(target)
|
|
552
|
+
}
|
|
553
|
+
} catch {
|
|
554
|
+
// Filesystem failure must not break the export response; the inline
|
|
555
|
+
// files still let the browser download attempt proceed.
|
|
556
|
+
}
|
|
557
|
+
}
|
|
528
558
|
// Export is a read-only projection: no revision bump.
|
|
529
559
|
void bumpRev
|
|
530
|
-
sendJson(res, 200, { cancelled: files.length === 0, files })
|
|
560
|
+
sendJson(res, 200, { cancelled: files.length === 0, files, savedPaths })
|
|
531
561
|
}
|
|
532
562
|
|
|
533
563
|
export { SEVERITIES, STATUSES, REALM_FILTERS, VULN_ORDER }
|