1 line
7.3 KiB
JavaScript
1 line
7.3 KiB
JavaScript
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{S as t,g as n,t as r}from"./react-QV7DAAIx.js";import{B as i,E as a,G as o,I as s,R as c,g as l,h as u,lt as d,tn as f,ut as p}from"./semi-65W_4I1v.js";import{A as m,D as h,F as g,I as _,L as v,_ as y,a as b,l as x,m as S,p as C,s as w}from"./index-C6SML8F9.js";import{a as T,n as E,r as D}from"./AssetBits-DtqSAj0f.js";import{r as O}from"./assetTarget-D2PEjBAg.js";var k=e(t(),1),A=e(r(),1),{Text:j}=o,M=[{value:7,label:`7 天`},{value:30,label:`30 天`},{value:90,label:`90 天`}];function N(e,t){let n=Number(e||0),r=Number(t||0);return r?Math.round(n/r*1e3)/10:0}function P(){let e=g(),t=n(),{hasPermission:r,hasAnyPermission:o}=_(),P=r(`asset:read`),F=o([`asset:read`,`fofa:execute`]),[I,L]=(0,k.useState)(30),R=b(()=>v.get(`/assets/stats`,{days:I}),[I],{skip:!P}),z=b(()=>v.get(`/assets`,{page:1,page_size:10,sort_by:`last_seen_at`,sort_order:`desc`}),[],{skip:!P}),B=R.data||{},V=B.coverage||{},H=Array.isArray(B.protocols)?B.protocols:[],U=(0,k.useMemo)(()=>H.reduce((e,t)=>e+Number(t.count||0),0),[H]),W=Array.isArray(z.data?.assets)?z.data.assets:[],G=[{id:`total`,label:e(`assets.totalAssets`,null,`资产总数`),value:h(B.total||0),detail:e(`assets.totalAssetsHint`,null,`当前纳入持续监测的资产`),loading:R.loading},{id:`ips`,label:e(`assets.ipCount`,null,`IP 数量`),value:h(B.ips||0),loading:R.loading},{id:`domains`,label:e(`assets.domainCount`,null,`域名数量`),value:h(B.domains||0),loading:R.loading},{id:`ports`,label:e(`assets.portCount`,null,`端口数量`),value:h(B.ports||0),loading:R.loading},{id:`protocols`,label:e(`assets.serviceTypes`,null,`服务类型`),value:h(H.length),detail:H[0]?`${e(`assets.topProtocol`,null,`主要协议`)}:${H[0].name}`:void 0,loading:R.loading},{id:`recent`,label:e(`assets.recentCount`,null,`近 7 天发现`),value:h(B.recent||0),detail:e(`assets.recentShare`,{percent:N(B.recent,B.total)},`占当前资产总量的 ${N(B.recent,B.total)}%`),loading:R.loading}],K=e=>{let n=new URLSearchParams({id:e.id});e.project_id?n.set(`project_id`,e.project_id):n.set(`scope`,`unassigned`),t(`/asset-library?${n}`)},q=[{title:e(`assets.target`,null,`目标`),dataIndex:`host`,render:(e,t)=>(0,A.jsxs)(`div`,{className:`asset-overview-target`,children:[(0,A.jsx)(T,{text:O(t),max:34}),(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:[t.ip,t.domain].filter(Boolean).join(` · `)||`—`})]})},{title:e(`assets.service`,null,`服务`),dataIndex:`protocol`,width:150,render:(e,t)=>(0,A.jsx)(E,{protocol:t.protocol,port:t.port})},{title:e(`assets.source`,null,`来源`),dataIndex:`source`,width:120,render:e=>(0,A.jsx)(T,{text:e,max:14})},{title:e(`assets.riskLevel`,null,`风险等级`),dataIndex:`risk_level`,width:120,render:(e,t)=>(0,A.jsx)(D,{asset:t})},{title:e(`assets.lastSeen`,null,`最近发现`),dataIndex:`last_seen_at`,width:130,render:t=>(0,A.jsx)(j,{size:`small`,children:m(t,e)})},{title:e(`common.actions`,null,`操作`),dataIndex:`id`,width:100,render:(t,n)=>(0,A.jsx)(c,{theme:`borderless`,size:`small`,onClick:()=>K(n),children:e(`common.view`,null,`查看`)})}],J=[{label:e(`assets.scannedAssets`,null,`已扫描资产`),value:h(V.scanned||0)},{label:e(`assets.recentlyScanned`,null,`近 30 天覆盖`),value:h(V.scanned_30d||0)},{label:e(`assets.neverScanned`,null,`从未扫描`),value:h(V.never_scanned||0)},{label:e(`assets.staleScans`,null,`超过 30 天未扫描`),value:h(V.stale||0)}];return(0,A.jsxs)(`div`,{className:`asset-overview-page`,children:[(0,A.jsx)(C,{title:e(`assets.overviewTitle`,null,`资产概览`),description:`汇总资产规模、服务类型、扫描覆盖与最近发现情况。`,extra:(0,A.jsxs)(s,{children:[(0,A.jsx)(u,{type:`button`,value:I,options:M,onChange:e=>L(Number(e.target.value)||30)}),(0,A.jsx)(c,{icon:(0,A.jsx)(p,{}),onClick:()=>{R.reload(),z.reload()},children:e(`common.refresh`,null,`刷新`)}),(0,A.jsx)(c,{icon:(0,A.jsx)(f,{}),onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),F&&(0,A.jsx)(c,{theme:`solid`,type:`primary`,icon:(0,A.jsx)(d,{}),onClick:()=>t(`/info-collect`),children:e(`nav.infoCollect`,null,`信息收集`)})]})}),!P&&(0,A.jsx)(i,{type:`warning`,bordered:!0,closeIcon:null,description:e(`assets.readDenied`,null,`当前账号没有 asset:read 权限,无法读取资产统计;请联系管理员授权。`)}),P&&(0,A.jsx)(x,{error:R.error,onRetry:()=>R.reload()}),P&&(0,A.jsx)(y,{metrics:G,columns:6}),P&&(0,A.jsxs)(`div`,{className:`asset-overview-columns`,children:[(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.protocolDistribution`,null,`协议分布`),description:e(`assets.protocolDistributionHint`,null,`按已识别服务查看资产暴露构成`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.protocolKinds`,{count:H.length},`${H.length} 种协议`)}),children:H.length===0?(0,A.jsx)(a,{title:e(`common.noData`,null,`暂无数据`),description:null,style:{padding:24}}):(0,A.jsx)(`div`,{className:`asset-overview-bars`,children:H.map(e=>{let t=N(e.count,B.total||U);return(0,A.jsxs)(`div`,{className:`asset-overview-bar-row`,children:[(0,A.jsx)(j,{size:`small`,className:`asset-overview-bar-label`,children:e.name||`unknown`}),(0,A.jsx)(l,{percent:t,showInfo:!1,stroke:`var(--semi-color-primary)`}),(0,A.jsxs)(j,{type:`tertiary`,size:`small`,className:`asset-overview-bar-value`,children:[h(e.count||0),` · `,t,`%`]})]},e.name)})})}),(0,A.jsx)(S,{className:`asset-overview-card`,title:e(`assets.scanCoverage`,null,`扫描覆盖`),description:e(`assets.scanCoverageHint`,null,`识别未扫描与长期未复查的资产缺口`),extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.coverageMeta`,{scanned:V.scanned||0,total:B.total||0},`${V.scanned||0} / ${B.total||0} 已覆盖`)}),children:(0,A.jsxs)(`div`,{className:`asset-overview-coverage`,children:[(0,A.jsxs)(`div`,{className:`asset-overview-coverage-main`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e(`assets.overallCoverage`,null,`总体覆盖率`)}),(0,A.jsx)(l,{percent:Number(V.rate||0),stroke:Number(V.rate||0)>=80?`var(--semi-color-success)`:void 0,format:e=>`${e}%`})]}),(0,A.jsx)(`div`,{className:`asset-overview-coverage-grid`,children:J.map(e=>(0,A.jsxs)(`div`,{className:`asset-overview-coverage-item`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:e.label}),(0,A.jsx)(j,{strong:!0,children:e.value})]},e.label))})]})}),(0,A.jsx)(S,{className:`asset-overview-card`,title:`观察覆盖`,description:`有成功回执的测评观察,或带成功工具回执的已确认项目事实。同一资产只计一次,不替代上面的扫描覆盖。`,extra:(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:`${B.observation?.observed||0} / ${B.observation?.total||B.total||0}`}),children:(0,A.jsxs)(`div`,{className:`asset-overview-coverage`,children:[(0,A.jsx)(j,{type:`tertiary`,size:`small`,children:`已有观察证据`}),(0,A.jsx)(l,{percent:Number(B.observation?.rate||0),format:e=>`${e}%`})]})})]}),P&&(0,A.jsxs)(S,{title:e(`assets.recentAssets`,null,`最近资产`),description:`按最近发现时间排列的前 10 条资产。`,extra:(0,A.jsx)(c,{theme:`borderless`,onClick:()=>t(`/asset-library`),children:e(`assets.viewLibrary`,null,`查看资产库`)}),children:[(0,A.jsx)(x,{error:z.error,onRetry:()=>z.reload()}),(0,A.jsx)(w,{columns:q,dataSource:W,loading:z.loading,rowKey:`id`,pagination:!1,onRefresh:()=>z.reload(),emptyText:e(`common.noData`,null,`暂无数据`)})]})]})}export{P as default}; |