@visulima/vis 1.0.0-alpha.42 → 1.0.0-alpha.44
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/CHANGELOG.md +54 -0
- package/LICENSE.md +256 -0
- package/bin/resolve-binary.mjs +85 -0
- package/bin/vis.mjs +76 -0
- package/dist/bin.d.ts +1 -0
- package/dist/bin.js +1 -2
- package/dist/binx.js +1 -1
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/CONFIG_FILES.js +8 -0
- package/dist/packem_chunks/bloom-status.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +113 -0
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +297 -434
- package/dist/packem_chunks/detect.js +3 -3
- package/dist/packem_chunks/dispatch.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +5 -1
- package/dist/packem_chunks/handler11.js +1 -5
- package/dist/packem_chunks/handler12.js +27 -1
- package/dist/packem_chunks/handler13.js +5 -27
- package/dist/packem_chunks/handler14.js +1 -5
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -5
- package/dist/packem_chunks/handler21.js +2 -2
- package/dist/packem_chunks/handler22.js +14 -2
- package/dist/packem_chunks/handler23.js +1 -5
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +5 -1
- package/dist/packem_chunks/handler27.js +1 -5
- package/dist/packem_chunks/handler28.js +3 -1
- package/dist/packem_chunks/handler29.js +1 -3
- package/dist/packem_chunks/handler3.js +4 -1
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler31.js +2 -1
- package/dist/packem_chunks/handler32.js +2 -2
- package/dist/packem_chunks/handler33.js +2 -2
- package/dist/packem_chunks/handler34.js +3 -2
- package/dist/packem_chunks/handler35.js +6 -3
- package/dist/packem_chunks/handler36.js +1 -6
- package/dist/packem_chunks/handler37.js +42 -1
- package/dist/packem_chunks/handler38.js +8 -42
- package/dist/packem_chunks/handler39.js +9 -8
- package/dist/packem_chunks/handler4.js +4 -4
- package/dist/packem_chunks/handler40.js +75 -9
- package/dist/packem_chunks/handler41.js +5 -75
- package/dist/packem_chunks/handler42.js +4 -5
- package/dist/packem_chunks/handler43.js +3 -4
- package/dist/packem_chunks/handler44.js +2 -3
- package/dist/packem_chunks/handler45.js +1 -2
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -1
- package/dist/packem_chunks/handler48.js +3 -1
- package/dist/packem_chunks/handler49.js +1 -3
- package/dist/packem_chunks/handler5.js +6 -4
- package/dist/packem_chunks/handler50.js +7 -1
- package/dist/packem_chunks/handler51.js +32 -6
- package/dist/packem_chunks/handler52.js +3 -33
- package/dist/packem_chunks/handler53.js +8 -3
- package/dist/packem_chunks/handler54.js +2 -6
- package/dist/packem_chunks/handler55.js +1 -4
- package/dist/packem_chunks/handler56.js +12 -1
- package/dist/packem_chunks/handler57.js +5 -12
- package/dist/packem_chunks/handler58.js +11 -5
- package/dist/packem_chunks/handler59.js +3 -11
- package/dist/packem_chunks/handler6.js +8 -6
- package/dist/packem_chunks/handler60.js +22 -3
- package/dist/packem_chunks/handler61.js +60 -21
- package/dist/packem_chunks/handler62.js +3 -61
- package/dist/packem_chunks/handler63.js +6 -3
- package/dist/packem_chunks/handler64.js +9 -6
- package/dist/packem_chunks/handler65.js +2 -9
- package/dist/packem_chunks/handler66.js +13 -13
- package/dist/packem_chunks/handler67.js +5 -5
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +4 -4
- package/dist/packem_chunks/handler7.js +1 -8
- package/dist/packem_chunks/handler70.js +16 -17
- package/dist/packem_chunks/handler71.js +12 -12
- package/dist/packem_chunks/handler72.js +5 -5
- package/dist/packem_chunks/handler73.js +7 -7
- package/dist/packem_chunks/handler74.js +3 -3
- package/dist/packem_chunks/handler75.js +3 -3
- package/dist/packem_chunks/handler76.js +63 -63
- package/dist/packem_chunks/handler77.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/index2.js +2 -2
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +3 -3
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/loader2.js +1 -1
- package/dist/packem_chunks/orchestrator.js +19 -19
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/ts-loader.js +22 -2
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +1 -1
- package/dist/packem_shared/{advisories-aiDtubZQ.js → advisories-CefYKEPe.js} +1 -1
- package/dist/packem_shared/{affected-shas-C1XuRlvo.js → affected-shas-CwRY5aoc.js} +1 -1
- package/dist/packem_shared/{ai-analysis-CubpCxZJ.js → ai-analysis-CO6S0afy.js} +7 -7
- package/dist/packem_shared/{ai-fix-Btd5AnSr.js → ai-fix-CI0Vvqld.js} +9 -9
- package/dist/packem_shared/augment-DaSS2Lgs.js +4 -0
- package/dist/packem_shared/bin-P6Q5tKrP.js +1 -0
- package/dist/packem_shared/{build-scripts-Doxce2VM.js → build-scripts-MTSK6TNr.js} +1 -1
- package/dist/packem_shared/{command-runtime-RiCMa2C8.js → command-runtime-BE-vKsGH.js} +1 -1
- package/dist/packem_shared/{cyclonedx-NUJ9R2GQ.js → cyclonedx-BeUmPgfO.js} +1 -1
- package/dist/packem_shared/dependency-scan-DpOFiZuI.js +1 -0
- package/dist/packem_shared/{docker-DKlF-gk3.js → docker-CViFYtmM.js} +1 -1
- package/dist/packem_shared/env-C2ZCnfP_.js +27 -0
- package/dist/packem_shared/failure-log-jFfZRJK9.js +2 -0
- package/dist/packem_shared/glob-fqg4KepW-1S3z30c8.js +1 -0
- package/dist/packem_shared/index-B0EsgdzO.js +1 -0
- package/dist/packem_shared/index-CE6MsgcV.js +22 -0
- package/dist/packem_shared/index-CQjzW7m8.js +1 -0
- package/dist/packem_shared/{index-Cb4x6lWY.js → index-Cg0IHaFI.js} +1 -1
- package/dist/packem_shared/{index-CPhv-r4c.js → index-D7EZ612R.js} +13 -13
- package/dist/packem_shared/{lifecycle-D5roTh0a.js → lifecycle-Dyb47wbD.js} +1 -1
- package/dist/packem_shared/{lockfile-DIGyLfmF.js → lockfile-C1qCKGH6.js} +1 -1
- package/dist/packem_shared/{manifests-pLwnVmCN.js → manifests-WBnsV_Eb.js} +1 -1
- package/dist/packem_shared/{min-release-age-pUAqTiv3.js → min-release-age-C71MO72F.js} +1 -1
- package/dist/packem_shared/missing-package-json-CTF71tE5.js +1 -0
- package/dist/packem_shared/{native-config-sync-4K9wWTj5.js → native-config-sync-BFDVK9LH.js} +4 -4
- package/dist/packem_shared/{osv-bloom-OuTfu_LE.js → osv-bloom-BsQ-aFiM.js} +1 -1
- package/dist/packem_shared/packument-DquNPIq9.js +1 -0
- package/dist/packem_shared/{pm-runner-Dws_Bw1y.js → pm-runner-D4jM58Oz.js} +1 -1
- package/dist/packem_shared/prompt-DjXHVgYU.js +1 -0
- package/dist/packem_shared/provenance-DIq8KyBV.js +1 -0
- package/dist/packem_shared/readJsonSync-CvkZyKmL-ihoybKvs.js +1 -0
- package/dist/packem_shared/registry-keys-C8K11ets.js +1 -0
- package/dist/packem_shared/resolve-explicit-Dr4kIybR.js +5 -0
- package/dist/packem_shared/{resolve-runtime-CJSWV-K8.js → resolve-runtime-Tx0bvg0h.js} +1 -1
- package/dist/packem_shared/run-file-DD7Ne23Z.js +1 -0
- package/dist/packem_shared/{runtime-check-0lUJvgKt.js → runtime-check-BXehSP06.js} +1 -1
- package/dist/packem_shared/s1ngularity-CtMmtXJo.js +1 -0
- package/dist/packem_shared/scan-progress-D4yywI6P.js +2 -0
- package/dist/packem_shared/{selectors-UmnAuc26.js → selectors-D4iCvITE.js} +1 -1
- package/dist/packem_shared/{signatures-BOUhghTv.js → signatures-CE8OAK-i.js} +2 -2
- package/dist/packem_shared/spinner-DuJJvFTl.js +1 -0
- package/dist/packem_shared/tabs-CgxCvjCY.js +1 -0
- package/dist/packem_shared/target-merge-DOm6h6tW.js +11 -0
- package/dist/packem_shared/target-options-CR0OuYJr.js +1 -0
- package/dist/packem_shared/toolchain-C44mPKPu.js +5 -0
- package/dist/packem_shared/{typosquats-DBOvXwph.js → typosquats-CQz-1Y6K.js} +1 -1
- package/dist/packem_shared/use-measured-height-XK9YSwtv.js +1 -0
- package/dist/packem_shared/utils-CRueU43T.js +1 -0
- package/dist/packem_shared/verify-DStfg3nb.js +1 -0
- package/dist/packem_shared/vis-update-app-Cpme_3Du.js +1 -0
- package/dist/packem_shared/{watch-Bkp_AAbc.js → watch-BXNI7dC6.js} +1 -1
- package/dist/packem_shared/watch-loop-JfGKIgKB.js +11 -0
- package/dist/packem_shared/window-ops-DDePlWLV.js +2 -0
- package/dist/runtime/preload.js +1 -1
- package/index.js +52 -52
- package/package.json +17 -13
- package/dist/packem_chunks/config.js +0 -18
- package/dist/packem_shared/CONFIG_FILES-MsOntfYT.js +0 -1
- package/dist/packem_shared/augment-8fIWWGSc.js +0 -3
- package/dist/packem_shared/bin-CnDBuLh3.js +0 -2
- package/dist/packem_shared/dependency-scan-B0HV_qeB.js +0 -1
- package/dist/packem_shared/failure-log-C7r6UZLP.js +0 -2
- package/dist/packem_shared/glob-fqg4KepW-7Bs2kZuM.js +0 -1
- package/dist/packem_shared/index-BKFEWXU_.js +0 -1
- package/dist/packem_shared/index-OQZQyN5R.js +0 -19
- package/dist/packem_shared/missing-package-json-DhYzuKhD.js +0 -1
- package/dist/packem_shared/provenance-C0P-UYOM.js +0 -1
- package/dist/packem_shared/readJsonSync-CvkZyKmL-CY7PZob_.js +0 -4
- package/dist/packem_shared/registry-keys-D4chF-Wj.js +0 -1
- package/dist/packem_shared/resolve-explicit-Cgheka3B.js +0 -5
- package/dist/packem_shared/run-file-B4TqKa0X.js +0 -1
- package/dist/packem_shared/s1ngularity-Du1NnSFP.js +0 -1
- package/dist/packem_shared/scan-progress-CN9ONR0y.js +0 -2
- package/dist/packem_shared/spinner-lhXugSx3.js +0 -1
- package/dist/packem_shared/tabs-DTiU3usb.js +0 -1
- package/dist/packem_shared/target-options-ChWcK60i.js +0 -1
- package/dist/packem_shared/toolchain-DyCKnGch.js +0 -5
- package/dist/packem_shared/use-measured-height-CK2Co3XI.js +0 -1
- package/dist/packem_shared/utils-Cxree603.js +0 -1
- package/dist/packem_shared/verify-CVPYlUrF.js +0 -1
- package/dist/packem_shared/vis-update-app-DtHkwBca.js +0 -1
- package/dist/packem_shared/watch-loop-D9zbXzRd.js +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as Et}from"node:module";import{V as we,E as D,s as ye,q as pt,Q as dt}from"../packem_shared/index.server-J83sowC4.js";import{I as Lt,m as z,f as J,v as be,T as Ze,B as Tt}from"../packem_shared/index-
|
|
1
|
+
import{createRequire as Et}from"node:module";import{V as we,E as D,s as ye,q as pt,Q as dt}from"../packem_shared/index.server-J83sowC4.js";import{I as Lt,m as z,f as J,v as be,T as Ze,B as Tt}from"../packem_shared/index-CE6MsgcV.js";import{I as De}from"../packem_shared/index-B0EsgdzO.js";import{whichBin as Pt}from"#native";import{r as zt,R as Wt,b as _t}from"../packem_shared/ai-analysis-CO6S0afy.js";import{N as Ht,O as Ut,B as Ft,Q as Gt,p as u,i as Qe}from"./cli-main.js";import"../packem_shared/public-api-WqUCiyIe.js";import{u as Ve}from"./ts-loader.js";import{e as Bt,W as Kt,v as qt,a as Jt,N as Yt,f as Zt,b as Qt,O as Xt}from"./catalog.js";import{w as ei,M as ti}from"../packem_shared/pm-runner-D4jM58Oz.js";import{s as L}from"../packem_shared/index-Cg0IHaFI.js";import{c as gt,s as he,p as ii,e as ai,g as ni}from"../packem_shared/index-CQjzW7m8.js";import{d as ri}from"../packem_shared/anolilab-text-CAM_E6uK.js";import{t as oi,b as si}from"../packem_shared/cyclonedx-BeUmPgfO.js";import{s as pi}from"../packem_shared/scan-progress-D4yywI6P.js";import{r as di,A as Xe,q as et}from"../packem_shared/advisories-CefYKEPe.js";import{a as ut}from"../packem_shared/readJsonSync-CvkZyKmL-ihoybKvs.js";import{l as gi,f as fi,a as ui}from"../packem_shared/dependency-scan-DpOFiZuI.js";import{r as mi}from"../packem_shared/manifests-WBnsV_Eb.js";import{l as bi,p as xi,O as ki}from"../packem_shared/osv-bloom-BsQ-aFiM.js";import{H as tt,h as $i,D as Si,y as Ni}from"../packem_shared/env-C2ZCnfP_.js";const Ot=Et(import.meta.url),ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Y=e=>{if(typeof ee<"u"&&ee.versions&&ee.versions.node){const[t,i]=ee.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return ee.getBuiltinModule(e)}return Ot(e)},{spawnSync:Dt}=Y("node:child_process"),{createInterface:Mt}=Y("node:readline"),{stripVTControlCharacters:Vt}=Y("node:util"),{createHash:ci}=Y("node:crypto"),{relative:ft,join:li}=Y("node:path"),{readFileSync:mt,existsSync:hi,writeFileSync:vi,renameSync:wi,unlinkSync:yi}=Y("node:fs"),it=(e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const i=[];for(const a of Lt(e,t))i.push(a.path);return i},xe=e=>`${e.packageName}@${e.packageVersion}:${e.vulnerability.id}`,Ai=e=>e==null||e===!0||e===""||e==="true"||e.toString().toLowerCase()==="all",Ci=(e,t)=>{if(Ai(t))return e;const i=String(t).trim();if(/^\d+$/.test(i)){const n=Number.parseInt(i,10)-1,o=e[n];return o?[o]:[]}const a=i.toLowerCase();return e.filter(n=>{const{aliases:o,id:r}=n.vulnerability;return r.toLowerCase()===a||(o??[]).some(c=>c.toLowerCase()===a)})},Ri=e=>{const{packageName:t,packageVersion:i,vulnerability:a}=e,n=(a.aliases??[]).join(", ")||"none",o=(a.fixedVersions??[]).join(", ")||"no fixed version published";return`You are a security engineer. Explain this dependency vulnerability for a developer triaging it.
|
|
2
2
|
|
|
3
3
|
Package: ${t}@${i}
|
|
4
4
|
Advisory: ${a.id} (aliases: ${n})
|
|
@@ -138,7 +138,7 @@ ${h.length>0?`
|
|
|
138
138
|
${v}
|
|
139
139
|
</tbody>
|
|
140
140
|
</table>`:""}
|
|
141
|
-
<footer class="sig mt-12 flex flex-wrap items-center justify-between gap-x-6 gap-y-3 pt-5 text-[10px] uppercase"><span class="sig-meta"><b>${S(e.tool.name)}</b> ${S(e.tool.version)} · generated ${S(t.toISOString())} · powered by OSV.dev</span><span class="sig-by inline-flex items-center gap-2"><span class="sig-by-label">built by</span><a class="sig-by-link inline-flex items-center" href="https://anolilab.com" rel="noreferrer noopener" target="_blank" aria-label="Anolilab">${
|
|
141
|
+
<footer class="sig mt-12 flex flex-wrap items-center justify-between gap-x-6 gap-y-3 pt-5 text-[10px] uppercase"><span class="sig-meta"><b>${S(e.tool.name)}</b> ${S(e.tool.version)} · generated ${S(t.toISOString())} · powered by OSV.dev</span><span class="sig-by inline-flex items-center gap-2"><span class="sig-by-label">built by</span><a class="sig-by-link inline-flex items-center" href="https://anolilab.com" rel="noreferrer noopener" target="_blank" aria-label="Anolilab">${ri}</a></span></footer>
|
|
142
142
|
</div>
|
|
143
143
|
</main>
|
|
144
144
|
<script>
|
|
@@ -279,7 +279,7 @@ ${v}
|
|
|
279
279
|
</body>
|
|
280
280
|
</html>
|
|
281
281
|
`},na={CRITICAL:"CRITICAL",HIGH:"HIGH",LOW:"LOW",MODERATE:"MEDIUM",UNKNOWN:"NONE"},Oe=(e,t)=>`pkg:npm/${e}@${t}`,at=(e,t)=>{const i=new Map;for(const a of e){const n=t(a),o=i.get(n);o?o.push(a):i.set(n,[a])}return i},ra=e=>{const t=e.now??new Date,i=t.toISOString(),a=e.trackingId??`vis-audit-${t.toISOString().slice(0,10)}`,n=[...at(e.findings,r=>r.packageName).entries()].sort(([r],[c])=>r.localeCompare(c)).map(([r,c])=>({branches:[...new Set(c.map(l=>l.packageVersion))].sort().map(l=>{const d=Oe(r,l);return{category:"product_version",name:l,product:{name:`${r}@${l}`,product_id:d,product_identification_helper:{purl:d}}}}),category:"product_name",name:r})),o=[...at(e.findings,r=>r.vulnerability.id).entries()].sort(([r],[c])=>r.localeCompare(c)).map(([r,c])=>{const l=c[0].vulnerability,d=[...new Set(c.map($=>Oe($.packageName,$.packageVersion)))].sort(),m=r.startsWith("CVE-"),b=[r,...l.aliases??[]],h=m?r:b.find($=>$.startsWith("CVE-")),v=b.filter($=>$!==h).map($=>({system_name:$.startsWith("GHSA-")?"GitHub Security Advisory":"OSV",text:$})),y=ze(l),g=c.filter($=>$.acknowledged).map($=>Oe($.packageName,$.packageVersion));return{...h?{cve:h}:{},...v.length>0?{ids:v}:{},notes:[{category:"description",text:l.summary||`Advisory ${r}`,title:"Advisory description"}],product_status:{known_affected:d},references:[{category:"external",summary:`${r} advisory record`,url:T(r)}],scores:[{cvss_v3:{baseScore:y,baseSeverity:na[l.severity]??"NONE",vectorString:"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L",version:"3.1"},products:d}],title:l.summary.split(`
|
|
282
|
-
`)[0]?.slice(0,200)||r,...g.length>0?{flags:[{label:"inline_mitigations_already_exist",product_ids:g}]}:{}}});return{document:{category:"csaf_vex",csaf_version:"2.0",distribution:{tlp:{label:"WHITE"}},publisher:{category:"vendor",name:e.tool.name,namespace:e.tool.informationUri},title:`vis audit · ${a}`,tracking:{current_release_date:i,id:a,initial_release_date:i,revision_history:[{date:i,number:"1",summary:"Initial audit emission"}],status:"final",version:"1"}},...n.length>0?{product_tree:{branches:n}}:{},...o.length>0?{vulnerabilities:o}:{}}},oa={CRITICAL:"critical",HIGH:"high",LOW:"low",MODERATE:"medium",UNKNOWN:"unknown"},nt=(e,t)=>{const i=new Map;for(const a of e){const n=t(a),o=i.get(n);o?o.push(a):i.set(n,[a])}return i},sa=(e,t=new Date)=>{const i=nt(e,n=>n.vulnerability.id),a=t.toISOString();return[...i.entries()].sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>{const r=o[0].vulnerability,c=oa[r.severity]??"unknown",l=ze(r),d=[...nt(o,y=>y.packageName).entries()].sort(([y],[g])=>y.localeCompare(g)).map(([y,g])=>{const $=[...new Set(g.map(x=>x.packageVersion))].sort();return{ref:
|
|
282
|
+
`)[0]?.slice(0,200)||r,...g.length>0?{flags:[{label:"inline_mitigations_already_exist",product_ids:g}]}:{}}});return{document:{category:"csaf_vex",csaf_version:"2.0",distribution:{tlp:{label:"WHITE"}},publisher:{category:"vendor",name:e.tool.name,namespace:e.tool.informationUri},title:`vis audit · ${a}`,tracking:{current_release_date:i,id:a,initial_release_date:i,revision_history:[{date:i,number:"1",summary:"Initial audit emission"}],status:"final",version:"1"}},...n.length>0?{product_tree:{branches:n}}:{},...o.length>0?{vulnerabilities:o}:{}}},oa={CRITICAL:"critical",HIGH:"high",LOW:"low",MODERATE:"medium",UNKNOWN:"unknown"},nt=(e,t)=>{const i=new Map;for(const a of e){const n=t(a),o=i.get(n);o?o.push(a):i.set(n,[a])}return i},sa=(e,t=new Date)=>{const i=nt(e,n=>n.vulnerability.id),a=t.toISOString();return[...i.entries()].sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>{const r=o[0].vulnerability,c=oa[r.severity]??"unknown",l=ze(r),d=[...nt(o,y=>y.packageName).entries()].sort(([y],[g])=>y.localeCompare(g)).map(([y,g])=>{const $=[...new Set(g.map(x=>x.packageVersion))].sort();return{ref:oi(y,$[0]),versions:$.map(x=>({status:"affected",version:x}))}}),m=(r.aliases??[]).filter(y=>y!==n).map(y=>({id:y,source:{name:ve(y),url:T(y)}})),b=o.some(y=>y.acknowledged),h=o.every(y=>y.acknowledged)?{justification:"code_not_reachable",response:["will_not_fix"],state:"not_affected"}:b?{state:"in_triage"}:void 0,v=r.fixedVersions??[];return{"bom-ref":`vuln:${n}`,id:n,source:{name:ve(n),url:T(n)},...m.length>0?{references:m}:{},description:r.summary||`Advisory ${n}`,ratings:[{method:"CVSSv31",score:l,severity:c,source:{name:ve(n),url:T(n)}}],...v.length>0?{recommendation:`Upgrade to one of: ${v.join(", ")}`}:{},affects:d,created:a,published:a,...h?{analysis:h}:{}}})},ca=e=>{const t=sa(e.findings,e.now);return{...e.bom,vulnerabilities:t}},wt="15.2.1",la=`https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v${wt}/dist/dependency-scanning-report-format.json`,pa={CRITICAL:"Critical",HIGH:"High",LOW:"Low",MODERATE:"Medium",UNKNOWN:"Unknown"},da={block:"High",info:"Info",warn:"Medium"},ga=Uint8Array.from([107,167,184,18,157,173,17,209,128,180,0,192,79,212,48,200]),rt=e=>{const t=ci("sha1");t.update(ga),t.update(e,"utf8");const i=t.digest();i[6]=(i[6]??0)&15|80,i[8]=(i[8]??0)&63|128;const a=i.subarray(0,16).toString("hex");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20,32)}`},ot=e=>e.startsWith("CVE-")?{name:e,type:"cve",url:T(e),value:e}:e.startsWith("GHSA-")?{name:e,type:"ghsa",url:T(e),value:e}:{name:e,type:"osv",url:T(e),value:e},fa=e=>{const t=(e.now??new Date).toISOString().replace(/\.\d{3}Z$/,""),i=e.artifactUri??(ft(e.workspaceRoot,`${e.workspaceRoot}/package.json`)||"package.json"),a=[];for(const n of e.findings){const{acknowledged:o,packageName:r,packageVersion:c,vulnerability:l}=n,d=[ot(l.id)];for(const v of l.aliases??[])v!==l.id&&d.push(ot(v));const m=[{name:`${ve(l.id)} advisory`,url:T(l.id)}],b=l.summary||`Advisory ${l.id}`,h=l.fixedVersions.length>0?`Upgrade ${r} to ${l.fixedVersions.join(" or ")}`:void 0;a.push({description:b,...o?{flags:[{description:"Acknowledged via vis accepted-risks",origin:"vis",type:"flagged-as-likely-false-positive"}]}:{},id:rt(`vis-audit|${l.id}|${r}@${c}`),identifiers:d,links:m,location:{dependency:{package:{name:r},version:c},file:i},name:`${l.id}: ${r}@${c}`,severity:pa[l.severity],...h?{solution:h}:{}})}for(const n of e.policyDecisions??[]){if(n.policy==="vulnerability")continue;const o=`vis.policy.${n.policy}`;a.push({description:n.reason,...n.acceptedRisk?{flags:[{description:"Acknowledged via vis accepted-risks",origin:"vis",type:"flagged-as-likely-false-positive"}]}:{},id:rt(`vis-audit|${o}|${n.packageName}@${n.version}`),identifiers:[{name:o,type:"vis_policy",url:`https://visulima.com/packages/vis/commands/audit#policy-${n.policy}`,value:o}],links:[{name:`vis policy: ${n.policy}`,url:`https://visulima.com/packages/vis/commands/audit#policy-${n.policy}`}],location:{dependency:{package:{name:n.packageName},version:n.version},file:i},name:`vis policy '${n.policy}': ${n.packageName}@${n.version}`,severity:da[n.severity]})}return{scan:{analyzer:{id:e.tool.name,name:e.tool.name,url:e.tool.informationUri,vendor:{name:"Visulima"},version:e.tool.version},end_time:t,scanner:{id:e.tool.name,name:e.tool.name,url:e.tool.informationUri,vendor:{name:"Visulima"},version:e.tool.version},start_time:t,status:"success",type:"dependency_scanning"},schema:la,version:wt,vulnerabilities:a}},K=e=>e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"),st=e=>`<![CDATA[${e.replaceAll("]]>","]]]]><![CDATA[>")}]]>`,ua=e=>{let t="";return e.status==="skipped"?t=` <skipped/>
|
|
283
283
|
`:e.status==="failure"?t=` <failure type="${K(e.failureType)}" message="${K(e.failureMessage)}">${st(e.failureText)}</failure>
|
|
284
284
|
`:e.systemOut!==void 0&&(t=` <system-out>${st(e.systemOut)}</system-out>
|
|
285
285
|
`),` <testcase classname="${K(e.classname)}" name="${K(e.name)}">
|
|
@@ -291,9 +291,9 @@ ${r} </testsuite>
|
|
|
291
291
|
${v.summary||`Advisory ${v.id}`}${y}`,failureType:Le(v.severity).toUpperCase(),name:v.id,status:m?"skipped":"failure"}}),n=(e.policyDecisions??[]).filter(d=>d.policy!=="vulnerability").map(d=>{let m;return d.acceptedRisk?m="skipped":d.severity==="info"?m="passing":m="failure",{classname:`${d.packageName}@${d.version}`,failureMessage:`${d.severity.toUpperCase()} vis.policy.${d.policy}`,failureText:d.reason,failureType:d.severity.toUpperCase(),name:`vis.policy.${d.policy}`,status:m,...m==="passing"?{systemOut:d.reason}:{}}}),o=a.length+n.length,r=a.filter(d=>d.status==="failure").length+n.filter(d=>d.status==="failure").length,c=a.filter(d=>d.status==="skipped").length+n.filter(d=>d.status==="skipped").length;let l=`<?xml version="1.0" encoding="UTF-8"?>
|
|
292
292
|
<testsuites name="${K(i)}" tests="${String(o)}" failures="${String(r)}" skipped="${String(c)}" errors="0" time="0">
|
|
293
293
|
`;return l+=ct("vulnerabilities",a,t),n.length>0&&(l+=ct("policies",n,t)),l+=`</testsuites>
|
|
294
|
-
`,l},ha=e=>{const t=new Map,i=[],a=e.artifactUri??(ft(e.workspaceRoot,
|
|
294
|
+
`,l},ha=e=>{const t=new Map,i=[],a=e.artifactUri??(ft(e.workspaceRoot,li(e.workspaceRoot,"package.json"))||"package.json");for(const r of e.findings){const{acknowledged:c,packageName:l,packageVersion:d,vulnerability:m}=r,b=Fi(m.severity),h=Le(m.severity);t.has(m.id)||t.set(m.id,{defaultConfiguration:{level:b},fullDescription:{text:m.summary||`Advisory ${m.id}`},helpUri:T(m.id),id:m.id,name:m.id,properties:{precision:"very-high","security-severity":Bi(m),"severity-label":h,tags:["security","vulnerability","supply-chain",`severity:${h}`]},shortDescription:{text:(m.summary.split(`
|
|
295
295
|
`)[0]??m.id).slice(0,200)}}),i.push({level:b,locations:[{logicalLocations:[{kind:"package",name:`${l}@${d}`}],physicalLocation:{artifactLocation:{uri:a}}}],message:{text:`${m.id}: ${l}@${d} — ${m.summary||"no summary"}${m.fixedVersions.length>0?` (fix: ${m.fixedVersions.join(", ")})`:""}`},partialFingerprints:{advisoryId:m.id,package:l,version:d},properties:{...c?{acknowledged:!0}:{},...m.aliases&&m.aliases.length>0?{aliases:m.aliases}:{},...typeof m.cvssScore=="number"?{cvssScore:m.cvssScore}:{},...m.fixedVersions.length>0?{fixedVersions:m.fixedVersions}:{},packageName:l,packageVersion:d,severityLabel:h},ruleId:m.id})}const n={block:"error",info:"note",warn:"warning"},o={block:"high",info:"none",warn:"medium"};for(const r of e.policyDecisions??[]){if(r.policy==="vulnerability")continue;const c=`vis.policy.${r.policy}`,l=n[r.severity],d=o[r.severity];t.has(c)||t.set(c,{defaultConfiguration:{level:l},fullDescription:{text:`vis policy '${r.policy}' (Socket.dev-style supply-chain gate)`},helpUri:`https://visulima.com/packages/vis/commands/audit#policy-${r.policy}`,id:c,name:c,properties:{precision:"high","security-severity":r.severity==="block"?"8.0":r.severity==="warn"?"5.5":"0.0","severity-label":d,tags:["security","supply-chain","policy",`policy:${r.policy}`]},shortDescription:{text:`vis policy: ${r.policy}`}}),i.push({level:l,locations:[{logicalLocations:[{kind:"package",name:`${r.packageName}@${r.version}`}],physicalLocation:{artifactLocation:{uri:a}}}],message:{text:r.reason},partialFingerprints:{package:r.packageName,policy:r.policy,version:r.version},properties:{...r.acceptedRisk?{acknowledged:!0}:{},packageName:r.packageName,packageVersion:r.version,severityLabel:d},ruleId:c})}return{$schema:"https://json.schemastore.org/sarif-2.1.0.json",runs:[{results:i,tool:{driver:{informationUri:e.tool.informationUri,name:e.tool.name,rules:[...t.values()],version:e.tool.version}}}],version:"2.1.0"}},va=["dependencies","devDependencies","optionalDependencies","peerDependencies"],lt=e=>{try{return{path:e,pkg:ut(e)}}catch{return}},wa=e=>{const t=[],i=lt(z(e,"package.json"));i&&t.push({path:i.path,pkg:i.pkg,workspaceName:i.pkg.name});const a=Bt(e);let n;if(a?n=a:i?.pkg.workspaces&&(Array.isArray(i.pkg.workspaces)?n=i.pkg.workspaces:i.pkg.workspaces.packages&&(n=i.pkg.workspaces.packages)),!n)return t;for(const o of Kt(e,n)){const r=lt(z(e,o,"package.json"));r&&t.push({path:r.path,pkg:r.pkg,workspaceName:r.pkg.name})}return t},ya=(e,t)=>{const i=[];for(const a of e)for(const n of va){const o=a.pkg[n]?.[t];typeof o=="string"&&i.push({field:n,manifest:a,range:o})}return i},yt=e=>{const t=wa(e.workspaceRoot),i=[],a=[],n=[],o=new Set;for(const r of e.findings){const c=r.vulnerability.fixedVersions[0];if(!c){n.push({packageName:r.packageName,reason:"no-fixed-version"});continue}const l=ya(t,r.packageName);if(l.length===0){n.push({packageName:r.packageName,reason:"transitive-only"});continue}const d=L.coerce(c),m=d?`^${d.version}`:c,b=d?d.version:c;for(const h of l){const v=`${h.manifest.path}::${h.field}::${r.packageName}::${b}`;if(o.has(v))continue;o.add(v);const y=xa(b,h.range),g={currentRange:h.range,field:h.field,inRange:y,manifestPath:h.manifest.path,packageName:r.packageName,targetSpec:m,targetVersion:b,workspaceName:h.manifest.workspaceName};y||e.allowMajor===!0?i.push(g):a.push(g)}}return{apply:i,skippedMajor:a,unmatched:n}},ba=/^(?:workspace|file|link|portal|patch|git\+|git:|github:|npm:|catalog|jsr|http|https):/i,xa=(e,t)=>{if(ba.test(t))return!0;const i=L.coerce(e)?.version??e;try{return L.satisfies(i,t)}catch{return!0}},ka=e=>{const t=[];if(e.apply.length>0){t.push(`Apply (${String(e.apply.length)}):`);for(const i of e.apply){const a=i.workspaceName?` [${i.workspaceName}]`:"";t.push(` + ${i.packageName}: ${i.currentRange} → ${i.targetSpec}${a}`)}}if(e.skippedMajor.length>0){t.push(`Skipped — major bump (${String(e.skippedMajor.length)}, requires --allow-major):`);for(const i of e.skippedMajor){const a=i.workspaceName?` [${i.workspaceName}]`:"";t.push(` ! ${i.packageName}: ${i.currentRange} → ${i.targetSpec}${a}`)}}if(e.unmatched.length>0){const i=e.unmatched.filter(n=>n.reason==="transitive-only"),a=e.unmatched.filter(n=>n.reason==="no-fixed-version");if(i.length>0){t.push(`Transitive only (${String(i.length)}, requires --fix-transitive):`);for(const n of i)t.push(` · ${n.packageName}`)}if(a.length>0){t.push(`No fixed version available (${String(a.length)}):`);for(const n of a)t.push(` · ${n.packageName}`)}}return t.length===0?"No direct-dep fixes to apply.":t.join(`
|
|
296
|
-
`)},$a=5,Sa=64,Na=(e,t)=>{if(t.length===0)return[];const i=new Set;for(const a of e){if(t.includes(a)){i.add(a);continue}let n=!1;for(const o of t)try{L.satisfies(o,a)&&(i.add(o),n=!0)}catch{}!n&&t.length===1&&i.add(t[0])}return[...i]},Aa=e=>{const t=new Map;for(const n of e.entries){let o=t.get(n.name);o||(o=[],t.set(n.name,o)),o.includes(n.version)||o.push(n.version)}const i=new Map;for(const n of e.entries){const o=`${n.name}@${n.version}`;let r=i.get(o);r||(r=new Map,i.set(o,r));for(const c of[n.dependencies,n.peerDependencies,n.optionalDependencies])if(c)for(const[l,d]of Object.entries(c)){const m=t.get(l)??[],b=Na(d,m);for(const h of b){const v=`${l}@${h}`;r.has(v)||r.set(v,{name:l,version:h})}}}const a=new Map;for(const[n,o]of i)a.set(n,{children:[...o.values()]});return{adjacency:a,versionsByName:t}},Ca=(e,t)=>{const i=t.get(e.name);if(!(!i||i.length===0)){if(i.includes(e.version))return{name:e.name,version:e.version};for(const a of i)try{if(L.satisfies(a,e.version))return{name:e.name,version:a}}catch{}if(i.length===1)return{name:e.name,version:i[0]}}},Ra=(e,t,i={})=>{const a=i.maxPathsPerTarget??$a,n=i.maxDepth??Sa;if(a<=0)return[];const{adjacency:o,versionsByName:r}=Aa(e),c=`${t.name}@${t.version}`,l=[],d=[],m=new Set;for(const v of e.roots){const y=Ca(v,r);if(!y)continue;const g=`${y.name}@${y.version}`;m.has(g)||(m.add(g),d.push(y))}const b=[];for(const v of d){const y=`${v.name}@${v.version}`;if(y===c){if(l.push([v]),l.length>=a)return l;continue}b.push({node:v,path:[v],visited:new Set([y])})}let h=0;for(;h<b.length&&l.length<a;){const v=b[h];if(h+=1,v.path.length>=n)continue;const y=o.get(`${v.node.name}@${v.node.version}`)?.children??[];for(const g of y){const $=`${g.name}@${g.version}`;if(v.visited.has($))continue;const x=[...v.path,g];if($===c){if(l.push(x),l.length>=a)return l;continue}const A=new Set(v.visited);A.add($),b.push({node:g,path:x,visited:A})}}return l},Ia={"crates.io":["Cargo.lock"],Go:["go.sum"],Maven:["gradle.lockfile","pom.xml"],PyPI:["uv.lock","poetry.lock","Pipfile.lock"],RubyGems:["Gemfile.lock"]},ja={cargo:"crates.io","crates.io":"crates.io",go:"Go",maven:"Maven",npm:"npm",pypi:"PyPI",rubygems:"RubyGems"},bt=e=>ja[e.toLowerCase()]??e,Ea=(e,t)=>{const i=bt(t),a=Ia[i]??[];for(const n of a){const o=z(e,n);if(
|
|
296
|
+
`)},$a=5,Sa=64,Na=(e,t)=>{if(t.length===0)return[];const i=new Set;for(const a of e){if(t.includes(a)){i.add(a);continue}let n=!1;for(const o of t)try{L.satisfies(o,a)&&(i.add(o),n=!0)}catch{}!n&&t.length===1&&i.add(t[0])}return[...i]},Aa=e=>{const t=new Map;for(const n of e.entries){let o=t.get(n.name);o||(o=[],t.set(n.name,o)),o.includes(n.version)||o.push(n.version)}const i=new Map;for(const n of e.entries){const o=`${n.name}@${n.version}`;let r=i.get(o);r||(r=new Map,i.set(o,r));for(const c of[n.dependencies,n.peerDependencies,n.optionalDependencies])if(c)for(const[l,d]of Object.entries(c)){const m=t.get(l)??[],b=Na(d,m);for(const h of b){const v=`${l}@${h}`;r.has(v)||r.set(v,{name:l,version:h})}}}const a=new Map;for(const[n,o]of i)a.set(n,{children:[...o.values()]});return{adjacency:a,versionsByName:t}},Ca=(e,t)=>{const i=t.get(e.name);if(!(!i||i.length===0)){if(i.includes(e.version))return{name:e.name,version:e.version};for(const a of i)try{if(L.satisfies(a,e.version))return{name:e.name,version:a}}catch{}if(i.length===1)return{name:e.name,version:i[0]}}},Ra=(e,t,i={})=>{const a=i.maxPathsPerTarget??$a,n=i.maxDepth??Sa;if(a<=0)return[];const{adjacency:o,versionsByName:r}=Aa(e),c=`${t.name}@${t.version}`,l=[],d=[],m=new Set;for(const v of e.roots){const y=Ca(v,r);if(!y)continue;const g=`${y.name}@${y.version}`;m.has(g)||(m.add(g),d.push(y))}const b=[];for(const v of d){const y=`${v.name}@${v.version}`;if(y===c){if(l.push([v]),l.length>=a)return l;continue}b.push({node:v,path:[v],visited:new Set([y])})}let h=0;for(;h<b.length&&l.length<a;){const v=b[h];if(h+=1,v.path.length>=n)continue;const y=o.get(`${v.node.name}@${v.node.version}`)?.children??[];for(const g of y){const $=`${g.name}@${g.version}`;if(v.visited.has($))continue;const x=[...v.path,g];if($===c){if(l.push(x),l.length>=a)return l;continue}const A=new Set(v.visited);A.add($),b.push({node:g,path:x,visited:A})}}return l},Ia={"crates.io":["Cargo.lock"],Go:["go.sum"],Maven:["gradle.lockfile","pom.xml"],PyPI:["uv.lock","poetry.lock","Pipfile.lock"],RubyGems:["Gemfile.lock"]},ja={cargo:"crates.io","crates.io":"crates.io",go:"Go",maven:"Maven",npm:"npm",pypi:"PyPI",rubygems:"RubyGems"},bt=e=>ja[e.toLowerCase()]??e,Ea=(e,t)=>{const i=bt(t),a=Ia[i]??[];for(const n of a){const o=z(e,n);if(hi(o))return o}},Oa=e=>{const t=new Set,i=[];for(const a of e){const n=`${a.name}@${a.version}`;t.has(n)||(t.add(n),i.push(a))}return i},Da=/\[\[package\]\]([\s\S]*?)(?=\[\[|$)/g,Ma=/^\s*name\s*=\s*"([^"]+)"\s*$/m,La=/^\s*version\s*=\s*"([^"]+)"\s*$/m,Ta=e=>{const t=[];for(const i of e.matchAll(Da)){const a=i[1]??"",n=Ma.exec(a)?.[1],o=La.exec(a)?.[1];n&&o&&t.push({isDev:!1,name:n,version:o})}return t},Pa=e=>{let t;try{t=JSON.parse(e)}catch{return[]}if(typeof t!="object"||t===null)return[];const i=[];for(const a of["default","develop"]){const n=t[a];if(!(typeof n!="object"||n===null))for(const[o,r]of Object.entries(n)){if(typeof r!="object"||r===null)continue;const c=r.version;if(typeof c!="string")continue;const l=c.replace(/^==/,"").trim();l.length>0&&i.push({isDev:!1,name:o,version:l})}}return i},Va=/<dependency>([\s\S]*?)<\/dependency>/g,za=/<groupId>\s*([^<\s]+)\s*<\/groupId>/,Wa=/<artifactId>\s*([^<\s]+)\s*<\/artifactId>/,_a=/<version>\s*([^<\s]+)\s*<\/version>/,Ha=e=>{const t=[];for(const i of e.matchAll(Va)){const a=i[1]??"",n=za.exec(a)?.[1],o=Wa.exec(a)?.[1],r=_a.exec(a)?.[1];!n||!o||!r||r.startsWith("${")||t.push({isDev:!1,name:`${n}:${o}`,version:r})}return t},Ua=e=>{const t=[];for(const i of e.split(/\r?\n/)){const a=i.trim();if(a.length===0||a.startsWith("#"))continue;const n=a.indexOf("="),o=(n===-1?a:a.slice(0,n)).split(":");if(o.length<3)continue;const[r,c,l]=o;!r||!c||!l||t.push({isDev:!1,name:`${r}:${c}`,version:l})}return t},Fa=e=>{const t=[];for(const i of e.split(/\r?\n/)){const a=i.trim();if(a.length===0)continue;const n=a.split(/\s+/);if(n.length<3)continue;const[o,r]=n;if(!o||!r?.endsWith("/go.mod"))continue;const c=r.slice(0,-7);c.length!==0&&t.push({isDev:!1,name:o,version:c})}return t},Ga=/^ {4}([^ ()]+) \(([^()]+)\)\s*$/,Ba=e=>{const t=[];let i=!1,a=!1;for(const n of e.split(/\r?\n/)){if(n.startsWith("GEM")){i=!0,a=!1;continue}if(i&&/^[A-Z]/.test(n)){i=!1,a=!1;continue}if(i&&n.trim()==="specs:"){a=!0;continue}if(a){const o=Ga.exec(n);if(o){const[,r,c]=o;r&&c&&t.push({isDev:!1,name:r,version:c})}}}return t},Ka=(e,t)=>{const i=Ea(e,t);if(!i)return[];let a;try{a=mt(i,"utf8")}catch{return[]}const n=i.split(/[/\\]/).pop()??"";let o;switch(n){case"Cargo.lock":case"poetry.lock":case"uv.lock":{o=Ta(a);break}case"Gemfile.lock":{o=Ba(a);break}case"go.sum":{o=Fa(a);break}case"gradle.lockfile":{o=Ua(a);break}case"Pipfile.lock":{o=Pa(a);break}case"pom.xml":{o=Ha(a);break}default:return[]}return Oa(o)},qa=["ts","tsx","js","jsx","mjs","cjs","mts","cts"],Ja=[/node_modules/,/\.git/,/\.next/,/\.cache/,/dist/,/build/,/coverage/,/\.turbo/,/\.nx/,/\.parcel-cache/],Ya=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Za=/(?:import|export)\s+(?:[\s\S]*?from\s+)?["']([^"'\n]+)["']/g,Qa=/(?:^|[^.\w$])require\s*\(\s*["']([^"'\n]+)["']\s*\)/g,Xa=/\bimport\s*\(\s*["']([^"'\n]+)["']\s*\)/g,en=e=>{if(e.startsWith(".")||e.startsWith("/")||/^[a-z][a-z0-9+.-]*:/i.test(e))return;const t=e.trim();if(t.length!==0){if(t.startsWith("@")){const i=t.split("/");return i.length<2?void 0:`${i[0]}/${i[1]}`}return t.split("/")[0]}},tn=e=>{const t=new Set,i=e.replaceAll(/\/\*[\s\S]*?\*\//g,"").replaceAll(/(^|[^:])\/\/.*$/gm,"$1"),a=n=>{n.lastIndex=0;let o;for(;(o=n.exec(i))!==null;){const r=en(o[1]);r&&t.add(r)}};return a(Za),a(Qa),a(Xa),t},an=e=>{const t=new Set;try{const i=ut(e);for(const a of Ya){const n=i[a];if(n&&typeof n=="object"&&!Array.isArray(n))for(const o of Object.keys(n))t.add(o)}}catch{}return t},nn=e=>{const t=e.skip??Ja,i=e.extensions??qa,a=new Set;let n=0;const o=it(e.workspaceRoot,{extensions:i,includeDirs:!1,skip:t});for(const l of o){n+=1;try{const d=mt(l,"utf8");for(const m of tn(d))a.add(m)}catch{}}const r=it(e.workspaceRoot,{extensions:["json"],includeDirs:!1,skip:t}).filter(l=>l.endsWith("/package.json")||l.endsWith(String.raw`\package.json`)||l.endsWith("package.json"));for(const l of r)for(const d of an(l))a.add(d);if(e.alwaysAssumeUsed)for(const l of e.alwaysAssumeUsed)a.add(l);const c=new Set;for(const l of e.vulnerablePackages)a.has(l)&&c.add(l);return{filesScanned:n,importedTotal:a,reachable:c}},rn=e=>{const t=L.coerce(e)?.major;return t!==void 0&&t>=10},on=e=>Object.fromEntries(Object.entries(e).sort(([t],[i])=>t.localeCompare(i))),sn=(e,t)=>`${JSON.stringify(e,void 0,t)}
|
|
297
297
|
`,xt=(e,t)=>{if(t.name==="pnpm"&&rn(t.version))return{filePath:z(e,"pnpm-workspace.yaml"),surface:"pnpm-workspace.yaml"};const i=z(e,"package.json");return t.name==="pnpm"?{filePath:i,surface:"package.json#pnpm.overrides"}:t.name==="yarn"?{filePath:i,surface:"package.json#resolutions"}:{filePath:i,surface:"package.json#overrides"}},cn=(e,t)=>{const{filePath:i,surface:a}=xt(e,t);if(!J(i))return{};if(a==="pnpm-workspace.yaml")try{return Ve(i)?.overrides??{}}catch{return{}}try{const n=JSON.parse(be(i));return a==="package.json#pnpm.overrides"?(n.pnpm??{}).overrides??{}:a==="package.json#resolutions"?n.resolutions??{}:n.overrides??{}}catch{return{}}},ln=(e,t)=>{const i=Object.keys(t).sort();if(i.length===0&&!/^overrides\s*:/m.test(e))return e;const a=`overrides:
|
|
298
298
|
${i.map(n=>` '${n}': '${t[n]}'`).join(`
|
|
299
299
|
`)}
|
|
@@ -302,14 +302,14 @@ ${i.map(n=>` '${n}': '${t[n]}'`).join(`
|
|
|
302
302
|
`}return`${e.endsWith(`
|
|
303
303
|
`)?e:`${e}
|
|
304
304
|
`}
|
|
305
|
-
${a}`},pn=(e,t,i,a)=>{const n=qt(e,t.length>0?t:void 0),o=t.length>0?JSON.parse(t):{};if(i==="package.json#pnpm.overrides"){const r=o.pnpm??{};r.overrides=a,o.pnpm=r}else i==="package.json#resolutions"?o.resolutions=a:o.overrides=a;return sn(o,n)},dn=(e,t,i)=>{const{filePath:a,surface:n}=xt(e,i),o=cn(e,i),r=J(a)?be(a):"",c=[],l={...o};for(const h of t.entries){const v=o[h.packageName];if(v===h.spec){c.push({...h,previousSpec:v,status:"unchanged"});continue}v===void 0?c.push({...h,status:"added"}):c.push({...h,previousSpec:v,status:"updated"}),l[h.packageName]=h.spec}const d=on(l),m=c.some(h=>h.status!=="unchanged"),b=n==="pnpm-workspace.yaml"?ln(r,d):pn(a,r,n,d);return{changed:m,entries:c,filePath:a,nextContent:b,previousContent:r,surface:n}},gn=e=>{if(!e.changed)return e;if(e.surface==="pnpm-workspace.yaml"&&e.previousContent.length===0)throw new Error(`${e.filePath} not found. Run \`pnpm init\` or create pnpm-workspace.yaml before applying overrides for pnpm v10+.`);const t=`${e.filePath}.tmp`;try{
|
|
306
|
-
${i.summary}${c}`},wn=(e,t)=>{const i=
|
|
307
|
-
`):u.error(p.message),process.exitCode=1;return}}!I&&(C.ignoredAdvisories.length>0||C.excludedPackages.length>0)&&u.info(`Loaded ${String(C.ignoredAdvisories.length)} ignored advisor${C.ignoredAdvisories.length===1?"y":"ies"} and ${String(C.excludedPackages.length)} excluded package${C.excludedPackages.length===1?"":"s"} from ${O.name} config.`),!I&&A.unsupported.length>0&&u.warn(`Ecosystems ${A.unsupported.map(s=>`'${s}'`).join(", ")} are not yet supported by the audit matcher. Supported: npm, pypi, crates.io, cargo, maven, go, rubygems.`);const P=
|
|
305
|
+
${a}`},pn=(e,t,i,a)=>{const n=qt(e,t.length>0?t:void 0),o=t.length>0?JSON.parse(t):{};if(i==="package.json#pnpm.overrides"){const r=o.pnpm??{};r.overrides=a,o.pnpm=r}else i==="package.json#resolutions"?o.resolutions=a:o.overrides=a;return sn(o,n)},dn=(e,t,i)=>{const{filePath:a,surface:n}=xt(e,i),o=cn(e,i),r=J(a)?be(a):"",c=[],l={...o};for(const h of t.entries){const v=o[h.packageName];if(v===h.spec){c.push({...h,previousSpec:v,status:"unchanged"});continue}v===void 0?c.push({...h,status:"added"}):c.push({...h,previousSpec:v,status:"updated"}),l[h.packageName]=h.spec}const d=on(l),m=c.some(h=>h.status!=="unchanged"),b=n==="pnpm-workspace.yaml"?ln(r,d):pn(a,r,n,d);return{changed:m,entries:c,filePath:a,nextContent:b,previousContent:r,surface:n}},gn=e=>{if(!e.changed)return e;if(e.surface==="pnpm-workspace.yaml"&&e.previousContent.length===0)throw new Error(`${e.filePath} not found. Run \`pnpm init\` or create pnpm-workspace.yaml before applying overrides for pnpm v10+.`);const t=`${e.filePath}.tmp`;try{vi(t,e.nextContent),wi(t,e.filePath)}catch(i){try{yi(t)}catch{}throw i}return e},fn=e=>{const t=new Map;for(const i of e){const a=i.vulnerability.fixedVersions[0];if(!a)continue;const n=L.coerce(a),o=n?`^${n.version}`:a;t.set(i.packageName,o)}return{entries:[...t.entries()].sort(([i],[a])=>i.localeCompare(a)).map(([i,a])=>({packageName:i,spec:a}))}},un={critical:we,high:dt,low:pt,medium:ye},Te=new Set(["cargo","crates.io","go","maven","npm","pypi","rubygems"]),mn=e=>{const t=(e??"npm").split(",").map(n=>n.trim()).filter(n=>n.length>0),i=t.length>0?t:["npm"],a=i.filter(n=>!Te.has(n.toLowerCase()));return{all:i,unsupported:a}},hn={CRITICAL:we,HIGH:dt,LOW:pt,MODERATE:ye,UNKNOWN:D},vn=(e,t,i,a)=>{const n=hn[i.severity]??D,o=a?` ${D("[acknowledged]")}`:"",r=i.fixedVersions??[],c=r.length>0?` (fix: ${r.join(", ")})`:"";return` ${n(i.severity)} ${i.id} — ${e}@${t}${o}
|
|
306
|
+
${i.summary}${c}`},wn=(e,t)=>{const i=Ni(e),a=`${String(Math.round(e.score.overall*100))}%`,n=t?` ${D("[acknowledged]")}`:"",o=e.alerts.length>0?`, ${String(e.alerts.length)} alert${e.alerts.length===1?"":"s"}`:"";return` ${a} ${i}@${e.version} (${Si(e.score.overall)}${o})${n}`},yn=new Set(["aube","auto","vis"]),te=e=>e!==void 0&&yn.has(e),bn=(e,t,i)=>{if(e!==void 0&&!te(e))throw new Error(`Invalid --backend value '${e}'. Expected one of: aube, auto, vis.`);const a=process.env.VIS_AUDIT_BACKEND;if(a!==void 0&&a!==""&&!te(a))throw new Error(`Invalid VIS_AUDIT_BACKEND value '${a}'. Expected one of: aube, auto, vis.`);const n=te(a)?a:void 0,o=te(t)?t:void 0,r=(te(e)?e:void 0)??n??o??"auto";return r==="aube"?"aube":r==="vis"?"vis":(i?.install?.backend??process.env.VIS_INSTALLER)==="aube"&&Pt("aube")!==null?"aube":"vis"},xn=e=>{if(e!==void 0)switch(e){case"critical":return"critical";case"high":return"high";case"low":return"low";case"medium":return"moderate";default:return e}},kn=(e,t,i)=>{const a=["audit"],n=xn(t.severity);n!==void 0&&a.push("--audit-level",n),(t.prodOnly===!0||t.prod===!0)&&a.push("--prod"),(t.json===!0||t.format==="json")&&a.push("--json");const o=t.fix===!0;t["fix-transitive"]===!0||t.fixTransitive===!0?a.push("--fix=override"):o&&a.push("--fix=update");const r=[];t.offline===!0&&r.push("--offline (aube has its own offline cache)"),(t.format==="sarif"||t.format==="csaf"||t.format==="cyclonedx"||t.format==="cyclonedx-vex"||t.format==="gitlab"||t.format==="junit")&&r.push(`--format=${String(t.format)} (only json/text is forwarded to aube)`),r.length>0&&u.warn(`Delegating to 'aube audit'. Skipping vis-only flags: ${r.join(", ")}`);const c=Dt("aube",a,{cwd:e,stdio:"inherit"});if(c.error){const{code:l}=c.error;return l==="ENOENT"?u.error("Backend 'aube' selected but the 'aube' binary was not found on PATH. Install aube or run with --backend vis."):u.error(`Failed to spawn aube: ${c.error.message}`),1}return c.status??1},$n=async(e,t,i,a,n)=>{if(bn(i.backend,a?.security?.audit?.backend,a)==="aube"){process.exitCode=kn(t,i);return}const o=i.severity??"low",r=i.format??"table",c=r==="sarif",l=r==="csaf",d=r==="cyclonedx-vex"||r==="cyclonedx",m=r==="gitlab",b=r==="junit",h=r==="json"||!!i.json,v=i.report,y=a?.security?.audit,g=a?.security?.policies,$=i.offline===void 0?!!y?.offlineByDefault:!!i.offline,x=i.db,A=mn(i.ecosystem),q=!!i.prodOnly,M=i.failOn??g?.vulnerability?.failOn,St=!!i.showFixes,ne=!!i.showAccepted,$e=a?.security?.acceptedRisks,We=g?.vulnerability?.usage,Nt=i.noUsage?!1:i.usage===void 0?!!We?.enabled:!!i.usage,I=h||c||l||d||m||b,_e=i.explain,Se=_e!==void 0,He=Se&&!c&&!l&&!d&&!m&&!b;if(Se&&$){u.error("`--explain` needs network access and cannot run in offline mode (--offline or security.audit.offlineByDefault)."),process.exitCode=1;return}Se&&!He&&u.warn(`\`--explain\` has no effect with --format=${r}; explanations are only rendered in table, json, and HTML output.`);const O=ei(t),C=Li(t,O.name);if($){const s=x??di(t);if(!await e.access(s).then(()=>!0).catch(()=>!1)){const p=new Xe(s);I?process.stderr.write(`${p.message}
|
|
307
|
+
`):u.error(p.message),process.exitCode=1;return}}!I&&(C.ignoredAdvisories.length>0||C.excludedPackages.length>0)&&u.info(`Loaded ${String(C.ignoredAdvisories.length)} ignored advisor${C.ignoredAdvisories.length===1?"y":"ies"} and ${String(C.excludedPackages.length)} excluded package${C.excludedPackages.length===1?"":"s"} from ${O.name} config.`),!I&&A.unsupported.length>0&&u.warn(`Ecosystems ${A.unsupported.map(s=>`'${s}'`).join(", ")} are not yet supported by the audit matcher. Supported: npm, pypi, crates.io, cargo, maven, go, rubygems.`);const P=gi(t,O.name,{includeDev:!q});if(P.length===0){u.info(`No ${O.name} lockfile entries found. Run ${O.name} install first.`);return}if(!I){const s=q?"production-only packages":"installed packages";u.info(`Scanning ${String(P.length)} ${s}${$?" (offline)":""}…`)}const re=P.map(s=>({name:s.name,version:s.version})),oe=a?.security?.audit?.advisories?.bloom?.mode??"off";let W=[];if(oe!=="off")try{const s=await bi(t,{softFail:oe==="on"});if(s){if(W=xi(s,re).map(p=>({name:p.name,version:p.version})),!I&&W.length>0){u.warn(`osv-bloom prefilter flagged ${String(W.length)} package${W.length===1?"":"s"} as possibly malicious (MAL-*). Confirming via the advisory query path…`);const p=10;for(const f of W.slice(0,p))u.warn(` ${we("[bloom]")} ${f.name}@${f.version}`);W.length>p&&u.warn(` …and ${String(W.length-p)} more (full list in --format json output)`)}}else I||u.info(D("osv-bloom cache absent — skipping prefilter (run `vis advisories bloom sync` to enable)."))}catch(s){if(s instanceof ki&&oe==="required"){const f=`${s.message} (security.audit.advisories.bloom.mode = "required")`;I?process.stderr.write(`${f}
|
|
308
308
|
`):u.error(f),process.exitCode=1;return}const p=s instanceof Error?s.message:String(s);if(oe==="required"){I?process.stderr.write(`osv-bloom prefilter failed: ${p}
|
|
309
|
-
`):u.error(`osv-bloom prefilter failed: ${p}`),process.exitCode=1;return}I||u.warn(`osv-bloom prefilter failed (continuing): ${p}`)}const se=new Set;$?se.add("socket").add("deps-dev"):(Qe("socket")&&se.add("socket"),Qe("depsDev")&&se.add("deps-dev"));const Ne=Jt(a?.security,{disabled:se,minimumScore:g?.score?.minimum}),Ae=Ne.length>0,At=Ne.map(s=>s.displayName).join(" + "),ce=g?.score?.minimum
|
|
310
|
-
`):u.warn(X)});if(p?.size===0)return[];const f=a?.security?.policies?.license,w=!!(f&&((f.allow?.length??0)>0||(f.deny?.length??0)>0)),k=p===void 0||p.has("license"),N=w&&k?
|
|
309
|
+
`):u.error(`osv-bloom prefilter failed: ${p}`),process.exitCode=1;return}I||u.warn(`osv-bloom prefilter failed (continuing): ${p}`)}const se=new Set;$?se.add("socket").add("deps-dev"):(Qe("socket")&&se.add("socket"),Qe("depsDev")&&se.add("deps-dev"));const Ne=Jt(a?.security,{disabled:se,minimumScore:g?.score?.minimum}),Ae=Ne.length>0,At=Ne.map(s=>s.displayName).join(" + "),ce=g?.score?.minimum??$i,G=fi(t,O.name),Ct=[{id:"vulnerabilities",label:$?"Known vulnerabilities (offline OSV cache)":"Known vulnerabilities (OSV)"},...Ae?[{id:"security",label:`Supply-chain reports (${At})`}]:[]],V=pi(Ct,{live:!I}),Rt=Date.now(),B=s=>{const p=Date.now()-s;return p>=1e3?`${(p/1e3).toFixed(1)}s`:`${String(Math.round(p))}ms`};let Ce,Re;try{const s=Date.now(),p=Date.now();V.start("vulnerabilities"),Ae&&V.start("security");const f=$?Promise.resolve().then(()=>et(re,{dbPath:x,ecosystem:A.all.find(w=>Te.has(w.toLowerCase()))??"npm",workspaceRoot:t})).then(w=>{let k=0;for(const N of w.values())k+=N.length;return V.finish("vulnerabilities",k>0?"warn":"ok",k>0?`${String(k)} found · ${B(s)}`:`none found · ${B(s)}`),w}).catch(w=>{const k=w instanceof Error?w.message:String(w);if(V.finish("vulnerabilities","error",k),w instanceof Xe)throw w;return new Map}):Yt(re).then(w=>{let k=0;for(const N of w.values())k+=N.length;return V.finish("vulnerabilities",k>0?"warn":"ok",k>0?`${String(k)} found · ${B(s)}`:`none found · ${B(s)}`),w}).catch(w=>{const k=w instanceof Error?w.message:String(w);return V.finish("vulnerabilities","error",k),new Map});[Ce,Re]=await Promise.all([f,Ae?Zt(Ne,re).then(w=>{let k=0,N=0;for(const X of w.values())k+=X.alerts.length,X.score.overall<ce&&(N+=1);const E=k+N;return V.finish("security",E>0?"warn":"ok",E>0?`${String(k)} alert${k===1?"":"s"}, ${String(N)} low-score · ${B(p)}`:`clean · ${B(p)}`),w}).catch(w=>{const k=w instanceof Error?w.message:String(w);return V.finish("security","error",k),new Map}):Promise.resolve(new Map)])}finally{V.stop()}h||u.info(D(`Scan completed in ${B(Rt)}`));const le=[];for(const s of P){if(Ti(s.name,C))continue;const p=Ce.get(s.name)??[],f=Re.get(`${s.name}@${s.version}`),w=tt(s.name,s.version,$e),k=p.length>0,N=f?f.score.overall<ce:!1,E=f?f.alerts.length>0:!1;(k||N||E)&&le.push({acceptedRisk:w,name:s.name,socketReport:f,version:s.version,vulnerabilities:p})}if($){const s=A.all.filter(p=>Te.has(p.toLowerCase())&&p.toLowerCase()!=="npm");for(const p of s){const f=bt(p),w=Ka(t,f);if(w.length!==0){I||u.info(D(`Scanning ${String(w.length)} ${f} packages…`));try{const k=et(w.map(N=>({name:N.name,version:N.version})),{dbPath:x,ecosystem:f,workspaceRoot:t});for(const N of w){const E=k.get(N.name)??[];E.length!==0&&le.push({acceptedRisk:tt(N.name,N.version,$e),name:N.name,version:N.version,vulnerabilities:E})}}catch(k){const N=k instanceof Error?k.message:String(k);u.warn(`Failed to scan ${f}: ${N}`)}}}}let R=le.filter(s=>{const p=s.vulnerabilities.some(k=>he(k.severity,o)),f=s.socketReport?.alerts.some(k=>he(k.severity==="medium"?"MODERATE":k.severity.toUpperCase(),o)),w=s.socketReport&&s.socketReport.score.overall<ce;return p||f||w});const It=i.policies,Ue=[],j=await(async()=>{const s=ni().map(E=>`'${E}'`).join(", "),p=ii(It,E=>{Ue.push(E);const X=`Unknown policy '${E}' — ignoring. Available: ${s}.`;I?process.stderr.write(`vis audit: ${X}
|
|
310
|
+
`):u.warn(X)});if(p?.size===0)return[];const f=a?.security?.policies?.license,w=!!(f&&((f.allow?.length??0)>0||(f.deny?.length??0)>0)),k=p===void 0||p.has("license"),N=w&&k?mi(t):void 0;return ai({manifestData:N,offline:$,osvFindings:Ce,packageManager:O.name,packages:P,socketReports:Re,workspaceRoot:t},"audit",{enabledPolicies:p,visConfig:a??{}})})();if(Nt){const s=new Set(R.filter(f=>f.vulnerabilities.length>0).map(f=>f.name)),p=nn({alwaysAssumeUsed:We?.alwaysAssumeUsed,vulnerablePackages:s,workspaceRoot:t});R=R.filter(f=>f.vulnerabilities.length===0?!0:p.reachable.has(f.name)),I||u.info(D(`Reachability filter: ${String(p.reachable.size)}/${String(s.size)} vulnerable packages reachable (${String(p.filesScanned)} files scanned).`))}const Fe=ui(t,O.name),Ge=Fe?R.map(s=>{const p=Ra(Fe,{name:s.name,version:s.version});return{...s,dependencyPaths:p}}):R.map(s=>({...s,dependencyPaths:[]})),_=()=>Ge.flatMap(s=>s.vulnerabilities.map(p=>({acknowledged:!!s.acceptedRisk||ae(p.id,C,p.aliases),dependencyPaths:s.dependencyPaths,packageName:s.name,packageVersion:s.version,vulnerability:p}))),Be=!!i.fix,Ke=!!i.fixTransitive,qe=!!i.yes,jt=!!i.allowMajor;if(Be||Ke){const s=_().filter(p=>!p.acknowledged);if(Be){const p=await Nn({actionableFindings:s,allowMajor:jt,pm:O,workspaceRoot:t,yes:qe});if(p!==void 0){process.exitCode=p;return}}if(Ke){const p=await An({actionableFindings:s,pm:O,visConfig:a,workspaceRoot:t,yes:qe});if(p!==void 0){process.exitCode=p;return}}}const pe=new Map;if(He){const s=Ci(_().filter(f=>!f.acknowledged).map(f=>({packageName:f.packageName,packageVersion:f.packageVersion,vulnerability:f.vulnerability})).sort(gt),_e),p=await Mi(s,a?.ai,{info:f=>{u.info(f)},warn:f=>{u.warn(f)}});for(const[f,w]of p)pe.set(f,w)}if(c){const s=ha({findings:_(),policyDecisions:j,tool:{informationUri:"https://github.com/visulima/visulima",name:"vis-audit",version:"alpha"},workspaceRoot:t});process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
311
311
|
`),ie(R,C,i.exitCode,M,j);return}if(l){const s=ra({findings:_(),tool:{informationUri:"https://github.com/visulima/visulima",name:"vis-audit",version:"alpha"}});process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
312
|
-
`),ie(R,C,i.exitCode,M,j);return}if(d){const{packageJsons:s,workspace:p}=Qt(t,a),f=Xt(t,p,s),w=
|
|
312
|
+
`),ie(R,C,i.exitCode,M,j);return}if(d){const{packageJsons:s,workspace:p}=Qt(t,a),f=Xt(t,p,s),w=si({includeDev:!q,projectGraph:f,workspace:p,workspaceRoot:t}),k=ca({bom:w,findings:_()});process.stdout.write(`${JSON.stringify(k,void 0,2)}
|
|
313
313
|
`),ie(R,C,i.exitCode,M,j);return}if(m){const s=fa({findings:_(),policyDecisions:j,tool:{informationUri:"https://github.com/visulima/visulima",name:"vis-audit",version:"alpha"},workspaceRoot:t});process.stdout.write(`${JSON.stringify(s,void 0,2)}
|
|
314
314
|
`),ie(R,C,i.exitCode,M,j);return}if(b){const s=ma({findings:_(),policyDecisions:j});process.stdout.write(s),ie(R,C,i.exitCode,M,j);return}const Ie={informationUri:"https://github.com/visulima/visulima",name:"vis-audit",version:"alpha"},de=zi({bloomHits:W,duplicates:G,explanations:pe,filtered:Ge,packagesScanned:P.length,policyDecisions:j,tool:Ie,unknownPolicyTokens:Ue,workspaceRoot:t});if(v){const s=aa({findings:_().map(f=>{const w=pe.get(xe({packageName:f.packageName,packageVersion:f.packageVersion,vulnerability:f.vulnerability}));return w?{...f,explanation:w}:f}),packagesScanned:P.length,policyDecisions:j,report:de,tool:{name:Ie.name,version:Ie.version}}),p=Tt(t,v);await e.writeFile(p,s,"utf8"),I||u.success(`HTML report written to ${p}`)}if(h){process.stdout.write(`${JSON.stringify(de,void 0,2)}
|
|
315
315
|
`),i.exitCode&&(de.summary.issues>0||de.summary.policyBlocks>0)&&(process.exitCode=1),Pe(R,C,M,j);return}if(R.length===0){u.success(`No security issues found across ${String(P.length)} packages.`);return}const Z={CRITICAL:[],HIGH:[],LOW:[],MODERATE:[]};for(const s of R)for(const p of s.vulnerabilities)if(he(p.severity,o)){const f=p.severity==="UNKNOWN"?"LOW":p.severity;Z[f]?.push({entry:s,vuln:p})}let ge=0,je=0;for(const s of["CRITICAL","HIGH","MODERATE","LOW"]){const p=Z[s];if(!(!p||p.length===0)){u.info(`
|
|
@@ -319,4 +319,4 @@ ${a}`},pn=(e,t,i,a)=>{const n=qt(e,t.length>0?t:void 0),o=t.length>0?JSON.parse(
|
|
|
319
319
|
── Duplicate Dependencies (${String(G.length)}) ──`);for(const s of G){const p=s.versions.join(", ");u.info(` ${s.name} — ${String(s.versions.length)} versions: ${ye(p)}`)}}const Je=new Set;for(const s of["CRITICAL","HIGH","MODERATE","LOW"]){const p=Z[s];if(p)for(const{vuln:f}of p)Je.add(f.id)}const Ee=j.filter(s=>{if(s.policy!=="vulnerability")return!0;const p=typeof s.data?.advisoryId=="string"?s.data.advisoryId:void 0;return s.severity==="block"&&p!==void 0&&!Je.has(p)});if(Ee.length>0){u.info(`
|
|
320
320
|
── Policy Decisions (${String(Ee.length)}) ──`);for(const s of Ee){const p=!!s.acceptedRisk;if(p&&!ne)continue;const f=s.severity==="block"?we:s.severity==="warn"?ye:D,w=p?` ${D("[acknowledged]")}`:"";u.info(` ${f(`[${s.severity}]`)} ${s.policy} — ${s.reason}${w}`)}}const fe=s=>!!s.acceptedRisk||s.vulnerabilities.length>0&&s.vulnerabilities.every(p=>ae(p.id,C,p.aliases)),Ye=R.filter(s=>!fe(s)).length;if(u.info(""),u.info("─ Audit Summary"),u.info(` ${String(P.length)} packages scanned`),C.ignoredAdvisories.length>0&&u.info(` ${String(C.ignoredAdvisories.length)} ${O.name} audit exclusion${C.ignoredAdvisories.length===1?"":"s"} applied`),ge>0){const s=Z.CRITICAL?.filter(f=>!fe(f.entry)).length??0,p=Z.HIGH?.filter(f=>!fe(f.entry)).length??0;u.error(` ${String(ge)} vulnerabilit${ge===1?"y":"ies"} found`),s>0&&u.error(` ${String(s)} critical`),p>0&&u.warn(` ${String(p)} high`)}else u.success(" No vulnerabilities found");if(Q.length>0){const s=Q.filter(p=>!fe(p)).length;u.warn(` ${String(s)} package${s===1?"":"s"} with Socket.dev supply chain issues`)}G.length>0&&(u.warn(` ${String(G.length)} package${G.length===1?"":"s"} with duplicate versions`),u.notice(" Run 'vis dedupe' or your package manager's dedupe command to reduce duplicates."));const ue=j.filter(s=>s.severity==="block"&&!s.acceptedRisk);if(ue.length>0&&u.error(` ${String(ue.length)} policy block${ue.length===1?"":"s"}`),je>0&&(u.info(` ${String(je)} acknowledged (accepted risks)`),ne||u.notice(" Use --show-accepted to see acknowledged issues.")),Ye===0&&u.success(`
|
|
321
321
|
All issues are acknowledged. No action required.`),i.sync&&$e){const s=new Set;for(const f of le)if(f.acceptedRisk){for(const w of f.vulnerabilities)if((w.id.startsWith("CVE-")||w.id.startsWith("GHSA-"))&&s.add(w.id),w.aliases)for(const k of w.aliases)(k.startsWith("CVE-")||k.startsWith("GHSA-"))&&s.add(k)}const p=[...s];if(p.length>0){u.info("");const f=Pi(O.name,t,p);for(const w of f)u.success(` ${w}`)}else u.info(`
|
|
322
|
-
No advisory IDs to sync to native PM config.`)}i.exitCode&&(Ye>0||ue.length>0)&&(process.exitCode=1),Pe(R,C,M,j)},kt=e=>!e||e.length===0?!1:e.some(t=>t.severity==="block"&&!t.acceptedRisk),Pe=(e,t,i,a)=>{kt(a)&&(process.exitCode=1),i&&e.some(n=>n.vulnerabilities.some(o=>n.acceptedRisk||ae(o.id,t,o.aliases)?!1:he(o.severity,i)))&&(process.exitCode=1)},ie=(e,t,i,a,n)=>{i&&(e.filter(o=>!o.acceptedRisk&&o.vulnerabilities.some(r=>!ae(r.id,t,r.aliases))).length>0||kt(n))&&(process.exitCode=1),Pe(e,t,a,n)},$t=async(e,t)=>{if(!process.stdin.isTTY)return t;const i=Mt({input:process.stdin,output:process.stderr});try{const a="[y/N]",n=await new Promise(o=>{i.question(`${e} ${D(a)} `,r=>{o(r.trim())})});return n.length===0?t:n.toLowerCase().startsWith("y")}finally{i.close()}},Sn=e=>e==="pnpm"||e==="npm"||e==="yarn"||e==="bun",Nn=async e=>{const t=yt({allowMajor:e.allowMajor,findings:e.actionableFindings,workspaceRoot:e.workspaceRoot});if(u.info(""),u.info("─ Apply (direct deps)"),u.info(ka(t)),t.apply.length===0){u.info("Nothing to apply for direct deps.");return}if(De&&!e.yes)return u.error("Refusing to run --fix in CI without --yes. Re-run with --yes once the plan above looks right."),1;if(!e.yes&&!await $t("Apply these direct-dep upgrades?",!1))return u.info("Aborted — no changes made."),0;const i=new Map;for(const a of t.apply){const n=a.workspaceName??"",o=i.get(n);o?o.push(a):i.set(n,[a])}for(const[a,n]of i){const o=n.map(l=>`${l.packageName}@${l.targetSpec}`),r=a.length>0?[a]:[];u.info(`Running ${e.pm.name} add ${o.join(" ")}${a.length>0?` --filter ${a}`:""}`);const c=
|
|
322
|
+
No advisory IDs to sync to native PM config.`)}i.exitCode&&(Ye>0||ue.length>0)&&(process.exitCode=1),Pe(R,C,M,j)},kt=e=>!e||e.length===0?!1:e.some(t=>t.severity==="block"&&!t.acceptedRisk),Pe=(e,t,i,a)=>{kt(a)&&(process.exitCode=1),i&&e.some(n=>n.vulnerabilities.some(o=>n.acceptedRisk||ae(o.id,t,o.aliases)?!1:he(o.severity,i)))&&(process.exitCode=1)},ie=(e,t,i,a,n)=>{i&&(e.filter(o=>!o.acceptedRisk&&o.vulnerabilities.some(r=>!ae(r.id,t,r.aliases))).length>0||kt(n))&&(process.exitCode=1),Pe(e,t,a,n)},$t=async(e,t)=>{if(!process.stdin.isTTY)return t;const i=Mt({input:process.stdin,output:process.stderr});try{const a="[y/N]",n=await new Promise(o=>{i.question(`${e} ${D(a)} `,r=>{o(r.trim())})});return n.length===0?t:n.toLowerCase().startsWith("y")}finally{i.close()}},Sn=e=>e==="pnpm"||e==="npm"||e==="yarn"||e==="bun",Nn=async e=>{const t=yt({allowMajor:e.allowMajor,findings:e.actionableFindings,workspaceRoot:e.workspaceRoot});if(u.info(""),u.info("─ Apply (direct deps)"),u.info(ka(t)),t.apply.length===0){u.info("Nothing to apply for direct deps.");return}if(De&&!e.yes)return u.error("Refusing to run --fix in CI without --yes. Re-run with --yes once the plan above looks right."),1;if(!e.yes&&!await $t("Apply these direct-dep upgrades?",!1))return u.info("Aborted — no changes made."),0;const i=new Map;for(const a of t.apply){const n=a.workspaceName??"",o=i.get(n);o?o.push(a):i.set(n,[a])}for(const[a,n]of i){const o=n.map(l=>`${l.packageName}@${l.targetSpec}`),r=a.length>0?[a]:[];u.info(`Running ${e.pm.name} add ${o.join(" ")}${a.length>0?` --filter ${a}`:""}`);const c=ti(e.pm,{exact:!1,filter:r,global:!1,optional:!1,packages:o,peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},e.workspaceRoot,console);if(c!==0)return u.error(`${e.pm.name} add exited ${String(c)} — aborting before rescan.`),c}return u.success("Direct-dep upgrades applied. Re-run `vis audit` to confirm the fixes landed."),0},An=async e=>{if(!Sn(e.pm.name))return u.error(`--fix-transitive is not supported for package manager "${e.pm.name}". Use pnpm, npm, yarn, or bun.`),1;const t=!!e.visConfig?.security?.audit?.apply?.transitive?.enabled;if(De&&(!e.yes||!t))return u.error("Refusing to run --fix-transitive in CI without both --yes and security.audit.apply.transitive.enabled = true. Overrides have a higher blast radius than direct bumps — gate on config."),1;const i=new Set(yt({findings:e.actionableFindings,workspaceRoot:e.workspaceRoot}).apply.map(r=>r.packageName)),a=e.actionableFindings.filter(r=>!i.has(r.packageName)),n=fn(a);if(n.entries.length===0){u.info(""),u.info("─ Apply transitive (overrides)"),u.info("Nothing to override — all vulnerable packages are direct deps or have no fixed version.");return}const o=dn(e.workspaceRoot,n,{name:e.pm.name,version:e.pm.version});u.info(""),u.info("─ Apply transitive (overrides)"),u.info(`Target: ${o.filePath} (${o.surface})`);for(const r of o.entries){const c=r.status==="added"?"+":r.status==="updated"?"~":"·",l=r.previousSpec?` (was ${r.previousSpec})`:"";u.info(` ${c} ${r.packageName}: ${r.spec}${l}`)}if(!o.changed){u.info("No changes — overrides already match the plan.");return}if(!e.yes){if(De)return 1;if(!await $t("Write these overrides?",!1))return u.info("Aborted — no changes made."),0}try{gn(o)}catch(r){const c=r instanceof Error?r.message:String(r);return u.error(`Failed to write overrides: ${c}`),1}return u.success(`Wrote ${String(o.entries.filter(r=>r.status!=="unchanged").length)} override${o.entries.length===1?"":"s"}. Run \`${e.pm.name} install\` then re-run \`vis audit\` to confirm the fixes landed.`),0},Jn=async({fs:e,logger:t,options:i,visConfig:a,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");await $n(e,n,i,a)};export{Jn as default,xn as mapSeverityToAube,bn as resolveAuditBackend};
|