1import{u as I,r as n,s as E,k as h,j as e,B as y,o as A}from"./index-kEOuaiYw.js";import{B as v}from"./badge-2Q3lsEI7.js";import{S as _}from"./skull-Dolr-ywv.js";import{S as O}from"./sparkles-f0r7S4tG.js";import{B as D}from"./bandage-Bc12CwZc.js";import{T as M}from"./timer-DVIEJiRT.js";import{L as P}from"./loader-circle-Lv4k1TNL.js";import{S as B}from"./shield-CFSy1L2g.js";import{Z as G}from"./zap-ChdOhQvS.js";import{R as Z}from"./rotate-ccw-BgyfkQC6.js";import{A as H}from"./activity-CyTvoNRM.js";import{E as K}from"./eye-BuG3SIXI.js";import{B as R}from"./bug-Dokb5iAT.js";const Q={critical:"bg-severity-critical/15 text-severity-critical border-severity-critical/30",high:"bg-severity-high/15 text-severity-high border-severity-high/30",medium:"bg-severity-medium/15 text-severity-medium border-severity-medium/30",low:"bg-severity-low/15 text-severity-low border-severity-low/30"},F={critical_miss:"text-severity-critical",good_patch:"text-severity-low",acceptable_skip:"text-muted-foreground",wasted_slot:"text-severity-medium"};function a({children:s,variant:t="neutral"}){const l={danger:"bg-severity-critical/15 text-severity-critical border-severity-critical/30",warn:"bg-severity-high/15 text-severity-high border-severity-high/30",info:"bg-chart-1/15 text-chart-1 border-chart-1/30",good:"bg-severity-low/15 text-severity-low border-severity-low/30",neutral:"bg-muted/30 text-muted-foreground border-border/50"};return e.jsx("span",{className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-medium border ${l[t]}`,children:s})}function U({c:s}){var l;const t=[];if(s.kev&&t.push(e.jsxs(a,{variant:"danger",children:[e.jsx(A,{className:"h-3 w-3"})," CISA KEV"]},"kev")),s.epss_score!=null){const d=(s.epss_score*100).toFixed(1),b=s.epss_score>.5?"danger":s.epss_score>.1?"warn":"neutral";t.push(e.jsxs(a,{variant:b,children:["EPSS ",d,"%"]},"epss"))}return s.exploitdb&&t.push(e.jsxs(a,{variant:"warn",children:[e.jsx(R,{className:"h-3 w-3"})," ExploitDB"]},"edb")),s.metasploit_module&&t.push(e.jsxs(a,{variant:"danger",children:[e.jsx(R,{className:"h-3 w-3"})," Metasploit"]},"msf")),s.nuclei&&t.push(e.jsx(a,{variant:"warn",children:"Nuclei"},"nuclei")),s.poc_in_github&&t.push(e.jsx(a,{variant:"warn",children:"PoC on GitHub"},"poc")),s.packetstorm&&t.push(e.jsx(a,{variant:"warn",children:"PacketStorm"},"pkt")),s.exploit_code_maturity&&t.push(e.jsxs(a,{variant:"info",children:["Maturity: ",s.exploit_code_maturity]},"ecm")),s.ransomware_affiliation&&(t.push(e.jsxs(a,{variant:"danger",children:[e.jsx(A,{className:"h-3 w-3"})," Ransomware-linked"]},"ransom")),(l=s.ransomware_groups_linked)!=null&&l.length&&t.push(e.jsx(a,{variant:"danger",children:s.ransomware_groups_linked.join(", ")},"rgroups"))),s.supply_chain_linked&&t.push(e.jsxs(a,{variant:"warn",children:["Supply Chain (",s.supply_chain_count??"?",")"]},"sc")),s.ssvc_decision&&t.push(e.jsxs(a,{variant:s.ssvc_decision==="Act"?"danger":s.ssvc_decision==="Attend"?"warn":"neutral",children:["SSVC: ",s.ssvc_decision]},"ssvc-d")),s.ssvc_exploitation&&t.push(e.jsxs(a,{variant:"info",children:["Exploitation: ",s.ssvc_exploitation]},"ssvc-e")),s.ssvc_automatable&&t.push(e.jsxs(a,{variant:s.ssvc_automatable==="yes"?"warn":"neutral",children:["Automatable: ",s.ssvc_automatable]},"ssvc-a")),s.ssvc_technical_impact&&t.push(e.jsxs(a,{variant:"info",children:["Impact: ",s.ssvc_technical_impact]},"ssvc-t")),s.attacker_value!=null&&t.push(e.jsxs(a,{variant:"info",children:["Attacker Value: ",s.attacker_value,"/5"]},"av")),s.attacker_exploitability!=null&&t.push(e.jsxs(a,{variant:"info",children:["Exploitability: ",s.attacker_exploitability,"/5"]},"ae")),s.patch_available!=null&&t.push(e.jsxs(a,{variant:s.patch_available?"good":"warn",children:[e.jsx(B,{className:"h-3 w-3"})," ",s.patch_available?`Patched (${s.patch_count??"?"})`:"No patch"]},"patch")),s.days_to_patch!=null&&t.push(e.jsxs(a,{variant:"neutral",children:[s.days_to_patch,"d to patch"]},"dtp")),s.greynoise_seen&&t.push(e.jsxs(a,{variant:"danger",children:[e.jsx(H,{className:"h-3 w-3"})," GreyNoise: ",s.greynoise_classification??"seen"]},"gn")),s.google_project_zero&&t.push(e.jsxs(a,{variant:"warn",children:[e.jsx(K,{className:"h-3 w-3"})," Project Zero"]},"gpz")),s.rapid7_analysis&&t.push(e.jsx(a,{variant:"info",children:"Rapid7 analysis"},"r7")),s.sum_of_flagging_sources!=null&&s.sum_of_flagging_sources>0&&t.push(e.jsxs(a,{variant:s.sum_of_flagging_sources>=5?"danger":s.sum_of_flagging_sources>=3?"warn":"neutral",children:[s.sum_of_flagging_sources," flagging sources"]},"flags")),s.nvd_status&&t.push(e.jsxs(a,{variant:"neutral",children:["NVD: ",s.nvd_status]},"nvd")),s.date_published&&t.push(e.jsxs(a,{variant:"neutral",children:["Published: ",new Date(s.date_published).toLocaleDateString()]},"pub")),t.length===0?null:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:"Intelligence Signals"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t})]})}function ce(){const{isAdmin:s}=I(),[t,l]=n.useState("idle"),[d,b]=n.useState([]),[u,V]=n.useState(5),[x,N]=n.useState(new Set),[g,w]=n.useState(60),[o,S]=n.useState(null),[j,L]=n.useState("random"),[k,q]=n.useState(null),f=n.useRef(null),m=n.useCallback(()=>{f.current&&(clearInterval(f.current),f.current=null)},[]),p=n.useCallback(async(r,c)=>{m(),l("scoring");try{const{data:i,error:z}=await E.functions.invoke("patch-or-perish",{body:{action:"score",queue:r,patched:Array.from(c)}});if(z||!(i!=null&&i.result)){h.error("AI scoring failed"),l("playing");return}S(i.result),l("result")}catch{h.error("Network error"),l("playing")}},[m]),C=n.useCallback(async()=>
1{l("loading"),S(null),N(new Set),m();try{const{data:r,error:c}=await E.functions.invoke("patch-or-perish",{body:{action:"deal",mode:j}});if(c||!(r!=null&&r.queue)){h.error("Could not load CVE queue"),l("idle");return}b(r.queue),q(r._queue_source??null),V(r.budget),w(r.timeLimit),l("playing"),f.current=setInterval(()=>{w(i=>i<=1?(p(r.queue,new Set),0):i-1)},1e3)}catch{h.error("Network error"),l("idle")}},[m,p,j]);n.useEffect(()=>()=>m(),[m]),n.useEffect(()=>{t==="playing"&&g<=0&&p(d,x)},[g,t,d,x,p]);const T=r=>{N(c=>{const i=new Set(c);return i.has(r)?i.delete(r):i.size<u?i.add(r):h.error(`Budget limit: you can only patch ${u} CVEs`),i})},$=u-x.size;return e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 sm:px-6 py-8 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-severity-critical/15 border border-severity-critical/30",children:e.jsx(_,{className:"h-5 w-5 text-severity-critical"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:"Patch or Perish"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["10 CVEs arrive â you can only patch ",u,". Choose wisely before time runs out."]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[t==="idle"&&e.jsx("div",{className:"flex items-center gap-1 rounded-md border border-border/50 bg-card p-0.5",children:["random","variety","theme"].map(r=>e.jsx("button",{onClick:()=>L(r),className:`text-[11px] px-2 py-1 rounded capitalize transition-colors ${j===r?"bg-chart-5/20 text-chart-5":"text-muted-foreground hover:text-foreground"}`,children:r},r))}),s&&k&&e.jsxs(v,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(O,{className:"h-3 w-3"}),k," pool"]}),t==="playing"&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(D,{className:"h-4 w-4 text-chart-5"}),e.jsxs("span",{className:"text-sm font-semibold",children:[$," slots left"]})]}),e.jsxs("div",{className:`flex items-center gap-1.5 ${g<=10?"text-severity-critical animate-pulse":"text-muted-foreground"}`,children:[e.jsx(M,{className:"h-4 w-4"}),e.jsxs("span",{className:"text-sm font-mono font-bold",children:[g,"s"]})]})]})]})]}),t==="idle"&&e.jsxs("div",{className:"rounded-xl border border-dashed border-border/50 bg-card/50 p-12 text-center space-y-4",children:[e.jsx(_,{className:"h-12 w-12 text-muted-foreground/30 mx-auto"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["A queue of 10 CVEs hits your desk. You have 60 seconds and only ",u," patch slots.",e.jsx("br",{}),"Prioritize the most dangerous ones â AI scores your triage."]}),e.jsxs(y,{onClick:C,className:"gap-2",children:[e.jsx(_,{className:"h-4 w-4"})," Start Round"]})]}),t==="loading"&&e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card p-12 text-center space-y-3",children:[e.jsx(P,{className:"h-8 w-8 animate-spin text-chart-5 mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading CVE queueâ¦"})]}),(t==="playing"||t==="scoring")&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:d.map(r=>{const c=x.has(r.cve_id),i=(r.cvss_severity??"").toLowerCase();return e.jsxs("button",{disabled:t!=="playing",onClick:()=>T(r.cve_id),className:`text-left rounded-xl border p-4 space-y-2 transition-all ${t==="playing"?"hover:border-chart-5/60 cursor-pointer":"cursor-default"} ${c?"border-severity-low/60 bg-severity-low/10":"border-border/50 bg-card"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-bold",children:r.cve_id}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[r.kev&&e.jsx(v,{variant:"destructive",className:"text-[9px] px-1.5 py-0",children:"KEV"}),r.ransomware_affiliation&&e.jsx(v,{variant:"outline",className:"text-[9px] px-1.5 py-0 border-severity-critical/40 text-severity-critical",children:"RANSOM"}),i&&e.jsx("span",{className:`text-[10px] font-semibold px-1.5 py-0.5 rounded border ${Q[i]??"bg-muted text-muted-foreground border-border"}`,children:(r.cvss_severity??"").toUpperCase()}),c&&e.jsx(v,{className:"text-[9px] px-1.5 py-0 bg-severity-low text-white",children:"PATCHED"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:r.description??"No description."}),e.jsx(U,{c:r})]},r.cve_id)})}),t==="playing"&&e.jsx("div",{className:"flex justify-center",children:e.jsxs(y,{onClick:()=>p(d,x),className:"gap-2",children:[e.jsx(B,{className:"h-4 w-4"})," Submit Triage (",x.size,"/",u," patched)"]})}),t==="scoring"&&e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card p-6 text-center space-y-2",children:[e.jsx(P,{className:"h-6 w-6 animate-spin text-chart-5 mx-auto"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"AI is scoring your triageâ¦"})]})]}),t==="result"&&o&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:`rounded-xl border p-5 flex items-center gap-4 ${o.score>=70?"border-severity-low/50 bg-severity-low/10":o.score>=40?"border-severity-medium/50 bg-severity-medium/10":"border-severity-critical/50 bg-severity-critical/10"}`,children:[e.jsxs("div",{className:"text-center min-w-[60px]",children:[e.jsx("div",{className:"text-2xl font-bold",children:o.grade}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[o.score,"/100"]})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",children:o.verdict}),o.critical_misses>0&&e.jsxs("p",{className:"text-xs text-severity-critical mt-1",children:["â ",o.
1critical_misses," critical miss",o.critical_misses>1?"es":""," â dangerous CVEs left unpatched"]})]})]}),e.jsxs("div",{className:"rounded-xl border border-border/50 bg-card p-5 space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Triage Breakdown"}),e.jsx("div",{className:"space-y-2",children:o.breakdown.map((r,c)=>e.jsxs("div",{className:"flex items-start gap-3 text-xs",children:[e.jsx("span",{className:"font-mono min-w-[140px] font-semibold",children:r.cve_id}),e.jsx("span",{className:`min-w-[100px] font-semibold capitalize ${F[r.rating]??"text-muted-foreground"}`,children:r.rating.replace("_"," ")}),e.jsx("span",{className:"text-muted-foreground",children:r.reason})]},c))})]}),e.jsxs("div",{className:"rounded-xl border border-chart-5/30 bg-chart-5/5 p-4 flex items-start gap-3",children:[e.jsx(G,{className:"h-4 w-4 text-chart-5 mt-0.5 flex-shrink-0"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:"Pro Tip:"})," ",o.tip]})]}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(y,{onClick:C,className:"gap-2",children:[e.jsx(Z,{className:"h-4 w-4"})," Next Round"]})})]})]})}export{ce as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.