1import{h,i as p,r as l,j as e,J as u}from"./index-Bx9M0crp.js";import{u as j}from"./useServerFn-Baf0EXbg.js";import{r as f}from"./role-middleware-DFefZqAZ.js";import{C as t}from"./card-ML64tcLm.js";import{B as o}from"./button-Bf3u_XuV.js";import{e as N}from"./export-rows-BmSEDRRs.js";import{t as g}from"./index-DgkAwKs6.js";import{S as b}from"./shield-alert-WIkuDhGY.js";import{R as v}from"./refresh-cw-B_8bxjy-.js";const y=h({method:"GET"}).middleware([f]).handler(p("cac3ed19071d749393ed29a9d152bcb41eda7d7b6da4735d1dfe224047ca4d9d")),r={"report-only":"Passo 1 â solo osservazione (nessun blocco)",partial:"Passo 2 â blocco su area admin e pagine senza mappe",enforce:"Passo 3 â blocco su tutto il portale"};function z(){const d=j(y),[a,m]=l.useState(null),[i,c]=l.useState(!0),n=()=>{c(!0),d().then(m).catch(s=>g.error(s instanceof Error?s.message:"Errore")).finally(()=>c(!1))};return l.useEffect(n,[]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("header",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(b,{className:"h-6 w-6 text-primary"})," Monitoraggio CSP"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Violazioni raccolte dai browser. Conservazione ",a?.retentionDays??90," giorni."]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{variant:"outline",size:"sm",onClick:n,disabled:i,children:[e.jsx(v,{className:`h-4 w-4 mr-2 ${i?"animate-spin":""}`})," Aggiorna"]}),e.jsxs(o,{variant:"outline",size:"sm",disabled:!a?.latest.length,onClick:()=>a&&N(a.latest,"csp-report"),children:[e.jsx(u,{className:"h-4 w-4 mr-2"})," Export CSV"]})]})]}),e.jsxs(t,{className:"p-4 space-y-2",children:[e.jsx("h2",{className:"font-semibold",children:"Rollout dell'enforcement"}),e.jsxs("ol",{className:"list-decimal space-y-1 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:r["report-only"]}),e.jsxs("li",{children:[r.partial," â variabile ",e.jsx("code",{children:"CSP_ENFORCE_SCOPE=admin"})]}),e.jsxs("li",{children:[r.enforce," â variabile ",e.jsx("code",{children:"CSP_ENFORCE=true"})]})]}),e.jsx("p",{className:"text-sm",children:"Prima di passare allo step successivo, verifica che le origini bloccate qui sotto siano tutte attese e aggiungile alla lista consentita."})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs(t,{className:"p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Violazioni registrate"}),e.jsx("p",{className:"text-3xl font-bold",children:a?.total??0})]}),e.jsxs(t,{className:"p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Direttive coinvolte"}),e.jsx("p",{className:"text-3xl font-bold",children:a?.byDirective.length??0})]}),e.jsxs(t,{className:"p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:"Origini bloccate"}),e.jsx("p",{className:"text-3xl font-bold",children:a?.byOrigin.length??0})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(t,{className:"p-4",children:[e.jsx("h2",{className:"font-semibold mb-3",children:"Per direttiva"}),e.jsxs("ul",{className:"space-y-1 text-sm",children:[(a?.byDirective??[]).map(s=>e.jsxs("li",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"font-mono text-xs",children:s.key}),e.jsx("span",{className:"text-muted-foreground",children:s.count})]},s.key)),a?.byDirective.length?null:e.jsx("li",{className:"text-muted-foreground",children:"Nessuna violazione."})]})]}),e.jsxs(t,{className:"p-4",children:[e.jsx("h2",{className:"font-semibold mb-3",children:"Per origine bloccata"}),e.jsxs("ul",{className:"space-y-1 text-sm",children:[(a?.byOrigin??[]).map(s=>e.jsxs("li",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"truncate",children:s.key}),e.jsx("span",{className:"text-muted-foreground",children:s.count})]},s.key)),a?.byOrigin.length?null:e.jsx("li",{className:"text-muted-foreground",children:"Nessuna origine bloccata."})]})]})]}),e.jsx(t,{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-left",children:e.jsxs("tr",{children:[e.jsx("th",{className:"p-3",children:"Data"}),e.jsx("th",{className:"p-3",children:"Direttiva"}),e.jsx("th",{className:"p-3",children:"Risorsa bloccata"}),e.jsx("th",{className:"p-3",children:"Pagina"}),e.jsx("th",{className:"p-3",children:"Modalità "})]})}),e.jsxs("tbody",{children:[(a?.latest??[]).map((s,x)=>e.jsxs("tr",{className:"border-t",children:[e.jsx("td",{className:"p-3 whitespace-nowrap",children:new Date(s.created_at).toLocaleStr
1ing("it-IT")}),e.jsx("td",{className:"p-3 font-mono text-xs",children:s.effective_directive??s.violated_directive}),e.jsx("td",{className:"p-3 truncate max-w-[22rem]",children:s.blocked_uri??"â"}),e.jsx("td",{className:"p-3 truncate max-w-[18rem] text-muted-foreground",children:s.document_uri??"â"}),e.jsx("td",{className:"p-3",children:s.disposition??"report"})]},`${s.created_at}-${x}`)),a?.latest.length?null:e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-6 text-center text-muted-foreground",children:"Nessun report ricevuto finora."})})]})]})})]})}export{z as component};
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.