1import{z as D,i as B,r as c,j as e,s as P,L as C,a6 as V,a5 as W,f as h}from"./index-Dyb6OM34.js";import{u as q}from"./reportNavigation-vW657kLt.js";import{B as z}from"./bot-htxe1CPf.js";import{D as H}from"./download-DW53UI31.js";import{S as M}from"./shield-alert-bUEox04e.js";import{I as J}from"./info-_-dNPtcb.js";import{L as G}from"./list-checks-COYS-Ec2.js";import{S as Y}from"./search-CJHE-yWd.js";const R="inline-flex w-fit items-center gap-2 rounded-md border border-slate-700/60 bg-slate-800/50 px-4 py-2 text-sm font-medium text-slate-300 transition-colors hover:border-slate-600 hover:bg-slate-800 hover:text-white";function K(s){if(s?.body&&typeof s.body=="string")try{return JSON.parse(s.body)}catch{return s}return s}const k={high:"border-orange-400/20 bg-orange-400/10 text-orange-400",medium:"border-amber-400/20 bg-amber-400/10 text-amber-400",low:"border-slate-400/20 bg-slate-400/10 text-slate-400"},_={pass:{label:"Pass",Icon:W,chip:"border-emerald-400/20 bg-emerald-400/10 text-emerald-400"},fail:{label:"Fail",Icon:V,chip:"border-red-400/20 bg-red-400/10 text-red-400"}};function N(s){const l=String(s||"").toLowerCase();return l.startsWith("new ")?"New grants":l.startsWith("unverified app")?"Unverified apps":"AI apps"}function Q(s){return s.map(l=>l.map(d=>`"${String(d??"").replace(/"/g,'""')}"`).join(",")).join(` 2`)}function u({label:s,value:l,tone:d="text-white"}){return e.jsxs("div",{className:"rounded-xl border border-slate-800 bg-slate-900/70 p-4",children:[e.jsx("p",{className:"min-h-[2rem] text-xs uppercase tracking-wider text-slate-500",children:s}),e.jsx("p",{className:`mt-1 text-2xl font-bold ${d}`,children:l})]})}u.propTypes={label:h.string.isRequired,value:h.oneOfType([h.string,h.number]).isRequired,tone:h.string};const X=[{value:"all",label:"All checks"},{value:"fail",label:"Findings"},{value:"AI apps",label:"AI apps"},{value:"Unverified apps",label:"Unverified apps"}];function oe(){const{jobId:s}=D(),l=q(),{getValidToken:d}=B(),[n,E]=c.useState(null),[I,y]=c.useState(!0),[v,S]=c.useState(null),[x,T]=c.useState("all"),[j,$]=c.useState("");c.useEffect(()=>{let t=!1;return(async()=>{const o=d();if(!o){S("Authentication required"),y(!1);return}try{const r=await fetch("https://api.bluelanternsecurity.io/results",{method:"POST",headers:{Authorization:`${o}`,"Content-Type":"application/json"},body:JSON.stringify({jobId:s})}),a=await r.json().catch(()=>null);if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);const p=K(a),g=p?.result??p;if(!g||typeof g!="object"||!Array.isArray(g.checks))throw new Error("Report data unavailable");t||(E(g),y(!1))}catch(r){console.error("Error fetching AI exposure report:",r),t||(S(r.message||"Failed to load report"),y(!1))}})(),()=>{t=!0}},[s,d]);const m=n?.summary||{},f=c.useMemo(()=>Array.isArray(n?.checks)?n.checks:[],[n]),w=c.useMemo(()=>{const t=j.trim().toLowerCase();return f.filter(i=>!(x==="fail"&&String(i.result).toLowerCase()!=="fail"||x!=="all"&&x!=="fail"&&N(i.name)!==x||t&&!String(i.name||"").toLowerCase().includes(t)))},[f,x,j]),F=()=>{if(!n)return;const t=[["Check","Family","Result","Severity","Description"]];f.forEach(a=>{t.push([a.name||"",N(a.name),a.result||"",String(a.result).toLowerCase()==="fail"&&a.severity||"",a.description||""])}),t.push([]),t.push(["Summary","","",""]),Object.entries(m).forEach(([a,p])=>t.push([a,Array.isArray(p)?p.join("; "):p,"",""]));const i=new Blob([Q(t)],{type:"text/csv"}),o=window.URL.createObjectURL(i),r=document.createElement("a");r.href=o,r.download=`ai_exposure_${s}.csv`,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(o)};if(I)return e.jsx("div",{className:"min-h-screen bg-slate-950 text-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-4 border-4 border-cyan-500/30 border-t-cyan-500 rounded-full animate-spin"}),e.jsx("p",{className:"text-lg text-slate-300",children:"Loading AI exposure report..."})]})});if(v||!n)return e.jsx("div",{className:"min-h-screen bg-slate-950 text-white flex flex-col items-center justify-center p-8",children:e.jsxs("div",{className:"text-center max-w-2xl w-full",children:[e.jsx(P,{className:"w-16 h-16 text-yellow-400 mx-auto mb-4"}),e.jsx("h1",{className:"text-2xl font-bold mb-2",children:v||"Report Not Found"}),e.jsx("p",{className:"text-slate-400 mb-6",children:"The report may still be processing, or it may have expired. Report data is retained for 7 days; the next daily scan produces a fresh report."}),e.jsx(C,{to:l.to,className:R,children:l.label})]})});
2const U=Number(m.ai_apps_total??0),A=Number(m.ai_apps_high_scope??0),O=Number(m.users_with_ai_grants??0),L=Number(m.unverified_apps??0),b=Array.isArray(n.new_since_last_scan)?n.new_since_last_scan:[];return e.jsx("div",{className:"min-h-screen bg-slate-950 pb-16 text-white",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 pt-24 sm:px-6",children:[e.jsx(C,{to:l.to,className:R,children:l.label}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"flex items-center gap-3 text-2xl font-bold sm:text-3xl",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-lg bg-cyan-500/10 border border-cyan-400/20",children:e.jsx(z,{className:"h-6 w-6 text-cyan-200"})}),"AI Exposure Report"]}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm text-slate-400",children:"Daily inventory of the third-party OAuth apps granted access to your org's data: AI tools that can reach mail, files, or calendars, and unverified apps holding data scopes. Built from grant metadata only â message and file content are never read."})]}),e.jsxs("button",{type:"button",onClick:F,className:"inline-flex items-center gap-2 rounded-lg border border-slate-700 bg-slate-800/60 px-4 py-2 text-sm font-medium text-slate-200 transition-colors hover:border-slate-600 hover:bg-slate-800",children:[e.jsx(H,{className:"h-4 w-4"}),"Export CSV"]})]}),e.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(u,{label:"AI apps found",value:U.toLocaleString()}),e.jsx(u,{label:"With data access",value:A.toLocaleString(),tone:A>0?"text-orange-400":"text-emerald-400"}),e.jsx(u,{label:"Users with AI grants",value:O.toLocaleString()}),e.jsx(u,{label:"Unverified apps",value:L.toLocaleString(),tone:L>0?"text-red-400":"text-emerald-400"})]}),b.length>0&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-red-500/20 bg-red-500/5 p-4 text-sm",children:[e.jsx(M,{className:"mt-0.5 h-5 w-5 shrink-0 text-red-400"}),e.jsxs("p",{className:"text-slate-300",children:[b.length===1?"One concerning app appeared":`${b.length} concerning apps appeared`," ","since the previous scan:"," ",e.jsx("span",{className:"font-medium text-white",children:b.join(", ")}),". Review who granted the access and revoke it from your admin console if it is not sanctioned."]})]}),n.first_scan===!0&&e.jsxs("div",{className:"mt-4 flex items-start gap-3 rounded-xl border border-slate-700/60 bg-slate-900/60 p-4 text-sm",children:[e.jsx(J,{className:"mt-0.5 h-5 w-5 shrink-0 text-cyan-400"}),e.jsx("p",{className:"text-slate-400",children:"First scan for this integration â the roster above is the baseline. From the next daily scan on, newly appearing risky apps are flagged here and can trigger alert rules."})]}),e.jsxs("div",{className:"mt-8 overflow-hidden rounded-2xl border border-slate-800 bg-slate-900",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-slate-800 p-4 sm:p-5",children:[e.jsxs("h2",{className:"flex items-center gap-2 text-base font-semibold text-white",children:[e.jsx(G,{className:"h-5 w-5 text-cyan-200"}),"Checks",e.jsxs("span",{className:"text-sm font-normal text-slate-500",children:[w.length.toLocaleString()," of ",f.length.toLocaleString()]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"flex items-center gap-1 rounded-lg border border-slate-800 bg-slate-950/60 p-1",children:X.map(t=>e.jsx("button",{type:"button",onClick:()=>T(t.value),className:`rounded-md px-3 py-1.5 text-xs font-medium transition-colors ${x===t.value?"bg-cyan-400/15 text-cyan-300":"text-slate-400 hover:text-white"}`,children:t.label},t.value))}),e.jsxs("div",{className:"relative",children:[e.jsx(Y,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-500"}),e.jsx("input",{type:"text",value:j,onChange:t=>$(t.target.value),placeholder:"Search checks",className:"w-44 rounded-lg border border-slate-700 bg-slate-950 py-1.5 pl-8 pr-3 text-xs text-white placeholder:text-slate-600 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-cyan-500"})]})]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[560px] text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-800 text-xs uppercase tracking-wider text-slate-500",children:[e.jsx("th",{className:"px-4 py-3 font-semibold sm:px-5",children:"Check"}),e.jsx("th",{className:"px-4 py-3 font-semibold sm:px-5",children:"Family"}),e.jsx("th",{className:"px-4 py-3 font-semibold sm:px-5",children:"Result"}),e.jsx("th",{className:"px-4 py-3 font-semibold sm:px-5",children:"Severity"}),e.jsx("th",{className:"px-4 py-3 font-semibold sm:px-5",children:"Detail"})]})}),e.jsxs("tbody",{className:"divide-y divide-slate-800/60",children:[w.map((t,i)=>{const o=_[String(t.result).toLowerCase()]||_.fail,r=String(t.severity||"").toLowerCase(),a=String(t.result).toLowerCase()==="fail";return e.jsxs("tr",{children:[e.jsx("td",{className:"px-4 py-3 sm:px-5",children:e.jsx("span",{className:"break-all font-mono text-xs text-slate-200",children:t.name})}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-300 sm:px-5",children:N(t.name)}),e.jsx("td",{className:"px-4 py-3 sm:px-5",children:e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium ${o.chip}`,children:[e.jsx(o.Icon,{className:"h-3.5 w-3.5"}),o.label]})}),e.jsx("td",{className:"px-4 py-3 sm:px-5",children:a?e.jsx("span",{className:`inline-flex rounded-full border px-2.5 py-0.5 text-xs font-medium capitalize ${k[r]||k.low}`,children:r||"low"}):e.jsx("span",{className:"text-xs text-slate-600",children:"â"})}),e.jsx("td",{className:"px-4 py-3 text-xs text-slate-400 sm:px-5",children:t.description||""})]},`${t.name}-${i}`)}),w.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:"5",className:"p-8 text-center text-sm text-slate-500",children:"No checks match the current filter."})})]})]})})]})]})})}export{oe 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.