diff --git a/src/app/routes/config/layout/manage/manage.component.html b/src/app/routes/config/layout/manage/manage.component.html index 8b743b8..1b3ff6e 100644 --- a/src/app/routes/config/layout/manage/manage.component.html +++ b/src/app/routes/config/layout/manage/manage.component.html @@ -22,7 +22,7 @@
-
+
@@ -131,7 +131,7 @@ "frequency_rate": 0.263449367088608, "frequency_avg": 111, "trend": 0.09 --> - {{ data.menu_name }} + {{ data.menu_name }} {{ data.req_frequency }} {{ data.frequency_rate| percent: '1.1-2' }} {{ data.frequency_avg| number: '1.2-2'}} diff --git a/src/app/routes/config/layout/manage/manage.component.ts b/src/app/routes/config/layout/manage/manage.component.ts index 43ae575..3a34909 100644 --- a/src/app/routes/config/layout/manage/manage.component.ts +++ b/src/app/routes/config/layout/manage/manage.component.ts @@ -71,7 +71,7 @@ export class ManageComponent implements OnInit { isVisible = false detail_data : any; destroySubscriptions: Subscription[] = []; - + exportIsVisable = true; constructor( private noticeService: NoticeService, public message: NzMessageService, @@ -83,99 +83,91 @@ export class ManageComponent implements OnInit { const workbook: XLSX.WorkBook = { Sheets: { 'data': worksheet }, SheetNames: ['data'] }; const excelBuffer: any = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' }); this.saveAsExcelFile(excelBuffer, excelFileName); - } + } private saveAsExcelFile(buffer: any, fileName: string): void { const data: Blob = new Blob([buffer], { type: EXCEL_TYPE }); saveAs(data, fileName + '_export_' + new Date().getTime() + EXCEL_EXTENSION); - } + } - onSubmit(){ - // 日期校验 - this.submitLoading = true; - this.tableisShow = this.dimension; - if (this.dateRange.length === 2) { - const startDate = this.dateRange[0]; - const endDate = this.dateRange[1]; - console.log(startDate); - - //alert(`Selected Date Range: ${startDate.toLocaleDateString()} - ${endDate.toLocaleDateString()}`); - - } else { - alert('Please select a date range.'); - } - // 获取es的查询最大日期范围 - // this.noticeService.getQueryRange().subscribe(resp => { - // if (resp.status === 200) { - // console.log(resp.data); - // } else { - // this.message.error(resp.msg); - // } - // }, - // error => { - // this.message.error('服务器错误'); - // }) + private getAnalysisResult(startDate,endDate,queryDates){ // 获取es的查询最大日期范围 + this.noticeService.getQueryRange().subscribe(resp => { + console.log("resp.retcode"+resp.retcode); + if (resp.retcode === 200) { + console.log(resp.data.query_range); + if (queryDates >resp.data.query_range ){ + alert('查询范围不能超过'+resp.data.query_range+'天'); + return; + }else{ + this.submitLoading = true; + this.noticeService.getUebaResult({"type":this.dimension,"startDate":startDate,"endDate":endDate}).subscribe(resp => { + if (resp.code === 200) { + this.summary_detal_data = resp + switch(this.dimension.toString()){ + case "1": + this.listOfData = resp.data.summary.ip; + break; + case "2": + this.listOfData = resp.data.summary.account; + break; + case "3": + this.listOfData = resp.data.summary.interface; + break; + case "4": + this.listOfData = resp.data.summary.menu; + break; + } + } + this.tableisShow = this.dimension; + this.submitLoading = false; + if(this.tableisShow!=undefined){ + this.exportIsVisable = false; + } + }, + error => { + this.message.error('服务器错误'); + this.submitLoading = false; + }) + // this.tableisShow = this.dimension; + //this.submitLoading = false; + } + }else{ + return undefined; + } + }, + error => { + this.message.error('服务器错误'); + }) + } - // 获取es数据 暂时mock数据 - this.summary_detal_data = this.mockData - this.listOfData=[] - if (this.summary_detal_data.code === 0) { - switch(this.dimension.toString()){ - case "1": - this.listOfData = this.summary_detal_data.data.summary.ip; - console.log("1"+this.dimension.toString()) - break; - case "2": - this.listOfData = this.summary_detal_data.data.summary.account; - console.log("2"+this.dimension.toString()) - break; - case "3": - this.listOfData = this.summary_detal_data.data.summary.interface; - console.log("3"+this.dimension.toString()) - break; - case "4": - this.listOfData = this.summary_detal_data.data.summary.menu; - console.log("4"+this.dimension.toString()) - break; - } + + + private querySubmit(){ + var startDate :any; + var endDate :any; + if (this.dateRange.length === 2) { + startDate = this.dateRange[0]; + endDate = this.dateRange[1]; } else { - this.message.error("error"); + alert('请选择查询范围'); + return; } - // this.listOfData = resp.data.summary.ip; - // this.noticeService.getUebaResult({"type":eventVal}).subscribe(resp => { - // if (resp.code === 200) { - // switch(this.dimension.toString()){ - // case "1": - // this.listOfData = resp.summary.ip; - // case "2": - // this.listOfData = resp.summary.account; - // case "3": - // this.listOfData = resp.summary.interface; - // case "4": - // this.listOfData = resp.summary.menu; - // } - // } else { - // this.message.error(resp.msg); - // } - // }, - // error => { - // this.message.error('服务器错误'); - // }) + let timeDiff = Math.abs(endDate.getTime() - startDate.getTime()); + let diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24)); + + this.getAnalysisResult(startDate,endDate,diffDays) + } + onSubmit(){ + this.querySubmit(); } ngOnInit() { const now = new Date(); const oneWeekAgo = new Date(); oneWeekAgo.setDate(now.getDate() - 7); - this.dateRange = [oneWeekAgo, now]; - - this.onSubmit() - } - getMenuItem(e) { - console.log(e.el.dataset.id); - // this.key = e.el.dataset.id; + //this.onSubmit() } exportExcel(){ @@ -206,28 +198,32 @@ export class ManageComponent implements OnInit { showModel(data){ var tmpdata :any; - switch(data.type){ - case 1: - tmpdata=this.summary_detal_data.data.detail.ip[data.key]; - break; - case 2 : - tmpdata=this.summary_detal_data.data.detail.account[data.key]; - break; - case 3 : - tmpdata=this.summary_detal_data.data.detail.interface[data.key]; - break; - case 4 : - tmpdata=this.summary_detal_data.data.detail.menu[data.key]; - break; - } - var diagData = { - "type": data.type, - [data.key]: tmpdata + if(this.summary_detal_data != undefined){ + switch(data.type){ + case 1: + tmpdata=this.summary_detal_data.data.detail.ip[data.key]; + break; + case 2 : + tmpdata=this.summary_detal_data.data.detail.account[data.key]; + break; + case 3 : + tmpdata=this.summary_detal_data.data.detail.interface[data.key]; + break; + case 4 : + tmpdata=this.summary_detal_data.data.detail.menu[data.key]; + break; + } + var diagData = { + "type": data.type, + "startTime": Math.floor(this.dateRange[0].getTime() / 1000), + "endTime": Math.floor(this.dateRange[1].getTime() / 1000), + [data.key]: tmpdata + } + + this.detail_data =diagData; + console.log(JSON.stringify(this.detail_data)); + this.isVisible=true; } - - this.detail_data =diagData; - console.log(JSON.stringify(this.detail_data)); - this.isVisible=true; } cancelSearch(): void { this.submitLoading = false; diff --git a/src/app/routes/config/layout/manage/path/path.component.ts b/src/app/routes/config/layout/manage/path/path.component.ts index 5576769..3086ccc 100644 --- a/src/app/routes/config/layout/manage/path/path.component.ts +++ b/src/app/routes/config/layout/manage/path/path.component.ts @@ -14,10 +14,12 @@ export class PathComponent implements OnInit, OnChanges { whiteListParam = {}; greyListParam = {}; rules; - + queryLogUrl = "/WebApi/isoc/static/base/#/route/threat-state/log/action?" + // /WebApi/isoc/static/base/#/route/threat-state/log/action?startTime=1717396269&endTime=1717403469&sip=zhang3 constructor( private noticeService: NoticeService, public message: NzMessageService, + ) {} ngOnInit() { @@ -26,10 +28,10 @@ export class PathComponent implements OnInit, OnChanges { // this.detail_data = JSON.parse(jsonStr); // } this.parseData(); - if (this.rules == null) { + if (this.rules === undefined) { this.noticeService.getDefaultRule().subscribe( resp => { - if (resp.status === 200) { + if (resp.code === 200) { this.rules = resp.data; } else { this.message.error(resp.msg); @@ -55,6 +57,9 @@ export class PathComponent implements OnInit, OnChanges { if (dataKey === 'type') { this.viewType = this.detail_data[dataKey]; } else { + if(dataKey === 'startTime'||dataKey === 'endTime'){ + continue; + } this.data = this.detail_data[dataKey]; this.data.forEach(item => { item['is_in_white_list'] = 0; @@ -133,6 +138,7 @@ export class PathComponent implements OnInit, OnChanges { case 4: break; } + this.greyListParam["type"]=0; this.noticeService.addGreyList(this.greyListParam).subscribe( resp => { if (resp.status === 200) { @@ -149,7 +155,25 @@ export class PathComponent implements OnInit, OnChanges { } clickFrequency(data) { - alert("点击超链接"); + if(this.detail_data!=undefined){ + var params = "startTime="+this.detail_data.startTime+"&endTime="+this.detail_data.endTime; + switch(this.detail_data.type) { + case 1: + params += "&sip="+data.req_ip; + break; + case 2: + params += "&sip="+data.req_account; + break; + case 3: + params += "&sip="+data.interface_addr; + break; + case 4: + params += "&sip="+data.menu_name; + break; + } + + window.open(this.queryLogUrl+params, '_blank'); + } } // 在组件类中 diff --git a/src/app/routes/config/service/https/notice.service.ts b/src/app/routes/config/service/https/notice.service.ts index 734d889..f3571e5 100644 --- a/src/app/routes/config/service/https/notice.service.ts +++ b/src/app/routes/config/service/https/notice.service.ts @@ -25,18 +25,19 @@ export class NoticeService { } swicthBtn(params: any) { - const url = '/notice/inner/v1/plugin/plugin_update_status'; + const url = '/notice/inner/v1/plugin/plugin_update_status/'; return this.httpService.put(url, {}, params); } getQueryRange() { + //{"msg": "\u67e5\u8be2\u6210\u529f", "data": {"query_range": 50, "queryable_day": {"incident": 14, "log": 7}}, "retcode": 200} const url = '/isoc/api/v1/isoc_sys_config/get_query_range'; return this.httpService.get(url,{}); } getUebaResult(params:any) { - const url = '/uebaMetricsAnalysis/ueba_metrics/get_summary_data_list'; - return this.httpService.get(url, params,30000); + const url = '/uebaMetricsAnalysis/ueba_metrics/get_summary_data_list/'; + return this.httpService.get(url, params); } // 引擎接口 @@ -246,7 +247,7 @@ export class NoticeService { // "code": 200, // "data": null // } - const url = '/ditingEngine/diting/global/whitelist_add'; + const url = '/ditingEngine/ueba/engine_name_list/add/'; return this.httpService.post(url,{}, params); }