@visulima/vis 1.0.0-alpha.19 → 1.0.0-alpha.20
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 +164 -0
- package/LICENSE.md +187 -779
- package/README.md +1 -1
- package/dist/config/index.d.ts +535 -121
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/bin.js +380 -286
- package/dist/packem_chunks/config.js +15 -14
- package/dist/packem_chunks/doctor-probe.js +2 -2
- package/dist/packem_chunks/fix.js +9 -9
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -2
- package/dist/packem_chunks/handler11.js +5 -1
- package/dist/packem_chunks/handler12.js +1 -5
- package/dist/packem_chunks/handler13.js +27 -1
- package/dist/packem_chunks/handler14.js +5 -20
- 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 +1 -5
- package/dist/packem_chunks/handler20.js +5 -2
- package/dist/packem_chunks/handler21.js +2 -18
- package/dist/packem_chunks/handler22.js +2 -1
- package/dist/packem_chunks/handler23.js +18 -1
- package/dist/packem_chunks/handler24.js +1 -5
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +5 -3
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +3 -1
- package/dist/packem_chunks/handler29.js +1 -7
- package/dist/packem_chunks/handler3.js +3 -3
- package/dist/packem_chunks/handler30.js +6 -22
- package/dist/packem_chunks/handler31.js +33 -3
- package/dist/packem_chunks/handler32.js +3 -1
- package/dist/packem_chunks/handler33.js +1 -2
- package/dist/packem_chunks/handler34.js +25 -24
- package/dist/packem_chunks/handler35.js +3 -3
- package/dist/packem_chunks/handler36.js +6 -21
- package/dist/packem_chunks/handler37.js +22 -428
- package/dist/packem_chunks/handler38.js +428 -6
- package/dist/packem_chunks/handler39.js +6 -5
- package/dist/packem_chunks/handler4.js +8 -2
- package/dist/packem_chunks/handler40.js +24 -10
- package/dist/packem_chunks/handler41.js +10 -24
- package/dist/packem_chunks/handler42.js +1 -1
- package/dist/packem_chunks/handler43.js +6 -6
- package/dist/packem_chunks/handler44.js +13 -13
- package/dist/packem_chunks/handler45.js +213 -3
- package/dist/packem_chunks/handler46.js +3 -27
- package/dist/packem_chunks/handler47.js +21 -161
- package/dist/packem_chunks/handler48.js +166 -33
- package/dist/packem_chunks/handler49.js +34 -0
- package/dist/packem_chunks/handler5.js +1 -8
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +2 -1
- package/dist/packem_chunks/heal-accept.js +2 -2
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +16 -16
- package/dist/packem_chunks/index.js +6 -6
- package/dist/packem_chunks/keys-refresh.js +4 -0
- package/dist/packem_chunks/list.js +3 -0
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/prune.js +3 -0
- package/dist/packem_chunks/run.js +1 -0
- package/dist/packem_chunks/status.js +2 -0
- package/dist/packem_chunks/sync.js +2 -0
- package/dist/packem_chunks/sync2.js +2 -0
- package/dist/packem_chunks/tripwire.js +2 -0
- package/dist/packem_shared/advisories-DsynpacV.js +1 -0
- package/dist/packem_shared/{ai-analysis-C_GpXikx.js → ai-analysis-uYuTIIXi.js} +1 -1
- package/dist/packem_shared/{ai-cache-DrCLD4gc.js → ai-cache-DuwHYx2O.js} +1 -1
- package/dist/packem_shared/{ai-fix-CWOz12Om.js → ai-fix-DzrA-dVz.js} +4 -4
- package/dist/packem_shared/applyDefaults-BOVDw1jD.js +1 -0
- package/dist/packem_shared/build-scripts-DsWMSWDs.js +1 -0
- package/dist/packem_shared/{cache-directory-C_U1qsIw.js → cache-directory-DQak1Vjc.js} +1 -1
- package/dist/packem_shared/cyclonedx-CiHXuG8M.js +4 -0
- package/dist/packem_shared/dependency-scan-DC3nAFHS.js +1 -0
- package/dist/packem_shared/{docker-B4s1fjiN.js → docker-B-CIN_nj.js} +19 -19
- package/dist/packem_shared/{failure-log-CSC6KfcO.js → failure-log-C3LEMmkq.js} +1 -1
- package/dist/packem_shared/{flakiness-DUtrm-wS.js → flakiness-Dq6K4ymq.js} +1 -1
- package/dist/packem_shared/glob-MHJQjR39-CQ2GC0b_.js +1 -0
- package/dist/packem_shared/{lifecycle-CgK8pcfa.js → lifecycle-Dv3nAtoD.js} +2 -2
- package/dist/packem_shared/{lockfile-i-qvq_k8.js → lockfile-C5DYMHVq.js} +1 -1
- package/dist/packem_shared/manifests-B0fMp872.js +1 -0
- package/dist/packem_shared/min-release-age-BFozFonQ.js +34 -0
- package/dist/packem_shared/native-config-sync-Dvi1g2nQ.js +21 -0
- package/dist/packem_shared/registry-keys-CewRFW0e.js +1 -0
- package/dist/packem_shared/resolve-explicit-CC4Kifk5.js +5 -0
- package/dist/packem_shared/{run-summary-utils-CJv75pla.js → run-summary-utils-BaBGP3bo.js} +1 -1
- package/dist/packem_shared/{runtime-check-CBU6W8qG.js → runtime-check-BusAwPb2.js} +1 -1
- package/dist/packem_shared/scan-progress-CMynp3eA.js +2 -0
- package/dist/packem_shared/signatures-5ZdjJ2Pu.js +2 -0
- package/dist/packem_shared/{toolchain-B7dckBQ1.js → toolchain-Cc3cwyLP.js} +3 -3
- package/dist/packem_shared/typosquats-BCeR-sLf.js +1 -0
- package/dist/packem_shared/verify-07kUNTuP.js +1 -0
- package/dist/packem_shared/{vis-update-app-D0uL3eO5.js → vis-update-app-CFrlJ3mW.js} +1 -1
- package/index.d.ts +358 -0
- package/index.js +56 -53
- package/package.json +14 -13
- package/schemas/vis-config.schema.json +595 -100
- package/dist/packem_shared/applyDefaults-DLY94gWA.js +0 -1
- package/dist/packem_shared/dependency-scan-YdgNVvoz.js +0 -2
- package/dist/packem_shared/readTomlSync-1fKo0R52-DtxWULlF.js +0 -109
- package/dist/packem_shared/typosquats-B3A38-qx.js +0 -1
- package/dist/packem_shared/verify-WDStBFvK.js +0 -1
|
@@ -1,3 +1,213 @@
|
|
|
1
|
-
var
|
|
2
|
-
`,"utf8")},"writeDevcontainerJson");var Er=Object.defineProperty,Ir=y((n,e)=>Er(n,"name",{value:e,configurable:!0}),"s$5");const Tr={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],deno:[{source:"${localWorkspaceFolderBasename}-deno-cache",target:"/home/node/.cache/deno",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},Pr=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],xe=Ir((n,e,s)=>{const l=[],a=new Set(s.map(d=>typeof d=="string"?d:d.target));if(n)for(const d of Tr[n])a.has(d.target)||l.push(d);const o=Object.keys(e);for(const{featureMatch:d,mounts:g}of Pr)if(o.some(f=>f.includes(d)))for(const f of g)a.has(f.target)||l.push(f);return l},"getSuggestedMounts"),A=["general","features","ports","lifecycle","extensions","environment","mounts","compose"];var Dr=Object.defineProperty,ee=y((n,e)=>Dr(n,"name",{value:e,configurable:!0}),"c$1");const J=ee(n=>structuredClone(n),"deepClone");class jr{static{y(this,"DevcontainerStore")}static{ee(this,"DevcontainerStore")}#o=new Set;#e;constructor(e,s,l=null){const a=e===null,o=e??{name:""},d=J(o);this.#e={config:d,detectedPm:l,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:s,isDirty:!1,mode:a?"create":"edit",originalConfig:a?null:J(o),section:"general",showTemplateSelector:a,suggestedMounts:xe(l,d.features??{},d.mounts??[]),templateIndex:0}}getSnapshot=ee(()=>this.#e,"getSnapshot");subscribe=ee(e=>(this.#o.add(e),()=>{this.#o.delete(e)}),"subscribe");setSection(e){e!==this.#e.section&&this.#r({...this.#e,fieldEditing:!1,fieldIndex:0,section:e})}nextSection(){const e=(A.indexOf(this.#e.section)+1)%A.length;this.setSection(A[e])}previousSection(){const e=(A.indexOf(this.#e.section)-1+A.length)%A.length;this.setSection(A[e])}setFieldIndex(e){e!==this.#e.fieldIndex&&this.#r({...this.#e,fieldIndex:Math.max(0,e)})}setFieldEditing(e){e!==this.#e.fieldEditing&&this.#r({...this.#e,fieldEditing:e})}setTemplateIndex(e){const s=Math.max(0,Math.min(e,$.length-1));s!==this.#e.templateIndex&&this.#r({...this.#e,templateIndex:s})}applyTemplate(e){const s=$.find(l=>l.id===e);s&&this.#r(this.#t({...this.#e,config:J(s.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#r({...this.#e,showTemplateSelector:!1})}updateConfig(e){this.#r({...this.#e,config:{...this.#e.config,...e},isDirty:!0})}toggleFeature(e){const s={...this.#e.config.features};s[e]===void 0?s[e]={}:delete s[e],this.#r(this.#t({...this.#e,config:{...this.#e.config,features:s},isDirty:!0}))}setFeatureSearch(e){this.#r({...this.#e,featureSearch:e,fieldIndex:0})}addPort(e){const s=this.#e.config.forwardPorts??[];if(s.includes(e))return;const l=[...s,e];this.#r({...this.#e,config:{...this.#e.config,forwardPorts:l},isDirty:!0})}removePort(e){const s=[...this.#e.config.forwardPorts??[]];s.splice(e,1),this.#r({...this.#e,config:{...this.#e.config,forwardPorts:s.length>0?s:void 0},isDirty:!0})}toggleExtension(e){const s={...this.#e.config.customizations},l={...s.vscode},a=[...l.extensions??[]],o=a.indexOf(e);o===-1?a.push(e):a.splice(o,1),l.extensions=a.length>0?a:void 0,s.vscode=l.extensions||l.settings?l:void 0,this.#r({...this.#e,config:{...this.#e.config,customizations:s.vscode||s.jetbrains?s:void 0},isDirty:!0})}setExtensionSearch(e){this.#r({...this.#e,extensionSearch:e,fieldIndex:0})}addEnvVar(e,s,l){const a=e==="container"?"containerEnv":"remoteEnv",o={...this.#e.config[a],[s]:l};this.#r({...this.#e,config:{...this.#e.config,[a]:o},isDirty:!0})}removeEnvVar(e,s){const l=e==="container"?"containerEnv":"remoteEnv",a={...this.#e.config[l]};delete a[s],this.#r({...this.#e,config:{...this.#e.config,[l]:Object.keys(a).length>0?a:void 0},isDirty:!0})}addMount(e){const s=[...this.#e.config.mounts??[],e];this.#r(this.#t({...this.#e,config:{...this.#e.config,mounts:s},isDirty:!0}))}removeMount(e){const s=[...this.#e.config.mounts??[]];s.splice(e,1),this.#r(this.#t({...this.#e,config:{...this.#e.config,mounts:s.length>0?s:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const e=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#r(this.#t({...this.#e,config:{...this.#e.config,mounts:e},isDirty:!0}))}setLifecycleCommand(e,s){this.#r({...this.#e,config:{...this.#e.config,[e]:s||void 0},isDirty:!0})}markClean(){this.#r({...this.#e,isDirty:!1,originalConfig:J(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const e=J(this.#e.config);for(const[s,l]of Object.entries(e))(l===""||l===void 0)&&delete e[s];return e.build&&(e.build.dockerfile===""&&delete e.build.dockerfile,e.build.context===""&&delete e.build.context,e.build.args&&Object.keys(e.build.args).length===0&&delete e.build.args,Object.keys(e.build).length===0&&delete e.build),e.forwardPorts?.length===0&&delete e.forwardPorts,e.mounts?.length===0&&delete e.mounts,e.runServices?.length===0&&delete e.runServices,e.capAdd?.length===0&&delete e.capAdd,e.securityOpt?.length===0&&delete e.securityOpt,e.features&&Object.keys(e.features).length===0&&delete e.features,e.customizations?.vscode?.extensions?.length===0&&delete e.customizations.vscode.extensions,e.customizations?.vscode&&Object.keys(e.customizations.vscode).length===0&&delete e.customizations.vscode,e.customizations&&Object.keys(e.customizations).length===0&&delete e.customizations,e.containerEnv&&Object.keys(e.containerEnv).length===0&&delete e.containerEnv,e.remoteEnv&&Object.keys(e.remoteEnv).length===0&&delete e.remoteEnv,e}#t(e){return{...e,suggestedMounts:xe(e.detectedPm,e.config.features??{},e.config.mounts??[])}}#r(e){this.#e=e;for(const s of this.#o)try{s()}catch{}}}const Ce=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],ke=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}];var Or=Object.defineProperty,Fe=y((n,e)=>Or(n,"name",{value:e,configurable:!0}),"r$1");const me=Fe(n=>{if(!n)return ke;const e=n.toLowerCase();return ke.filter(s=>s.name.toLowerCase().includes(e)||s.id.toLowerCase().includes(e)||s.description.toLowerCase().includes(e))},"filterFeatures"),ge=Fe(n=>{if(!n)return Ce;const e=n.toLowerCase();return Ce.filter(s=>s.name.toLowerCase().includes(e)||s.id.toLowerCase().includes(e)||s.description.toLowerCase().includes(e))},"filterExtensions");var Fr=Object.defineProperty,Ar=y((n,e)=>Fr(n,"name",{value:e,configurable:!0}),"l$1");const Ae=["dockerComposeFile","service"],Lr={dockerComposeFile:"Compose File",service:"Service"},Se={dockerComposeFile:"docker-compose.yml",service:"app"},Mr={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},Br=Ar(({config:n,fieldEditing:e,fieldIndex:s,onUpdate:l})=>{const a=!!n.dockerComposeFile,o=!!(n.image||n.build);return i(c,{flexDirection:"column",paddingX:1,children:[r(c,{marginBottom:1,children:r(t,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),o&&a&&r(c,{marginBottom:1,children:r(t,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ae.map((d,g)=>{const f=g===s,p=n[d]??"",x=Array.isArray(n[d])?n[d].join(", "):p;return i(c,{flexDirection:"column",marginBottom:1,children:[i(c,{children:[r(c,{width:20,children:i(t,{bold:f,color:f?"cyan":"white",children:[f?"❯ ":" ",Lr[d],":"]})}),r(c,{flexGrow:1,children:f&&e?r(he,{defaultValue:x,onChange:y(v=>{l({[d]:v||void 0})},"onChange"),placeholder:Se[d]}):r(t,{color:x?"white":"gray",children:x||Se[d]})})]}),r(c,{paddingLeft:4,children:r(t,{dimColor:!0,children:Mr[d]})})]},d)}),r(c,{marginTop:1,children:i(t,{dimColor:!0,children:[r(t,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",r(t,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",r(t,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},"DockerComposeSection"),Nr=Ae.length;var $r=Object.defineProperty,Le=y((n,e)=>$r(n,"name",{value:e,configurable:!0}),"h$2");const zr=Le(({config:n,fieldIndex:e})=>{const s=n.containerEnv??{},l=n.remoteEnv??{},a=Object.keys(s),o=Object.keys(l),d=a.length,g=a.length+1,f=g+o.length,p=e<=d,x=e>d;return i(c,{flexDirection:"column",paddingX:1,children:[i(c,{borderColor:p?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[i(c,{flexShrink:0,marginBottom:a.length>0?1:0,children:[r(t,{bold:!0,color:p?"cyan":"white",children:"containerEnv"}),r(t,{dimColor:!0,children:" — baked into the container image"})]}),a.map((v,w)=>{const k=w===e;return r(c,{flexShrink:0,children:i(t,{color:k?"cyan":void 0,inverse:k,wrap:"truncate",children:[k?" ❯ ":" ",r(t,{bold:!0,children:v}),r(t,{dimColor:!0,children:" = "}),r(t,{children:s[v]})]})},v)}),r(c,{flexShrink:0,marginTop:a.length>0?1:0,children:i(t,{color:e===d?"cyan":"gray",inverse:e===d,children:[" ","+ Add variable..."]})})]}),i(c,{borderColor:x?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[i(c,{flexShrink:0,marginBottom:o.length>0?1:0,children:[r(t,{bold:!0,color:x?"cyan":"white",children:"remoteEnv"}),r(t,{dimColor:!0,children:" — set at runtime by the IDE"})]}),o.map((v,w)=>{const k=g+w===e;return r(c,{flexShrink:0,children:i(t,{color:k?"cyan":void 0,inverse:k,wrap:"truncate",children:[k?" ❯ ":" ",r(t,{bold:!0,children:v}),r(t,{dimColor:!0,children:" = "}),r(t,{children:l[v]})]})},v)}),r(c,{flexShrink:0,marginTop:o.length>0?1:0,children:i(t,{color:e===f?"cyan":"gray",inverse:e===f,children:[" ","+ Add variable..."]})})]}),r(c,{flexShrink:0,marginTop:1,children:i(t,{dimColor:!0,wrap:"truncate",children:[r(t,{bold:!0,color:"white",children:"a"}),"/",r(t,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",r(t,{bold:!0,color:"white",children:"d"})," ","remove"," ",r(t,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},"EnvironmentSection"),Gr=Le(n=>{const e=Object.keys(n.containerEnv??{}).length,s=Object.keys(n.remoteEnv??{}).length;return e+1+s+1},"getEnvFieldCount");var Rr=Object.defineProperty,_r=y((n,e)=>Rr(n,"name",{value:e,configurable:!0}),"g$2");const Wr=_r(({config:n,fieldIndex:e,scrollOffset:s,searchText:l,viewportHeight:a})=>{const o=q(()=>new Set(n.customizations?.vscode?.extensions),[n.customizations?.vscode?.extensions]),d=q(()=>ge(l),[l]),g=d.length,f=g>a&&a>0;return i(c,{flexDirection:"column",flexGrow:1,children:[i(c,{flexShrink:0,gap:1,paddingX:1,children:[i(t,{bold:!0,color:"cyan",children:[o.size," ","selected"]}),l&&i(t,{dimColor:!0,children:["— filter:"," ",r(t,{color:"yellow",children:l})," ","(",d.length," ","results)"]})]}),i(c,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[r(c,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:r(c,{flexDirection:"column",marginTop:-s,children:d.map((p,x)=>{const v=x===e,w=o.has(p.id);return i(c,{flexShrink:0,height:1,children:[r(t,{children:v?">":" "}),i(t,{color:w?"white":"gray",children:[" ",w?"☑":"☐"," "]}),r(c,{flexGrow:1,children:i(t,{bold:v,inverse:v,wrap:"truncate",children:[p.name,i(t,{dimColor:!0,children:[" ","-",p.id]})]})})]},p.id)})})}),f&&r(c,{flexShrink:0,marginLeft:1,marginRight:1,children:r(je,{contentHeight:g,placement:"inset",scrollOffset:s,style:"block",viewportHeight:a})})]}),d.length===0&&r(c,{paddingX:1,children:r(t,{dimColor:!0,children:"No extensions match the search."})})]})},"ExtensionsSection");var Ur=Object.defineProperty,Xr=y((n,e)=>Ur(n,"name",{value:e,configurable:!0}),"g$1");const Vr=Xr(({config:n,fieldIndex:e,scrollOffset:s,searchText:l,viewportHeight:a})=>{const o=q(()=>new Set(Object.keys(n.features??{})),[n.features]),d=q(()=>me(l),[l]),g=d.length,f=g>a&&a>0;return i(c,{flexDirection:"column",flexGrow:1,children:[i(c,{flexShrink:0,gap:1,paddingX:1,children:[i(t,{bold:!0,color:"cyan",children:[o.size," ","selected"]}),l&&i(t,{dimColor:!0,children:["— filter:"," ",r(t,{color:"yellow",children:l})," ","(",d.length," ","results)"]})]}),i(c,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[r(c,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:r(c,{flexDirection:"column",marginTop:-s,children:d.map((p,x)=>{const v=x===e,w=o.has(p.id);return i(c,{flexShrink:0,height:1,children:[r(t,{children:v?">":" "}),i(t,{color:w?"white":"gray",children:[" ",w?"☑":"☐"," "]}),r(c,{flexGrow:1,children:i(t,{bold:v,inverse:v,wrap:"truncate",children:[p.name,i(t,{dimColor:!0,children:[" ","-",p.description]})]})})]},p.id)})})}),f&&r(c,{flexShrink:0,marginLeft:1,marginRight:1,children:r(je,{contentHeight:g,placement:"inset",scrollOffset:s,style:"block",viewportHeight:a})})]}),d.length===0&&r(c,{paddingX:1,children:r(t,{dimColor:!0,children:"No features match the search."})})]})},"FeaturesSection");var Hr=Object.defineProperty,Jr=y((n,e)=>Hr(n,"name",{value:e,configurable:!0}),"u$1");const ue=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],qr={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},Ee={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},re=["privileged","overrideCommand"],Yr={overrideCommand:"Override Command",privileged:"Privileged"},Kr=ue.length+re.length,Qr=Jr(({config:n,fieldEditing:e,fieldIndex:s,onUpdate:l})=>i(c,{flexDirection:"column",paddingX:1,children:[r(c,{marginBottom:1,children:r(t,{bold:!0,color:"cyan",children:"General Configuration"})}),ue.map((a,o)=>{const d=o===s,g=n[a]??"";return i(c,{marginBottom:1,children:[r(c,{width:20,children:i(t,{bold:d,color:d?"cyan":"white",children:[d?"❯ ":" ",qr[a],":"]})}),r(c,{flexGrow:1,children:d&&e?r(he,{defaultValue:g,onChange:y(f=>{l({[a]:f})},"onChange"),placeholder:Ee[a]}):r(t,{color:g?"white":"gray",children:g||Ee[a]})})]},a)}),re.map((a,o)=>{const d=ue.length+o===s,g=n[a]??!1;return i(c,{marginBottom:o<re.length-1?1:0,children:[r(c,{width:20,children:i(t,{bold:d,color:d?"cyan":"white",children:[d?"❯ ":" ",Yr[a],":"]})}),r(c,{flexGrow:1,children:i(t,{color:g?"green":"gray",children:[g?"yes":"no",d&&r(t,{dimColor:!0,children:" (Space to toggle)"})]})})]},a)}),r(c,{marginTop:1,children:i(t,{dimColor:!0,children:[r(t,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",r(t,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",r(t,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",r(t,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),"GeneralSection"),Me=Kr,le=re;var Zr=Object.defineProperty,et=y((n,e)=>Zr(n,"name",{value:e,configurable:!0}),"s$3");const Be=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],rt={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},tt={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},ot=et(({config:n,fieldEditing:e,fieldIndex:s,onSetCommand:l})=>i(c,{flexDirection:"column",paddingX:1,children:[r(c,{marginBottom:1,children:r(t,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),Be.map((a,o)=>{const d=o===s,g=n[a],f=Array.isArray(g)?g.join(" && "):g??"";return i(c,{flexDirection:"column",marginBottom:1,children:[r(c,{children:i(t,{bold:d,color:d?"cyan":"white",children:[d?"❯ ":" ",rt[a]]})}),r(c,{paddingLeft:4,children:r(t,{dimColor:!0,children:tt[a]})}),r(c,{paddingLeft:4,children:d&&e?r(he,{defaultValue:f,onChange:y(p=>{l(a,p)},"onChange"),placeholder:"e.g. npm install"}):r(t,{color:f?"green":"gray",children:f||"(not set)"})})]},a)}),r(c,{marginTop:1,children:i(t,{dimColor:!0,children:[r(t,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",r(t,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",r(t,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),"LifecycleSection"),nt=Be.length;var it=Object.defineProperty,Ne=y((n,e)=>it(n,"name",{value:e,configurable:!0}),"s$2");const Ie=Ne(n=>typeof n=="string"?n:`[${n.type}] ${n.source} → ${n.target}`,"formatMount"),ct=Ne(({addingMount:n,config:e,detectedPm:s,fieldIndex:l,mountPhase:a,mountSource:o,mountTarget:d,mountType:g,suggestedMounts:f})=>{const p=e.mounts??[];return i(c,{flexDirection:"column",paddingX:1,children:[i(c,{flexShrink:0,gap:1,paddingX:1,children:[i(t,{bold:!0,color:"cyan",children:[p.length," ","mounts"]}),s&&i(t,{dimColor:!0,children:["— detected:"," ",r(t,{color:"white",children:s})]})]}),f.length>0&&!n&&i(c,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[i(c,{flexShrink:0,children:[r(t,{bold:!0,color:"yellow",children:"Suggested mounts"}),i(t,{dimColor:!0,children:[" ","— press"," ",r(t,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),f.map((x,v)=>r(c,{flexShrink:0,children:i(t,{dimColor:!0,wrap:"truncate",children:[" + ",Ie(x)]})},`suggestion-${String(v)}`))]}),p.length>0&&r(c,{flexDirection:"column",marginBottom:1,children:p.map((x,v)=>{const w=v===l;return i(c,{flexShrink:0,height:1,children:[r(t,{children:w?">":" "}),r(c,{flexGrow:1,children:i(t,{bold:w,inverse:w,wrap:"truncate",children:[" ",Ie(x)]})})]},`mount-${String(v)}`)})}),!n&&r(c,{flexShrink:0,children:i(t,{color:l===p.length?"cyan":"gray",inverse:l===p.length,children:[" ","+ Add mount..."]})}),n&&i(c,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[r(c,{flexShrink:0,marginBottom:1,children:r(t,{bold:!0,color:"cyan",children:"New Mount"})}),i(c,{flexShrink:0,children:[r(c,{width:12,children:i(t,{bold:a==="source",color:a==="source"?"cyan":"white",children:[a==="source"?"❯ ":" ","Source:"]})}),r(t,{color:o?"yellow":"gray",children:o||(a==="source"?"_":"(type source, Enter to continue)")})]}),i(c,{flexShrink:0,children:[r(c,{width:12,children:i(t,{bold:a==="target",color:a==="target"?"cyan":"white",children:[a==="target"?"❯ ":" ","Target:"]})}),r(t,{color:d?"yellow":"gray",children:d||(a==="target"?"_":"/container/path")})]}),i(c,{flexShrink:0,children:[r(c,{width:12,children:i(t,{bold:a==="type",color:a==="type"?"cyan":"white",children:[a==="type"?"❯ ":" ","Type:"]})}),a==="type"?i(t,{children:[r(t,{bold:g==="volume",color:g==="volume"?"cyan":"gray",children:"[1] volume"})," ",r(t,{bold:g==="bind",color:g==="bind"?"cyan":"gray",children:"[2] bind"})," ",r(t,{bold:g==="tmpfs",color:g==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):r(t,{color:"gray",children:g})]}),r(c,{flexShrink:0,marginTop:1,children:r(t,{dimColor:!0,wrap:"truncate",children:a==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),p.length===0&&!n&&f.length===0&&r(c,{marginTop:1,children:r(t,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},"MountsSection");var st=Object.defineProperty,at=y((n,e)=>st(n,"name",{value:e,configurable:!0}),"s$1");const lt=at(({addingPort:n,addPortValue:e,config:s,fieldIndex:l})=>{const a=s.forwardPorts??[],o=l===a.length;return i(c,{flexDirection:"column",paddingX:1,children:[i(c,{marginBottom:1,children:[r(t,{bold:!0,color:"cyan",children:"Forwarded Ports"}),i(t,{dimColor:!0,children:[" ","(",a.length," ","ports)"]})]}),a.map((d,g)=>{const f=g===l;return r(c,{children:i(t,{color:f?"cyan":void 0,inverse:f,children:[" ",String(d)]})},`port-${String(d)}`)}),r(c,{marginTop:a.length>0?1:0,children:i(t,{color:o?"cyan":"gray",inverse:o,children:[" ",o&&n?i(t,{children:["Enter port:"," ",r(t,{color:"yellow",children:e||"_"})]}):"+ Add port..."]})}),r(c,{marginTop:1,children:i(t,{dimColor:!0,children:[r(t,{bold:!0,color:"white",children:"Enter"})," ",o?"type port number, Enter to confirm":"select"," ",r(t,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",r(t,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},"PortsSection");var dt=Object.defineProperty,ut=y((n,e)=>dt(n,"name",{value:e,configurable:!0}),"a");const ht=ut(({focused:n,hadComments:e,jsonPreview:s,mode:l,scrollRef:a})=>i(c,{borderColor:n?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i(c,{flexShrink:0,paddingX:1,children:[r(t,{bold:!0,color:n?"cyan":"white",children:"Preview"}),i(t,{dimColor:!0,children:[" ","(",l==="create"?"new":"edit",")"]})]}),e&&l==="edit"&&r(c,{flexShrink:0,paddingX:1,children:r(t,{color:"yellow",children:"Comments will not be preserved."})}),r(gr,{flexGrow:1,ref:a,scrollbar:!0,scrollbarColor:"gray",children:s.split(`
|
|
3
|
-
`).map((o,d)=>r(t,{color:"green",children:o},`line-${String(d)}`))})]}),"PreviewPanel");var mt=Object.defineProperty,gt=y((n,e)=>mt(n,"name",{value:e,configurable:!0}),"r");const ft=gt(n=>{const e=[],s=[],l=[];if(!n.image&&!n.build&&!n.dockerComposeFile&&e.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),n.build&&(n.image&&s.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),n.build.dockerfile||e.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),n.dockerComposeFile&&!n.service&&e.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),n.features!==void 0&&(typeof n.features!="object"||Array.isArray(n.features))&&e.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),n.forwardPorts)if(Array.isArray(n.forwardPorts))for(const[a,o]of n.forwardPorts.entries())typeof o=="number"&&(o<1||o>65535)&&e.push({field:"forwardPorts",message:`Invalid port ${String(o)} at index ${String(a)}`});else e.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return n.customizations?.vscode?.extensions&&!Array.isArray(n.customizations.vscode.extensions)&&e.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),n.customizations?.vscode?.settings&&typeof n.customizations.vscode.settings!="object"&&e.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),n.name||l.push({field:"name",message:"Consider adding a name for better identification"}),(!n.features||Object.keys(n.features).length===0)&&l.push({field:"features",message:"Consider adding features for common tools"}),(!n.customizations?.vscode?.extensions||n.customizations.vscode.extensions.length===0)&&l.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),n.privileged&&s.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:e,suggestions:l,valid:e.length===0,warnings:s}},"validateConfig");var pt=Object.defineProperty,$e=y((n,e)=>pt(n,"name",{value:e,configurable:!0}),"$");const Te=80,Pe=15,vt=120,ze=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],yt=new Map(ze.map(n=>[n.id,n.description])),bt=$e((n,e,s,l)=>{switch(n){case"compose":return Nr;case"environment":return Gr(e);case"extensions":return ge(l).length;case"features":return me(s).length;case"general":return Me;case"lifecycle":return nt;case"mounts":return(e.mounts?.length??0)+1;case"ports":return(e.forwardPorts?.length??0)+1;default:return 0}},"getFieldCount"),wt=$e(({onSave:n,store:e})=>{const{exit:s}=hr(),{columns:l,rows:a}=mr(),o=rr(e.subscribe,e.getSnapshot),[d,g]=C(!1),[f,p]=C(!1),[x,v]=C(!1),[w,k]=C(null),[S,D]=C("editor"),[Y,fe]=C(0),[te,oe]=C(!1),[pe,z]=C(""),[G,R]=C(null),[_,j]=C(""),[ve,O]=C(""),[W,L]=C("key"),[ne,K]=C(!1),[ie,M]=C(""),[ce,B]=C(""),[ye,U]=C("volume"),[I,N]=C("source"),se=Z(null),F=Z(null),P=Z(null),Q=Z(!0);ae(()=>(Q.current=!0,()=>{Q.current=!1,P.current&&clearTimeout(P.current)}),[]);const be=bt(o.section,o.config,o.featureSearch,o.extensionSearch),X=Math.max(1,a-9);ae(()=>{o.section!=="features"&&o.section!=="extensions"||fe(h=>o.fieldIndex>=h+X?o.fieldIndex-X+1:o.fieldIndex<h?o.fieldIndex:h)},[o.fieldIndex,o.section,X]),ae(()=>{fe(0)},[o.section,o.featureSearch,o.extensionSearch]);const Ge=tr(()=>{const h=e.cleanConfig(),m=ft(h);if(!m.valid){const b=m.errors[0];k(b?`Error: ${b.message}`:"Validation failed"),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{Q.current&&k(null)},3e3);return}n(h),e.markClean();const u=m.warnings.length;k(u>0?`Saved! (${String(u)} warning${u>1?"s":""})`:"Saved!"),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{Q.current&&k(null)},2e3)},[n,e]);H((h,m)=>{if(m.downArrow||h==="j")e.setTemplateIndex(o.templateIndex+1);else if(m.upArrow||h==="k")e.setTemplateIndex(o.templateIndex-1);else if(m.return){const u=$[o.templateIndex];u&&e.applyTemplate(u.id)}else m.escape&&e.dismissTemplateSelector()},{isActive:o.showTemplateSelector}),H((h,m)=>{if(m.escape){oe(!1),z("");return}if(m.return){const u=Number.parseInt(pe,10);!Number.isNaN(u)&&u>0&&u<=65535&&e.addPort(u),oe(!1),z("");return}if(m.backspace){z(u=>u.slice(0,-1));return}h&&/^\d$/u.test(h)&&z(u=>u+h)},{isActive:te}),H((h,m)=>{if(m.escape){R(null),j(""),O(""),L("key");return}if(m.return){if(W==="key"&&_){L("value");return}if(W==="value"&&_){e.addEnvVar(G,_,ve),R(null),j(""),O(""),L("key");return}}if(m.backspace){W==="key"?j(u=>u.slice(0,-1)):O(u=>u.slice(0,-1));return}h&&!m.ctrl&&!m.meta&&(W==="key"?j(u=>u+h):O(u=>u+h))},{isActive:G!==null}),H((h,m)=>{if(m.escape){K(!1),M(""),B(""),N("source");return}if(m.return){if(I==="source"&&ie){N("target");return}if(I==="target"&&ce){N("type");return}if(I==="type"){e.addMount({source:ie,target:ce,type:ye}),K(!1),M(""),B(""),N("source");return}}if(I==="type"){switch(h){case"1":{U("volume");break}case"2":{U("bind");break}case"3":{U("tmpfs");break}}return}if(m.backspace){I==="source"?M(u=>u.slice(0,-1)):I==="target"&&B(u=>u.slice(0,-1));return}h&&!m.ctrl&&!m.meta&&(I==="source"?M(u=>u+h):I==="target"&&B(u=>u+h))},{isActive:ne}),H((h,m)=>{if(h==="c"&&m.ctrl){s();return}if(!f){if(d){m.escape||h==="?"?g(!1):m.downArrow||h==="j"?se.current?.scrollBy(1):m.upArrow||h==="k"?se.current?.scrollBy(-1):h==="q"&&(g(!1),p(!0));return}if(x){if(m.escape){v(!1),o.section==="features"?e.setFeatureSearch(""):e.setExtensionSearch("");return}if(m.return){v(!1);return}if(m.backspace){o.section==="features"?e.setFeatureSearch(o.featureSearch.slice(0,-1)):e.setExtensionSearch(o.extensionSearch.slice(0,-1));return}if(h&&!m.ctrl&&!m.meta){o.section==="features"?e.setFeatureSearch(o.featureSearch+h):e.setExtensionSearch(o.extensionSearch+h);return}return}if(o.fieldEditing){if(m.escape){e.setFieldEditing(!1);return}if(m.return){e.setFieldEditing(!1);return}return}if(h==="?"){g(!0);return}if(h==="q"){o.isDirty?p(!0):s();return}if(h==="s"){Ge();return}if(m.tab){D(u=>u==="editor"?"preview":"editor");return}if(S==="preview"){if(m.downArrow||h==="j"){F.current?.scrollBy(1);return}if(m.upArrow||h==="k"){F.current?.scrollBy(-1);return}if(m.pageDown){F.current?.scrollBy(10);return}if(m.pageUp){F.current?.scrollBy(-10);return}if(m.home){F.current?.scrollToTop();return}if(m.end){F.current?.scrollToBottom();return}m.escape&&D("editor");return}if(m.downArrow||h==="j"){be>0&&e.setFieldIndex(Math.min(o.fieldIndex+1,be-1));return}if(m.upArrow||h==="k"){e.setFieldIndex(Math.max(o.fieldIndex-1,0));return}if(m.return){switch(o.section){case"compose":case"general":case"lifecycle":{e.setFieldEditing(!0);break}case"environment":{const u=Object.keys(o.config.containerEnv??{}).length,b=u,T=u+1+Object.keys(o.config.remoteEnv??{}).length;o.fieldIndex===b?(R("container"),j(""),O(""),L("key")):o.fieldIndex===T&&(R("remote"),j(""),O(""),L("key"));break}case"mounts":{const u=o.config.mounts??[];o.fieldIndex===u.length&&(K(!0),M(""),B(""),U("volume"),N("source"));break}case"ports":{const u=o.config.forwardPorts??[];o.fieldIndex===u.length&&(oe(!0),z(""));break}}return}if(h===" "){switch(o.section){case"extensions":{const u=ge(o.extensionSearch)[o.fieldIndex];u&&e.toggleExtension(u.id);break}case"features":{const u=me(o.featureSearch)[o.fieldIndex];u&&e.toggleFeature(u.id);break}case"general":{const u=Me-le.length,b=o.fieldIndex-u;if(b>=0&&b<le.length){const T=le[b];e.updateConfig({[T]:!o.config[T]})}break}}return}if(h==="/"){(o.section==="features"||o.section==="extensions")&&v(!0);return}if(h==="A"&&o.section==="mounts"){e.applySuggestedMounts();return}if(h==="a"){if(o.section==="environment"){const u=Object.keys(o.config.containerEnv??{}).length,b=o.fieldIndex<=u?"container":"remote";R(b),j(""),O(""),L("key")}else o.section==="mounts"&&(K(!0),M(""),B(""),U("volume"),N("source"));return}if(h==="d")switch(o.section){case"environment":{const u=Object.keys(o.config.containerEnv??{}),b=Object.keys(o.config.remoteEnv??{});if(o.fieldIndex<u.length)e.removeEnvVar("container",u[o.fieldIndex]),u.length===1||o.fieldIndex>=u.length-1&&e.setFieldIndex(u.length-2);else{const T=o.fieldIndex-u.length-1;T>=0&&T<b.length&&(e.removeEnvVar("remote",b[T]),b.length===1||T>=b.length-1&&e.setFieldIndex(o.fieldIndex-1))}break}case"mounts":{const u=o.config.mounts??[];if(o.fieldIndex<u.length){e.removeMount(o.fieldIndex);const b=u.length-1;o.fieldIndex>=b&&b>0&&e.setFieldIndex(b-1)}break}case"ports":{const u=o.config.forwardPorts??[];if(o.fieldIndex<u.length){e.removePort(o.fieldIndex);const b=u.length-1;o.fieldIndex>=b&&b>0&&e.setFieldIndex(b-1)}break}}}},{isActive:!o.showTemplateSelector&&!te&&G===null&&!ne});const Re=q(()=>e.getJsonPreview(),[o.config]);if(l<Te||a<Pe)return r(c,{alignItems:"center",height:a,justifyContent:"center",width:l,children:i(t,{color:"yellow",children:["Terminal too small (",l,"x",a,"), need"," ",Te,"x",Pe]})});if(o.showTemplateSelector)return r(c,{alignItems:"center",flexDirection:"column",height:a,justifyContent:"center",width:l,children:i(c,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[r(c,{justifyContent:"center",marginBottom:1,children:r(t,{bold:!0,color:"cyan",children:"Select a Template"})}),$.map((h,m)=>{const u=m===o.templateIndex;return r(c,{children:i(t,{color:u?"cyan":void 0,inverse:u,children:[u?" ❯ ":" ",r(t,{bold:u,children:h.name}),i(t,{dimColor:!0,children:[" ","-",h.description]})]})},h.id)}),r(c,{justifyContent:"center",marginTop:1,children:i(t,{dimColor:!0,children:[r(t,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",r(t,{bold:!0,color:"white",children:"Enter"})," ","select"," ",r(t,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let E;switch(o.section){case"compose":{E=r(Br,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:y(h=>{e.updateConfig(h)},"onUpdate")});break}case"environment":{E=i(c,{flexDirection:"column",children:[r(zr,{config:o.config,fieldIndex:o.fieldIndex}),G!==null&&r(c,{marginTop:1,paddingX:1,children:i(t,{color:"cyan",children:["Add"," ",G," ","env:"," ",W==="key"?i(t,{children:["key=",r(t,{color:"yellow",children:_||"_"})," ","(Enter to set value)"]}):i(t,{children:[_,"=",r(t,{color:"yellow",children:ve||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{E=r(Wr,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:Y,searchText:o.extensionSearch,viewportHeight:X});break}case"features":{E=r(Vr,{config:o.config,fieldIndex:o.fieldIndex,scrollOffset:Y,searchText:o.featureSearch,viewportHeight:X});break}case"general":{E=r(Qr,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onUpdate:y(h=>{e.updateConfig(h)},"onUpdate")});break}case"lifecycle":{E=r(ot,{config:o.config,fieldEditing:o.fieldEditing,fieldIndex:o.fieldIndex,onSetCommand:y((h,m)=>{e.setLifecycleCommand(h,m)},"onSetCommand")});break}case"mounts":{E=r(ct,{addingMount:ne,config:o.config,detectedPm:o.detectedPm,fieldIndex:o.fieldIndex,mountPhase:I,mountSource:ie,mountTarget:ce,mountType:ye,suggestedMounts:o.suggestedMounts});break}case"ports":{E=r(lt,{addingPort:te,addPortValue:pe,config:o.config,fieldIndex:o.fieldIndex});break}default:E=r(t,{children:"Unknown section"})}const _e=i(c,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[i(c,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[i(c,{gap:1,children:[r(t,{bold:!0,color:"white",children:"q"}),r(t,{dimColor:!0,children:"QUIT"})]}),i(c,{gap:1,children:[r(t,{bold:!0,color:"white",children:"?"}),r(t,{dimColor:!0,children:"HELP"})]}),i(c,{gap:1,children:[r(t,{bold:!0,color:"white",children:"↑↓"}),r(t,{dimColor:!0,children:"NAV"})]}),(o.section==="features"||o.section==="extensions")&&i(c,{gap:1,children:[r(t,{bold:!0,color:"white",children:"Space"}),r(t,{dimColor:!0,children:"CHECK"})]}),i(c,{gap:1,children:[r(t,{bold:!0,color:"white",children:"←→"}),r(t,{dimColor:!0,children:"TABS"})]}),i(c,{gap:1,children:[r(t,{bold:!0,color:"white",children:"Tab"}),r(t,{dimColor:!0,children:"PANEL"})]}),(o.section==="features"||o.section==="extensions")&&i(c,{gap:1,children:[r(t,{bold:!0,color:"white",children:"/"}),r(t,{dimColor:!0,children:"FILTER"})]}),i(c,{gap:1,children:[r(t,{bold:!0,color:"white",children:"s"}),r(t,{dimColor:!0,children:"SAVE"})]})]}),i(c,{paddingX:1,children:[w&&i(t,{color:w.startsWith("Error")?"red":"green",children:[w," "]}),o.isDirty&&r(t,{color:"yellow",children:"[modified]"}),!o.isDirty&&!w&&r(t,{dimColor:!0,children:"[saved]"})]})]}),We=i(lr,{footer:i(t,{dimColor:!0,children:[r(t,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",r(t,{bold:!0,color:"white",children:"?"}),"/",r(t,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:se,title:"KEYBOARD SHORTCUTS",visible:d,width:56,children:[i(c,{flexDirection:"column",marginBottom:1,children:[i(c,{marginBottom:1,children:[r(t,{dimColor:!0,children:"── "}),r(t,{bold:!0,color:"white",children:"NAVIGATION"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"←→"}),r(t,{dimColor:!0,children:" Switch tabs"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"↑↓"}),"/",r(t,{bold:!0,color:"white",children:"j/k"}),r(t,{dimColor:!0,children:" Navigate within section"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"Tab"}),r(t,{dimColor:!0,children:" Switch editor/preview panel"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"Enter"}),r(t,{dimColor:!0,children:" Edit selected field"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"Esc"}),r(t,{dimColor:!0,children:" Stop editing / cancel"})]})]}),i(c,{flexDirection:"column",marginBottom:1,children:[i(c,{marginBottom:1,children:[r(t,{dimColor:!0,children:"── "}),r(t,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"Space"}),r(t,{dimColor:!0,children:" Toggle selection"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"/"}),r(t,{dimColor:!0,children:" Search / filter"})]})]}),i(c,{flexDirection:"column",marginBottom:1,children:[i(c,{marginBottom:1,children:[r(t,{dimColor:!0,children:"── "}),r(t,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"a"}),r(t,{dimColor:!0,children:" Add new entry"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"d"}),r(t,{dimColor:!0,children:" Delete selected entry"})]})]}),i(c,{flexDirection:"column",children:[i(c,{marginBottom:1,children:[r(t,{dimColor:!0,children:"── "}),r(t,{bold:!0,color:"white",children:"ACTIONS"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"s"}),r(t,{dimColor:!0,children:" Save configuration"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"q"}),r(t,{dimColor:!0,children:" Quit"})]}),i(t,{children:[" ",r(t,{bold:!0,color:"white",children:"?"}),r(t,{dimColor:!0,children:" Toggle help"})]})]})]}),Ue=r(ht,{focused:S==="preview",hadComments:o.hadComments,jsonPreview:Re,mode:o.mode,scrollRef:F}),we=l>=vt,Xe=we?Math.floor(l*.38):0;return i(c,{flexDirection:"column",height:a,width:l,children:[i(c,{flexShrink:0,gap:1,paddingX:1,children:[r(t,{bold:!0,inverse:!0,children:" VIS "}),i(t,{wrap:"truncate",children:[o.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),r(c,{flexShrink:0,paddingX:1,paddingY:1,children:r(ur,{defaultValue:o.section,keyMap:{useNumbers:!1,useTab:!1},onChange:y(h=>{e.setSection(h),D("editor")},"onChange"),showIndex:!1,children:ze.map(({id:h,label:m})=>r(dr,{name:h,children:m},h))})}),r(c,{flexShrink:0,paddingRight:2,children:r(t,{dimColor:!0,wrap:"truncate",children:yt.get(o.section)??""})}),i(c,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[r(c,{borderColor:S==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:E}),we&&r(c,{flexShrink:0,width:Xe,children:Ue})]}),_e,r(Ke,{autoExitSeconds:3,onCancel:y(()=>{p(!1)},"onCancel"),visible:f}),We]})},"VisDevcontainerApp");var xt=Object.defineProperty,De=y((n,e)=>xt(n,"name",{value:e,configurable:!0}),"c");const Gt=De(async({logger:n,options:e,workspaceRoot:s})=>{if(!s)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const l=s,a=e.template,o=e.output,d=!!process.stdout.isTTY&&!Ze;let g=null;try{g=Qe(l).name}catch{}const f=kr(l);let p=f?.config??null;const x=f?.hadComments??!1;if(a&&!f){const S=$.find(D=>D.id===a);if(!S){const D=$.map(Y=>Y.id).join(", ");throw new Error(`Unknown template "${a}". Valid templates: ${D}`)}p=S.config}if(!d){p?n.info(JSON.stringify(p,null,2)):(n.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const v=setInterval(()=>{},1e3),w=new jr(p,x,g);a&&!f&&w.dismissTemplateSelector();let k=null;if(await Ye(er.createElement(wt,{onSave:De(S=>{Sr(l,S,o),k=S},"onSave"),store:w}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(v),k){const S=o??".devcontainer/devcontainer.json";n.info(`DevContainer config saved to ${S}`)}},"execute");export{Gt as default};
|
|
1
|
+
var wt=Object.defineProperty;var x=(e,t)=>wt(e,"name",{value:t,configurable:!0});import{createRequire as St}from"node:module";import{ay as Rt,u as Ee,ax as U,h as Ot,k as Pt,a9 as G,a$ as Lt,E as j,e as fe,q as tt,bu as st,a as Ie,a8 as jt,ab as Et,A as It,p as f,i as Dt,J as Wt,T as Mt,N as Ft,y as Ht,m as Vt,ae as Tt,s as Re,af as Ut}from"./bin.js";import{M as H,i as K,$ as ne,B as Ge,n as nt,O as Gt,C as rt}from"./config.js";import{t as _t,n as De,b as qt}from"../packem_shared/cyclonedx-CiHXuG8M.js";import{s as Bt}from"../packem_shared/scan-progress-CMynp3eA.js";import{r as Jt,A as _e,q as qe}from"../packem_shared/advisories-DsynpacV.js";import{L as ot,l as Yt,f as Xt}from"../packem_shared/dependency-scan-DC3nAFHS.js";import{r as Zt}from"../packem_shared/manifests-B0fMp872.js";import{x as Qt}from"../packem_shared/build-scripts-DsWMSWDs.js";import{F as es}from"../packem_shared/lockfile-C5DYMHVq.js";const xt=St(import.meta.url),ee=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,je=x(e=>{if(typeof ee<"u"&&ee.versions&&ee.versions.node){const[t,s]=ee.versions.node.split(".").map(Number);if(t>22||t===22&&s>=3||t===20&&s>=16)return ee.getBuiltinModule(e)}return xt(e)},"__cjs_getBuiltinModule"),{existsSync:Ze,readFileSync:Qe,writeFileSync:et,renameSync:Ct,unlinkSync:At}=je("node:fs"),{createInterface:Nt}=je("node:readline"),{relative:Kt,join:zt}=je("node:path");var ts=Object.defineProperty,ss=x((e,t)=>ts(e,"name",{value:t,configurable:!0}),"t"),ns=Object.defineProperty,rs=ss((e,t)=>ns(e,"name",{value:t,configurable:!0}),"s"),os=Object.defineProperty,is=rs((e,t)=>os(e,"name",{value:t,configurable:!0}),"n");const Ke=is((e,t={})=>{Array.isArray(t.extensions)||(t.extensions=["js","mjs","cjs","ts"]);const s=[];for(const n of Rt(e,t))s.push(n.path);return s},"collectSync");var as=Object.defineProperty,_=x((e,t)=>as(e,"name",{value:t,configurable:!0}),"o$1");const ge=_(e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],"toStringArray"),Oe=_((e,t)=>{for(const s of t)if(s===e||s.endsWith("*")&&e.startsWith(s.slice(0,-1)))return!0;return!1},"matchesGlobList"),it=_(e=>{const t=H(e,"pnpm-workspace.yaml");if(!K(t))return{excludedPackages:[],ignoredAdvisories:[]};try{const s=Ee(t);return{excludedPackages:[],ignoredAdvisories:[...ge(s?.auditConfig?.ignoreCves),...ge(s?.auditConfig?.ignoreGhsas)]}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readPnpmAuditExclusions"),at=_(e=>{const t=H(e,".yarnrc.yml");if(!K(t))return{excludedPackages:[],ignoredAdvisories:[]};try{const s=Ee(t);return{excludedPackages:ge(s?.npmAuditExcludePackages),ignoredAdvisories:ge(s?.npmAuditIgnoreAdvisories)}}catch{return{excludedPackages:[],ignoredAdvisories:[]}}},"readYarnAuditExclusions"),cs=_((e,t)=>{switch(t){case"pnpm":return it(e);case"yarn":return at(e);default:return{excludedPackages:[],ignoredAdvisories:[]}}},"readNativeAuditExclusions"),te=_((e,t,s)=>{if(Oe(e,t.ignoredAdvisories))return!0;if(s){for(const n of s)if(Oe(n,t.ignoredAdvisories))return!0}return!1},"isAdvisoryExcluded"),ls=_((e,t)=>Oe(e,t.excludedPackages),"isPackageExcluded"),ps=_((e,t,s)=>{if(s.length===0)return["No advisory IDs to sync."];const n=[];switch(e){case"bun":{n.push(`bun has no audit config file. Use CLI flags: bun audit ${s.map(r=>`--ignore ${r}`).join(" ")}`);break}case"npm":{n.push("npm has no native audit exclusion config. vis accepted risks are the only layer.");break}case"pnpm":{const r=H(t,"pnpm-workspace.yaml");if(!K(r)){n.push("pnpm-workspace.yaml not found. Cannot sync.");break}const i=it(t),o=new Set(i.ignoredAdvisories.filter($=>$.startsWith("CVE-"))),a=new Set(i.ignoredAdvisories.filter($=>$.startsWith("GHSA-"))),p=s.filter($=>$.startsWith("CVE-")),d=s.filter($=>$.startsWith("GHSA-")),u=[...new Set([...o,...p])],k=[...new Set([...a,...d])],m=p.filter($=>!o.has($)).length,b=d.filter($=>!a.has($)).length;if(m===0&&b===0){n.push("All advisory IDs already present in pnpm-workspace.yaml.");break}let h=ne(r);if(u.length>0){const $=` ignoreCves:
|
|
2
|
+
${u.map(w=>` - ${w}`).join(`
|
|
3
|
+
`)}
|
|
4
|
+
`;/auditConfig:/.test(h)?h=/ignoreCves:/.test(h)?h.replace(/ignoreCves:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,$):h.replace(/auditConfig:\s*\n/,`auditConfig:
|
|
5
|
+
${$}`):h=`${h.trimEnd()}
|
|
6
|
+
|
|
7
|
+
auditConfig:
|
|
8
|
+
${$}`,m>0&&n.push(`Added ${String(m)} new CVE${m===1?"":"s"} to pnpm-workspace.yaml (${String(u.length)} total)`)}if(k.length>0){const $=` ignoreGhsas:
|
|
9
|
+
${k.map(w=>` - ${w}`).join(`
|
|
10
|
+
`)}
|
|
11
|
+
`;/auditConfig:/.test(h)&&(h=/ignoreGhsas:/.test(h)?h.replace(/ignoreGhsas:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,$):h.replace(/(auditConfig:[\s\S]*?)(\n\S|\n?$)/m,`$1${$}$2`)),b>0&&n.push(`Added ${String(b)} new GHSA${b===1?"":"s"} to pnpm-workspace.yaml (${String(k.length)} total)`)}Ge(r,h);break}case"yarn":{const r=H(t,".yarnrc.yml");if(!K(r)){n.push(".yarnrc.yml not found. Cannot sync.");break}const i=at(t),o=new Set(i.ignoredAdvisories),a=[...new Set([...o,...s])],p=s.filter(k=>!o.has(k)).length;if(p===0){n.push("All advisory IDs already present in .yarnrc.yml.");break}let d=ne(r);const u=`npmAuditIgnoreAdvisories:
|
|
12
|
+
${a.map(k=>` - "${k}"`).join(`
|
|
13
|
+
`)}
|
|
14
|
+
`;d=/npmAuditIgnoreAdvisories:/.test(d)?d.replace(/npmAuditIgnoreAdvisories:\s*\n(?:\s+-\s+(?:\S.*|[\t\v\f \u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\n)*/,u):`${d.trimEnd()}
|
|
15
|
+
|
|
16
|
+
${u}`,Ge(r,d),n.push(`Synced ${String(p)} advisor${p===1?"y":"ies"} to .yarnrc.yml (${String(a.length)} total)`);break}default:n.push(`Unknown package manager: ${e}`)}return n},"syncAcceptedRisksToNativeConfig");var ds=Object.defineProperty,z=x((e,t)=>ds(e,"name",{value:t,configurable:!0}),"p$2");const us=["CRITICAL","HIGH","MODERATE","LOW","UNKNOWN"],C=z(e=>e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"),"escapeHtml"),fs=z(e=>e.startsWith("CVE-")?`https://nvd.nist.gov/vuln/detail/${e}`:e.startsWith("GHSA-")?`https://github.com/advisories/${e}`:`https://osv.dev/vulnerability/${e}`,"advisoryUri"),gs=z((e,t)=>{if(t.length===0)return{kind:"unknown",label:"no fix"};const s=U.coerce(e);if(!s)return{kind:"unknown",label:"non-semver"};let n,r;for(const i of t){const o=U.coerce(i);if(!o)continue;const a=U.diff(s,o);a==="major"||a==="premajor"?n||(n=i):a&&!r&&(r=i)}return r?{kind:"minor-patch",label:`safe to ${r}`}:n?{kind:"major",label:`requires major bump to ${n}`}:{kind:"unknown",label:"no usable fix"}},"breakingMarker"),ze={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},ms=z(e=>{const{acknowledged:t,packageName:s,packageVersion:n,remediation:r,vulnerability:i}=e,{severity:o}=i,a=gs(n,i.fixedVersions),p=i.fixedVersions.length>0?i.fixedVersions.join(", "):"—",d=r?`<code class="copyable" data-cmd="${C(r)}">${C(r)}</code>`:'<span class="muted">advisory only</span>';return`<tr data-severity="${o}" data-package="${C(s)}" data-advisory="${C(i.id)}">
|
|
17
|
+
<td><span class="badge badge-${o.toLowerCase()}">${o}</span></td>
|
|
18
|
+
<td><span class="marker marker-${a.kind}" title="${C(a.label)}"></span></td>
|
|
19
|
+
<td><code>${C(s)}</code></td>
|
|
20
|
+
<td><code>${C(n)}</code></td>
|
|
21
|
+
<td><a href="${C(fs(i.id))}" rel="noreferrer noopener" target="_blank">${C(i.id)}</a>${t?' <span class="ack">[acknowledged]</span>':""}</td>
|
|
22
|
+
<td>${C(i.summary)}</td>
|
|
23
|
+
<td><code>${C(p)}</code></td>
|
|
24
|
+
<td>${d}</td>
|
|
25
|
+
</tr>`},"renderRow"),vs=z(e=>{const t=e.now??new Date,s=[...e.findings].sort((d,u)=>{const k=ze[d.vulnerability.severity??"UNKNOWN"]??4,m=ze[u.vulnerability.severity??"UNKNOWN"]??4;return k!==m?k-m:d.packageName.localeCompare(u.packageName)||d.packageVersion.localeCompare(u.packageVersion)}),n={CRITICAL:0,HIGH:0,LOW:0,MODERATE:0,UNKNOWN:0};for(const d of s)n[d.vulnerability.severity??"UNKNOWN"]+=1;const r=s.map(d=>ms(d)).join(`
|
|
26
|
+
`),i=us.filter(d=>n[d]>0).map(d=>`<span class="badge badge-${d.toLowerCase()}">${n[d]} ${d}</span>`).join(" "),o=s.length===0,a=(e.policyDecisions??[]).filter(d=>d.policy!=="vulnerability"),p=[...a].sort((d,u)=>{const k=z(m=>m==="block"?0:m==="warn"?1:2,"rank");return k(d.severity)-k(u.severity)||d.policy.localeCompare(u.policy)||d.packageName.localeCompare(u.packageName)}).map(d=>{const u=d.acceptedRisk?' <span class="ack">[acknowledged]</span>':"";return`<tr>
|
|
27
|
+
<td><span class="policy-badge policy-${d.severity}">${d.severity.toUpperCase()}</span></td>
|
|
28
|
+
<td><code>${C(d.policy)}</code></td>
|
|
29
|
+
<td><code>${C(d.packageName)}</code></td>
|
|
30
|
+
<td><code>${C(d.version)}</code></td>
|
|
31
|
+
<td>${C(d.reason)}${u}</td>
|
|
32
|
+
</tr>`}).join(`
|
|
33
|
+
`);return`<!doctype html>
|
|
34
|
+
<html lang="en">
|
|
35
|
+
<head>
|
|
36
|
+
<meta charset="utf-8">
|
|
37
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
38
|
+
<title>vis audit · ${C(t.toISOString().slice(0,10))}</title>
|
|
39
|
+
<style>
|
|
40
|
+
:root {
|
|
41
|
+
--bg: #0e1116;
|
|
42
|
+
--fg: #d6dde6;
|
|
43
|
+
--muted: #8b95a1;
|
|
44
|
+
--border: #20262e;
|
|
45
|
+
--row-hover: #161b22;
|
|
46
|
+
--critical: #ff4757;
|
|
47
|
+
--high: #ff8c42;
|
|
48
|
+
--medium: #fbbf24;
|
|
49
|
+
--low: #38bdf8;
|
|
50
|
+
--unknown: #6b7280;
|
|
51
|
+
--major: #ff4757;
|
|
52
|
+
--minor: #22c55e;
|
|
53
|
+
}
|
|
54
|
+
@media (prefers-color-scheme: light) {
|
|
55
|
+
:root {
|
|
56
|
+
--bg: #ffffff;
|
|
57
|
+
--fg: #1f2328;
|
|
58
|
+
--muted: #57606a;
|
|
59
|
+
--border: #d0d7de;
|
|
60
|
+
--row-hover: #f6f8fa;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
* { box-sizing: border-box; }
|
|
64
|
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--fg); margin: 0; padding: 24px; }
|
|
65
|
+
h1 { font-size: 22px; margin: 0 0 8px; }
|
|
66
|
+
.meta { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
|
|
67
|
+
.summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
|
|
68
|
+
.controls { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
|
|
69
|
+
.controls input { background: var(--bg); color: var(--fg); border: 1px solid var(--border); padding: 6px 10px; border-radius: 6px; font-size: 13px; min-width: 240px; }
|
|
70
|
+
.controls select { background: var(--bg); color: var(--fg); border: 1px solid var(--border); padding: 6px 10px; border-radius: 6px; font-size: 13px; }
|
|
71
|
+
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
72
|
+
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
|
|
73
|
+
th { font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; }
|
|
74
|
+
th:hover { color: var(--fg); }
|
|
75
|
+
tr:hover td { background: var(--row-hover); }
|
|
76
|
+
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }
|
|
77
|
+
code.copyable { cursor: pointer; padding: 2px 4px; border-radius: 4px; }
|
|
78
|
+
code.copyable:hover { background: var(--row-hover); }
|
|
79
|
+
a { color: var(--low); text-decoration: none; }
|
|
80
|
+
a:hover { text-decoration: underline; }
|
|
81
|
+
.muted { color: var(--muted); }
|
|
82
|
+
.ack { color: var(--muted); font-style: italic; font-size: 12px; }
|
|
83
|
+
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
|
|
84
|
+
.badge-critical { background: rgba(255, 71, 87, 0.2); color: var(--critical); }
|
|
85
|
+
.badge-high { background: rgba(255, 140, 66, 0.2); color: var(--high); }
|
|
86
|
+
.badge-moderate { background: rgba(251, 191, 36, 0.2); color: var(--medium); }
|
|
87
|
+
.badge-low { background: rgba(56, 189, 248, 0.2); color: var(--low); }
|
|
88
|
+
.badge-unknown { background: rgba(107, 114, 128, 0.2); color: var(--unknown); }
|
|
89
|
+
.marker { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
|
|
90
|
+
.marker-major { background: var(--major); }
|
|
91
|
+
.marker-minor-patch { background: var(--minor); }
|
|
92
|
+
.marker-unknown { background: var(--unknown); }
|
|
93
|
+
.clean { padding: 32px; text-align: center; color: var(--muted); font-size: 14px; border: 1px dashed var(--border); border-radius: 8px; }
|
|
94
|
+
h2 { font-size: 16px; margin: 24px 0 12px; }
|
|
95
|
+
.policy-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
|
|
96
|
+
.policy-block { background: rgba(255, 71, 87, 0.2); color: var(--critical); }
|
|
97
|
+
.policy-warn { background: rgba(251, 191, 36, 0.2); color: var(--medium); }
|
|
98
|
+
.policy-info { background: rgba(107, 114, 128, 0.2); color: var(--unknown); }
|
|
99
|
+
</style>
|
|
100
|
+
</head>
|
|
101
|
+
<body>
|
|
102
|
+
<h1>vis audit</h1>
|
|
103
|
+
<div class="meta">${C(e.tool.name)} ${C(e.tool.version)} · ${C(t.toISOString())} · ${e.packagesScanned} packages scanned · ${s.length} findings</div>
|
|
104
|
+
<div class="summary">${i||'<span class="badge badge-low">CLEAN</span>'}</div>
|
|
105
|
+
${o?'<div class="clean">No security issues found.</div>':`
|
|
106
|
+
<div class="controls">
|
|
107
|
+
<input id="filter" type="search" placeholder="Filter by package or advisory…" aria-label="Filter findings" />
|
|
108
|
+
<select id="severity" aria-label="Filter by severity">
|
|
109
|
+
<option value="">All severities</option>
|
|
110
|
+
<option value="CRITICAL">Critical only</option>
|
|
111
|
+
<option value="HIGH">High and above</option>
|
|
112
|
+
<option value="MODERATE">Moderate and above</option>
|
|
113
|
+
<option value="LOW">Low and above</option>
|
|
114
|
+
</select>
|
|
115
|
+
</div>
|
|
116
|
+
<table id="findings">
|
|
117
|
+
<thead>
|
|
118
|
+
<tr>
|
|
119
|
+
<th data-sort="severity">Severity</th>
|
|
120
|
+
<th title="Green = safe upgrade · Red = requires major bump">Δ</th>
|
|
121
|
+
<th data-sort="package">Package</th>
|
|
122
|
+
<th>Version</th>
|
|
123
|
+
<th>Advisory</th>
|
|
124
|
+
<th>Summary</th>
|
|
125
|
+
<th>Fix</th>
|
|
126
|
+
<th>Remediation</th>
|
|
127
|
+
</tr>
|
|
128
|
+
</thead>
|
|
129
|
+
<tbody>
|
|
130
|
+
${r}
|
|
131
|
+
</tbody>
|
|
132
|
+
</table>`}
|
|
133
|
+
${a.length>0?`
|
|
134
|
+
<h2>Policy Decisions (${a.length})</h2>
|
|
135
|
+
<table id="policies">
|
|
136
|
+
<thead>
|
|
137
|
+
<tr>
|
|
138
|
+
<th>Severity</th>
|
|
139
|
+
<th>Policy</th>
|
|
140
|
+
<th>Package</th>
|
|
141
|
+
<th>Version</th>
|
|
142
|
+
<th>Reason</th>
|
|
143
|
+
</tr>
|
|
144
|
+
</thead>
|
|
145
|
+
<tbody>
|
|
146
|
+
${p}
|
|
147
|
+
</tbody>
|
|
148
|
+
</table>`:""}
|
|
149
|
+
<script>
|
|
150
|
+
(() => {
|
|
151
|
+
const rank = { CRITICAL: 0, HIGH: 1, MODERATE: 2, LOW: 3, UNKNOWN: 4 };
|
|
152
|
+
const filter = document.getElementById('filter');
|
|
153
|
+
const severity = document.getElementById('severity');
|
|
154
|
+
const rows = Array.from(document.querySelectorAll('#findings tbody tr'));
|
|
155
|
+
|
|
156
|
+
const apply = () => {
|
|
157
|
+
const q = (filter?.value ?? '').toLowerCase().trim();
|
|
158
|
+
const minSev = severity?.value ?? '';
|
|
159
|
+
const sevCap = minSev ? rank[minSev] ?? 4 : 4;
|
|
160
|
+
for (const row of rows) {
|
|
161
|
+
const pkg = row.getAttribute('data-package') ?? '';
|
|
162
|
+
const adv = row.getAttribute('data-advisory') ?? '';
|
|
163
|
+
const sev = row.getAttribute('data-severity') ?? 'UNKNOWN';
|
|
164
|
+
const queryHit = !q || pkg.toLowerCase().includes(q) || adv.toLowerCase().includes(q);
|
|
165
|
+
const sevHit = !minSev || (rank[sev] ?? 4) <= sevCap;
|
|
166
|
+
row.style.display = queryHit && sevHit ? '' : 'none';
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
filter?.addEventListener('input', apply);
|
|
171
|
+
severity?.addEventListener('change', apply);
|
|
172
|
+
|
|
173
|
+
// Click-to-copy on remediation cells.
|
|
174
|
+
document.addEventListener('click', (event) => {
|
|
175
|
+
const target = event.target;
|
|
176
|
+
if (!(target instanceof HTMLElement) || !target.classList.contains('copyable')) return;
|
|
177
|
+
const cmd = target.getAttribute('data-cmd') ?? target.textContent ?? '';
|
|
178
|
+
navigator.clipboard?.writeText(cmd).then(() => {
|
|
179
|
+
const orig = target.textContent;
|
|
180
|
+
target.textContent = '✓ copied';
|
|
181
|
+
setTimeout(() => { target.textContent = orig; }, 900);
|
|
182
|
+
}).catch(() => {});
|
|
183
|
+
});
|
|
184
|
+
})();
|
|
185
|
+
<\/script>
|
|
186
|
+
</body>
|
|
187
|
+
</html>
|
|
188
|
+
`},"emitAuditHtml");var ys=Object.defineProperty,me=x((e,t)=>ys(e,"name",{value:t,configurable:!0}),"u$1");const hs={CRITICAL:"CRITICAL",HIGH:"HIGH",LOW:"LOW",MODERATE:"MEDIUM",UNKNOWN:"NONE"},ks={CRITICAL:9.5,HIGH:8,LOW:2.5,MODERATE:5.5,UNKNOWN:0},xe=me((e,t)=>`pkg:npm/${e}@${t}`,"productId"),$s=me(e=>e.startsWith("CVE-")?`https://nvd.nist.gov/vuln/detail/${e}`:e.startsWith("GHSA-")?`https://github.com/advisories/${e}`:`https://osv.dev/vulnerability/${e}`,"advisoryUri"),Be=me((e,t)=>{const s=new Map;for(const n of e){const r=t(n),i=s.get(r);i?i.push(n):s.set(r,[n])}return s},"groupBy"),bs=me(e=>{const t=e.now??new Date,s=t.toISOString(),n=e.trackingId??`vis-audit-${t.toISOString().slice(0,10)}`,r=[...Be(e.findings,o=>o.packageName).entries()].sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>({branches:[...new Set(a.map(p=>p.packageVersion))].sort().map(p=>{const d=xe(o,p);return{category:"product_version",name:p,product:{name:`${o}@${p}`,product_id:d,product_identification_helper:{purl:d}}}}),category:"product_name",name:o})),i=[...Be(e.findings,o=>o.vulnerability.id).entries()].sort(([o],[a])=>o.localeCompare(a)).map(([o,a])=>{const p=a[0].vulnerability,d=[...new Set(a.map(w=>xe(w.packageName,w.packageVersion)))].sort(),u=o.startsWith("CVE-"),k=[o,...p.aliases??[]],m=u?o:k.find(w=>w.startsWith("CVE-")),b=k.filter(w=>w!==m).map(w=>({system_name:w.startsWith("GHSA-")?"GitHub Security Advisory":"OSV",text:w})),h=typeof p.cvssScore=="number"&&Number.isFinite(p.cvssScore)?p.cvssScore:ks[p.severity]??0,$=a.filter(w=>w.acknowledged).map(w=>xe(w.packageName,w.packageVersion));return{...m?{cve:m}:{},...b.length>0?{ids:b}:{},notes:[{category:"description",text:p.summary||`Advisory ${o}`,title:"Advisory description"}],product_status:{known_affected:d},references:[{category:"external",summary:`${o} advisory record`,url:$s(o)}],scores:[{cvss_v3:{baseScore:h,baseSeverity:hs[p.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:p.summary.split(`
|
|
189
|
+
`)[0]?.slice(0,200)||o,...$.length>0?{flags:[{label:"inline_mitigations_already_exist",product_ids:$}]}:{}}});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 · ${n}`,tracking:{current_release_date:s,id:n,initial_release_date:s,revision_history:[{date:s,number:"1",summary:"Initial audit emission"}],status:"final",version:"1"}},...r.length>0?{product_tree:{branches:r}}:{},...i.length>0?{vulnerabilities:i}:{}}},"emitCsaf");var ws=Object.defineProperty,oe=x((e,t)=>ws(e,"name",{value:t,configurable:!0}),"c$3");const Ss={CRITICAL:"critical",HIGH:"high",LOW:"low",MODERATE:"medium",UNKNOWN:"unknown"},xs={CRITICAL:9.5,HIGH:8,LOW:2.5,MODERATE:5.5,UNKNOWN:0},Ce=oe(e=>e.startsWith("CVE-")?`https://nvd.nist.gov/vuln/detail/${e}`:e.startsWith("GHSA-")?`https://github.com/advisories/${e}`:`https://osv.dev/vulnerability/${e}`,"advisoryUri"),Ae=oe(e=>e.startsWith("CVE-")?"NVD":e.startsWith("GHSA-")?"GitHub Advisory Database":"OSV","advisorySourceName"),Je=oe((e,t)=>{const s=new Map;for(const n of e){const r=t(n),i=s.get(r);i?i.push(n):s.set(r,[n])}return s},"groupBy"),Cs=oe((e,t=new Date)=>{const s=Je(e,r=>r.vulnerability.id),n=t.toISOString();return[...s.entries()].sort(([r],[i])=>r.localeCompare(i)).map(([r,i])=>{const o=i[0].vulnerability,a=Ss[o.severity]??"unknown",p=typeof o.cvssScore=="number"&&Number.isFinite(o.cvssScore)?o.cvssScore:xs[o.severity]??0,d=[...Je(i,h=>h.packageName).entries()].sort(([h],[$])=>h.localeCompare($)).map(([h,$])=>{const w=[...new Set($.map(D=>D.packageVersion))].sort();return{ref:_t(h,w[0]),versions:w.map(D=>({status:"affected",version:D}))}}),u=(o.aliases??[]).filter(h=>h!==r).map(h=>({id:h,source:{name:Ae(h),url:Ce(h)}})),k=i.some(h=>h.acknowledged),m=i.every(h=>h.acknowledged)?{justification:"code_not_reachable",response:["will_not_fix"],state:"not_affected"}:k?{state:"in_triage"}:void 0,b=o.fixedVersions??[];return{"bom-ref":`vuln:${r}`,id:r,source:{name:Ae(r),url:Ce(r)},...u.length>0?{references:u}:{},description:o.summary||`Advisory ${r}`,ratings:[{method:"CVSSv31",score:p,severity:a,source:{name:Ae(r),url:Ce(r)}}],...b.length>0?{recommendation:`Upgrade to one of: ${b.join(", ")}`}:{},affects:d,created:n,published:n,...m?{analysis:m}:{}}})},"buildCycloneDxVulnerabilities"),As=oe(e=>{const t=Cs(e.findings,e.now);return{...e.bom,vulnerabilities:t}},"emitCycloneDxVex");var Ns=Object.defineProperty,We=x((e,t)=>Ns(e,"name",{value:t,configurable:!0}),"a$1");const Rs={CRITICAL:"error",HIGH:"error",LOW:"note",MODERATE:"warning",UNKNOWN:"none"},Os={CRITICAL:"9.5",HIGH:"8.0",LOW:"2.5",MODERATE:"5.5",UNKNOWN:"0.0"},Ps={CRITICAL:"critical",HIGH:"high",LOW:"low",MODERATE:"medium",UNKNOWN:"none"},Ls=We(e=>e.startsWith("CVE-")?`https://nvd.nist.gov/vuln/detail/${e}`:e.startsWith("GHSA-")?`https://github.com/advisories/${e}`:`https://osv.dev/vulnerability/${e}`,"advisoryUri"),js=We(e=>typeof e.cvssScore=="number"&&Number.isFinite(e.cvssScore)?e.cvssScore.toFixed(1):Os[e.severity]??"0.0","securitySeverity"),Es=We(e=>{const t=new Map,s=[],n=e.artifactUri??(Kt(e.workspaceRoot,zt(e.workspaceRoot,"package.json"))||"package.json");for(const o of e.findings){const{acknowledged:a,packageName:p,packageVersion:d,vulnerability:u}=o,k=Rs[u.severity]??"none",m=Ps[u.severity]??"none";t.has(u.id)||t.set(u.id,{defaultConfiguration:{level:k},fullDescription:{text:u.summary||`Advisory ${u.id}`},helpUri:Ls(u.id),id:u.id,name:u.id,properties:{precision:"very-high","security-severity":js(u),"severity-label":m,tags:["security","vulnerability","supply-chain",`severity:${m}`]},shortDescription:{text:(u.summary.split(`
|
|
190
|
+
`)[0]??u.id).slice(0,200)}}),s.push({level:k,locations:[{logicalLocations:[{kind:"package",name:`${p}@${d}`}],physicalLocation:{artifactLocation:{uri:n}}}],message:{text:`${u.id}: ${p}@${d} — ${u.summary||"no summary"}${u.fixedVersions.length>0?` (fix: ${u.fixedVersions.join(", ")})`:""}`},partialFingerprints:{advisoryId:u.id,package:p,version:d},properties:{...a?{acknowledged:!0}:{},...u.aliases&&u.aliases.length>0?{aliases:u.aliases}:{},...typeof u.cvssScore=="number"?{cvssScore:u.cvssScore}:{},...u.fixedVersions.length>0?{fixedVersions:u.fixedVersions}:{},packageName:p,packageVersion:d,severityLabel:m},ruleId:u.id})}const r={block:"error",info:"note",warn:"warning"},i={block:"high",info:"none",warn:"medium"};for(const o of e.policyDecisions??[]){if(o.policy==="vulnerability")continue;const a=`vis.policy.${o.policy}`,p=r[o.severity],d=i[o.severity];t.has(a)||t.set(a,{defaultConfiguration:{level:p},fullDescription:{text:`vis policy '${o.policy}' (Socket.dev-style supply-chain gate)`},helpUri:`https://visulima.com/packages/vis/commands/audit#policy-${o.policy}`,id:a,name:a,properties:{precision:"high","security-severity":o.severity==="block"?"8.0":o.severity==="warn"?"5.5":"0.0","severity-label":d,tags:["security","supply-chain","policy",`policy:${o.policy}`]},shortDescription:{text:`vis policy: ${o.policy}`}}),s.push({level:p,locations:[{logicalLocations:[{kind:"package",name:`${o.packageName}@${o.version}`}],physicalLocation:{artifactLocation:{uri:n}}}],message:{text:o.reason},partialFingerprints:{package:o.packageName,policy:o.policy,version:o.version},properties:{...o.acceptedRisk?{acknowledged:!0}:{},packageName:o.packageName,packageVersion:o.version,severityLabel:d},ruleId:a})}return{$schema:"https://json.schemastore.org/sarif-2.1.0.json",runs:[{results:s,tool:{driver:{informationUri:e.tool.informationUri,name:e.tool.name,rules:[...t.values()],version:e.tool.version}}}],version:"2.1.0"}},"emitSarif");var Is=Object.defineProperty,B=x((e,t)=>Is(e,"name",{value:t,configurable:!0}),"c$2");const Ds=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Ye=B(e=>{try{return{path:e,pkg:nt(e)}}catch{return}},"readPackageJsonSafe"),Ws=B(e=>{const t=[],s=Ye(H(e,"package.json"));s&&t.push({path:s.path,pkg:s.pkg,workspaceName:s.pkg.name});const n=Ot(e);let r;if(n?r=n:s?.pkg.workspaces&&(Array.isArray(s.pkg.workspaces)?r=s.pkg.workspaces:s.pkg.workspaces.packages&&(r=s.pkg.workspaces.packages)),!r)return t;for(const i of Pt(e,r)){const o=Ye(H(e,i,"package.json"));o&&t.push({path:o.path,pkg:o.pkg,workspaceName:o.pkg.name})}return t},"collectWorkspaceManifests"),Ms=B((e,t)=>{const s=[];for(const n of e)for(const r of Ds){const i=n.pkg[r]?.[t];typeof i=="string"&&s.push({field:r,manifest:n,range:i})}return s},"findDeclarations"),ct=B(e=>{const t=Ws(e.workspaceRoot),s=[],n=[],r=[],i=new Set;for(const o of e.findings){const a=o.vulnerability.fixedVersions[0];if(!a){r.push({packageName:o.packageName,reason:"no-fixed-version"});continue}const p=Ms(t,o.packageName);if(p.length===0){r.push({packageName:o.packageName,reason:"transitive-only"});continue}const d=U.coerce(a),u=d?`^${d.version}`:a,k=d?d.version:a;for(const m of p){const b=`${m.manifest.path}::${m.field}::${o.packageName}::${k}`;if(i.has(b))continue;i.add(b);const h=Hs(k,m.range),$={currentRange:m.range,field:m.field,inRange:h,manifestPath:m.manifest.path,packageName:o.packageName,targetSpec:u,targetVersion:k,workspaceName:m.manifest.workspaceName};h||e.allowMajor===!0?s.push($):n.push($)}}return{apply:s,skippedMajor:n,unmatched:r}},"buildDirectApplyPlan"),Fs=/^(?:workspace|file|link|portal|patch|git\+|git:|github:|npm:|catalog|jsr|http|https):/i,Hs=B((e,t)=>{if(Fs.test(t))return!0;const s=U.coerce(e)?.version??e;try{return U.satisfies(s,t)}catch{return!0}},"satisfiesRange"),Vs=B(e=>{const t=[];if(e.apply.length>0){t.push(`Apply (${String(e.apply.length)}):`);for(const s of e.apply){const n=s.workspaceName?` [${s.workspaceName}]`:"";t.push(` + ${s.packageName}: ${s.currentRange} → ${s.targetSpec}${n}`)}}if(e.skippedMajor.length>0){t.push(`Skipped — major bump (${String(e.skippedMajor.length)}, requires --allow-major):`);for(const s of e.skippedMajor){const n=s.workspaceName?` [${s.workspaceName}]`:"";t.push(` ! ${s.packageName}: ${s.currentRange} → ${s.targetSpec}${n}`)}}if(e.unmatched.length>0){const s=e.unmatched.filter(r=>r.reason==="transitive-only"),n=e.unmatched.filter(r=>r.reason==="no-fixed-version");if(s.length>0){t.push(`Transitive only (${String(s.length)}, requires --fix-transitive):`);for(const r of s)t.push(` · ${r.packageName}`)}if(n.length>0){t.push(`No fixed version available (${String(n.length)}):`);for(const r of n)t.push(` · ${r.packageName}`)}}return t.length===0?"No direct-dep fixes to apply.":t.join(`
|
|
191
|
+
`)},"formatDirectApplyPlan");var Ts=Object.defineProperty,E=x((e,t)=>Ts(e,"name",{value:t,configurable:!0}),"i");const Us={"crates.io":["Cargo.lock"],Go:["go.sum"],Maven:["gradle.lockfile","pom.xml"],PyPI:["uv.lock","poetry.lock","Pipfile.lock"],RubyGems:["Gemfile.lock"]},Gs={cargo:"crates.io","crates.io":"crates.io",go:"Go",maven:"Maven",npm:"npm",pypi:"PyPI",rubygems:"RubyGems"},lt=E(e=>Gs[e.toLowerCase()]??e,"canonicalEcosystem"),_s=E((e,t)=>{const s=lt(t),n=Us[s]??[];for(const r of n){const i=H(e,r);if(Ze(i))return i}},"findEcosystemLockfile"),qs=E(e=>{const t=new Set,s=[];for(const n of e){const r=`${n.name}@${n.version}`;t.has(r)||(t.add(r),s.push(n))}return s},"dedupe"),Ks=/\[\[package\]\]([\s\S]*?)(?=\[\[|$)/g,zs=/^\s*name\s*=\s*"([^"]+)"\s*$/m,Bs=/^\s*version\s*=\s*"([^"]+)"\s*$/m,Js=E(e=>{const t=[];for(const s of e.matchAll(Ks)){const n=s[1]??"",r=zs.exec(n)?.[1],i=Bs.exec(n)?.[1];r&&i&&t.push({isDev:!1,name:r,version:i})}return t},"parseTomlPackages"),Ys=E(e=>{let t;try{t=JSON.parse(e)}catch{return[]}if(typeof t!="object"||t===null)return[];const s=[];for(const n of["default","develop"]){const r=t[n];if(!(typeof r!="object"||r===null))for(const[i,o]of Object.entries(r)){if(typeof o!="object"||o===null)continue;const a=o.version;if(typeof a!="string")continue;const p=a.replace(/^==/,"").trim();p.length>0&&s.push({isDev:!1,name:i,version:p})}}return s},"parsePipfileLock"),Xs=/<dependency>([\s\S]*?)<\/dependency>/g,Zs=/<groupId>\s*([^<\s]+)\s*<\/groupId>/,Qs=/<artifactId>\s*([^<\s]+)\s*<\/artifactId>/,en=/<version>\s*([^<\s]+)\s*<\/version>/,tn=E(e=>{const t=[];for(const s of e.matchAll(Xs)){const n=s[1]??"",r=Zs.exec(n)?.[1],i=Qs.exec(n)?.[1],o=en.exec(n)?.[1];!r||!i||!o||o.startsWith("${")||t.push({isDev:!1,name:`${r}:${i}`,version:o})}return t},"parsePomXml"),sn=E(e=>{const t=[];for(const s of e.split(/\r?\n/)){const n=s.trim();if(n.length===0||n.startsWith("#"))continue;const r=n.indexOf("="),i=(r===-1?n:n.slice(0,r)).split(":");if(i.length<3)continue;const[o,a,p]=i;!o||!a||!p||t.push({isDev:!1,name:`${o}:${a}`,version:p})}return t},"parseGradleLockfile"),nn=E(e=>{const t=[];for(const s of e.split(/\r?\n/)){const n=s.trim();if(n.length===0)continue;const r=n.split(/\s+/);if(r.length<3)continue;const[i,o]=r;if(!i||!o?.endsWith("/go.mod"))continue;const a=o.slice(0,-7);a.length!==0&&t.push({isDev:!1,name:i,version:a})}return t},"parseGoSum"),rn=/^ {4}([^ ()]+) \(([^()]+)\)\s*$/,on=E(e=>{const t=[];let s=!1,n=!1;for(const r of e.split(/\r?\n/)){if(r.startsWith("GEM")){s=!0,n=!1;continue}if(s&&/^[A-Z]/.test(r)){s=!1,n=!1;continue}if(s&&r.trim()==="specs:"){n=!0;continue}if(n){const i=rn.exec(r);if(i){const[,o,a]=i;o&&a&&t.push({isDev:!1,name:o,version:a})}}}return t},"parseGemfileLock"),an=E((e,t)=>{const s=_s(e,t);if(!s)return[];let n;try{n=Qe(s,"utf8")}catch{return[]}const r=s.split(/[/\\]/).pop()??"";let i;switch(r){case"Cargo.lock":case"poetry.lock":case"uv.lock":{i=Js(n);break}case"Gemfile.lock":{i=on(n);break}case"go.sum":{i=nn(n);break}case"gradle.lockfile":{i=sn(n);break}case"Pipfile.lock":{i=Ys(n);break}case"pom.xml":{i=tn(n);break}default:return[]}return qs(i)},"lockedPackagesForEcosystem"),pt=["firstSeen","installScripts","license","malware","publisherChange","score","unexpectedDeps","vulnerability"];var cn=Object.defineProperty,ln=x((e,t)=>cn(e,"name",{value:t,configurable:!0}),"n$1");const pn=ln((e,t)=>{const s=t.security?.policies?.installScripts;if(!s)return[];const n=s.allow??{},r=s.strict===!0;if(!r&&Object.keys(n).length===0)return[];const i=Qt(e.workspaceRoot,n,{pinVersions:t.security?.pinVersions===!0});if(i.unapproved.length===0)return[];const o=t.security?.acceptedRisks,a=r?"block":"warn";return i.unapproved.map(p=>({acceptedRisk:G(p.name,p.version??"*",o,"installScripts"),data:{hooks:p.hooks},packageName:p.name,policy:"installScripts",reason:`${p.name}${p.version?`@${p.version}`:""} declares unapproved build script(s): ${p.hooks.join(", ")}`,severity:a,version:p.version??"*"}))},"evaluateInstallScriptsPolicy");var dn=Object.defineProperty,ie=x((e,t)=>dn(e,"name",{value:t,configurable:!0}),"a");const un=new Set(["AND","OR"]),fn=ie(e=>{const t=e.replaceAll("("," ").replaceAll(")"," ").split(/\s+/).map(r=>r.trim()).filter(r=>r.length>0),s=[];let n=!1;for(const r of t){const i=r.toUpperCase();if(n){n=!1;continue}if(i==="WITH"){n=!0;continue}if(un.has(i))continue;const o=r.endsWith("+"),a=o?r.slice(0,-1):r,p=De(a)??a;s.push(p),o&&s.push(`${p}-or-later`)}return s},"extractSpdxLeaves"),gn=ie(e=>{if(typeof e.license=="string"){const t=e.license.trim();return t.length>0?t:void 0}if(e.license&&typeof e.license=="object"&&typeof e.license.type=="string"){const t=e.license.type.trim();if(t.length>0)return t}if(Array.isArray(e.licenses)&&e.licenses.length>0){const t=e.licenses.map(s=>s&&typeof s.type=="string"?s.type.trim():"").filter(s=>s.length>0);if(t.length>0)return t.length===1?t[0]:`(${t.join(" OR ")})`}},"declaredLicense"),mn=ie((e,t)=>{if(t.length===0)return;const s=new Set(t.map(n=>De(n)??n).map(n=>n.toLowerCase()));for(const n of e)if(s.has(n.toLowerCase()))return n},"findDeniedLeaf"),vn=ie((e,t)=>{if(t.length===0)return;const s=new Set(t.map(n=>De(n)??n).map(n=>n.toLowerCase()));for(const n of e)if(!s.has(n.toLowerCase()))return n},"findUnallowedLeaf"),yn=ie((e,t)=>{const s=t.security?.policies?.license;if(!s)return[];const n=s.allow??[],r=s.deny??[];if(n.length===0&&r.length===0)return[];const i=t.security?.acceptedRisks,o=[];for(const a of e.packages){const p=e.manifestData?.get(`${a.name}@${a.version}`),d=p?gn(p):void 0;if(!d){n.length>0&&o.push({acceptedRisk:G(a.name,a.version,i,"license"),data:{declaredLicense:null},packageName:a.name,policy:"license",reason:`${a.name}@${a.version} declares no license; allow-list mode requires one of: ${n.join(", ")}`,severity:"block",version:a.version});continue}const u=fn(d),k=mn(u,r);if(k){o.push({acceptedRisk:G(a.name,a.version,i,"license"),data:{declaredLicense:d,deniedLicense:k},packageName:a.name,policy:"license",reason:`${a.name}@${a.version} uses denied license '${k}' (declared: ${d})`,severity:"block",version:a.version});continue}const m=vn(u,n);m&&o.push({acceptedRisk:G(a.name,a.version,i,"license"),data:{allowList:n,declaredLicense:d,unallowedLicense:m},packageName:a.name,policy:"license",reason:`${a.name}@${a.version} uses license '${m}' which is not on the allow-list (declared: ${d})`,severity:"block",version:a.version})}return o},"evaluateLicensePolicy");var hn=Object.defineProperty,ve=x((e,t)=>hn(e,"name",{value:t,configurable:!0}),"l$1");const kn=ve(e=>{for(const t of Object.values(ot))if(e===t.file||e.endsWith(`/${t.file}`)||e.endsWith(`.${t.file}`))return t.type},"detectLockfileType"),$n=ve((e,t,s)=>{const n=Gt(t)?t:rt(e,t);let r;try{r=ne(n)}catch{return}const i=kn(n)??ot[s]?.type;if(!i)return;const o=es(r,i);if(o.length===0)return;const a=new Set;for(const p of o)a.add(`${p.name}@${p.version}`);return a},"loadBaselineKeys"),bn=ve((e,t)=>{for(const s of t)if(s===e||s.endsWith("*")&&e.startsWith(s.slice(0,-1)))return!0;return!1},"matchesAllowList"),wn=ve((e,t)=>{const s=t.security?.policies?.unexpectedDeps;if(!s)return[];const n=s.allow??[],r=s.baselineLockfile;if(n.length===0&&!r)return[];const i=r?$n(e.workspaceRoot,r,e.packageManager):void 0,o=t.security?.acceptedRisks,a=[];for(const p of e.packages){const d=n.length===0||bn(p.name,n),u=i?i.has(`${p.name}@${p.version}`):!0;if(d&&u)continue;const k=[],m={};d||(k.push(`not on allow-list (${n.length} entr${n.length===1?"y":"ies"})`),m.allowList=n),!u&&i&&(k.push(`not present in baseline lockfile (${r})`),m.baselineLockfile=r),a.push({acceptedRisk:G(p.name,p.version,o,"unexpectedDeps"),data:m,packageName:p.name,policy:"unexpectedDeps",reason:`${p.name}@${p.version} is unexpected: ${k.join("; ")}`,severity:"block",version:p.version})}return a},"evaluateUnexpectedDepsPolicy");var Sn=Object.defineProperty,xn=x((e,t)=>Sn(e,"name",{value:t,configurable:!0}),"E$2");const Xe={CRITICAL:0,HIGH:1,LOW:3,MODERATE:2,UNKNOWN:4},se=xn((e,t)=>{const s=Xe[t.toUpperCase()]??2;return(Xe[e.toUpperCase()]??4)<=s},"severityPassesFilter");var Cn=Object.defineProperty,An=x((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"c$1");const Nn=An((e,t)=>{if(!e.osvFindings||e.osvFindings.size===0)return[];const s=t.security?.policies?.vulnerability?.failOn,n=t.security?.acceptedRisks,r=[];for(const i of e.packages){const o=e.osvFindings.get(i.name);if(!(!o||o.length===0))for(const a of o){const p=s?se(a.severity,s)?"block":"warn":"info";r.push({acceptedRisk:G(i.name,i.version,n,"vulnerability"),data:{advisoryId:a.id,aliases:a.aliases??[],cvssScore:a.cvssScore,fixedVersions:a.fixedVersions,severity:a.severity,summary:a.summary},packageName:i.name,policy:"vulnerability",reason:`${a.severity} ${a.id} affects ${i.name}@${i.version}: ${a.summary}`,severity:p,version:i.version})}}return r},"evaluateVulnerabilityPolicy");var Rn=Object.defineProperty,T=x((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"n");const dt=[{evaluate:Nn,isConfigured:T(e=>e.security?.policies?.vulnerability!==void 0,"isConfigured"),name:"vulnerability",offlineSupported:!0,surfaces:["audit","doctor"]},{evaluate:yn,isConfigured:T(e=>{const t=e.security?.policies?.license;return!!(t&&(t.allow&&t.allow.length>0||t.deny&&t.deny.length>0))},"isConfigured"),name:"license",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:pn,isConfigured:T(e=>{const t=e.security?.policies?.installScripts;return!!(t&&(t.allow&&Object.keys(t.allow).length>0||t.strict===!0))},"isConfigured"),name:"installScripts",offlineSupported:!0,surfaces:["audit","doctor","install"]},{evaluate:wn,isConfigured:T(e=>{const t=e.security?.policies?.unexpectedDeps;return!!(t&&(t.allow&&t.allow.length>0||typeof t.baselineLockfile=="string"))},"isConfigured"),name:"unexpectedDeps",offlineSupported:!0,surfaces:["audit","doctor","install"]}],On=T((e,t,s)=>dt.filter(n=>n.surfaces.includes(e)?s!==void 0?s.has(n.name):n.isConfigured(t):!1),"selectModules"),Pn=T(async(e,t,s)=>{const n=On(t,s.visConfig,s.enabledPolicies),r=[];for(const i of n){if(e.offline&&!i.offlineSupported){r.push({packageName:"*",policy:i.name,reason:`policy.${i.name} skipped: requires network (--offline)`,severity:"info",version:"*"});continue}try{const o=await i.evaluate(e,s.visConfig);r.push(...o)}catch(o){const a=o instanceof Error?o.message:String(o);r.push({packageName:"*",policy:i.name,reason:`policy.${i.name} failed: ${a}`,severity:"info",version:"*"})}}return r},"evaluatePolicies"),Ln=(()=>{const e=new Map;for(const t of pt)e.set(t.toLowerCase(),t);return e})(),jn=T(()=>dt.map(e=>e.name),"getRegisteredPolicyNames"),En=T((e,t)=>{if(e===void 0)return;const s=e.trim().toLowerCase();if(s===""||s==="none")return new Set;if(s==="all")return new Set(pt);const n=new Set;for(const r of e.split(",").map(i=>i.trim()).filter(i=>i.length>0)){const i=r.replace(/^_+/,"").replaceAll(/_+([a-z])/g,(a,p)=>p.toUpperCase()),o=Ln.get(i.toLowerCase());o===void 0?t?.(r):n.add(o)}return n},"parsePoliciesFlag");var In=Object.defineProperty,re=x((e,t)=>In(e,"name",{value:t,configurable:!0}),"c");const Dn=["ts","tsx","js","jsx","mjs","cjs","mts","cts"],Wn=[/node_modules/,/\.git/,/\.next/,/\.cache/,/dist/,/build/,/coverage/,/\.turbo/,/\.nx/,/\.parcel-cache/],Mn=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Fn=/(?:import|export)\s+(?:[\s\S]*?from\s+)?["']([^"'\n]+)["']/g,Hn=/(?:^|[^.\w$])require\s*\(\s*["']([^"'\n]+)["']\s*\)/g,Vn=/\bimport\s*\(\s*["']([^"'\n]+)["']\s*\)/g,Tn=re(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 s=t.split("/");return s.length<2?void 0:`${s[0]}/${s[1]}`}return t.split("/")[0]}},"normalizePackageName"),Un=re(e=>{const t=new Set,s=e.replaceAll(/\/\*[\s\S]*?\*\//g,"").replaceAll(/(^|[^:])\/\/.*$/gm,"$1"),n=re(r=>{r.lastIndex=0;let i;for(;(i=r.exec(s))!==null;){const o=Tn(i[1]);o&&t.add(o)}},"collect");return n(Fn),n(Hn),n(Vn),t},"extractImportedNames"),Gn=re(e=>{const t=new Set;try{const s=nt(e);for(const n of Mn){const r=s[n];if(r&&typeof r=="object"&&!Array.isArray(r))for(const i of Object.keys(r))t.add(i)}}catch{}return t},"extractPackageJsonNames"),_n=re(e=>{const t=e.skip??Wn,s=e.extensions??Dn,n=new Set;let r=0;const i=Ke(e.workspaceRoot,{extensions:s,includeDirs:!1,skip:t});for(const p of i){r+=1;try{const d=Qe(p,"utf8");for(const u of Un(d))n.add(u)}catch{}}const o=Ke(e.workspaceRoot,{extensions:["json"],includeDirs:!1,skip:t}).filter(p=>p.endsWith("/package.json")||p.endsWith(String.raw`\package.json`)||p.endsWith("package.json"));for(const p of o)for(const d of Gn(p))n.add(d);if(e.alwaysAssumeUsed)for(const p of e.alwaysAssumeUsed)n.add(p);const a=new Set;for(const p of e.vulnerablePackages)n.has(p)&&a.add(p);return{filesScanned:r,importedTotal:n,reachable:a}},"computeReachableVulnerablePackages");var qn=Object.defineProperty,I=x((e,t)=>qn(e,"name",{value:t,configurable:!0}),"o");const Kn=I(e=>{const t=U.coerce(e)?.major;return t!==void 0&&t>=10},"PNPM_V10_PLUS"),zn=I(e=>Object.fromEntries(Object.entries(e).sort(([t],[s])=>t.localeCompare(s))),"sortByKey"),Bn=I((e,t)=>`${JSON.stringify(e,void 0,t)}
|
|
192
|
+
`,"stringifyJson"),ut=I((e,t)=>{if(t.name==="pnpm"&&Kn(t.version))return{filePath:H(e,"pnpm-workspace.yaml"),surface:"pnpm-workspace.yaml"};const s=H(e,"package.json");return t.name==="pnpm"?{filePath:s,surface:"package.json#pnpm.overrides"}:t.name==="yarn"?{filePath:s,surface:"package.json#resolutions"}:{filePath:s,surface:"package.json#overrides"}},"resolveOverrideSurface"),Jn=I((e,t)=>{const{filePath:s,surface:n}=ut(e,t);if(!K(s))return{};if(n==="pnpm-workspace.yaml")try{return Ee(s)?.overrides??{}}catch{return{}}try{const r=JSON.parse(ne(s));return n==="package.json#pnpm.overrides"?(r.pnpm??{}).overrides??{}:n==="package.json#resolutions"?r.resolutions??{}:r.overrides??{}}catch{return{}}},"readExistingOverrides"),Yn=I((e,t)=>{const s=Object.keys(t).sort();if(s.length===0&&!/^overrides\s*:/m.test(e))return e;const n=`overrides:
|
|
193
|
+
${s.map(r=>` '${r}': '${t[r]}'`).join(`
|
|
194
|
+
`)}
|
|
195
|
+
`;if(e.length===0)return n;if(/^overrides\s*:/m.test(e)){const r=e.replace(/^overrides\s*:[^\n]*\n(?:[ \t][^\n]*\n)*/m,n);return r.endsWith(`
|
|
196
|
+
`)?r:`${r}
|
|
197
|
+
`}return`${e.endsWith(`
|
|
198
|
+
`)?e:`${e}
|
|
199
|
+
`}
|
|
200
|
+
${n}`},"renderPnpmWorkspaceOverrides"),Xn=I((e,t,s,n)=>{const r=Lt(e,t.length>0?t:void 0),i=t.length>0?JSON.parse(t):{};if(s==="package.json#pnpm.overrides"){const o=i.pnpm??{};o.overrides=n,i.pnpm=o}else s==="package.json#resolutions"?i.resolutions=n:i.overrides=n;return Bn(i,r)},"renderPackageJsonWithOverrides"),Zn=I((e,t,s)=>{const{filePath:n,surface:r}=ut(e,s),i=Jn(e,s),o=K(n)?ne(n):"",a=[],p={...i};for(const m of t.entries){const b=i[m.packageName];if(b===m.spec){a.push({...m,previousSpec:b,status:"unchanged"});continue}b===void 0?a.push({...m,status:"added"}):a.push({...m,previousSpec:b,status:"updated"}),p[m.packageName]=m.spec}const d=zn(p),u=a.some(m=>m.status!=="unchanged"),k=r==="pnpm-workspace.yaml"?Yn(o,d):Xn(n,o,r,d);return{changed:u,entries:a,filePath:n,nextContent:k,previousContent:o,surface:r}},"planOverrideWrite"),Qn=I(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{et(t,e.nextContent),Ct(t,e.filePath)}catch(s){try{At(t)}catch{}throw s}return e},"applyOverridePlan"),er=I(e=>{const t=new Map;for(const s of e){const n=s.vulnerability.fixedVersions[0];if(!n)continue;const r=U.coerce(n),i=r?`^${r.version}`:n;t.set(s.packageName,i)}return{entries:[...t.entries()].sort(([s],[n])=>s.localeCompare(n)).map(([s,n])=>({packageName:s,spec:n}))}},"buildOverridePlanFromFindings");var tr=Object.defineProperty,R=x((e,t)=>tr(e,"name",{value:t,configurable:!0}),"y");const sr={critical:Ie,high:st,low:tt,medium:fe},Pe=new Set(["cargo","crates.io","go","maven","npm","pypi","rubygems"]),nr=R(e=>{const t=(e??"npm").split(",").map(r=>r.trim()).filter(r=>r.length>0),s=t.length>0?t:["npm"],n=s.filter(r=>!Pe.has(r.toLowerCase()));return{all:s,unsupported:n}},"parseEcosystems"),rr={CRITICAL:Ie,HIGH:st,LOW:tt,MODERATE:fe,UNKNOWN:j},or=R((e,t,s,n)=>{const r=rr[s.severity]??j,i=n?` ${j("[acknowledged]")}`:"",o=s.fixedVersions??[],a=o.length>0?` (fix: ${o.join(", ")})`:"";return` ${r(s.severity)} ${s.id} — ${e}@${t}${i}
|
|
201
|
+
${s.summary}${a}`},"formatVulnLine"),ir=R((e,t)=>{const s=jt(e),n=`${String(Math.round(e.score.overall*100))}%`,r=t?` ${j("[acknowledged]")}`:"",i=e.alerts.length>0?`, ${String(e.alerts.length)} alert${e.alerts.length===1?"":"s"}`:"";return` ${n} ${s}@${e.version} (${Et(e.score.overall)}${i})${r}`},"formatSocketLine"),ar=R(async(e,t,s,n)=>{const r=t.severity??"low",i=t.format??"table",o=i==="sarif",a=i==="csaf",p=i==="cyclonedx-vex"||i==="cyclonedx",d=i==="json"||!!t.json,u=t.report,k=s?.security?.audit,m=s?.security?.policies,b=t.offline===void 0?!!k?.offlineByDefault:!!t.offline,h=t.db,$=nr(t.ecosystem),w=!!t.prodOnly,D=t.failOn??m?.vulnerability?.failOn,mt=!!t.showFixes,ae=!!t.showAccepted,vt=s?.security?.socket,ye=s?.security?.acceptedRisks,Me=m?.vulnerability?.usage,yt=t.noUsage?!1:t.usage===void 0?!!Me?.enabled:!!t.usage,W=d||o||a||p,L=It(e),A=cs(e,L.name);if(b){const c=h??Jt(e);if(!Ze(c)){const l=new _e(c);W?process.stderr.write(`${l.message}
|
|
202
|
+
`):f.error(l.message),process.exitCode=1;return}}!W&&(A.ignoredAdvisories.length>0||A.excludedPackages.length>0)&&f.info(`Loaded ${String(A.ignoredAdvisories.length)} ignored advisor${A.ignoredAdvisories.length===1?"y":"ies"} and ${String(A.excludedPackages.length)} excluded package${A.excludedPackages.length===1?"":"s"} from ${L.name} config.`),!W&&$.unsupported.length>0&&f.warn(`Ecosystems ${$.unsupported.map(c=>`'${c}'`).join(", ")} are not yet supported by the audit matcher. Supported: npm, pypi, crates.io, cargo, maven, go, rubygems.`);const M=Yt(e,L.name,{includeDev:!w});if(M.length===0){f.info(`No ${L.name} lockfile entries found. Run ${L.name} install first.`);return}if(!W){const c=w?"production-only packages":"installed packages";f.info(`Scanning ${String(M.length)} ${c}${b?" (offline)":""}…`)}const he=M.map(c=>({name:c.name,version:c.version})),J=b||Dt("socket")?void 0:Wt(vt,m?.score?.minimum),ce=J?.minimumScore??m?.score?.minimum??Tt,V=Xt(e,L.name),ht=[{id:"vulnerabilities",label:b?"Known vulnerabilities (offline OSV cache)":"Known vulnerabilities (OSV)"},...J?[{id:"socket",label:"Socket.dev supply-chain reports"}]:[]],F=Bt(ht,{live:!W}),kt=Date.now(),q=R(c=>{const l=Date.now()-c;return l>=1e3?`${(l/1e3).toFixed(1)}s`:`${String(Math.round(l))}ms`},"fmtElapsed");let ke,$e;try{const c=Date.now(),l=Date.now();F.start("vulnerabilities"),J&&F.start("socket");const v=b?Promise.resolve().then(()=>qe(he,{dbPath:h,ecosystem:$.all.find(g=>Pe.has(g.toLowerCase()))??"npm",workspaceRoot:e})).then(g=>{let y=0;for(const S of g.values())y+=S.length;return F.finish("vulnerabilities",y>0?"warn":"ok",y>0?`${String(y)} found · ${q(c)}`:`none found · ${q(c)}`),g}).catch(g=>{const y=g instanceof Error?g.message:String(g);if(F.finish("vulnerabilities","error",y),g instanceof _e)throw g;return new Map}):Mt(he).then(g=>{let y=0;for(const S of g.values())y+=S.length;return F.finish("vulnerabilities",y>0?"warn":"ok",y>0?`${String(y)} found · ${q(c)}`:`none found · ${q(c)}`),g}).catch(g=>{const y=g instanceof Error?g.message:String(g);return F.finish("vulnerabilities","error",y),new Map});[ke,$e]=await Promise.all([v,J?Ft(he,J).then(g=>{let y=0,S=0;for(const Q of g.values())y+=Q.alerts.length,Q.score.overall<ce&&(S+=1);const P=y+S;return F.finish("socket",P>0?"warn":"ok",P>0?`${String(y)} alert${y===1?"":"s"}, ${String(S)} low-score · ${q(l)}`:`clean · ${q(l)}`),g}).catch(g=>{const y=g instanceof Error?g.message:String(g);return F.finish("socket","error",y),new Map}):Promise.resolve(new Map)])}finally{F.stop()}d||f.info(j(`Scan completed in ${q(kt)}`));const le=[];for(const c of M){if(ls(c.name,A))continue;const l=ke.get(c.name)??[],v=$e.get(`${c.name}@${c.version}`),g=G(c.name,c.version,ye),y=l.length>0,S=v?v.score.overall<ce:!1,P=v?v.alerts.length>0:!1;(y||S||P)&&le.push({acceptedRisk:g,name:c.name,socketReport:v,version:c.version,vulnerabilities:l})}if(b){const c=$.all.filter(l=>Pe.has(l.toLowerCase())&&l.toLowerCase()!=="npm");for(const l of c){const v=lt(l),g=an(e,v);if(g.length!==0){W||f.info(j(`Scanning ${String(g.length)} ${v} packages…`));try{const y=qe(g.map(S=>({name:S.name,version:S.version})),{dbPath:h,ecosystem:v,workspaceRoot:e});for(const S of g){const P=y.get(S.name)??[];P.length!==0&&le.push({acceptedRisk:G(S.name,S.version,ye),name:S.name,version:S.version,vulnerabilities:P})}}catch(y){const S=y instanceof Error?y.message:String(y);f.warn(`Failed to scan ${v}: ${S}`)}}}}let N=le.filter(c=>{const l=c.vulnerabilities.some(y=>se(y.severity,r)),v=c.socketReport?.alerts.some(y=>se(y.severity==="medium"?"MODERATE":y.severity.toUpperCase(),r)),g=c.socketReport&&c.socketReport.score.overall<ce;return l||v||g});const $t=t.policies,be=[],O=await(async()=>{const c=jn().map(P=>`'${P}'`).join(", "),l=En($t,P=>{be.push(P);const Q=`Unknown policy '${P}' — ignoring. Available: ${c}.`;W?process.stderr.write(`vis audit: ${Q}
|
|
203
|
+
`):f.warn(Q)});if(l?.size===0)return[];const v=s?.security?.policies?.license,g=!!(v&&((v.allow?.length??0)>0||(v.deny?.length??0)>0)),y=l===void 0||l.has("license"),S=g&&y?Zt(e):void 0;return Pn({manifestData:S,offline:b,osvFindings:ke,packageManager:L.name,packages:M,socketReports:$e,workspaceRoot:e},"audit",{enabledPolicies:l,visConfig:s??{}})})();if(yt){const c=new Set(N.filter(v=>v.vulnerabilities.length>0).map(v=>v.name)),l=_n({alwaysAssumeUsed:Me?.alwaysAssumeUsed,vulnerablePackages:c,workspaceRoot:e});N=N.filter(v=>v.vulnerabilities.length===0?!0:l.reachable.has(v.name)),W||f.info(j(`Reachability filter: ${String(l.reachable.size)}/${String(c.size)} vulnerable packages reachable (${String(l.filesScanned)} files scanned).`))}const Y=R(()=>N.flatMap(c=>c.vulnerabilities.map(l=>({acknowledged:!!c.acceptedRisk||te(l.id,A,l.aliases),packageName:c.name,packageVersion:c.version,vulnerability:l}))),"findingsForReport"),Fe=!!t.fix,He=!!t.fixTransitive,Ve=!!t.yes,bt=!!t.allowMajor;if(Fe||He){const c=Y().filter(l=>!l.acknowledged);if(Fe){const l=await lr({actionableFindings:c,allowMajor:bt,pm:L,visConfig:s,workspaceRoot:e,yes:Ve});if(l!==void 0){process.exitCode=l;return}}if(He){const l=await pr({actionableFindings:c,pm:L,visConfig:s,workspaceRoot:e,yes:Ve});if(l!==void 0){process.exitCode=l;return}}}if(o){const c=Es({findings:Y(),policyDecisions:O,tool:{informationUri:"https://github.com/visulima/visulima",name:"vis-audit",version:"alpha"},workspaceRoot:e});process.stdout.write(`${JSON.stringify(c,void 0,2)}
|
|
204
|
+
`),Ne(N,A,t.exitCode,D,O);return}if(a){const c=bs({findings:Y(),tool:{informationUri:"https://github.com/visulima/visulima",name:"vis-audit",version:"alpha"},workspaceRoot:e});process.stdout.write(`${JSON.stringify(c,void 0,2)}
|
|
205
|
+
`),Ne(N,A,t.exitCode,D,O);return}if(p){const{packageJsons:c,workspace:l}=Ht(e,s),v=Vt(e,l,c),g=qt({includeDev:!w,projectGraph:v,workspace:l,workspaceRoot:e}),y=As({bom:g,findings:Y()});process.stdout.write(`${JSON.stringify(y,void 0,2)}
|
|
206
|
+
`),Ne(N,A,t.exitCode,D,O);return}if(u){const c=vs({findings:Y(),packagesScanned:M.length,policyDecisions:O,tool:{name:"vis-audit",version:"alpha"},workspaceRoot:e}),l=rt(e,u);et(l,c,"utf8"),W||f.success(`HTML report written to ${l}`)}if(d){const c={duplicates:V.map(l=>({name:l.name,versionCount:l.versions.length,versions:l.versions})),packages:M.length,policies:O.map(l=>({acceptedRisk:l.acceptedRisk??null,data:l.data??null,packageName:l.packageName,policy:l.policy,reason:l.reason,severity:l.severity,version:l.version})),results:N.map(l=>({acceptedRisk:l.acceptedRisk??null,name:l.name,socketAlerts:l.socketReport?.alerts??[],socketScore:l.socketReport?.score.overall??null,version:l.version,vulnerabilities:l.vulnerabilities})),summary:{accepted:N.filter(l=>l.acceptedRisk).length,duplicatePackages:V.length,issues:N.filter(l=>!l.acceptedRisk).length,policyBlocks:O.filter(l=>l.severity==="block"&&!l.acceptedRisk).length,policyDecisions:O.length,total:N.length},warnings:be.length>0?be.map(l=>({kind:"unknown-policy",token:l})):[]};process.stdout.write(`${JSON.stringify(c,void 0,2)}
|
|
207
|
+
`),t.exitCode&&(c.summary.issues>0||c.summary.policyBlocks>0)&&(process.exitCode=1),Le(N,A,D,O);return}if(N.length===0){f.success(`No security issues found across ${String(M.length)} packages.`);return}const X={CRITICAL:[],HIGH:[],LOW:[],MODERATE:[]};for(const c of N)for(const l of c.vulnerabilities)if(se(l.severity,r)){const v=l.severity==="UNKNOWN"?"LOW":l.severity;X[v]?.push({entry:c,vuln:l})}let pe=0,we=0;for(const c of["CRITICAL","HIGH","MODERATE","LOW"]){const l=X[c];if(!(!l||l.length===0)){f.info(`
|
|
208
|
+
── ${c} (${String(l.length)}) ──`);for(const{entry:v,vuln:g}of l){const y=!!v.acceptedRisk||te(g.id,A,g.aliases);y&&(we++,!ae)||(pe++,f.info(or(v.name,v.version,g,y)),mt&&(g.fixedVersions??[]).length>0&&f.notice(` Fix: update to ${g.fixedVersions.at(-1)}`))}}}const Z=N.filter(c=>c.socketReport&&(c.socketReport.score.overall<ce||c.socketReport.alerts.length>0));if(Z.length>0){f.info(`
|
|
209
|
+
── Socket.dev Supply Chain (${String(Z.length)}) ──`);for(const c of Z){if(!c.socketReport)continue;const l=!!c.acceptedRisk;if(!(l&&!ae)){f.info(ir(c.socketReport,l));for(const v of c.socketReport.alerts){const g=sr[v.severity]??j;f.info(` ${g(`[${v.severity.toUpperCase()}]`)} ${v.type} — ${v.category}`)}}}}if(V.length>0){f.info(`
|
|
210
|
+
── Duplicate Dependencies (${String(V.length)}) ──`);for(const c of V){const l=c.versions.join(", ");f.info(` ${c.name} — ${String(c.versions.length)} versions: ${fe(l)}`)}}const Te=new Set;for(const c of["CRITICAL","HIGH","MODERATE","LOW"]){const l=X[c];if(l)for(const{vuln:v}of l)Te.add(v.id)}const Se=O.filter(c=>{if(c.policy!=="vulnerability")return!0;const l=typeof c.data?.advisoryId=="string"?c.data.advisoryId:void 0;return c.severity==="block"&&l!==void 0&&!Te.has(l)});if(Se.length>0){f.info(`
|
|
211
|
+
── Policy Decisions (${String(Se.length)}) ──`);for(const c of Se){const l=!!c.acceptedRisk;if(l&&!ae)continue;const v=c.severity==="block"?Ie:c.severity==="warn"?fe:j,g=l?` ${j("[acknowledged]")}`:"";f.info(` ${v(`[${c.severity}]`)} ${c.policy} — ${c.reason}${g}`)}}const de=R(c=>!!c.acceptedRisk||c.vulnerabilities.length>0&&c.vulnerabilities.every(l=>te(l.id,A,l.aliases)),"isEntryExcluded"),Ue=N.filter(c=>!de(c)).length;if(f.info(""),f.info("─ Audit Summary"),f.info(` ${String(M.length)} packages scanned`),A.ignoredAdvisories.length>0&&f.info(` ${String(A.ignoredAdvisories.length)} ${L.name} audit exclusion${A.ignoredAdvisories.length===1?"":"s"} applied`),pe>0){const c=X.CRITICAL?.filter(v=>!de(v.entry)).length??0,l=X.HIGH?.filter(v=>!de(v.entry)).length??0;f.error(` ${String(pe)} vulnerabilit${pe===1?"y":"ies"} found`),c>0&&f.error(` ${String(c)} critical`),l>0&&f.warn(` ${String(l)} high`)}else f.success(" No vulnerabilities found");if(Z.length>0){const c=Z.filter(l=>!de(l)).length;f.warn(` ${String(c)} package${c===1?"":"s"} with Socket.dev supply chain issues`)}V.length>0&&(f.warn(` ${String(V.length)} package${V.length===1?"":"s"} with duplicate versions`),f.notice(" Run 'vis dedupe' or your package manager's dedupe command to reduce duplicates."));const ue=O.filter(c=>c.severity==="block"&&!c.acceptedRisk);if(ue.length>0&&f.error(` ${String(ue.length)} policy block${ue.length===1?"":"s"}`),we>0&&(f.info(` ${String(we)} acknowledged (accepted risks)`),ae||f.notice(" Use --show-accepted to see acknowledged issues.")),Ue===0&&f.success(`
|
|
212
|
+
All issues are acknowledged. No action required.`),t.sync&&ye){const c=new Set;for(const v of le)if(v.acceptedRisk){for(const g of v.vulnerabilities)if((g.id.startsWith("CVE-")||g.id.startsWith("GHSA-"))&&c.add(g.id),g.aliases)for(const y of g.aliases)(y.startsWith("CVE-")||y.startsWith("GHSA-"))&&c.add(y)}const l=[...c];if(l.length>0){f.info("");const v=ps(L.name,e,l);for(const g of v)f.success(` ${g}`)}else f.info(`
|
|
213
|
+
No advisory IDs to sync to native PM config.`)}t.exitCode&&(Ue>0||ue.length>0)&&(process.exitCode=1),Le(N,A,D,O)},"executeAudit"),ft=R(e=>!e||e.length===0?!1:e.some(t=>t.severity==="block"&&!t.acceptedRisk),"hasBlockingPolicy"),Le=R((e,t,s,n)=>{ft(n)&&(process.exitCode=1),s&&e.some(r=>r.vulnerabilities.some(i=>r.acceptedRisk||te(i.id,t,i.aliases)?!1:se(i.severity,s)))&&(process.exitCode=1)},"applyFailOnGate"),Ne=R((e,t,s,n,r)=>{s&&(e.filter(i=>!i.acceptedRisk&&i.vulnerabilities.some(o=>!te(o.id,t,o.aliases))).length>0||ft(r))&&(process.exitCode=1),Le(e,t,n,r)},"applyExitGate"),gt=R(async(e,t)=>{if(!process.stdin.isTTY)return t;const s=Nt({input:process.stdin,output:process.stderr});try{const n=t?"[Y/n]":"[y/N]",r=await new Promise(i=>{s.question(`${e} ${j(n)} `,o=>{i(o.trim())})});return r.length===0?t:r.toLowerCase().startsWith("y")}finally{s.close()}},"promptYesNo"),cr=R(e=>e==="pnpm"||e==="npm"||e==="yarn"||e==="bun","isTransitiveOnlyPm"),lr=R(async e=>{const t=ct({allowMajor:e.allowMajor,findings:e.actionableFindings,workspaceRoot:e.workspaceRoot});if(f.info(""),f.info("─ Apply (direct deps)"),f.info(Vs(t)),t.apply.length===0){f.info("Nothing to apply for direct deps.");return}if(Re&&!e.yes)return f.error("Refusing to run --fix in CI without --yes. Re-run with --yes once the plan above looks right."),1;if(!e.yes&&!await gt("Apply these direct-dep upgrades?",!1))return f.info("Aborted — no changes made."),0;const s=new Map;for(const n of t.apply){const r=n.workspaceName??"",i=s.get(r);i?i.push(n):s.set(r,[n])}for(const[n,r]of s){const i=r.map(p=>`${p.packageName}@${p.targetSpec}`),o=n.length>0?[n]:[];f.info(`Running ${e.pm.name} add ${i.join(" ")}${n.length>0?` --filter ${n}`:""}`);const a=Ut(e.pm,{exact:!1,filter:o,global:!1,optional:!1,packages:i,peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},e.workspaceRoot,console);if(a!==0)return f.error(`${e.pm.name} add exited ${String(a)} — aborting before rescan.`),a}return f.success("Direct-dep upgrades applied. Re-run `vis audit` to confirm the fixes landed."),0},"runApplyDirect"),pr=R(async e=>{if(!cr(e.pm.name))return f.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(Re&&(!e.yes||!t))return f.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 s=new Set(ct({findings:e.actionableFindings,workspaceRoot:e.workspaceRoot}).apply.map(o=>o.packageName)),n=e.actionableFindings.filter(o=>!s.has(o.packageName)),r=er(n);if(r.entries.length===0){f.info(""),f.info("─ Apply transitive (overrides)"),f.info("Nothing to override — all vulnerable packages are direct deps or have no fixed version.");return}const i=Zn(e.workspaceRoot,r,{name:e.pm.name,version:e.pm.version});f.info(""),f.info("─ Apply transitive (overrides)"),f.info(`Target: ${i.filePath} (${i.surface})`);for(const o of i.entries){const a=o.status==="added"?"+":o.status==="updated"?"~":"·",p=o.previousSpec?` (was ${o.previousSpec})`:"";f.info(` ${a} ${o.packageName}: ${o.spec}${p}`)}if(!i.changed){f.info("No changes — overrides already match the plan.");return}if(!e.yes){if(Re)return 1;if(!await gt("Write these overrides?",!1))return f.info("Aborted — no changes made."),0}try{Qn(i)}catch(o){const a=o instanceof Error?o.message:String(o);return f.error(`Failed to write overrides: ${a}`),1}return f.success(`Wrote ${String(i.entries.filter(o=>o.status!=="unchanged").length)} override${i.entries.length===1?"":"s"}. Run \`${e.pm.name} install\` then re-run \`vis audit\` to confirm the fixes landed.`),0},"runApplyTransitive"),wr=R(async({logger:e,options:t,visConfig:s,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");await ar(n,t,s,e)},"execute");export{wr as default};
|