1、新增功能探针联动处置、心跳在线检测
2、syslog-consumer模块拆分 syslog-consumer-rule模块实现日志数据消费、解析、泛化入库。
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
FROM openjdk:8
|
||||
|
||||
MAINTAINER chenchunan@139.com
|
||||
|
||||
# 创建程序运行和日志目录
|
||||
RUN mkdir -p /app
|
||||
RUN mkdir -p /app/logs
|
||||
WORKDIR /app
|
||||
# 挂载日志运行目录
|
||||
VOLUME /app/logs
|
||||
|
||||
ADD syslog-consumer-rule-1.0.0.jar syslog-consumer-rule.jar
|
||||
EXPOSE 8289
|
||||
CMD java -jar syslog-consumer-rule.jar
|
||||
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
# 实时分析调度器设计方案
|
||||
|
||||
## 概述
|
||||
|
||||
每个规则根据窗口类型(滚动、滑动、会话)独立管理下次运行时间,而不是所有规则统一每30秒执行一次。
|
||||
|
||||
## 核心设计
|
||||
|
||||
### 1. 窗口类型与执行间隔映射
|
||||
|
||||
| 窗口类型 | 配置参数 | 执行间隔 | 示例 |
|
||||
|---------|---------|---------|------|
|
||||
| **TUMBLE**<br/>滚动窗口 | `tumble_window_size` + `tumble_window_size_unit` | 等于窗口大小 | 窗口5分钟 → 每5分钟执行 |
|
||||
| **HOP**<br/>滑动窗口 | `hop_slide` + `hop_slide_unit` | 等于滑动步长 | 步长5分钟 → 每5分钟执行 |
|
||||
| **SESSION**<br/>会话窗口 | `session_window_size` + `session_window_size_unit` | 等于会话超时时间 | 超时30分钟 → 每30分钟执行 |
|
||||
| **NONE**<br/>无窗口 | - | 默认30秒 | 每30秒执行 |
|
||||
|
||||
### 2. 执行流程
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ 应用启动 │
|
||||
│ └─> initAllRules() │
|
||||
│ └─> 加载所有实时规则 │
|
||||
│ └─> 为每个规则初始化下次执行时间(Redis) │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ 定时调度(每10秒检查一次) │
|
||||
│ └─> checkAndExecuteRules() │
|
||||
│ └─> 查询所有实时规则 │
|
||||
│ └─> 对每个规则: │
|
||||
│ ├─> 获取下次执行时间(Redis) │
|
||||
│ ├─> 判断是否到执行时间 │
|
||||
│ │ ├─> 是 → 执行规则 → 更新下次执行时间 │
|
||||
│ │ └─> 否 → 跳过 │
|
||||
│ └─> 继续下一个规则 │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 3. 时间计算逻辑
|
||||
|
||||
#### TUMBLE(滚动窗口)
|
||||
```
|
||||
下次执行时间 = 当前时间 + 窗口大小
|
||||
```
|
||||
|
||||
**示例**:
|
||||
- 窗口大小:5分钟
|
||||
- 执行时间:10:00:00
|
||||
- 下次执行:10:05:00
|
||||
|
||||
#### HOP(滑动窗口)
|
||||
```
|
||||
下次执行时间 = 当前时间 + 滑动步长
|
||||
```
|
||||
|
||||
**示例**:
|
||||
- 窗口大小:10分钟,步长:5分钟
|
||||
- 执行时间:10:00:00
|
||||
- 下次执行:10:05:00
|
||||
|
||||
#### SESSION(会话窗口)
|
||||
```
|
||||
下次执行时间 = 当前时间 + 会话超时时间
|
||||
```
|
||||
|
||||
**示例**:
|
||||
- 会话超时:30分钟
|
||||
- 执行时间:10:00:00
|
||||
- 下次执行:10:30:00
|
||||
|
||||
## 数据结构
|
||||
|
||||
### Redis Key 设计
|
||||
|
||||
```
|
||||
rule:next_execute:{ruleId}
|
||||
```
|
||||
|
||||
**示例**:
|
||||
```
|
||||
rule:next_execute:rule-001 -> "2026-02-27 10:30:00"
|
||||
rule:next_execute:rule-002 -> "2026-02-27 10:00:00"
|
||||
```
|
||||
|
||||
**过期时间**:30天
|
||||
|
||||
## 配置示例
|
||||
|
||||
### application.yml
|
||||
|
||||
```yaml
|
||||
spring:
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
password:
|
||||
database: 0
|
||||
timeout: 3000
|
||||
|
||||
analysis:
|
||||
realtime:
|
||||
enabled: true
|
||||
# 检查间隔(秒) - 频率越高越精确,但消耗资源
|
||||
check-interval-seconds: 10
|
||||
offline:
|
||||
enabled: true
|
||||
cron-expression: "0 0 */1 * * ?"
|
||||
```
|
||||
|
||||
### pom.xml(添加Redis依赖)
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## 核心组件
|
||||
|
||||
### 1. RuleExecutionTimeService
|
||||
规则执行时间管理服务接口,负责:
|
||||
- 获取规则下次执行时间
|
||||
- 更新规则下次执行时间(根据窗口类型计算)
|
||||
- 初始化规则执行时间
|
||||
- 删除规则执行时间
|
||||
|
||||
### 2. RuleExecutionTimeServiceImpl
|
||||
规则执行时间管理服务实现(基于Redis),核心方法:
|
||||
- `calculateTumbleNextExecuteTime()`: 计算滚动窗口下次执行时间
|
||||
- `calculateHopNextExecuteTime()`: 计算滑动窗口下次执行时间
|
||||
- `calculateSessionNextExecuteTime()`: 计算会话窗口下次执行时间
|
||||
|
||||
### 3. RealtimeAnalysisScheduler
|
||||
实时分析调度器,核心逻辑:
|
||||
- 应用启动时初始化所有规则执行时间
|
||||
- 每10秒检查一次规则是否需要执行
|
||||
- 根据窗口类型独立计算下次执行时间
|
||||
|
||||
## 日志示例
|
||||
|
||||
### 初始化日志
|
||||
```
|
||||
INFO - ========== 初始化实时分析调度器 ==========
|
||||
INFO - 查询到 3 个实时分析规则
|
||||
INFO - 初始化规则: ruleId=001, ruleName=暴力破解检测, windowType=HOP, nextExecuteTime=2026-02-27 10:05:00
|
||||
INFO - 初始化规则: ruleId=002, ruleName=端口扫描检测, windowType=TUMBLE, nextExecuteTime=2026-02-27 10:05:00
|
||||
INFO - 初始化规则: ruleId=003, ruleName=会话异常检测, windowType=SESSION, nextExecuteTime=2026-02-27 10:30:00
|
||||
INFO - ========== 实时分析调度器初始化完成 ==========
|
||||
```
|
||||
|
||||
### 执行日志
|
||||
```
|
||||
INFO - 执行规则: ruleId=001, ruleName=暴力破解检测, nextTime=2026-02-27 10:05:00, now=2026-02-27 10:05:00
|
||||
INFO - 滑动窗口下次执行时间: 步长=5m,nextTime=2026-02-27 10:10:00
|
||||
INFO - 更新规则下次执行时间,ruleId=001, ruleName=暴力破解检测, windowType=HOP, nextExecuteTime=2026-02-27 10:10:00
|
||||
INFO - 本次调度执行规则数: 1, 跳过规则数: 2
|
||||
```
|
||||
|
||||
## 优势
|
||||
|
||||
1. ✅ **独立周期**:每个规则根据窗口类型独立配置执行周期
|
||||
2. ✅ **高性能**:Redis缓存,每次检查只需毫秒级
|
||||
3. ✅ **分布式支持**:多节点共享Redis,避免重复执行
|
||||
4. ✅ **动态调整**:运行时修改窗口配置,下次执行自动生效
|
||||
5. ✅ **资源优化**:避免低频规则频繁执行浪费资源
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **Redis依赖**:需要安装并启动Redis服务
|
||||
2. **时间精度**:调度检查间隔默认10秒,可根据需要调整
|
||||
3. **窗口配置**:规则必须配置窗口类型和大小参数
|
||||
4. **异常恢复**:应用重启后,Redis中记录的执行时间保持不变
|
||||
5. **并发控制**:同一规则同时只能有一个实例在执行
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
# ============================================
|
||||
# Syslog Consumer 部署配置
|
||||
# ============================================
|
||||
# 使用方法: docker compose -f docker-compose-consumer.yaml up -d
|
||||
# ============================================
|
||||
|
||||
|
||||
services:
|
||||
# ============================================
|
||||
# Syslog Consumer - 数据消费服务 (平台端)
|
||||
# ============================================
|
||||
syslog-consumer:
|
||||
build:
|
||||
context: ./syslog-consumer-rule
|
||||
dockerfile: Dockerfile
|
||||
image: syslog-consumer-rule:1.2.0
|
||||
container_name: syslog-consumer-rule
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# 环境配置
|
||||
- SPRING_PROFILES_ACTIVE=dev
|
||||
- TZ=Asia/Shanghai
|
||||
# 数据库配置
|
||||
- spring.datasource.url=jdbc:postgresql://117.72.68.72:54329/ecosys
|
||||
- spring.datasource.username=postgres
|
||||
- spring.datasource.password=TnLanWaidYSwTSG5
|
||||
- spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
# HikariCP 连接池配置
|
||||
- spring.datasource.hikari.maximum-pool-size=50
|
||||
- spring.datasource.hikari.minimum-idle=5
|
||||
- spring.datasource.hikari.connection-timeout=30000
|
||||
- spring.datasource.hikari.idle-timeout=600000
|
||||
- spring.datasource.hikari.max-lifetime=900000
|
||||
- spring.datasource.hikari.pool-name=HikariPool-SyslogConsumer
|
||||
- spring.datasource.hikari.auto-commit=false
|
||||
- spring.datasource.hikari.schema=public
|
||||
# Redis配置
|
||||
- spring.redis.host=192.168.222.131
|
||||
- spring.redis.port=6379
|
||||
- spring.redis.password=
|
||||
- spring.redis.database=0
|
||||
- spring.redis.timeout=2000
|
||||
- spring.cache.redis.time-to-live=600000
|
||||
# Kafka配置
|
||||
- spring.kafka.consumer.bootstrap-servers=192.168.222.130:9092
|
||||
- spring.kafka.consumer.group-id=test-group-app
|
||||
- spring.kafka.consumer.auto-offset-reset=latest
|
||||
- spring.kafka.consumer.enable-auto-commit=false
|
||||
- spring.kafka.consumer.topic=test-topic
|
||||
- spring.kafka.consumer.max-poll-records=1000
|
||||
- spring.kafka.listener.ack-mode=manual
|
||||
- spring.kafka.listener.concurrency=2
|
||||
- spring.kafka.listener.type=batch
|
||||
# InfluxDB配置
|
||||
- influxdb.url=http://192.168.222.131:8086
|
||||
- influxdb.token=3Tvu-IZWtaY03UDkbUDlufD0kxn85keo9LhYQcv2Cxk0LJmXqqHkNVrO664DbaJAYwoGI7UIg904KqZC7Q_ZFA==
|
||||
- influxdb.org=yelang
|
||||
- influxdb.bucket=yelangbucket
|
||||
- influxdb.batch.size=1000
|
||||
- influxdb.flush.interval=1000
|
||||
- influxdb.connection.timeout=30s
|
||||
- influxdb.connection.read-timeout=30s
|
||||
- influxdb.connection.write-timeout=60s
|
||||
# Elasticsearch配置
|
||||
- spring.elasticsearch.uris=http://192.168.1.174:9200
|
||||
- spring.elasticsearch.username=CONTAINER_NAME
|
||||
- spring.elasticsearch.password=t2NZCiajmdazxBrF
|
||||
- spring.elasticsearch.connection-timeout=10s
|
||||
- spring.elasticsearch.socket-timeout=30s
|
||||
# API配置
|
||||
- interlocking.api-key=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
|
||||
- interlocking.api.base-url=http://192.168.222.131:8089/xdrservice/interlocking
|
||||
# 探针心跳配置
|
||||
- probe.heartbeat.enabled=true
|
||||
- probe.heartbeat.offline-threshold-minutes=10
|
||||
- probe.status.check.cron=0 */10 * * * ?
|
||||
- probe.heartbeat.tenant-id=000000
|
||||
- probe.heartbeat.history.keep-days=10
|
||||
- probe.heartbeat.history.cleanup-enabled=true
|
||||
- probe.history.cleanup.cron=0 0 1 * * ?
|
||||
# 告警健康检查配置
|
||||
- alarm.health-check.alarm-hours=4
|
||||
- alarm.health-check.alarm-visit-hours=2
|
||||
- alarm.health-check.enabled=true
|
||||
# 关联分析规则配置
|
||||
- analysis.realtime.enabled=true
|
||||
- analysis.realtime.check-interval-seconds=10
|
||||
# 分区表检查配置
|
||||
- partition.check.tomorrow.enabled=true
|
||||
- partition.check.future.days=7
|
||||
- partition.auto.create=true
|
||||
# 定时任务配置
|
||||
- spring.task.scheduling.pool.size=10
|
||||
# 日志配置
|
||||
- logging.level.com.common.schedule=INFO
|
||||
- logging.level.com.common.service=INFO
|
||||
# ETL配置
|
||||
- etl.batch.page-size=1000
|
||||
- etl.batch.insert-batch-size=500
|
||||
- etl.schedule.cron=0 0 2 * * ?
|
||||
# JVM配置
|
||||
- JAVA_OPTS=-Xms512m -Xmx1024m -XX:+UseG1GC -XX:MaxGCPauseMillis=200
|
||||
ports:
|
||||
- "8089:8089"
|
||||
volumes:
|
||||
- /home/syslog/logs:/app/logs
|
||||
networks:
|
||||
- xdr-network
|
||||
|
||||
|
||||
# ============================================
|
||||
# 网络配置
|
||||
# ============================================
|
||||
networks:
|
||||
xdr-network:
|
||||
driver: bridge
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
# ============================================
|
||||
# Syslog Consumer 部署配置
|
||||
# ============================================
|
||||
# 使用方法: docker compose -f docker-compose-consumer.yaml up -d
|
||||
# ============================================
|
||||
|
||||
|
||||
services:
|
||||
# ============================================
|
||||
# Syslog Consumer-rule - 数据消费规则服务(平台端)
|
||||
# ============================================
|
||||
syslog-consumer:
|
||||
build:
|
||||
context: ./consumer-rule
|
||||
dockerfile: Dockerfile
|
||||
image: syslog-consumer-rule:1.0.1
|
||||
container_name: syslog-consumer-rule
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# 环境配置
|
||||
- SPRING_PROFILES_ACTIVE=prod
|
||||
- TZ=Asia/Shanghai
|
||||
# 数据库配置
|
||||
- spring.datasource.url=jdbc:postgresql://192.168.4.26:5432/ecosys
|
||||
- spring.datasource.username=postgres
|
||||
- spring.datasource.password=caZ2TcmXNSW8L2Ap
|
||||
- spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
# HikariCP 连接池配置
|
||||
- spring.datasource.hikari.maximum-pool-size=50
|
||||
- spring.datasource.hikari.minimum-idle=5
|
||||
- spring.datasource.hikari.connection-timeout=30000
|
||||
- spring.datasource.hikari.idle-timeout=600000
|
||||
- spring.datasource.hikari.max-lifetime=900000
|
||||
- spring.datasource.hikari.pool-name=HikariPool-SyslogConsumer
|
||||
- spring.datasource.hikari.auto-commit=false
|
||||
- spring.datasource.hikari.schema=public
|
||||
# Redis配置
|
||||
- spring.redis.host=192.168.4.26
|
||||
- spring.redis.port=6379
|
||||
- spring.redis.password=123456
|
||||
- spring.redis.database=0
|
||||
- spring.redis.timeout=2000
|
||||
- spring.cache.redis.time-to-live=600000
|
||||
# Kafka配置
|
||||
- spring.kafka.consumer.bootstrap-servers=192.168.4.26:9092
|
||||
- spring.kafka.consumer.group-id=agent-01-syslog-group
|
||||
- spring.kafka.consumer.auto-offset-reset=latest
|
||||
- spring.kafka.consumer.enable-auto-commit=false
|
||||
- spring.kafka.consumer.topic=agenet-01-syslog-topic
|
||||
- spring.kafka.consumer.max-poll-records=1000
|
||||
- spring.kafka.listener.ack-mode=manual
|
||||
- spring.kafka.listener.concurrency=2
|
||||
- spring.kafka.listener.type=batch
|
||||
# InfluxDB配置
|
||||
- influxdb.url=http://192.168.4.26:8087
|
||||
- influxdb.token=LFjXZyRxTf1V84oN-wwjhSjS4qIK-ZMoHzQJB67ir3qHNSBVJbMcTkPuNmM0cNxvzFEDWLYNzrz1VJKMitY5hw==
|
||||
- influxdb.org=influxdb
|
||||
- influxdb.bucket=yelangbucket
|
||||
- influxdb.batch.size=1000
|
||||
- influxdb.flush.interval=1000
|
||||
- influxdb.connection.timeout=30s
|
||||
- influxdb.connection.read-timeout=30s
|
||||
- influxdb.connection.write-timeout=60s
|
||||
# 定时任务配置
|
||||
- spring.task.scheduling.pool.size=10
|
||||
# 日志配置
|
||||
- logging.level.com.common.schedule=INFO
|
||||
- logging.level.com.common.service=INFO
|
||||
|
||||
# JVM配置
|
||||
- JAVA_OPTS=-Xms1024m -Xmx4096m -XX:+UseG1GC -XX:MaxGCPauseMillis=200
|
||||
ports:
|
||||
- "8289:8289"
|
||||
volumes:
|
||||
- /home/syslog/logs:/app/logs
|
||||
networks:
|
||||
- xdr-network
|
||||
#
|
||||
# ============================================
|
||||
# 网络配置
|
||||
# ============================================
|
||||
networks:
|
||||
xdr-network:
|
||||
driver: bridge
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# ============================================
|
||||
# Syslog Consumer 部署配置
|
||||
# ============================================
|
||||
# 使用方法: docker compose -f docker-compose-consumer.yaml up -d
|
||||
# ============================================
|
||||
|
||||
|
||||
services:
|
||||
# ============================================
|
||||
# Syslog Consumer - 数据消费服务 (平台端)
|
||||
# ============================================
|
||||
syslog-consumer:
|
||||
build:
|
||||
context: ./syslog-consumer-rule
|
||||
dockerfile: Dockerfile
|
||||
image: syslog-consumer-rule:1.0.1
|
||||
container_name: syslog-consumer-rule
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# 环境配置
|
||||
- SPRING_PROFILES_ACTIVE=dev
|
||||
- TZ=Asia/Shanghai
|
||||
# 数据库配置
|
||||
- spring.datasource.url=jdbc:postgresql://117.72.68.72:54329/ecosys
|
||||
- spring.datasource.username=postgres
|
||||
- spring.datasource.password=TnLanWaidYSwTSG5
|
||||
- spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
# HikariCP 连接池配置
|
||||
- spring.datasource.hikari.maximum-pool-size=50
|
||||
- spring.datasource.hikari.minimum-idle=5
|
||||
- spring.datasource.hikari.connection-timeout=30000
|
||||
- spring.datasource.hikari.idle-timeout=600000
|
||||
- spring.datasource.hikari.max-lifetime=900000
|
||||
- spring.datasource.hikari.pool-name=HikariPool-SyslogConsumer
|
||||
- spring.datasource.hikari.auto-commit=false
|
||||
- spring.datasource.hikari.schema=public
|
||||
# Redis配置
|
||||
- spring.redis.host=192.168.222.131
|
||||
- spring.redis.port=6379
|
||||
- spring.redis.password=
|
||||
- spring.redis.database=0
|
||||
- spring.redis.timeout=2000
|
||||
- spring.cache.redis.time-to-live=600000
|
||||
# Kafka配置
|
||||
- spring.kafka.consumer.bootstrap-servers=192.168.222.130:9092
|
||||
- spring.kafka.consumer.group-id=test-group-app
|
||||
- spring.kafka.consumer.auto-offset-reset=latest
|
||||
- spring.kafka.consumer.enable-auto-commit=false
|
||||
- spring.kafka.consumer.topic=test-topic
|
||||
- spring.kafka.consumer.max-poll-records=1000
|
||||
- spring.kafka.listener.ack-mode=manual
|
||||
- spring.kafka.listener.concurrency=2
|
||||
- spring.kafka.listener.type=batch
|
||||
# InfluxDB配置
|
||||
- influxdb.url=http://192.168.222.131:8086
|
||||
- influxdb.token=3Tvu-IZWtaY03UDkbUDlufD0kxn85keo9LhYQcv2Cxk0LJmXqqHkNVrO664DbaJAYwoGI7UIg904KqZC7Q_ZFA==
|
||||
- influxdb.org=yelang
|
||||
- influxdb.bucket=yelangbucket
|
||||
- influxdb.batch.size=1000
|
||||
- influxdb.flush.interval=1000
|
||||
- influxdb.connection.timeout=30s
|
||||
- influxdb.connection.read-timeout=30s
|
||||
- influxdb.connection.write-timeout=60s
|
||||
|
||||
# 定时任务配置
|
||||
- spring.task.scheduling.pool.size=10
|
||||
# 日志配置
|
||||
- logging.level.com.common.schedule=INFO
|
||||
- logging.level.com.common.service=INFO
|
||||
# JVM配置
|
||||
- JAVA_OPTS=-Xms1024m -Xmx4096m -XX:+UseG1GC -XX:MaxGCPauseMillis=200
|
||||
ports:
|
||||
- "8289:8289"
|
||||
volumes:
|
||||
- /home/syslog/logs:/app/logs
|
||||
networks:
|
||||
- xdr-network
|
||||
|
||||
# ============================================
|
||||
# 网络配置
|
||||
# ============================================
|
||||
networks:
|
||||
xdr-network:
|
||||
driver: bridge
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
--0.�л�����˴��Ŀ¼
|
||||
cd /opt/syslog/docker/consumer-rule
|
||||
|
||||
|
||||
--1.�鿴����������
|
||||
docker ps -a
|
||||
|
||||
--2.���docker image�ļ� (Dockerfile ��ǰĿ¼��
|
||||
docker build -t syslog-consumer-rule:v1.X.X .
|
||||
|
||||
|
||||
--3.ֹͣ���� ��ɾ��
|
||||
docker stop syslog-consumer-rule && docker rm syslog-consumer-rule
|
||||
|
||||
--4.����docker �ļ�
|
||||
docker run --restart unless-stopped -e TZ=Asia/Shanghai -d --name ct-syslog-consumer-rule -p 8289:8289 -v /home/syslog/logs:/app/logs --privileged=true syslog-consumer-rule:v1.X.X
|
||||
�ڳ�CMD��
|
||||
docker run --restart unless-stopped -e TZ=Asia/Shanghai -d --name ct-syslog-consumer-rule -p 8289:8289 -v /data/syslog/logs:/app/logs --privileged=true syslog-consumer-rule:v1.X.X
|
||||
|
||||
--������������
|
||||
docker run -d --name ct-syslog-consumer-rule -p 8089:8089 --privileged=true syslog-consumer-rule:v1.X.X
|
||||
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>security-xdr</artifactId>
|
||||
<groupId>com.haobang</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>syslog-consumer-rule</name>
|
||||
<artifactId>syslog-consumer-rule</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<influxdb-client.version>6.9.0</influxdb-client.version>
|
||||
<slf4j.version>1.7.36</slf4j.version>
|
||||
<logback.version>1.2.11</logback.version>
|
||||
<config.version>1.4.2</config.version>
|
||||
<junit.version>5.9.2</junit.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mybatis.version>3.5.10</mybatis.version>
|
||||
<postgresql.version>42.5.4</postgresql.version>
|
||||
<pagehelper.version>1.4.6</pagehelper.version>
|
||||
</properties>
|
||||
<description>syslog-consumer-rule</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Boot Starter (包含事务管理) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>2.7.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
<!-- InfluxDB Client for Java -->
|
||||
<dependency>
|
||||
<groupId>com.influxdb</groupId>
|
||||
<artifactId>influxdb-client-java</artifactId>
|
||||
<version>${influxdb-client.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 配置管理 -->
|
||||
<dependency>
|
||||
<groupId>com.typesafe</groupId>
|
||||
<artifactId>config</artifactId>
|
||||
<version>${config.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 日志 -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis核心库 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
<artifactId>mybatis</artifactId>
|
||||
<version>${mybatis.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- PostgreSQL驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.13.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20231013</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.24</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.83</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<!-- 如果使用 Quartz 调度器(可选) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Spring Boot 缓存 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Redis 缓存实现 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Elasticsearch -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- PageHelper分页插件 -->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>${pagehelper.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 测试 -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.dameng</groupId>
|
||||
<artifactId>DmJdbcDriver18</artifactId>
|
||||
<version>8.1.2.141</version> <!-- 请根据你的数据库版本替换 -->
|
||||
</dependency>
|
||||
<!-- Bouncy Castle 国密算法支持 -->
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15to18</artifactId>
|
||||
<version>1.78</version> <!-- 兼容 Java 1.8 -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.Modules;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
public class DMTDMTest {
|
||||
public static void main(String[] args) {
|
||||
// 连接信息
|
||||
String url = "jdbc:postgresql://139.9.39.176:16502/dameng";
|
||||
String user = "SYSDBA";
|
||||
String password = "Sysdba12345"; // 如果已修改密码,请替换为实际密码
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
// 1. 加载驱动(JDBC 4.0 后自动加载,但显式加载更稳妥)
|
||||
Class.forName("dm.jdbc.driver.DmDriver");
|
||||
System.out.println("达梦 JDBC 驱动加载成功");
|
||||
|
||||
// 2. 建立连接
|
||||
conn = DriverManager.getConnection(url, user, password);
|
||||
System.out.println("数据库连接成功!");
|
||||
|
||||
// 3. 执行查询(达梦支持 DUAL 表)
|
||||
stmt = conn.createStatement();
|
||||
rs = stmt.executeQuery("SELECT 1 FROM DUAL");
|
||||
|
||||
if (rs.next()) {
|
||||
int result = rs.getInt(1);
|
||||
System.out.println("查询结果: " + result);
|
||||
}
|
||||
|
||||
// 4. 可选:查询当前时间
|
||||
rs.close();
|
||||
rs = stmt.executeQuery("SELECT SYSDATE FROM DUAL");
|
||||
if (rs.next()) {
|
||||
Timestamp now = rs.getTimestamp(1);
|
||||
System.out.println("服务器当前时间: " + now);
|
||||
}
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.err.println("未找到达梦 JDBC 驱动,请检查 DmJdbcDriver18.jar 是否在 classpath 中");
|
||||
e.printStackTrace();
|
||||
} catch (SQLException e) {
|
||||
System.err.println("数据库连接或操作失败");
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// 5. 关闭资源
|
||||
try { if (rs != null) rs.close(); } catch (SQLException e) { e.printStackTrace(); }
|
||||
try { if (stmt != null) stmt.close(); } catch (SQLException e) { e.printStackTrace(); }
|
||||
try { if (conn != null) conn.close(); } catch (SQLException e) { e.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package com.Modules.Device;
|
||||
|
||||
public class deviceInfo {
|
||||
}
|
||||
+618
@@ -0,0 +1,618 @@
|
||||
package com.Modules.NormalData;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.common.entity.XdrHoneypot;
|
||||
import com.common.mapper.XdrHoneypotMapper;
|
||||
import com.common.service.SyslogNonNormalMessageService;
|
||||
import com.common.util.*;
|
||||
import com.config.AppConfig;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.common.entity.SyslogMessage;
|
||||
import com.influx.SyslogToInfluxApp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.common.service.DmNormalizeRuleService;
|
||||
import com.common.service.DmColumnService;
|
||||
import com.common.service.SyslogNormalDataService;
|
||||
import com.common.entity.DmColumn;
|
||||
import com.common.service.impl.DmColumnServiceImpl;
|
||||
import com.common.mapper.DmColumnMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.common.mapper.DmColumnMapper;
|
||||
import com.common.mapper.DmNormalizeRuleMapper;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import com.common.entity.RuleContent.*;
|
||||
import com.common.entity.SyslogNonNormalMessage;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import com.common.service.LogDataFilterService;
|
||||
import com.common.service.LogDataCompleteService;
|
||||
import com.common.service.DeviceCollectTaskService;
|
||||
import com.common.entity.DeviceCollectTask;
|
||||
import com.common.entity.DeviceDevice;
|
||||
import com.common.util.TimeConversionUtils;
|
||||
import com.common.service.DeviceDeviceService;
|
||||
|
||||
public class LogNormalProcessor {
|
||||
private static final Logger logger = LoggerFactory.getLogger(LogNormalProcessor.class);
|
||||
|
||||
private String strLogMsg ;
|
||||
private String strKafkaMessage;
|
||||
private String strDeviceInfo;
|
||||
private String strDataType ="json" ;
|
||||
private Map<String, Object> messageMap ;
|
||||
private Map<String, String> deviceInfoMap ;
|
||||
private String strSyslogUUID ;
|
||||
private String strSyslogTopic ;
|
||||
private boolean isSaveNonNormal =false ;
|
||||
|
||||
@Autowired
|
||||
public DmNormalizeRuleService dmNormalizeRuleService ;
|
||||
@Autowired
|
||||
public DmColumnService dmColumnService ;
|
||||
@Autowired
|
||||
public SyslogNormalDataService syslogNormalDataService =SpringContextUtil.getBean(SyslogNormalDataService.class);
|
||||
@Autowired
|
||||
private SyslogNonNormalMessageService messageService =SpringContextUtil.getBean(SyslogNonNormalMessageService.class);
|
||||
@Autowired
|
||||
private LogDataFilterService logDataFilterService= SpringContextUtil.getBean(LogDataFilterService.class);
|
||||
|
||||
@Autowired
|
||||
private LogDataCompleteService logDataCompleteService= SpringContextUtil.getBean(LogDataCompleteService.class);
|
||||
@Autowired
|
||||
private DeviceCollectTaskService deviceCollectTaskService= SpringContextUtil.getBean(DeviceCollectTaskService.class);
|
||||
@Autowired
|
||||
private DeviceDeviceService deviceDeviceService= SpringContextUtil.getBean(DeviceDeviceService.class);
|
||||
|
||||
@Autowired
|
||||
SyslogNonNormalMessage syslogNonNormalMessage=new SyslogNonNormalMessage();
|
||||
|
||||
@Autowired
|
||||
DmColumnMapper dmColumnMapper;
|
||||
@Autowired
|
||||
DmNormalizeRuleMapper dmNormalizeRuleMapper;
|
||||
|
||||
private List<Map<String, Object>> dmNormalizeRuleList;
|
||||
private List<Map<String, Object>> dmColumnList;
|
||||
private LinkedHashMap<String, Object> OrginalColumnMap ;
|
||||
|
||||
public LogNormalProcessor( String LogMsg, String syslogUUID,String syslogTopic) {
|
||||
|
||||
/** 标准化数据处理步骤 */
|
||||
//初始化 (获取syslog_normal_data 表全部字段的属性、设备ID对应的规则设置、转化成JSON)
|
||||
//判断数据解析类型(json、键值、xml、正则表达式、分割符)解析syslogMessage 字段转成 HashMAP
|
||||
//匹配规则内容,获取字段映射关系配置,抽取命中的字段名称、数值
|
||||
//判断字段内容及类型,根据数据类型属性,进行内容转换。
|
||||
//生成insert SQL语句、执行入库操作。
|
||||
strKafkaMessage=LogMsg;
|
||||
strSyslogUUID=syslogUUID;
|
||||
strSyslogTopic=syslogTopic;
|
||||
|
||||
if(!LogMsg.isEmpty()) {
|
||||
strLogMsg = SyslogParser.substringAfterFirstCloseBracket(LogMsg);
|
||||
strDeviceInfo=SyslogParser.substringBeforeFirstChar(LogMsg,']');
|
||||
}
|
||||
else{
|
||||
LogMsg="[receive_time=20251118165909470 device_id=1 device_name=honeypot vendor=changting data_type=json device_collect_id=1]<14>1 2025-09-24T11:52:26Z 5f46d3be75e1 supermario 128 honeypot_event - {\"source\":\"honeypot1\",\"id\":\"f6a13c35-bf9d-4da6-a181-50ce23e7ef6a\",\"start_time\":\"2023-09-03T11:07:02.50167643Z\",\"time\":\"2023-09-03T11:16:18.883885281Z\",\"risk_level\":4,\"connection\":\"b18f3fbe-3fbf-4495-815f-ff26f6fb0bdf\",\"file_info\":null,\"extra\":{\"payload\":{\"format\":\"line\",\"name\":{\"cn\":\"攻击载荷\",\"en\":\"payload\"},\"value\":\"\"},\"uid\":{\"format\":\"line\",\"name\":{\"cn\":\"\",\"en\":\"\"},\"uid\":\"b4cbc73c-25d0-4429-ae1b-a856cdf1a651\",\"value\":\"\"}},\"type\":\"WEB_ATTACK_SCANNER\",\"agent_sn\":\"caa7da42-0cca-4cb1-b501-1f1eb2b588d5\",\"agent_name\":\" 教育局蜜罐探针\",\"honeypot_id\":\"11a9ac6bdf38ae2aaa49ec4f1b4a921bff71952cb9f175bdd8ee1f0497057bc6\",\"honeypot_name\":\"茂名市中小学管理平台管理后台\",\"src_ip\":\"117.50.189.7\",\"src_port\":58512,\"src_mac\":\"\",\"dest_ip\":\"192.168.222.2\",\"dest_port\":9200,\"proxy_ip\":null,\"node\":\"WRx3\"}";
|
||||
strLogMsg="<14>1 2025-09-24T11:52:26Z 5f46d3be75e1 supermario 128 honeypot_event - {\"source\":\"honeypot1\",\"id\":\"f6a13c35-bf9d-4da6-a181-50ce23e7ef6a\",\"start_time\":\"2023-09-03T11:07:02.50167643Z\",\"time\":\"2023-09-03T11:16:18.883885281Z\",\"risk_level\":4,\"connection\":\"b18f3fbe-3fbf-4495-815f-ff26f6fb0bdf\",\"file_info\":null,\"extra\":{\"payload\":{\"format\":\"line\",\"name\":{\"cn\":\"攻击载荷\",\"en\":\"payload\"},\"value\":\"\"},\"uid\":{\"format\":\"line\",\"name\":{\"cn\":\"\",\"en\":\"\"},\"uid\":\"b4cbc73c-25d0-4429-ae1b-a856cdf1a651\",\"value\":\"\"}},\"type\":\"WEB_ATTACK_SCANNER\",\"agent_sn\":\"caa7da42-0cca-4cb1-b501-1f1eb2b588d5\",\"agent_name\":\" 教育局蜜罐探针\",\"honeypot_id\":\"11a9ac6bdf38ae2aaa49ec4f1b4a921bff71952cb9f175bdd8ee1f0497057bc6\",\"honeypot_name\":\"茂名市中小学管理平台管理后台\",\"src_ip\":\"117.50.189.7\",\"src_port\":58512,\"src_mac\":\"\",\"dest_ip\":\"192.168.222.2\",\"dest_port\":9200,\"proxy_ip\":null,\"node\":\"WRx3\"}";
|
||||
strDeviceInfo=SyslogParser.substringBeforeFirstChar(LogMsg,']');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 初始化数据init()
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
Map<String,String> mapdev =SyslogParser.parseKeyValuePairs(strDeviceInfo);
|
||||
deviceInfoMap=mapdev;
|
||||
//获取日志对应的设备ID
|
||||
long deviceID=Long.parseLong(mapdev.get("device_id"));
|
||||
System.out.println("device_id:"+deviceID );
|
||||
strDataType=mapdev.get("data_type");
|
||||
//getDeviceID(strLogMsg);
|
||||
try{
|
||||
// 通过工具类获取Service实例
|
||||
dmColumnService= SpringContextUtil.getBean(DmColumnService.class);
|
||||
dmNormalizeRuleService= SpringContextUtil.getBean(DmNormalizeRuleService.class);
|
||||
if(deviceID>0) {
|
||||
dmNormalizeRuleList = dmNormalizeRuleService.selectByDeviceIdAuto(deviceID);
|
||||
}
|
||||
//dmColumnList=dmColumnService.selectAllNormal();
|
||||
//System.out.println("dmColumnList size:"+ dmColumnList.size());
|
||||
|
||||
//OrginalColumnMap=getMessageToMap(strLogMsg);
|
||||
//解析SyslogMessage
|
||||
//SyslogMessage logMsg = SyslogParser.parse(strLogMsg);
|
||||
//设备对应的规则normal rule Map 进行标准化数据处理
|
||||
for (int i = 0; i < dmNormalizeRuleList.size(); i++) {
|
||||
try {
|
||||
Map<String, Object> dmNormalizeRule = dmNormalizeRuleList.get(i);
|
||||
String data_type = dmNormalizeRule.get("data_type").toString();
|
||||
//数据类型及格式不符,则break;
|
||||
System.out.println("索引: " + i + ", 值: " + dmNormalizeRule);
|
||||
System.out.println("normalrule ID: " + dmNormalizeRule.get("id") + ", display_name:" + dmNormalizeRule.get("display_name") + " data_type:" + dmNormalizeRule.get("data_type"));
|
||||
//数据类型不匹配,则跳过规则
|
||||
//if (!data_type.equals(strDataType)) break;
|
||||
|
||||
//获取syslog message 文本解析配置项
|
||||
OrginalColumnMap = getMessageToMap(dmNormalizeRule, strLogMsg, data_type);
|
||||
if ((OrginalColumnMap == null) || (OrginalColumnMap.size()==0)) {
|
||||
logger.error("OrginalColumnMap 对象获取为空");
|
||||
//保存非标日志信息
|
||||
syslogNonNormalMessage.setReason("Log解析异常");
|
||||
syslogNonNormalMessage.setReasonDetail("log解析异常,返回规则名称:"+dmNormalizeRule.get("display_name") +",OrginalColumnMap 对象获取为空");
|
||||
if(isSaveNonNormal==false)
|
||||
SaveNonNormalMessage(deviceID, DateTime.now());
|
||||
continue;
|
||||
}
|
||||
List<HashMap<String, Object>> destColumnList = getRuleContentMappers(dmNormalizeRule);
|
||||
//解析字段匹配已命中的配置规则字段
|
||||
List<HashMap<String, Object>> ruleColumnList = getNormalColumnList(OrginalColumnMap, destColumnList);
|
||||
//System.out.println("ruleColumnList :"+ ruleColumnList);
|
||||
Map<String, Object> destMap = getColumnMap(ruleColumnList);
|
||||
//List<HashMap<String ,Object>> destMap2= getCompleteColumnsList(dmNormalizeRule);
|
||||
|
||||
//数据处理-过滤规则
|
||||
if (logDataFilterService.evaluateFilterRule(dmNormalizeRule.get("rule_content").toString(), destMap))
|
||||
continue;
|
||||
|
||||
//数据处理-补全规则
|
||||
logDataCompleteService.processDataCompletion(dmNormalizeRule.get("rule_content").toString(), destMap);
|
||||
//long ruleid=Long.parseLong(dmNormalizeRule.get("id").toString());
|
||||
SaveNormalData(deviceID, DateTime.now(), destMap, Long.parseLong(dmNormalizeRule.get("id").toString()), dmNormalizeRule.get("name").toString());
|
||||
|
||||
} catch (Exception ex) {
|
||||
logger.error("泛化规则处理失败:" + ex.getMessage());
|
||||
System.out.println(ex.getMessage());
|
||||
/**
|
||||
//保存非标日志信息
|
||||
syslogNonNormalMessage.setReason("泛化规则处理失败");
|
||||
syslogNonNormalMessage.setReasonDetail("泛化规则处理失败,失败详情:"+ ex.getMessage());
|
||||
SaveNonNormalMessage(deviceID,DateTime.now());
|
||||
**/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.error("处理初始化异常:"+ex.getMessage());
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//获取数据泛化规则的列表字段,提取 Cropper_params
|
||||
public Cropper_paramsType getCropperParams( Map<String, Object> dmNormalizeRule )
|
||||
{
|
||||
Cropper_paramsType cropperParams = new Cropper_paramsType();
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( dmNormalizeRule.get("rule_content").toString());
|
||||
if (jsonObject.isEmpty()) return null;
|
||||
|
||||
cropperParams.sethead_key(jsonObject.getJSONObject("cropper_params").get("head_key").toString());
|
||||
//需要判断是否字符串head_offset是否空
|
||||
cropperParams.sethead_offset(Integer.parseInt(jsonObject.getJSONObject("cropper_params").get("head_offset").toString()));
|
||||
cropperParams.settail_key(jsonObject.getJSONObject("cropper_params").get("tail_key").toString());
|
||||
//需要判断是否字符串tail_offset是否空
|
||||
cropperParams.settail_offset( Integer.parseInt(jsonObject.getJSONObject("cropper_params").get("tail_offset").toString()));
|
||||
return cropperParams;
|
||||
}catch (Exception ex) {
|
||||
logger.error("getCropperParams:"+ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<HashMap<String ,Object>> getRuleContentMappers( Map<String, Object> dmNormalizeRule )
|
||||
{
|
||||
List<HashMap<String, Object>> filedList =null;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
// 转换为list Map
|
||||
//Map<String, Object> rule_contentMap = objectMapper.readValue( dmNormalizeRule.get("rule_content").toString(), Map.class);
|
||||
//if (rule_contentMap.isEmpty()) return null;
|
||||
JSONObject jsonObject = new JSONObject( dmNormalizeRule.get("rule_content").toString());
|
||||
if (jsonObject.isEmpty()) return null;
|
||||
ObjectMapper objectMapper_mappers = new ObjectMapper();
|
||||
filedList =readJsonToList( jsonObject.get("mappers").toString() );
|
||||
|
||||
}catch (Exception ex) {
|
||||
logger.error("getRuleContentMappers异常:"+ex.getMessage());
|
||||
}
|
||||
return filedList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<HashMap<String, Object>> getCompleteColumnsList( Map<String, Object> dmNormalizeRule )
|
||||
{
|
||||
List<HashMap<String, Object>> filedList =null;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
// 转换为list Map
|
||||
//Map<String, Object> rule_contentMap = objectMapper.readValue( dmNormalizeRule.get("rule_content").toString(), Map.class);
|
||||
//if (rule_contentMap.isEmpty()) return null;
|
||||
JSONObject jsonObject = new JSONObject( dmNormalizeRule.get("rule_content").toString());
|
||||
if (jsonObject.isEmpty()) return null;
|
||||
ObjectMapper objectMapper_mappers = new ObjectMapper();
|
||||
filedList =readJsonToList( jsonObject.get("complete_columns").toString() );
|
||||
|
||||
}catch (Exception ex) {
|
||||
logger.error("getCompleteColumnsList:"+ex.getMessage());
|
||||
}
|
||||
return filedList;
|
||||
}
|
||||
/**
|
||||
* 将JSON 字符串转换为 List<HashMap<String, Object>>
|
||||
*/
|
||||
public static List<HashMap<String, Object>> readJsonToList(String jsonStr) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
return objectMapper.readValue(
|
||||
jsonStr,
|
||||
new TypeReference<List<HashMap<String, Object>>>() {}
|
||||
);
|
||||
} catch (Exception e) {
|
||||
|
||||
logger.error("readJsonToList 解析失败:"+jsonStr);
|
||||
//throw new RuntimeException("JSON 解析失败: " + e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**\
|
||||
* 判断日志信息的数据类型
|
||||
* @param logMsg
|
||||
* @return
|
||||
*/
|
||||
public String getLogDataType( String logMsg)
|
||||
{
|
||||
//判断日志信息的数据类型(json、regex、kv、sep、xml)
|
||||
//默认返回json
|
||||
return "json";
|
||||
}
|
||||
|
||||
public int getDeviceID( String logMsg)
|
||||
{
|
||||
//解析日志信息头部,获取device_id
|
||||
// 默认返回device_id =1
|
||||
return 1;
|
||||
}
|
||||
//获取log 内容字段及数据值
|
||||
public LinkedHashMap<String, Object> getMessageToMap( String MsgContent )
|
||||
{
|
||||
LinkedHashMap<String, Object> linkMap =null;
|
||||
if(strDataType.equals("json")) {
|
||||
//json 类型
|
||||
//解析SyslogMessage
|
||||
SyslogMessage msg = SyslogParser.parse(MsgContent);
|
||||
System.out.println("解析结果-log content: " + msg.getMessage().toString());
|
||||
String complexJson = "{\"source\":\"honeypot1\",\"id\":\"f6a13c35-bf9d-4da6-a181-50ce23e7ef6a\",\"start_time\":\"2023-09-03T11:07:02.50167643Z\",\"time\":\"2023-09-03T11:16:18.883885281Z\",\"risk_level\":4,\"connection\":\"b18f3fbe-3fbf-4495-815f-ff26f6fb0bdf\",\"file_info\":null,\"extra\":{\"payload\":{\"format\":\"line\",\"name\":{\"cn\":\"攻击载荷\",\"en\":\"payload\"},\"value\":\"\"},\"uid\":{\"format\":\"line\",\"name\":{\"cn\":\"\",\"en\":\"\"},\"uid\":\"b4cbc73c-25d0-4429-ae1b-a856cdf1a651\",\"value\":\"\"}},\"type\":\"WEB_ATTACK_SCANNER\",\"agent_sn\":\"caa7da42-0cca-4cb1-b501-1f1eb2b588d5\",\"agent_name\":\" 教育局蜜罐探针\",\"honeypot_id\":\"11a9ac6bdf38ae2aaa49ec4f1b4a921bff71952cb9f175bdd8ee1f0497057bc6\",\"honeypot_name\":\"茂名市中小学管理平台管理后台\",\"src_ip\":\"117.50.189.7\",\"src_port\":58512,\"src_mac\":\"\",\"dest_ip\":\"192.168.222.2\",\"dest_port\":9200,\"proxy_ip\":null,\"node\":\"WRx3\"}";
|
||||
System.out.println("complexJson content: " + complexJson);
|
||||
//静态字符串、编码有问题,临时用 静态字符串做测试,流程环境没问题
|
||||
if(AppConfig.geRunEnvironment().equals("dev")) {
|
||||
//LinkedHashMap<String, Object> flatMap = JsonParser.parseJsonToFlatMap(complexJson);
|
||||
LinkedHashMap<String, Object> flatMap =JsonParser.jsonToMap(complexJson);
|
||||
flatMap.forEach((key, value) -> System.out.println(key + " = " + value));
|
||||
return flatMap;
|
||||
}
|
||||
else
|
||||
{
|
||||
//LinkedHashMap<String, Object> flatMap = JsonParser.parseJsonToFlatMap(msg.getMessage());
|
||||
LinkedHashMap<String, Object> flatMap =JsonParser.jsonToMap(msg.getMessage());
|
||||
flatMap.forEach((key, value) -> System.out.println(key + " = " + value));
|
||||
return flatMap;
|
||||
}
|
||||
}
|
||||
else if(strDataType.equals("kv")) //key-value 键值类型
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if(strDataType.equals("sep")) //分隔符
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if(strDataType.equals("xml")) //类型 xml
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else if(strDataType.equals("regex")) //正则表达式
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// List<Map<String, Object>> rulelst=dmNormalizeRuleService.selectByDeviceId((long)1);
|
||||
return linkMap;
|
||||
}
|
||||
|
||||
|
||||
//获取log message内容字段及数据值
|
||||
public LinkedHashMap<String, Object> getMessageToMap( Map<String, Object> dmNormalizeRule, String MsgContent , String dataType)
|
||||
{
|
||||
LinkedHashMap<String, Object> linkMap = new LinkedHashMap<>();
|
||||
try {
|
||||
//String decode =dmNormalizeRule.get("decode").toString();
|
||||
Cropper_paramsType cropperParams = getCropperParams(dmNormalizeRule);
|
||||
if (dataType.equals("json")) {
|
||||
String strJson = logNormalData.ParserMessageJsonType(MsgContent, cropperParams);
|
||||
LinkedHashMap<String, Object> result1 = NestedJsonParserUtil.safeParseJson(strJson);
|
||||
LinkedHashMap<String, Object> flattened = NestedJsonUtils.flattenNestedJson(result1);
|
||||
return flattened;
|
||||
//parseJsonToFlatMap 复杂的json转换、解析过程有异常
|
||||
//return JsonParser.parseJsonToFlatMap(strJson);
|
||||
// return JsonParser.jsonToMap(strJson);
|
||||
}
|
||||
else if (dataType.equals("kv")) //key-value 键值类型
|
||||
{
|
||||
String strKeyVal = logNormalData.ParserMessageJsonType(MsgContent, cropperParams);
|
||||
KvTextParser kvTextParser =new KvTextParser();
|
||||
kv_paramsType kvparams=logNormalData.getkv_paramsType( dmNormalizeRule);
|
||||
linkMap= kvTextParser.parseKvText(strKeyVal,kvparams);
|
||||
return linkMap;
|
||||
}
|
||||
else if (dataType.equals("sep")) //分隔符
|
||||
{
|
||||
//获取分隔符
|
||||
String SepKey=logNormalData.sepType(dmNormalizeRule);
|
||||
String strSep = logNormalData.ParserMessageJsonType(MsgContent, cropperParams);
|
||||
linkMap= TextParserUtil.parseSeparatedText(strSep, SepKey);
|
||||
return linkMap;
|
||||
}
|
||||
else if (dataType.equals("xml")) //类型 xml
|
||||
{
|
||||
return linkMap;
|
||||
}
|
||||
else if (dataType.equals("regex")) //正则表达式
|
||||
{
|
||||
String strRegex = logNormalData.ParserMessageJsonType(MsgContent, cropperParams);
|
||||
String regexp= logNormalData.Regexp(dmNormalizeRule);
|
||||
linkMap= RegexTextParser.parseWithRegex(strRegex,regexp );
|
||||
return linkMap;
|
||||
}
|
||||
}catch (Exception ex) {
|
||||
logger.error("getMessageToMap:"+ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
return linkMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备ID获取配置规则
|
||||
* @param device_id
|
||||
* @return List<Map<String, Object>>
|
||||
*/
|
||||
public List<Map<String, Object>> getRuleList( long device_id)
|
||||
{
|
||||
List<Map<String, Object>> rulelst=dmNormalizeRuleService.selectByDeviceId((long)1);
|
||||
if (rulelst!=null)
|
||||
{
|
||||
System.out.println("rulelst: " + rulelst);
|
||||
}
|
||||
else{
|
||||
logger.error(" List<Map<String, Object>> rulelst is null!" );
|
||||
}
|
||||
return rulelst;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找命中配置规则的字段及数值
|
||||
* @param destColumnList 泛化目标字段list
|
||||
* @param destColumnList 日志源字段及数值list
|
||||
* @return
|
||||
*/
|
||||
public List<HashMap<String,Object>> getNormalColumnList( LinkedHashMap<String, Object> orginColumnMap ,List<HashMap<String, Object>> destColumnList )
|
||||
{
|
||||
List<HashMap<String, Object>> columnlist =new ArrayList<>();
|
||||
// 原始解析字段遍历泛化规则目标字段
|
||||
for (Map.Entry<String, Object > entry : orginColumnMap.entrySet()) {
|
||||
//System.out.println(entry.getKey() + ": " + entry.getValue());
|
||||
for (Map<String, Object> map : destColumnList) {
|
||||
//System.out.println( "origin_field: " + map.get("origin_field").toString());
|
||||
if ( map.get("origin_field").toString().equals(entry.getKey()) ) {
|
||||
System.out.println(map);
|
||||
Map<String, Object> normalColumMap =new LinkedHashMap<>();
|
||||
normalColumMap.put("origin_field",entry.getKey() );
|
||||
normalColumMap.put("dest_field",map.get("dest_field").toString());
|
||||
normalColumMap.put("action",(HashMap<String, Object>)map.get("action") );
|
||||
//normalColumMap.put("mapping ",entry.getKey() );
|
||||
normalColumMap.put("origin_field_value",entry.getValue() );
|
||||
// System.out.println("action: " + map.get("action").toString());
|
||||
if( ((HashMap<String, Object>)map.get("action")).get("type").equals("equal"))
|
||||
//直接赋值
|
||||
normalColumMap.put("dest_field_value",entry.getValue() );
|
||||
else if(((HashMap<String, Object>)map.get("action")).get("type").equals("mapping"))
|
||||
{
|
||||
//mapping 映射枚举值
|
||||
normalColumMap.put("dest_field_value",entry.getValue() );
|
||||
normalColumMap.put("action_param",((HashMap<String, Object>)map.get("action")).get("param") );
|
||||
HashMap<String, Object> action_param=(HashMap<String, Object>)((HashMap<String, Object>)map.get("action")).get("param") ;
|
||||
//匹配并获取映射枚举值
|
||||
normalColumMap.put("dest_field_value",getMappingValue(action_param ,entry.getValue().toString() ));
|
||||
}
|
||||
else if(((HashMap<String, Object>)map.get("action")).get("type").equals("time"))
|
||||
{
|
||||
//time 类型
|
||||
//normalColumMap.put("dest_field_value",entry.getValue() );
|
||||
normalColumMap.put("action_param",((HashMap<String, Object>)map.get("action")).get("param") );
|
||||
HashMap<String, Object> action_param=(HashMap<String, Object>)((HashMap<String, Object>)map.get("action")).get("param") ;
|
||||
//匹配时间格式并转成换整型格式
|
||||
try {
|
||||
long longTime = TimeConversionUtils.convertToMillis(entry.getValue().toString(), action_param.get("timezone").toString());
|
||||
normalColumMap.put("dest_field_value", longTime);
|
||||
} catch (Exception e) {
|
||||
logger.error("时间类型转换错误,源值:" + entry.getValue().toString() + ",java_date_format:" + action_param.get("java_date_format").toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
columnlist.add((HashMap<String, Object>)normalColumMap);
|
||||
//System.out.println( "normalColumMap: " +normalColumMap);
|
||||
//存在源字段配置多个目标字段,使用continue,而不是break
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return columnlist;
|
||||
}
|
||||
|
||||
/**
|
||||
* paramMapping Map匹配查找对应的值
|
||||
* @param paramMappingValueMap
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Object getMappingValue(HashMap<String, Object> paramMappingValueMap,String value)
|
||||
{
|
||||
HashMap<String, Object> Map= (HashMap<String, Object>)paramMappingValueMap.get("mapping");
|
||||
for (Map.Entry<String, Object > entry : Map.entrySet()) {
|
||||
if ( entry.getKey().equals(value) ) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段Map,包含字段field及Value值
|
||||
* @param normalColumnList
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object > getColumnMap( List<HashMap<String,Object>> normalColumnList )
|
||||
{
|
||||
Map<String, Object > columnMap= new HashMap<>();
|
||||
for (Map<String, Object> map : normalColumnList) {
|
||||
|
||||
Object destFieldValue = map.get("dest_field_value");
|
||||
// 判断 dest_field_value 是否为 String 且包含 "\u0000"
|
||||
if (destFieldValue instanceof String && ((String) destFieldValue).contains("\u0000")) {
|
||||
// 替换掉所有 "\u0000" 字符
|
||||
destFieldValue = ((String) destFieldValue).replace("\u0000", "");
|
||||
}
|
||||
columnMap.put(map.get("dest_field").toString(), destFieldValue);
|
||||
//columnMap.put(map.get("dest_field").toString(),map.get("dest_field_value"));
|
||||
}
|
||||
return columnMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据到标准化表
|
||||
* @param deviceId
|
||||
* @param logtime
|
||||
* @param logColumnMap
|
||||
*/
|
||||
public void SaveNormalData(long deviceId , DateTime logtime, Map<String, Object > logColumnMap, long normalizeRuleId ,String normalizeRuleName)
|
||||
{
|
||||
try {
|
||||
if(logColumnMap.isEmpty() )
|
||||
{
|
||||
logger.error("SaveNormalData ->logColumnMap 为空,syslogUUID:" +this.strSyslogUUID);
|
||||
//保存非标日志信息
|
||||
syslogNonNormalMessage.setReason("未命中规则");
|
||||
syslogNonNormalMessage.setReasonDetail("失败详情:logColumnMap对象字段为空" );
|
||||
if(isSaveNonNormal==false)
|
||||
SaveNonNormalMessage(deviceId,DateTime.now());
|
||||
return ;
|
||||
}
|
||||
Map<String, Object> columnMap = logColumnMap;
|
||||
//补全设备信息字段
|
||||
CompletionDeviceInfo(columnMap, deviceId);
|
||||
|
||||
columnMap.put("device_id", deviceId);
|
||||
columnMap.put("log_time", logtime);
|
||||
columnMap.put("id", UUID.randomUUID().toString());
|
||||
columnMap.put("normalize_rule_id", normalizeRuleId);
|
||||
columnMap.put("normalize_rule_name", normalizeRuleName);
|
||||
columnMap.put("syslog_uuid", this.strSyslogUUID);
|
||||
columnMap.put("syslog_topic", this.strSyslogTopic);
|
||||
System.out.println("columnMap:"+columnMap);
|
||||
syslogNormalDataService.insertDynamic(columnMap);
|
||||
} catch (Exception e) {
|
||||
logger.error("SaveNormalData失败 " );
|
||||
//保存非标日志信息
|
||||
syslogNonNormalMessage.setReason("入库失败");
|
||||
syslogNonNormalMessage.setReasonDetail("入库失败,normalizeRuleName :"+normalizeRuleName+",失败详情:"+ e.getMessage());
|
||||
if(isSaveNonNormal==false)
|
||||
SaveNonNormalMessage(deviceId,DateTime.now());
|
||||
throw new RuntimeException("SaveNormalData 失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 补全设备信息字段
|
||||
* @param columnMap
|
||||
* @param deviceID
|
||||
*/
|
||||
public void CompletionDeviceInfo(Map<String, Object> columnMap ,Long deviceID)
|
||||
{
|
||||
try {
|
||||
DeviceDevice devInfo = deviceDeviceService.getByIdSafely( Long.valueOf(deviceID).intValue() );
|
||||
if (devInfo != null) {
|
||||
columnMap.put("device_ip", devInfo.getIp());
|
||||
columnMap.put("device_manufacturer", devInfo.getVendor());
|
||||
columnMap.put("device_name", devInfo.getName());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("CompletionDeviceInfo 失败!ID:"+deviceID );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存非标日志记录
|
||||
* @param deviceId
|
||||
* @param logtime
|
||||
*/
|
||||
public void SaveNonNormalMessage(long deviceId , DateTime logtime)
|
||||
{
|
||||
try {
|
||||
SyslogNonNormalMessage normalMessage =new SyslogNonNormalMessage() ;
|
||||
//获取日志对应的设备ID
|
||||
Integer collect_id= Integer.parseInt(this.deviceInfoMap.get("device_collect_id"));
|
||||
DeviceCollectTask deviceCollectTask=deviceCollectTaskService.getById(collect_id);
|
||||
normalMessage.setId( UUID.randomUUID().toString());
|
||||
normalMessage.setDeviceId((int)deviceId);
|
||||
normalMessage.setLogTime(logtime.toLocalDateTime());
|
||||
normalMessage.setRuleTime(logtime.toLocalDateTime());
|
||||
normalMessage.setSyslogMessage(this.strLogMsg);
|
||||
normalMessage.setSyslogTopic(this.strSyslogTopic);
|
||||
normalMessage.setSyslogUuid(this.strSyslogUUID);
|
||||
normalMessage.setHeaderMessage(this.strDeviceInfo);
|
||||
normalMessage.setEtlNode("etlgo");
|
||||
normalMessage.setReason( syslogNonNormalMessage.getReason());
|
||||
normalMessage.setReasonDetail( syslogNonNormalMessage.getReasonDetail());
|
||||
//采集探针名称
|
||||
normalMessage.setRuleResult("FAIL");
|
||||
normalMessage.setDeviceName(deviceInfoMap.get("device_name"));
|
||||
normalMessage.setCollectTaskId(collect_id);
|
||||
if(deviceCollectTask!=null)
|
||||
normalMessage.setCollectTaskName(deviceCollectTask.getTaskName());
|
||||
this.messageService.saveMessage(normalMessage );
|
||||
isSaveNonNormal=true;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("SaveNonNormalMessage 失败:" );
|
||||
throw new RuntimeException("SaveNonNormalMessage 失败: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String strlogMessage= "<14>1 2025-09-24T11:52:26Z 5f46d3be75e1 supermario 128 honeypot_event - {\"source\":\"honeypot1\",\"id\":\"f6a13c35-bf9d-4da6-a181-50ce23e7ef6a\",\"start_time\":\"2023-09-03T11:07:02.50167643Z\",\"time\":\"2023-09-03T11:16:18.883885281Z\",\"risk_level\":4,\"connection\":\"b18f3fbe-3fbf-4495-815f-ff26f6fb0bdf\",\"file_info\":null,\"extra\":{\"payload\":{\"format\":\"line\",\"name\":{\"cn\":\"攻击载荷\",\"en\":\"payload\"},\"value\":\"\"},\"uid\":{\"format\":\"line\",\"name\":{\"cn\":\"\",\"en\":\"\"},\"uid\":\"b4cbc73c-25d0-4429-ae1b-a856cdf1a651\",\"value\":\"\"}},\"type\":\"WEB_ATTACK_SCANNER\",\"agent_sn\":\"caa7da42-0cca-4cb1-b501-1f1eb2b588d5\",\"agent_name\":\" 教育局蜜罐探针\",\"honeypot_id\":\"11a9ac6bdf38ae2aaa49ec4f1b4a921bff71952cb9f175bdd8ee1f0497057bc6\",\"honeypot_name\":\"茂名市中小学管理平台管理后台\",\"src_ip\":\"117.50.189.7\",\"src_port\":58512,\"src_mac\":\"\",\"dest_ip\":\"192.168.222.2\",\"dest_port\":9200,\"proxy_ip\":null,\"node\":\"WRx3\"}";
|
||||
String strMsgContent= "{\"source\":\"honeypot1\",\"id\":\"f6a13c35-bf9d-4da6-a181-50ce23e7ef6a\",\"start_time\":\"2023-09-03T11:07:02.50167643Z\",\"time\":\"2023-09-03T11:16:18.883885281Z\",\"risk_level\":4,\"connection\":\"b18f3fbe-3fbf-4495-815f-ff26f6fb0bdf\",\"file_info\":null,\"extra\":{\"payload\":{\"format\":\"line\",\"name\":{\"cn\":\"攻击载荷\",\"en\":\"payload\"},\"value\":\"\"},\"uid\":{\"format\":\"line\",\"name\":{\"cn\":\"\",\"en\":\"\"},\"uid\":\"b4cbc73c-25d0-4429-ae1b-a856cdf1a651\",\"value\":\"\"}},\"type\":\"WEB_ATTACK_SCANNER\",\"agent_sn\":\"caa7da42-0cca-4cb1-b501-1f1eb2b588d5\",\"agent_name\":\" 教育局蜜罐探针\",\"honeypot_id\":\"11a9ac6bdf38ae2aaa49ec4f1b4a921bff71952cb9f175bdd8ee1f0497057bc6\",\"honeypot_name\":\"茂名市中小学管理平台管理后台\",\"src_ip\":\"117.50.189.7\",\"src_port\":58512,\"src_mac\":\"\",\"dest_ip\":\"192.168.222.2\",\"dest_port\":9200,\"proxy_ip\":null,\"node\":\"WRx3\"}";
|
||||
//Map<String, Object> flatMap =(new logNormalData()).getMessageToMap(strMsgContent);
|
||||
//flatMap.forEach((key, value) -> System.out.println(key + " = " + value));
|
||||
//LogNormalProcessor logData =new LogNormalProcessor(strlogMessage,);
|
||||
//logData.init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+419
@@ -0,0 +1,419 @@
|
||||
package com.Modules.NormalData;
|
||||
|
||||
import com.influx.InfluxDBClient;
|
||||
import com.common.util.SyslogParser;
|
||||
import com.config.AppConfig;
|
||||
import com.influxdb.client.domain.WritePrecision;
|
||||
import com.influxdb.client.write.Point;
|
||||
import com.influxdb.client.WriteApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.kafka.annotation.KafkaListener;
|
||||
import org.springframework.kafka.support.Acknowledgment;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import com.common.util.Sm4Util;
|
||||
import com.config.AppConfig;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SysLogProcessor {
|
||||
|
||||
@Autowired
|
||||
@Qualifier("logNormalProcessorExecutor")
|
||||
private Executor taskExecutor;
|
||||
|
||||
@Value("${app.processor.batch-size:100}")
|
||||
private int batchSize;
|
||||
|
||||
@Value("${app.processor.process-timeout-ms:30000}")
|
||||
private long processTimeoutMs;
|
||||
|
||||
private static String strhexKey=AppConfig.getSM4Key();
|
||||
private final AtomicInteger totalProcessed = new AtomicInteger(0);
|
||||
private final AtomicInteger currentBatchCount = new AtomicInteger(0);
|
||||
// 初始化 InfluxDB 客户端
|
||||
private final com.influx.InfluxDBClient influxClient = new InfluxDBClient();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 方案一:直接多线程并行处理(推荐)
|
||||
* 单线程消费,每条消息独立提交给线程池处理
|
||||
*/
|
||||
public void listen(List<String> records, Acknowledgment ack) {
|
||||
try {
|
||||
// 处理业务逻辑
|
||||
for (String record : records) {
|
||||
System.out.println(record);
|
||||
}
|
||||
// 手动提交偏移量
|
||||
ack.acknowledge(); // 告诉Kafka这条消息已成功处理
|
||||
} catch (Exception e) {
|
||||
// 不提交偏移量,消息会被重新消费
|
||||
}
|
||||
}
|
||||
@KafkaListener(
|
||||
topics = "${spring.kafka.consumer.topic:agent-syslog-topic}",
|
||||
concurrency = "2" // 多线程消费
|
||||
)
|
||||
public void consumeAndParallelProcess(List<ConsumerRecord<String, String>> records, Acknowledgment ack) {
|
||||
if (records.isEmpty()) {
|
||||
ack.acknowledge();
|
||||
return;
|
||||
}
|
||||
log.info("开始处理批次消息,数量: {}", records.size());
|
||||
currentBatchCount.set(records.size());
|
||||
|
||||
try {
|
||||
List<CompletableFuture<Void>> processingFutures = new ArrayList<>();
|
||||
|
||||
// 为每条消息创建独立的处理任务
|
||||
for (ConsumerRecord<String, String> record : records) {
|
||||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
// 异步处理单条消息
|
||||
log.info("收到syslogmessage:"+ Sm4Util.decryptCbc(record.value(), strhexKey));
|
||||
processSingleMessageAsync(record);
|
||||
} catch (Exception e) {
|
||||
log.error("处理消息失败, topic: {}, partition: {}, offset: {}",
|
||||
record.topic(), record.partition(), record.offset(), e);
|
||||
} finally {
|
||||
// 计数器递减
|
||||
if (currentBatchCount.decrementAndGet() == 0) {
|
||||
log.debug("批次所有消息处理完成");
|
||||
}
|
||||
}
|
||||
}, taskExecutor);
|
||||
|
||||
processingFutures.add(future);
|
||||
}
|
||||
|
||||
// 等待所有处理任务完成(带超时)
|
||||
CompletableFuture<Void> allFutures = CompletableFuture.allOf(
|
||||
processingFutures.toArray(new CompletableFuture[0])
|
||||
);
|
||||
|
||||
try {
|
||||
allFutures.get(processTimeoutMs, TimeUnit.MILLISECONDS);
|
||||
log.info("批次处理完成,总数: {}", records.size());
|
||||
} catch (java.util.concurrent.TimeoutException e) {
|
||||
log.warn("批次处理超时,已处理: {}/{}",
|
||||
records.size() - currentBatchCount.get(), records.size());
|
||||
}
|
||||
|
||||
// 提交偏移量
|
||||
ack.acknowledge();
|
||||
totalProcessed.addAndGet(records.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("消费处理异常", e);
|
||||
ack.acknowledge(); // 异常情况下也提交偏移量,避免阻塞
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方案二:分批多线程处理
|
||||
* 将大批次拆分为小批次进行并行处理
|
||||
*/
|
||||
/**
|
||||
@KafkaListener(
|
||||
topics = "${kafka.topic.log-normal-batch:log-normal-topic-batch}",
|
||||
concurrency = "1"
|
||||
)
|
||||
*/
|
||||
public void consumeAndBatchProcess(List<ConsumerRecord<String, String>> records,
|
||||
Acknowledgment ack) {
|
||||
if (records.isEmpty()) {
|
||||
ack.acknowledge();
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("开始分批处理消息,总数: {}", records.size());
|
||||
|
||||
try {
|
||||
List<CompletableFuture<Void>> batchFutures = new ArrayList<>();
|
||||
|
||||
// 将消息列表拆分为多个批次进行并行处理
|
||||
for (int i = 0; i < records.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, records.size());
|
||||
final List<ConsumerRecord<String, String>> batch = records.subList(i, end);
|
||||
final int batchIndex = i / batchSize + 1;
|
||||
|
||||
CompletableFuture<Void> batchFuture = CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
processMessageBatch(batch, batchIndex);
|
||||
} catch (Exception e) {
|
||||
log.error("批次处理异常, 批次: {}", batchIndex, e);
|
||||
}
|
||||
}, taskExecutor);
|
||||
|
||||
batchFutures.add(batchFuture);
|
||||
}
|
||||
|
||||
// 等待所有批次处理完成
|
||||
CompletableFuture<Void> allBatches = CompletableFuture.allOf(
|
||||
batchFutures.toArray(new CompletableFuture[0])
|
||||
);
|
||||
|
||||
allBatches.get(processTimeoutMs, TimeUnit.MILLISECONDS);
|
||||
|
||||
// 提交偏移量
|
||||
ack.acknowledge();
|
||||
log.info("全部分批处理完成,总数: {}", records.size());
|
||||
totalProcessed.addAndGet(records.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("分批消费处理异常", e);
|
||||
ack.acknowledge();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方案三:带优先级的处理
|
||||
* 根据消息内容决定处理优先级
|
||||
*/
|
||||
/**
|
||||
@KafkaListener(
|
||||
topics = "${kafka.topic.log-normal-priority:log-normal-topic-priority}",
|
||||
concurrency = "1"
|
||||
)
|
||||
*/
|
||||
public void consumeWithPriority(List<ConsumerRecord<String, String>> records,
|
||||
Acknowledgment ack) {
|
||||
if (records.isEmpty()) {
|
||||
ack.acknowledge();
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("开始优先级处理消息,数量: {}", records.size());
|
||||
|
||||
try {
|
||||
List<CompletableFuture<Void>> highPriorityFutures = new ArrayList<>();
|
||||
List<CompletableFuture<Void>> normalPriorityFutures = new ArrayList<>();
|
||||
|
||||
// 根据消息内容分类处理
|
||||
for (ConsumerRecord<String, String> record : records) {
|
||||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||
processSingleMessageAsync(record);
|
||||
}, taskExecutor);
|
||||
|
||||
// 根据消息内容判断优先级(这里简单根据key判断)
|
||||
if (isHighPriorityMessage(record)) {
|
||||
highPriorityFutures.add(future);
|
||||
} else {
|
||||
normalPriorityFutures.add(future);
|
||||
}
|
||||
}
|
||||
|
||||
// 优先处理高优先级任务
|
||||
if (!highPriorityFutures.isEmpty()) {
|
||||
CompletableFuture.allOf(
|
||||
highPriorityFutures.toArray(new CompletableFuture[0])
|
||||
).get(processTimeoutMs / 2, TimeUnit.MILLISECONDS);
|
||||
log.info("高优先级消息处理完成: {}", highPriorityFutures.size());
|
||||
}
|
||||
|
||||
// 然后处理普通优先级任务
|
||||
if (!normalPriorityFutures.isEmpty()) {
|
||||
CompletableFuture.allOf(
|
||||
normalPriorityFutures.toArray(new CompletableFuture[0])
|
||||
).get(processTimeoutMs / 2, TimeUnit.MILLISECONDS);
|
||||
log.info("普通优先级消息处理完成: {}", normalPriorityFutures.size());
|
||||
}
|
||||
|
||||
ack.acknowledge();
|
||||
totalProcessed.addAndGet(records.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("优先级消费处理异常", e);
|
||||
ack.acknowledge();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步处理单条消息
|
||||
*/
|
||||
@Async("logNormalProcessorExecutor")
|
||||
public void processSingleMessageAsync(ConsumerRecord<String, String> record) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
// 模拟消息解析
|
||||
//String message = parseMessage(record);
|
||||
// 模拟业务处理
|
||||
//processBusinessLogic(message);
|
||||
|
||||
//Message进行SM4解密
|
||||
String Sm4message=Sm4Util.decryptCbc(record.value(), strhexKey);
|
||||
System.out.println("Sm4message:"+Sm4message);
|
||||
|
||||
|
||||
String sysLogUUID =getSysLogUUID();
|
||||
String strDeviceInfo= SyslogParser.substringBeforeFirstChar(Sm4message,']');
|
||||
Map<String,String> mapdev =SyslogParser.parseKeyValuePairs(strDeviceInfo);
|
||||
|
||||
// 初始化 InfluxDB 客户端
|
||||
Point point = Point.measurement("syslog_security_"+sysLogUUID.substring(0,8) )
|
||||
.addTag("device_id", mapdev.get("device_id")) // 添加设备ID标签
|
||||
.addTag("device_collect_id", mapdev.get("device_collect_id")) // 添加探针ID标签
|
||||
.addTag("uuid", sysLogUUID) //syslog uuid
|
||||
.addTag("topic", AppConfig.getTopic()) //kafka topic
|
||||
.addField("message", Sm4message) // 添加字段
|
||||
.addField("receive_time", mapdev.get("receive_time")) // 添加字段
|
||||
.addField("uuid", sysLogUUID)
|
||||
.time(System.currentTimeMillis(), WritePrecision.MS) ;// 毫秒级时间戳
|
||||
//influxClient.writePointBlocking(point);
|
||||
///写入单点(异步,立即返回)
|
||||
influxClient.writePoint(point);
|
||||
|
||||
System.out.println("influxdb wirte syslog ,value:"+ record.key());
|
||||
// 日志信息插入pg XdrHoneypot 表
|
||||
//insertSingleRecord( record.value());
|
||||
|
||||
//String syslogMessage= AppConfig.geRunEnvironment().equals("test")? record.value().substring(34) : record.value();
|
||||
String syslogMessage= Sm4message;
|
||||
//剔除测试环境本机syslog新增的头部信息
|
||||
LogNormalProcessor logNormalProcessor = new LogNormalProcessor(syslogMessage,sysLogUUID,AppConfig.getTopic());
|
||||
//LogNormalProcessor logNormalProcessor =new LogNormalProcessor(record.value());
|
||||
logNormalProcessor.init();
|
||||
System.out.println("insert postgres syslog ,value:"+ record.key());
|
||||
long costTime = System.currentTimeMillis() - startTime;
|
||||
log.debug("消息处理完成, offset: {}, 耗时: {}ms", record.offset(), costTime);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("异步处理消息失败, offset: {}", record.offset(), e);
|
||||
// 这里可以添加重试逻辑或死信队列处理
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理消息批次
|
||||
*/
|
||||
private void processMessageBatch(List<ConsumerRecord<String, String>> batch, int batchIndex) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
log.debug("开始处理批次: {}, 数量: {}", batchIndex, batch.size());
|
||||
|
||||
try {
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
|
||||
// 批次内并行处理
|
||||
for (ConsumerRecord<String, String> record : batch) {
|
||||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||
processSingleMessageAsync(record);
|
||||
}, taskExecutor);
|
||||
futures.add(future);
|
||||
}
|
||||
|
||||
// 等待批次内所有任务完成
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
||||
.get(processTimeoutMs, TimeUnit.MILLISECONDS);
|
||||
|
||||
long costTime = System.currentTimeMillis() - startTime;
|
||||
log.info("批次处理完成: {}, 数量: {}, 总耗时: {}ms",
|
||||
batchIndex, batch.size(), costTime);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("批次处理异常: {}", batchIndex, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为高优先级消息
|
||||
*/
|
||||
private boolean isHighPriorityMessage(ConsumerRecord<String, String> record) {
|
||||
// 简单的优先级判断逻辑
|
||||
// 可以根据key、header、或消息内容来判断
|
||||
return record.key() != null &&
|
||||
(record.key().contains("ERROR") || record.key().contains("URGENT"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息解析(模拟)
|
||||
*/
|
||||
private String parseMessage(ConsumerRecord<String, String> record) {
|
||||
// 模拟解析耗时
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return record.value();
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务逻辑处理(模拟)
|
||||
*/
|
||||
private void processBusinessLogic(String message) {
|
||||
// 模拟业务处理耗时
|
||||
try {
|
||||
Thread.sleep(5); // 模拟5ms处理时间
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
// 这里可以添加具体的业务逻辑
|
||||
// 例如:数据转换、验证、丰富等
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取处理统计信息
|
||||
*/
|
||||
public ProcessingStats getProcessingStats() {
|
||||
return new ProcessingStats(
|
||||
totalProcessed.get(),
|
||||
currentBatchCount.get()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理统计信息类
|
||||
*/
|
||||
public static class ProcessingStats {
|
||||
private final int totalProcessed;
|
||||
private final int currentBatchCount;
|
||||
|
||||
public ProcessingStats(int totalProcessed, int currentBatchCount) {
|
||||
this.totalProcessed = totalProcessed;
|
||||
this.currentBatchCount = currentBatchCount;
|
||||
}
|
||||
|
||||
public int getTotalProcessed() { return totalProcessed; }
|
||||
public int getCurrentBatchCount() { return currentBatchCount; }
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志信息UUID,格式: yyyyMMddxxxxxxxx
|
||||
* @return
|
||||
*/
|
||||
private static String getSysLogUUID ()
|
||||
{
|
||||
// 获取当前日期
|
||||
LocalDate currentDate = LocalDate.now();
|
||||
// 定义格式 (yyyyMMdd)
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||
// 格式化日期
|
||||
String formattedDate = currentDate.format(formatter);
|
||||
return formattedDate +"-"+ UUID.randomUUID() ;
|
||||
}
|
||||
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
package com.Modules.NormalData;
|
||||
import com.common.entity.RuleContent.Cropper_paramsType;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.common.entity.SyslogMessage;
|
||||
import com.common.util.JsonParser;
|
||||
import com.common.util.SyslogParser;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.common.service.DmNormalizeRuleService;
|
||||
import com.common.service.DmColumnService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.common.util.StringExtractorUtil;
|
||||
import com.common.entity.RuleContent.kv_paramsType;
|
||||
|
||||
|
||||
public class logNormalData {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(logNormalData.class);
|
||||
|
||||
private String strLogMsg ;
|
||||
private Map<String, Object> messageMap ;
|
||||
@Autowired
|
||||
public DmNormalizeRuleService dmNormalizeRuleService =new DmNormalizeRuleService();
|
||||
@Autowired
|
||||
public DmColumnService dmColumnService ;
|
||||
|
||||
public logNormalData( String LogMsg) {
|
||||
|
||||
strLogMsg=LogMsg;
|
||||
/** 处理步骤 */
|
||||
//初始化 (获取syslog_normal_data 表全部字段的属性、设备ID对应的规则设置、转化成JSON)
|
||||
//判断数据解析类型(json、键值、xml、正则表达式、分割符)解析syslogMessage 字段转成 HashMAP
|
||||
//匹配规则内容,获取字段映射关系配置,抽取命中的字段名称、数值
|
||||
//判断字段内容及类型,根据数据类型属性,进行内容转换。
|
||||
//生成insert SQL语句、执行入库操作。
|
||||
}
|
||||
|
||||
public Map<String, Object> getMessageToMap( String MsgContent)
|
||||
{
|
||||
//解析SyslogMessage
|
||||
SyslogMessage msg = SyslogParser.parse(MsgContent);
|
||||
System.out.println("解析结果-log content: " + msg.getMessage().toString());
|
||||
Map<String, Object> flatMap = JsonParser.parseJsonToFlatMap(msg.getMessage().toString());
|
||||
flatMap.forEach((key, value) -> System.out.println(key + " = " + value));
|
||||
List<Map<String, Object>> rulelst=dmNormalizeRuleService.selectByDeviceId((long)1);
|
||||
return flatMap;
|
||||
}
|
||||
|
||||
|
||||
public List<Map<String, Object>> getRuleList( long device_id)
|
||||
{
|
||||
List<Map<String, Object>> rulelst=dmNormalizeRuleService.selectByDeviceId((long)1);
|
||||
if (rulelst!=null)
|
||||
{
|
||||
System.out.println("rulelst: " + rulelst);
|
||||
}
|
||||
return rulelst;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析数据项内容,Json格式类型
|
||||
* @param MsgContent
|
||||
* @param cropperParams
|
||||
* @return
|
||||
*/
|
||||
public static String ParserMessageJsonType(String MsgContent , Cropper_paramsType cropperParams)
|
||||
{
|
||||
System.out.println("ParserMessageJsonType MsgContent:" +MsgContent );
|
||||
if(cropperParams ==null) {
|
||||
return removeBOM(JsonParser.extractJsonFromLogMessage(MsgContent));
|
||||
}
|
||||
String strJson ="";
|
||||
if(cropperParams.gettail_key().equals("") && cropperParams.gettail_offset()==0 ) {
|
||||
strJson = StringExtractorUtil.extractFromStartToEnd(MsgContent, cropperParams.gethead_key(), cropperParams.gethead_offset());
|
||||
System.out.println("ParserMessageJsonType extractFromStartToEnd strJson" +strJson );
|
||||
}
|
||||
else {
|
||||
strJson= StringExtractorUtil.extract(MsgContent,cropperParams.gethead_key(),cropperParams.gethead_offset(),cropperParams.gettail_key(),cropperParams.gettail_offset() );
|
||||
//return removeBOM(MsgContent).trim();
|
||||
}
|
||||
return removeBOM(strJson).trim();
|
||||
}
|
||||
|
||||
public static String removeBOM(String s) {
|
||||
if (s != null && s.startsWith("\uFEFF")) {
|
||||
return s.substring(1);
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
//获取数据泛化规则的rule_content列表字段,kv类型提取 kv_params 节点值
|
||||
public static kv_paramsType getkv_paramsType( Map<String, Object> dmNormalizeRule )
|
||||
{
|
||||
kv_paramsType kvParams = new kv_paramsType();
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( dmNormalizeRule.get("rule_content").toString());
|
||||
if (jsonObject.isEmpty()) return null;
|
||||
kvParams.setInternal(jsonObject.getJSONObject("kv_params").get("internal").toString());
|
||||
kvParams.setExternal(jsonObject.getJSONObject("kv_params").get("external").toString());
|
||||
kvParams.setL_trim(jsonObject.getJSONObject("kv_params").get("l_trim").toString());
|
||||
kvParams.setR_trim( jsonObject.getJSONObject("kv_params").get("r_trim").toString());
|
||||
return kvParams;
|
||||
}catch (Exception ex) {
|
||||
logger.error("getkv_paramsType:"+ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//获取数据泛化规则的rule_content列表字段,sep类型提取 sep 节点值(分隔符)
|
||||
public static String sepType( Map<String, Object> dmNormalizeRule )
|
||||
{
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( dmNormalizeRule.get("rule_content").toString());
|
||||
if (jsonObject.isEmpty()) return null;
|
||||
return jsonObject.get("sep").toString();
|
||||
}catch (Exception ex) {
|
||||
logger.error("regexp:"+ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//获取数据泛化规则的rule_content列表字段,regex类型提取 regexp 节点值(分隔符)
|
||||
public static String Regexp ( Map <String, Object> dmNormalizeRule )
|
||||
{
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( dmNormalizeRule.get("rule_content").toString());
|
||||
if (jsonObject.isEmpty()) return null;
|
||||
return jsonObject.get("regexp").toString();
|
||||
}catch (Exception ex) {
|
||||
logger.error("sepType:"+ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
|
||||
String strlogMessage= "<14>1 2025-09-24T11:52:26Z 5f46d3be75e1 supermario 128 honeypot_event - {\"source\":\"honeypot1\",\"id\":\"f6a13c35-bf9d-4da6-a181-50ce23e7ef6a\",\"start_time\":\"2023-09-03T11:07:02.50167643Z\",\"time\":\"2023-09-03T11:16:18.883885281Z\",\"risk_level\":4,\"connection\":\"b18f3fbe-3fbf-4495-815f-ff26f6fb0bdf\",\"file_info\":null,\"extra\":{\"payload\":{\"format\":\"line\",\"name\":{\"cn\":\"攻击载荷\",\"en\":\"payload\"},\"value\":\"\"},\"uid\":{\"format\":\"line\",\"name\":{\"cn\":\"\",\"en\":\"\"},\"uid\":\"b4cbc73c-25d0-4429-ae1b-a856cdf1a651\",\"value\":\"\"}},\"type\":\"WEB_ATTACK_SCANNER\",\"agent_sn\":\"caa7da42-0cca-4cb1-b501-1f1eb2b588d5\",\"agent_name\":\" 教育局蜜罐探针\",\"honeypot_id\":\"11a9ac6bdf38ae2aaa49ec4f1b4a921bff71952cb9f175bdd8ee1f0497057bc6\",\"honeypot_name\":\"茂名市中小学管理平台管理后台\",\"src_ip\":\"117.50.189.7\",\"src_port\":58512,\"src_mac\":\"\",\"dest_ip\":\"192.168.222.2\",\"dest_port\":9200,\"proxy_ip\":null,\"node\":\"WRx3\"}";
|
||||
String strMsgContent= "{\"source\":\"honeypot1\",\"id\":\"f6a13c35-bf9d-4da6-a181-50ce23e7ef6a\",\"start_time\":\"2023-09-03T11:07:02.50167643Z\",\"time\":\"2023-09-03T11:16:18.883885281Z\",\"risk_level\":4,\"connection\":\"b18f3fbe-3fbf-4495-815f-ff26f6fb0bdf\",\"file_info\":null,\"extra\":{\"payload\":{\"format\":\"line\",\"name\":{\"cn\":\"攻击载荷\",\"en\":\"payload\"},\"value\":\"\"},\"uid\":{\"format\":\"line\",\"name\":{\"cn\":\"\",\"en\":\"\"},\"uid\":\"b4cbc73c-25d0-4429-ae1b-a856cdf1a651\",\"value\":\"\"}},\"type\":\"WEB_ATTACK_SCANNER\",\"agent_sn\":\"caa7da42-0cca-4cb1-b501-1f1eb2b588d5\",\"agent_name\":\" 教育局蜜罐探针\",\"honeypot_id\":\"11a9ac6bdf38ae2aaa49ec4f1b4a921bff71952cb9f175bdd8ee1f0497057bc6\",\"honeypot_name\":\"茂名市中小学管理平台管理后台\",\"src_ip\":\"117.50.189.7\",\"src_port\":58512,\"src_mac\":\"\",\"dest_ip\":\"192.168.222.2\",\"dest_port\":9200,\"proxy_ip\":null,\"node\":\"WRx3\"}";
|
||||
//Map<String, Object> flatMap =(new logNormalData()).getMessageToMap(strMsgContent);
|
||||
//flatMap.forEach((key, value) -> System.out.println(key + " = " + value));
|
||||
logNormalData logData =new logNormalData( strlogMessage);
|
||||
Cropper_paramsType cropperParams =new Cropper_paramsType();
|
||||
cropperParams.settail_offset(0);
|
||||
cropperParams.settail_key("");
|
||||
cropperParams.sethead_key("{");
|
||||
cropperParams.sethead_offset(-1);
|
||||
String str= ParserMessageJsonType(strlogMessage,cropperParams);
|
||||
System.out.println("parser msg:"+str);
|
||||
|
||||
//List<Map<String, Object>> rulelst= logData.getRuleList(1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.Modules.etl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class TimeWindowCalculator {
|
||||
|
||||
/**
|
||||
* 获取前一个5分钟完整时间周期的开始时间和结束时间
|
||||
* @param currentTime 当前任务调度时间
|
||||
* @return 包含开始时间和结束时间的数组,[0]=开始时间,[1]=结束时间
|
||||
*/
|
||||
public static LocalDateTime[] getPrevious5MinuteWindow(LocalDateTime currentTime) {
|
||||
// 获取当前时间的分钟数
|
||||
int currentMinute = currentTime.getMinute();
|
||||
|
||||
// 计算前一个5分钟周期的结束分钟数(向下取整到5的倍数)
|
||||
int previousWindowEndMinute = (currentMinute / 5) * 5;
|
||||
|
||||
// 构建前一个周期的结束时间
|
||||
LocalDateTime previousWindowEnd = currentTime
|
||||
.withMinute(previousWindowEndMinute)
|
||||
.withSecond(0)
|
||||
.withNano(0);
|
||||
|
||||
// 前一个周期的开始时间是结束时间减去5分钟
|
||||
LocalDateTime previousWindowStart = previousWindowEnd.minusMinutes(5);
|
||||
|
||||
return new LocalDateTime[]{previousWindowStart, previousWindowEnd};
|
||||
}
|
||||
|
||||
/**
|
||||
* 重载方法:使用当前系统时间
|
||||
*/
|
||||
public static LocalDateTime[] getPrevious5MinuteWindow() {
|
||||
return getPrevious5MinuteWindow(LocalDateTime.now());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 测试用例
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// 测试1: 15:06:00
|
||||
LocalDateTime testTime1 = LocalDateTime.of(2025, 11, 18, 15, 7, 15);
|
||||
LocalDateTime[] window1 = getPrevious5MinuteWindow(testTime1);
|
||||
System.out.println("当前时间: " + testTime1.format(formatter));
|
||||
System.out.println("前一个5分钟周期: " +
|
||||
window1[0].format(formatter) + " - " +
|
||||
window1[1].format(formatter));
|
||||
System.out.println();
|
||||
|
||||
// 测试2: 15:10:00
|
||||
LocalDateTime testTime2 = LocalDateTime.of(2025, 11, 18, 15, 12, 20);
|
||||
LocalDateTime[] window2 = getPrevious5MinuteWindow(testTime2);
|
||||
System.out.println("当前时间: " + testTime2.format(formatter));
|
||||
System.out.println("前一个5分钟周期: " +
|
||||
window2[0].format(formatter) + " - " +
|
||||
window2[1].format(formatter));
|
||||
System.out.println();
|
||||
|
||||
// 测试3: 整点情况 16:00:00
|
||||
LocalDateTime testTime3 = LocalDateTime.of(2025, 11, 18, 16, 0, 15);
|
||||
LocalDateTime[] window3 = getPrevious5MinuteWindow(testTime3);
|
||||
System.out.println("当前时间: " + testTime3.format(formatter));
|
||||
System.out.println("前一个5分钟周期: " +
|
||||
window3[0].format(formatter) + " - " +
|
||||
window3[1].format(formatter));
|
||||
System.out.println();
|
||||
|
||||
// 测试4: 使用当前系统时间
|
||||
LocalDateTime[] currentWindow = getPrevious5MinuteWindow();
|
||||
System.out.println("当前系统时间的前一个5分钟周期: " +
|
||||
currentWindow[0].format(formatter) + " - " +
|
||||
currentWindow[1].format(formatter));
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.Modules.etl.handler;
|
||||
|
||||
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
import java.sql.*;
|
||||
|
||||
@MappedTypes(byte[][].class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY)
|
||||
public class ArrayByteTypeHandler extends BaseTypeHandler<byte[][]> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, byte[][] parameter, JdbcType jdbcType) throws SQLException {
|
||||
Array array = ps.getConnection().createArrayOf("bytea", parameter);
|
||||
ps.setArray(i, array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[][] getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return getArray(rs.getArray(columnName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[][] getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return getArray(rs.getArray(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[][] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return getArray(cs.getArray(columnIndex));
|
||||
}
|
||||
|
||||
private byte[][] getArray(Array array) throws SQLException {
|
||||
if (array != null) {
|
||||
Object[] objArray = (Object[]) array.getArray();
|
||||
byte[][] result = new byte[objArray.length][];
|
||||
for (int i = 0; i < objArray.length; i++) {
|
||||
result[i] = (byte[]) objArray[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.Modules.etl.handler;
|
||||
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
import java.sql.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
@MappedTypes(Integer[].class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY)
|
||||
public class ArrayIntegerTypeHandler extends BaseTypeHandler<Integer[]> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, Integer[] parameter, JdbcType jdbcType) throws SQLException {
|
||||
Array array = ps.getConnection().createArrayOf("integer", parameter);
|
||||
ps.setArray(i, array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer[] getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return getArray(rs.getArray(columnName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer[] getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return getArray(rs.getArray(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return getArray(cs.getArray(columnIndex));
|
||||
}
|
||||
|
||||
private Integer[] getArray(Array array) throws SQLException {
|
||||
if (array != null) {
|
||||
Object[] objArray = (Object[]) array.getArray();
|
||||
return Arrays.copyOf(objArray, objArray.length, Integer[].class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.Modules.etl.handler;
|
||||
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
import java.sql.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
@MappedTypes(String[].class)
|
||||
@MappedJdbcTypes(JdbcType.ARRAY)
|
||||
public class ArrayStringTypeHandler extends BaseTypeHandler<String[]> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, String[] parameter, JdbcType jdbcType) throws SQLException {
|
||||
Array array = ps.getConnection().createArrayOf("text", parameter);
|
||||
ps.setArray(i, array);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return getArray(rs.getArray(columnName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return getArray(rs.getArray(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return getArray(cs.getArray(columnIndex));
|
||||
}
|
||||
|
||||
private String[] getArray(Array array) throws SQLException {
|
||||
if (array != null) {
|
||||
Object[] objArray = (Object[]) array.getArray();
|
||||
return Arrays.copyOf(objArray, objArray.length, String[].class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.Modules.etl.handler;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.retry.annotation.Backoff;
|
||||
import org.springframework.retry.annotation.Recover;
|
||||
import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ETLRetryHandler {
|
||||
|
||||
/**
|
||||
* 带重试机制的ETL任务执行
|
||||
*/
|
||||
@Retryable(value = Exception.class, maxAttempts = 3, backoff = @Backoff(delay = 5000))
|
||||
public void executeWithRetry(Runnable etlTask) {
|
||||
try {
|
||||
etlTask.run();
|
||||
} catch (Exception e) {
|
||||
log.warn("ETL任务执行失败,准备重试", e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试失败后的恢复处理
|
||||
*/
|
||||
@Recover
|
||||
public void recover(Exception e, Runnable etlTask) {
|
||||
log.error("ETL任务重试多次后仍然失败", e);
|
||||
// 这里可以发送告警通知、记录失败状态等
|
||||
throw new RuntimeException("ETL任务最终执行失败", e);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.Modules.etl.handler;
|
||||
|
||||
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
|
||||
@MappedTypes(LocalDateTime.class)
|
||||
public class TimestamptzTypeHandler extends BaseTypeHandler<LocalDateTime> {
|
||||
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i,
|
||||
LocalDateTime parameter, JdbcType jdbcType)
|
||||
throws SQLException {
|
||||
if (parameter == null) {
|
||||
ps.setTimestamp(i, null);
|
||||
} else {
|
||||
// 转换为Timestamp
|
||||
ps.setTimestamp(i, Timestamp.valueOf(parameter));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(ResultSet rs, String columnName)
|
||||
throws SQLException {
|
||||
Timestamp timestamp = rs.getTimestamp(columnName);
|
||||
return convertToLocalDateTime(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(ResultSet rs, int columnIndex)
|
||||
throws SQLException {
|
||||
Timestamp timestamp = rs.getTimestamp(columnIndex);
|
||||
return convertToLocalDateTime(timestamp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDateTime getNullableResult(CallableStatement cs, int columnIndex)
|
||||
throws SQLException {
|
||||
Timestamp timestamp = cs.getTimestamp(columnIndex);
|
||||
return convertToLocalDateTime(timestamp);
|
||||
}
|
||||
|
||||
private LocalDateTime convertToLocalDateTime(Timestamp timestamp) {
|
||||
if (timestamp == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 方法1: 直接从Timestamp转换
|
||||
return timestamp.toLocalDateTime();
|
||||
|
||||
// 方法2: 通过Instant转换(处理时区)
|
||||
// Instant instant = timestamp.toInstant();
|
||||
// return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to convert TIMESTAMPTZ to LocalDateTime", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class Alarm {
|
||||
private String id;
|
||||
private LocalDateTime createdAt;
|
||||
private String alarmName;
|
||||
private String alarmLevel;
|
||||
private String alarmType;
|
||||
private String alarmMajorType;
|
||||
private String alarmMinorType;
|
||||
private Integer alarmAreaId;
|
||||
private String[] attackIp;
|
||||
private String[] victimIp;
|
||||
private String[] victimWebUrl;
|
||||
private Integer[] attackChainPhase;
|
||||
private Integer[] deviceId;
|
||||
private String[] tag;
|
||||
private String comment;
|
||||
private String[] originLogIds;
|
||||
private String queryId;
|
||||
private Integer judgedState;
|
||||
private Integer disposedState;
|
||||
private String dispositionAdvice;
|
||||
private Integer attackResult;
|
||||
private Integer fall;
|
||||
private byte[] payload;
|
||||
private Integer[] operateEvent;
|
||||
private Integer[] attackPort;
|
||||
private Integer[] victimPort;
|
||||
private String attackMethod;
|
||||
private String businessExt;
|
||||
private LocalDateTime logStartAt;
|
||||
private LocalDateTime logEndAt;
|
||||
private String httpStatus;
|
||||
private String dnsInfo;
|
||||
private String accountInfo;
|
||||
private String attackerInfo;
|
||||
private String victimInfo;
|
||||
private String suspiciousAction;
|
||||
private String vulnInfo;
|
||||
private String weakPwd;
|
||||
private String complianceBaseline;
|
||||
private String fileInfo;
|
||||
private String fileTags;
|
||||
private String endpointInfo;
|
||||
private String endpointProtection;
|
||||
private String originInfo;
|
||||
private String protocolInfo;
|
||||
private String emailInfo;
|
||||
private String sensitiveData;
|
||||
private Integer hitIntelligence;
|
||||
private String windowTime;
|
||||
private LocalDateTime updatedAt;
|
||||
private String engineType;
|
||||
private String attackIpPic;
|
||||
private String victimIpPic;
|
||||
private LocalDateTime operationAt;
|
||||
private String attackDirection;
|
||||
private LocalDateTime etlTime;
|
||||
private Integer logCount;
|
||||
private Integer isAssetHit;
|
||||
private Boolean focused;
|
||||
private Boolean baseFocused;
|
||||
private Boolean isUpdated;
|
||||
private int alarmSource;
|
||||
private String[] httpReqHeader;
|
||||
private String[] httpReqBody;
|
||||
private String[] httpRespHeader;
|
||||
private String[] httpRespBody;
|
||||
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class AlarmVisit {
|
||||
private String id;
|
||||
private LocalDateTime createdAt;
|
||||
private String alarmName;
|
||||
private String alarmLevel;
|
||||
private String alarmType;
|
||||
private String alarmMajorType;
|
||||
private String alarmMinorType;
|
||||
private Integer alarmAreaId;
|
||||
private String[] attackIp;
|
||||
private String[] victimIp;
|
||||
private String[] victimWebUrl;
|
||||
private Integer[] attackChainPhase;
|
||||
private Integer[] deviceId;
|
||||
private String[] tag;
|
||||
private String comment;
|
||||
private String[] originLogIds;
|
||||
private String queryId;
|
||||
private Integer judgedState;
|
||||
private Integer disposedState;
|
||||
private String dispositionAdvice;
|
||||
private Integer attackResult;
|
||||
private Integer fall;
|
||||
private byte[] payload;
|
||||
private Integer[] operateEvent;
|
||||
private Integer[] attackPort;
|
||||
private Integer[] victimPort;
|
||||
private String attackMethod;
|
||||
private String businessExt;
|
||||
private LocalDateTime logStartAt;
|
||||
private LocalDateTime logEndAt;
|
||||
private String httpStatus;
|
||||
private String dnsInfo;
|
||||
private String accountInfo;
|
||||
private String attackerInfo;
|
||||
private String victimInfo;
|
||||
private String suspiciousAction;
|
||||
private String vulnInfo;
|
||||
private String weakPwd;
|
||||
private String complianceBaseline;
|
||||
private String fileInfo;
|
||||
private String fileTags;
|
||||
private String endpointInfo;
|
||||
private String endpointProtection;
|
||||
private String originInfo;
|
||||
private String protocolInfo;
|
||||
private String emailInfo;
|
||||
private String sensitiveData;
|
||||
private Integer hitIntelligence;
|
||||
private String windowTime;
|
||||
private LocalDateTime updatedAt;
|
||||
private String engineType;
|
||||
private String attackIpPic;
|
||||
private String victimIpPic;
|
||||
private LocalDateTime operationAt;
|
||||
private String attackDirection;
|
||||
private LocalDateTime etlTime;
|
||||
private Integer logCount;
|
||||
private Integer isAssetHit;
|
||||
private Boolean focused;
|
||||
private Boolean baseFocused;
|
||||
private Boolean isUpdated;
|
||||
private int alarmSource;
|
||||
private String[] httpReqHeader;
|
||||
private String[] httpReqBody;
|
||||
private String[] httpRespHeader;
|
||||
private String[] httpRespBody;
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 分析规则实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisAnalysisRule {
|
||||
|
||||
/**
|
||||
* 规则唯一标识(UUID)
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 创建用户账号
|
||||
*/
|
||||
private String createUser;
|
||||
|
||||
/**
|
||||
* 规则名称(界面显示用)
|
||||
*/
|
||||
private String ruleName;
|
||||
|
||||
/**
|
||||
* 分析方式:高级版/基础版
|
||||
*/
|
||||
private String analysisMethod;
|
||||
|
||||
/**
|
||||
* 运行模式:realtime-实时流式/offline-离线批处理
|
||||
*/
|
||||
private String runMode;
|
||||
|
||||
/**
|
||||
* 规则输出类型:risk_alarm-风险告警/statistics-统计报表
|
||||
*/
|
||||
private String ruleOutput;
|
||||
|
||||
/**
|
||||
* 所属组织机构编码
|
||||
*/
|
||||
private String organization;
|
||||
|
||||
/**
|
||||
* 任务状态:running-正在执行/stopped-已停止/waiting-等待中
|
||||
*/
|
||||
private String taskStatus;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除 1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 记录创建时间(带时区)
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 记录更新时间(带时区)
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 规则备注说明文本
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 多租户隔离ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 规则详细描述
|
||||
*/
|
||||
private String ruleDesc;
|
||||
|
||||
/**
|
||||
* 规则分类编码(预留扩展用)
|
||||
*/
|
||||
private Integer ruleType;
|
||||
|
||||
/**
|
||||
* 规则启用状态(0-禁用/1-启用等)
|
||||
*/
|
||||
private Integer ruleStatus;
|
||||
|
||||
/**
|
||||
* 规则配置内容(JSON或结构化文本)
|
||||
*/
|
||||
private String ruleContent;
|
||||
|
||||
/**
|
||||
* 规则计算表达式(如SQL片段或自定义脚本)
|
||||
*/
|
||||
private String ruleExpression;
|
||||
|
||||
/**
|
||||
* 规则执行优先级(数值越大优先级越高)
|
||||
*/
|
||||
private Long priority;
|
||||
|
||||
/**
|
||||
* 规则标签,多个标签用逗号分隔
|
||||
*/
|
||||
private String tags;
|
||||
|
||||
/**
|
||||
* 规则版本号,用于版本管理
|
||||
*/
|
||||
private Integer version;
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private Integer subsetId;
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析字段配置实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisField {
|
||||
|
||||
/**
|
||||
* 主键ID,自增序列
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 关联的规则配置UUID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 字段类型(如维度/指标/计算字段等)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 数据源名称,如数据库连接名或数据流标识
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表别名,用于SQL语句中的表引用
|
||||
*/
|
||||
private String tableAlias;
|
||||
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 字段描述
|
||||
*/
|
||||
private String columnDesc;
|
||||
|
||||
/**
|
||||
* 字段数据类型(如int/varchar/decimal等)
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 计算函数名(如SUM/COUNT/自定义函数,NULL表示原始字段)
|
||||
*/
|
||||
private String fn;
|
||||
|
||||
/**
|
||||
* 函数参数列表,JSON数组格式(即使无参数也保留空数组)
|
||||
*/
|
||||
private String arguments;
|
||||
|
||||
/**
|
||||
* 字段显示占位符(用于前端展示的默认文本)
|
||||
*/
|
||||
private String placeholder;
|
||||
|
||||
/**
|
||||
* 基础类型编码(预留分类扩展用)
|
||||
*/
|
||||
private Integer baseType;
|
||||
|
||||
/**
|
||||
* 字段分类ID
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志(0-未删除/1-已删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注说明
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID,默认000000表示系统级配置
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 告警字段名(别名)
|
||||
*/
|
||||
private String alarmColumnName;
|
||||
|
||||
/**
|
||||
* 告警字段描述
|
||||
*/
|
||||
private String alarmColumnDesc;
|
||||
}
|
||||
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package com.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析过滤条件实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("analysis_filter")
|
||||
public class AnalysisFilter {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 数据源
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据库名
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表别名
|
||||
*/
|
||||
private String tableAlias;
|
||||
|
||||
/**
|
||||
* 列名
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 列描述
|
||||
*/
|
||||
private String columnDesc;
|
||||
|
||||
/**
|
||||
* 数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 函数名
|
||||
*/
|
||||
private String fn;
|
||||
|
||||
/**
|
||||
* 函数参数
|
||||
*/
|
||||
private Object arguments;
|
||||
|
||||
/**
|
||||
* 操作符
|
||||
*/
|
||||
private String operator;
|
||||
|
||||
/**
|
||||
* 筛选值
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* 基础类型
|
||||
*/
|
||||
private Integer baseType;
|
||||
|
||||
/**
|
||||
* 分类ID
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-正常 1-删除
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 关联条件逻辑表ID
|
||||
*/
|
||||
private Integer condId;
|
||||
|
||||
/**
|
||||
* 表达式执行顺序号
|
||||
*/
|
||||
private Integer seqNum;
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 分组规则配置实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisGroupBy {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 分组类型:1-标准分组 2-窗口分组
|
||||
*/
|
||||
private Integer groupType;
|
||||
|
||||
/**
|
||||
* 窗口类型:tumble/hop/session
|
||||
*/
|
||||
private String windowType;
|
||||
|
||||
/**
|
||||
* 窗口配置(关联AnalysisGroupByWindow)
|
||||
*/
|
||||
private AnalysisGroupByWindow window;
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除,1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析分组字段配置实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisGroupByColumn {
|
||||
|
||||
/**
|
||||
* 主键ID:自增唯一标识符
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 分组ID:关联分析分组的外键
|
||||
*/
|
||||
private Integer groupById;
|
||||
|
||||
/**
|
||||
* 数据源名称:数据来源系统标识
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据库名称:字段所在的数据库
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* 表名:字段所在的物理表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表别名:查询时使用的表别名
|
||||
*/
|
||||
private String tableAlias;
|
||||
|
||||
/**
|
||||
* 字段名:物理字段名称
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 字段描述:业务层面的字段说明
|
||||
*/
|
||||
private String columnDesc;
|
||||
|
||||
/**
|
||||
* 数据类型:字段的数据类型(如varchar、int4)
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 基础类型:字段的业务基础类型编码
|
||||
*/
|
||||
private Integer baseType;
|
||||
|
||||
/**
|
||||
* 分类ID:字段所属的业务分类ID
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 创建部门:创建记录的部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除,1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间:记录创建时间戳
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间:记录最后更新时间戳
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人:记录创建者ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人:记录最后更新者ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注:扩展说明信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID:多租户环境下的租户标识
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 规则ID:关联的业务规则UUID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 用户组ID:关联的权限用户组ID
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 字段唯一ID:跨表唯一的字段标识符
|
||||
*/
|
||||
private Long fieldId;
|
||||
|
||||
/**
|
||||
* 排序号:字段展示顺序
|
||||
*/
|
||||
private Integer sort;
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package com.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析分组聚合条件配置实体类
|
||||
* 存储GROUP BY后的HAVING筛选条件定义
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("analysis_group_by_having")
|
||||
public class AnalysisGroupByHaving {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private Integer groupById;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
private String dataSource;
|
||||
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String database;
|
||||
|
||||
/**
|
||||
* 表名
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
/**
|
||||
* 表别名
|
||||
*/
|
||||
private String tableAlias;
|
||||
|
||||
/**
|
||||
* 字段名
|
||||
*/
|
||||
private String columnName;
|
||||
|
||||
/**
|
||||
* 字段描述
|
||||
*/
|
||||
private String columnDesc;
|
||||
|
||||
/**
|
||||
* 字段数据类型
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 聚合函数名(如SUM/COUNT/AVG等)
|
||||
*/
|
||||
private String fn;
|
||||
|
||||
/**
|
||||
* 聚合函数参数列表,JSON数组格式
|
||||
*/
|
||||
private Object arguments;
|
||||
|
||||
/**
|
||||
* 比较运算符(如>、<、=、>=、<=、IN、LIKE等)
|
||||
*/
|
||||
private String operator;
|
||||
|
||||
/**
|
||||
* 比较值,JSON格式存储
|
||||
*/
|
||||
private Object value;
|
||||
|
||||
/**
|
||||
* 基础类型标识
|
||||
*/
|
||||
private Integer baseType;
|
||||
|
||||
/**
|
||||
* 分类ID,用于条件分组归类
|
||||
*/
|
||||
private Integer categoryId;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除 1-已删除
|
||||
*/
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 记录创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 记录更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注说明
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 分析时间窗口配置实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisGroupByWindow {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 分组ID
|
||||
*/
|
||||
private Integer groupById;
|
||||
|
||||
/**
|
||||
* 窗口类型:tumble/hop/session
|
||||
*/
|
||||
private String windowType;
|
||||
|
||||
// ============ 滚动窗口配置 ============
|
||||
|
||||
/**
|
||||
* 滚动窗口时间类型:second/minute/hour
|
||||
*/
|
||||
private String tumbleWindowTimeType;
|
||||
|
||||
/**
|
||||
* 滚动窗口大小
|
||||
*/
|
||||
private Integer tumbleWindowSize;
|
||||
|
||||
/**
|
||||
* 滚动窗口单位:s/m/h/d
|
||||
*/
|
||||
private String tumbleWindowSizeUnit;
|
||||
|
||||
// ============ 滑动窗口配置 ============
|
||||
|
||||
/**
|
||||
* 滑动窗口时间类型
|
||||
*/
|
||||
private String hopWindowTimeType;
|
||||
|
||||
/**
|
||||
* 滑动窗口大小
|
||||
*/
|
||||
private Integer hopWindowSize;
|
||||
|
||||
/**
|
||||
* 滑动窗口单位:s/m/h/d
|
||||
*/
|
||||
private String hopWindowSizeUnit;
|
||||
|
||||
/**
|
||||
* 滑动窗口步长
|
||||
*/
|
||||
private Integer hopWindowSlide;
|
||||
|
||||
/**
|
||||
* 滑动窗口步长单位:s/m/h/d
|
||||
*/
|
||||
private String hopWindowSlideUnit;
|
||||
|
||||
/**
|
||||
* 滑动窗口告警频率:是否每个窗口仅告警一次
|
||||
*/
|
||||
private Boolean hopWindowAlarmOncePerWindow;
|
||||
|
||||
// ============ 会话窗口配置 ============
|
||||
|
||||
/**
|
||||
* 会话窗口时间类型
|
||||
*/
|
||||
private String sessionWindowTimeType;
|
||||
|
||||
/**
|
||||
* 会话窗口超时时间
|
||||
*/
|
||||
private Integer sessionWindowSize;
|
||||
|
||||
/**
|
||||
* 会话窗口单位:s/m/h/d
|
||||
*/
|
||||
private String sessionWindowSizeUnit;
|
||||
|
||||
// ============ 公共字段 ============
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除,1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import java.util.UUID;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 分析规则任务运行历史及状态记录
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisTaskHistory {
|
||||
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 持续时间(秒)
|
||||
*/
|
||||
private Long durationTime;
|
||||
|
||||
/**
|
||||
* 进度百分比
|
||||
*/
|
||||
private Integer progressPercent;
|
||||
|
||||
/**
|
||||
* 输入数据量
|
||||
*/
|
||||
private Long inputCount;
|
||||
|
||||
/**
|
||||
* 输出数据量
|
||||
*/
|
||||
private Long outputCount;
|
||||
|
||||
/**
|
||||
* 状态(RUNNING/CANCELED/KILLED/COMPLETED/FAILED)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志(0-正常,1-删除)
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 用户自定义函数实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisUserDefinedFunction {
|
||||
|
||||
/**
|
||||
* 函数ID
|
||||
*/
|
||||
private String functionId;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 函数名称
|
||||
*/
|
||||
private String functionName;
|
||||
|
||||
/**
|
||||
* 函数类型:AGGREGATE-聚合函数/SCALAR-标量函数/WINDOW-窗口函数
|
||||
*/
|
||||
private String functionType;
|
||||
|
||||
/**
|
||||
* 函数描述
|
||||
*/
|
||||
private String functionDesc;
|
||||
|
||||
/**
|
||||
* 函数实现SQL
|
||||
*/
|
||||
private String functionSql;
|
||||
|
||||
/**
|
||||
* 返回类型
|
||||
*/
|
||||
private String returnType;
|
||||
|
||||
/**
|
||||
* 参数定义(JSON格式)
|
||||
*/
|
||||
private String params;
|
||||
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
private Boolean enabled;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除 1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* WHERE条件逻辑表实体类(仅存储条件逻辑组信息)
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AnalysisWhereCondition {
|
||||
|
||||
/**
|
||||
* 条件ID
|
||||
*/
|
||||
private Integer condId;
|
||||
|
||||
/**
|
||||
* 规则ID
|
||||
*/
|
||||
private String ruleId;
|
||||
|
||||
/**
|
||||
* 逻辑运算符:AND, OR
|
||||
*/
|
||||
private String logicalOp;
|
||||
|
||||
/**
|
||||
* 序号
|
||||
*/
|
||||
private Integer seqNum;
|
||||
|
||||
/**
|
||||
* 父节点ID
|
||||
*/
|
||||
private Integer parentCondId;
|
||||
|
||||
/**
|
||||
* 创建部门ID
|
||||
*/
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 删除标志:0-未删除 1-已删除
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 备注信息
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.common.entity;
|
||||
|
||||
public class ApiResponse<T> {
|
||||
|
||||
private boolean success;
|
||||
private String message;
|
||||
private T data;
|
||||
private String errorCode;
|
||||
|
||||
// 成功响应
|
||||
public static <T> ApiResponse<T> success(T data) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setSuccess(true);
|
||||
response.setMessage("操作成功");
|
||||
response.setData(data);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> success(String message, T data) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setSuccess(true);
|
||||
response.setMessage(message);
|
||||
response.setData(data);
|
||||
return response;
|
||||
}
|
||||
|
||||
// 失败响应
|
||||
public static <T> ApiResponse<T> error(String message) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setSuccess(false);
|
||||
response.setMessage(message);
|
||||
return response;
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> error(String message, String errorCode) {
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setSuccess(false);
|
||||
response.setMessage(message);
|
||||
response.setErrorCode(errorCode);
|
||||
return response;
|
||||
}
|
||||
|
||||
// Getter和Setter方法
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setErrorCode(String errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
//@Document(indexName = "applog-#{T(java.time.LocalDate).now().format(T(java.time.format.DateTimeFormatter).ofPattern('yyyyMMdd'))}")
|
||||
public class AppLog {
|
||||
|
||||
// ES元数据字段
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@Field(type = FieldType.Keyword)
|
||||
private String index;
|
||||
|
||||
@Field(type = FieldType.Keyword)
|
||||
private String type = "_doc";
|
||||
|
||||
@Field(type = FieldType.Float)
|
||||
private Float score = 1.0f;
|
||||
|
||||
// 日志内容字段(对应_source)
|
||||
@Field(name = "dtTime", type = FieldType.Long)
|
||||
private Long dtTime;
|
||||
|
||||
@Field(name = "collecttime", type = FieldType.Long)
|
||||
private Long collectTime;
|
||||
|
||||
@Field(name = "logType", type = FieldType.Keyword)
|
||||
private String logType;
|
||||
|
||||
@Field(name = "traceId", type = FieldType.Keyword)
|
||||
private String traceId;
|
||||
|
||||
@Field(name = "method", type = FieldType.Text)
|
||||
private String method;
|
||||
|
||||
@Field(name = "appName", type = FieldType.Keyword)
|
||||
private String appName;
|
||||
|
||||
@Field(name = "ip", type = FieldType.Keyword)
|
||||
private String ip;
|
||||
|
||||
@Field(name = "className", type = FieldType.Text)
|
||||
private String className;
|
||||
|
||||
@Field(name = "env", type = FieldType.Keyword)
|
||||
private String env;
|
||||
|
||||
@Field(name = "content", type = FieldType.Text)
|
||||
private String content;
|
||||
|
||||
@Field(name = "threadName", type = FieldType.Text)
|
||||
private String threadName;
|
||||
|
||||
@Field(name = "logLevel", type = FieldType.Keyword)
|
||||
private String logLevel;
|
||||
|
||||
@Field(name = "seq", type = FieldType.Keyword)
|
||||
private String seq;
|
||||
|
||||
@Field(name = "_indexed_at", type = FieldType.Long)
|
||||
private Long indexedAt;
|
||||
|
||||
// 系统字段
|
||||
private Date createTime = new Date();
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class AppLogEntity {
|
||||
private Long id;
|
||||
|
||||
// ES元数据字段
|
||||
private String esIndex;
|
||||
private String esType = "_doc";
|
||||
private String esId;
|
||||
private Float esScore = 1.0f;
|
||||
|
||||
// 日志内容字段
|
||||
private Long dtTime;
|
||||
private Long collectTime;
|
||||
private String logType;
|
||||
private String traceId;
|
||||
private String method;
|
||||
private String appName;
|
||||
private String ip;
|
||||
private String className;
|
||||
private String env;
|
||||
private String content;
|
||||
private String threadName;
|
||||
private String logLevel;
|
||||
private String seq;
|
||||
private Long indexedAt;
|
||||
|
||||
// 分区字段
|
||||
private LocalDateTime logDate;
|
||||
|
||||
// 系统字段
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 探针心跳状态实体类
|
||||
* 对应表: device_collect_heartbeat
|
||||
*/
|
||||
@Data
|
||||
public class DeviceCollectHeartbeat {
|
||||
|
||||
/** 自增主键 */
|
||||
private Long id;
|
||||
|
||||
/** 探针唯一标识(由探针上报) */
|
||||
private String collectId;
|
||||
|
||||
/** 探针名称(可选) */
|
||||
private String collectName;
|
||||
|
||||
/** 探针IP(支持IPv6) */
|
||||
private String deviceIp;
|
||||
|
||||
/** 探针版本 */
|
||||
private String appVersion;
|
||||
|
||||
/** 最后一次心跳时间(毫秒精度) */
|
||||
private LocalDateTime lastHeartbeat;
|
||||
|
||||
/** 累计心跳次数(可监控丢包率) */
|
||||
private Long heartbeatCount;
|
||||
|
||||
/** 在线状态:online / offline */
|
||||
private String status;
|
||||
|
||||
/** 连续心跳失败次数(平台侧计算) */
|
||||
private Integer failCount;
|
||||
|
||||
/** 最后更新时间 */
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
|
||||
|
||||
public DeviceCollectHeartbeat() {
|
||||
this.heartbeatCount = 1L;
|
||||
this.status = "online";
|
||||
this.failCount = 0;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新心跳
|
||||
*/
|
||||
public void updateHeartbeat() {
|
||||
this.lastHeartbeat = LocalDateTime.now();
|
||||
this.heartbeatCount = (this.heartbeatCount == null ? 1L : this.heartbeatCount + 1);
|
||||
this.status = "online";
|
||||
this.failCount = 0;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记为离线
|
||||
*/
|
||||
public void markOffline() {
|
||||
this.status = "offline";
|
||||
this.failCount = (this.failCount == null ? 1 : this.failCount + 1);
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* 恢复在线
|
||||
*/
|
||||
public void markOnline() {
|
||||
this.status = "online";
|
||||
this.failCount = 0;
|
||||
this.updateTime = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 探针心跳历史记录实体类
|
||||
* 对应表: device_collect_heartbeat_history
|
||||
*/
|
||||
@Data
|
||||
public class DeviceCollectHeartbeatHistory {
|
||||
|
||||
/** 自增主键 */
|
||||
private Long id;
|
||||
|
||||
/** 探针唯一标识 */
|
||||
private String collectId;
|
||||
|
||||
/** 心跳上报时间 */
|
||||
private LocalDateTime heartbeatTime;
|
||||
|
||||
/** 探针IP */
|
||||
private String deviceIp;
|
||||
|
||||
/** 探针版本 */
|
||||
private String appVersion;
|
||||
|
||||
/** 记录创建时间 */
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
|
||||
public DeviceCollectHeartbeatHistory() {
|
||||
this.createdAt = LocalDateTime.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从心跳状态创建历史记录
|
||||
*/
|
||||
public static DeviceCollectHeartbeatHistory fromHeartbeat(DeviceCollectHeartbeat heartbeat) {
|
||||
DeviceCollectHeartbeatHistory history = new DeviceCollectHeartbeatHistory();
|
||||
history.setCollectId(heartbeat.getCollectId());
|
||||
history.setHeartbeatTime(heartbeat.getLastHeartbeat());
|
||||
history.setDeviceIp(heartbeat.getDeviceIp());
|
||||
history.setAppVersion(heartbeat.getAppVersion());
|
||||
history.setCreatedAt(LocalDateTime.now());
|
||||
return history;
|
||||
}
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
public class DeviceCollectTask {
|
||||
private Integer id;
|
||||
private OffsetDateTime createdAt;
|
||||
private OffsetDateTime updatedAt;
|
||||
private OffsetDateTime deletedAt;
|
||||
private Integer deviceId;
|
||||
private Integer method;
|
||||
private String taskName;
|
||||
private OffsetDateTime firstTime;
|
||||
private OffsetDateTime lastSuccessTime;
|
||||
private OffsetDateTime lastFailedTime;
|
||||
private Integer detailId;
|
||||
private Integer epm;
|
||||
private Integer epmPeak;
|
||||
private Integer processArchitecture;
|
||||
private Integer taskCount;
|
||||
private OffsetDateTime recentDiscoverTime;
|
||||
private Integer epmUpperLimit;
|
||||
|
||||
// Getter and Setter 方法
|
||||
public Integer getId() { return id; }
|
||||
public void setId(Integer id) { this.id = id; }
|
||||
|
||||
public OffsetDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(OffsetDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public OffsetDateTime getUpdatedAt() { return updatedAt; }
|
||||
public void setUpdatedAt(OffsetDateTime updatedAt) { this.updatedAt = updatedAt; }
|
||||
|
||||
public OffsetDateTime getDeletedAt() { return deletedAt; }
|
||||
public void setDeletedAt(OffsetDateTime deletedAt) { this.deletedAt = deletedAt; }
|
||||
|
||||
public Integer getDeviceId() { return deviceId; }
|
||||
public void setDeviceId(Integer deviceId) { this.deviceId = deviceId; }
|
||||
|
||||
public Integer getMethod() { return method; }
|
||||
public void setMethod(Integer method) { this.method = method; }
|
||||
|
||||
public String getTaskName() { return taskName; }
|
||||
public void setTaskName(String taskName) { this.taskName = taskName; }
|
||||
|
||||
public OffsetDateTime getFirstTime() { return firstTime; }
|
||||
public void setFirstTime(OffsetDateTime firstTime) { this.firstTime = firstTime; }
|
||||
|
||||
public OffsetDateTime getLastSuccessTime() { return lastSuccessTime; }
|
||||
public void setLastSuccessTime(OffsetDateTime lastSuccessTime) { this.lastSuccessTime = lastSuccessTime; }
|
||||
|
||||
public OffsetDateTime getLastFailedTime() { return lastFailedTime; }
|
||||
public void setLastFailedTime(OffsetDateTime lastFailedTime) { this.lastFailedTime = lastFailedTime; }
|
||||
|
||||
public Integer getDetailId() { return detailId; }
|
||||
public void setDetailId(Integer detailId) { this.detailId = detailId; }
|
||||
|
||||
public Integer getEpm() { return epm; }
|
||||
public void setEpm(Integer epm) { this.epm = epm; }
|
||||
|
||||
public Integer getEpmPeak() { return epmPeak; }
|
||||
public void setEpmPeak(Integer epmPeak) { this.epmPeak = epmPeak; }
|
||||
|
||||
public Integer getProcessArchitecture() { return processArchitecture; }
|
||||
public void setProcessArchitecture(Integer processArchitecture) { this.processArchitecture = processArchitecture; }
|
||||
|
||||
public Integer getTaskCount() { return taskCount; }
|
||||
public void setTaskCount(Integer taskCount) { this.taskCount = taskCount; }
|
||||
|
||||
public OffsetDateTime getRecentDiscoverTime() { return recentDiscoverTime; }
|
||||
public void setRecentDiscoverTime(OffsetDateTime recentDiscoverTime) { this.recentDiscoverTime = recentDiscoverTime; }
|
||||
|
||||
public Integer getEpmUpperLimit() { return epmUpperLimit; }
|
||||
public void setEpmUpperLimit(Integer epmUpperLimit) { this.epmUpperLimit = epmUpperLimit; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceCollectTask{" +
|
||||
"id=" + id +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", deletedAt=" + deletedAt +
|
||||
", deviceId=" + deviceId +
|
||||
", method=" + method +
|
||||
", taskName='" + taskName + '\'' +
|
||||
", firstTime=" + firstTime +
|
||||
", lastSuccessTime=" + lastSuccessTime +
|
||||
", lastFailedTime=" + lastFailedTime +
|
||||
", detailId=" + detailId +
|
||||
", epm=" + epm +
|
||||
", epmPeak=" + epmPeak +
|
||||
", processArchitecture=" + processArchitecture +
|
||||
", taskCount=" + taskCount +
|
||||
", recentDiscoverTime=" + recentDiscoverTime +
|
||||
", epmUpperLimit=" + epmUpperLimit +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
@Data
|
||||
public class DeviceCollectTaskTime {
|
||||
private String deviceCollectId;
|
||||
private LocalDateTime firstTime; // 首次成功时间
|
||||
private LocalDateTime lastSuccessTime; // 最后成功时间
|
||||
private LocalDateTime lastFailTime; // 最后失败时间
|
||||
}
|
||||
+376
@@ -0,0 +1,376 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
public class DeviceDevice {
|
||||
public Integer id;
|
||||
public LocalDateTime createdAt;
|
||||
public LocalDateTime updatedAt;
|
||||
public LocalDateTime deletedAt;
|
||||
public String name;
|
||||
public String ip;
|
||||
public Integer deviceGroup;
|
||||
public Integer deviceType;
|
||||
public String vendor;
|
||||
public String productName;
|
||||
public Integer organizationId;
|
||||
public LocalDateTime lastReceiveTime;
|
||||
public Integer agentId;
|
||||
public Integer detailId;
|
||||
public Integer controlAgentId;
|
||||
public LocalDateTime licenseStartTime;
|
||||
public LocalDateTime licenseEndTime;
|
||||
public Boolean isMonitoring;
|
||||
public Long securityScopeId;
|
||||
public Long ownerId;
|
||||
public Long sshConfigId;
|
||||
public Short status;
|
||||
public Long createdById;
|
||||
public Integer decodeType;
|
||||
public Integer missPolicy;
|
||||
public String tenantId;
|
||||
public LocalDateTime createTime;
|
||||
public LocalDateTime updateTime;
|
||||
public Long createBy;
|
||||
public Long updateBy;
|
||||
public String delFlag;
|
||||
public String managerName;
|
||||
public Integer todayParseCount;
|
||||
public Integer todayNonLogCount;
|
||||
public Long createDept;
|
||||
public Integer deviceCollectId;
|
||||
|
||||
|
||||
// Getter and Setter methods
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(LocalDateTime createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public LocalDateTime getDeletedAt() {
|
||||
return deletedAt;
|
||||
}
|
||||
|
||||
public void setDeletedAt(LocalDateTime deletedAt) {
|
||||
this.deletedAt = deletedAt;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Integer getDeviceGroup() {
|
||||
return deviceGroup;
|
||||
}
|
||||
|
||||
public void setDeviceGroup(Integer deviceGroup) {
|
||||
this.deviceGroup = deviceGroup;
|
||||
}
|
||||
|
||||
public Integer getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(Integer deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public String getVendor() {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
public void setVendor(String vendor) {
|
||||
this.vendor = vendor;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public Integer getOrganizationId() {
|
||||
return organizationId;
|
||||
}
|
||||
|
||||
public void setOrganizationId(Integer organizationId) {
|
||||
this.organizationId = organizationId;
|
||||
}
|
||||
|
||||
public LocalDateTime getLastReceiveTime() {
|
||||
return lastReceiveTime;
|
||||
}
|
||||
|
||||
public void setLastReceiveTime(LocalDateTime lastReceiveTime) {
|
||||
this.lastReceiveTime = lastReceiveTime;
|
||||
}
|
||||
|
||||
public Integer getAgentId() {
|
||||
return agentId;
|
||||
}
|
||||
|
||||
public void setAgentId(Integer agentId) {
|
||||
this.agentId = agentId;
|
||||
}
|
||||
|
||||
public Integer getDetailId() {
|
||||
return detailId;
|
||||
}
|
||||
|
||||
public void setDetailId(Integer detailId) {
|
||||
this.detailId = detailId;
|
||||
}
|
||||
|
||||
public Integer getControlAgentId() {
|
||||
return controlAgentId;
|
||||
}
|
||||
|
||||
public void setControlAgentId(Integer controlAgentId) {
|
||||
this.controlAgentId = controlAgentId;
|
||||
}
|
||||
|
||||
public LocalDateTime getLicenseStartTime() {
|
||||
return licenseStartTime;
|
||||
}
|
||||
|
||||
public void setLicenseStartTime(LocalDateTime licenseStartTime) {
|
||||
this.licenseStartTime = licenseStartTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getLicenseEndTime() {
|
||||
return licenseEndTime;
|
||||
}
|
||||
|
||||
public void setLicenseEndTime(LocalDateTime licenseEndTime) {
|
||||
this.licenseEndTime = licenseEndTime;
|
||||
}
|
||||
|
||||
public Boolean getIsMonitoring() {
|
||||
return isMonitoring;
|
||||
}
|
||||
|
||||
public void setIsMonitoring(Boolean isMonitoring) {
|
||||
this.isMonitoring = isMonitoring;
|
||||
}
|
||||
|
||||
public Long getSecurityScopeId() {
|
||||
return securityScopeId;
|
||||
}
|
||||
|
||||
public void setSecurityScopeId(Long securityScopeId) {
|
||||
this.securityScopeId = securityScopeId;
|
||||
}
|
||||
|
||||
public Long getOwnerId() {
|
||||
return ownerId;
|
||||
}
|
||||
|
||||
public void setOwnerId(Long ownerId) {
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
public Long getSshConfigId() {
|
||||
return sshConfigId;
|
||||
}
|
||||
|
||||
public void setSshConfigId(Long sshConfigId) {
|
||||
this.sshConfigId = sshConfigId;
|
||||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getCreatedById() {
|
||||
return createdById;
|
||||
}
|
||||
|
||||
public void setCreatedById(Long createdById) {
|
||||
this.createdById = createdById;
|
||||
}
|
||||
|
||||
public Integer getDecodeType() {
|
||||
return decodeType;
|
||||
}
|
||||
|
||||
public void setDecodeType(Integer decodeType) {
|
||||
this.decodeType = decodeType;
|
||||
}
|
||||
|
||||
public Integer getMissPolicy() {
|
||||
return missPolicy;
|
||||
}
|
||||
|
||||
public void setMissPolicy(Integer missPolicy) {
|
||||
this.missPolicy = missPolicy;
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public Long getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(Long createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Long getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(Long updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public String getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(String delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public String getManagerName() {
|
||||
return managerName;
|
||||
}
|
||||
|
||||
public void setManagerName(String managerName) {
|
||||
this.managerName = managerName;
|
||||
}
|
||||
|
||||
public Integer getTodayParseCount() {
|
||||
return todayParseCount;
|
||||
}
|
||||
|
||||
public void setTodayParseCount(Integer todayParseCount) {
|
||||
this.todayParseCount = todayParseCount;
|
||||
}
|
||||
|
||||
public Integer getTodayNonLogCount() {
|
||||
return todayNonLogCount;
|
||||
}
|
||||
|
||||
public void setTodayNonLogCount(Integer todayNonLogCount) {
|
||||
this.todayNonLogCount = todayNonLogCount;
|
||||
}
|
||||
|
||||
public Long getCreateDept() {
|
||||
return createDept;
|
||||
}
|
||||
|
||||
public void setCreateDept(Long createDept) {
|
||||
this.createDept = createDept;
|
||||
}
|
||||
|
||||
public Integer getDeviceCollectId() {
|
||||
return deviceCollectId;
|
||||
}
|
||||
|
||||
public void setDeviceCollectId(Integer deviceCollectId) {
|
||||
this.deviceCollectId = deviceCollectId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceDevice{" +
|
||||
"id=" + id +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", deletedAt=" + deletedAt +
|
||||
", name='" + name + '\'' +
|
||||
", ip='" + ip + '\'' +
|
||||
", deviceGroup=" + deviceGroup +
|
||||
", deviceType=" + deviceType +
|
||||
", vendor='" + vendor + '\'' +
|
||||
", productName='" + productName + '\'' +
|
||||
", organizationId=" + organizationId +
|
||||
", lastReceiveTime=" + lastReceiveTime +
|
||||
", agentId=" + agentId +
|
||||
", detailId=" + detailId +
|
||||
", controlAgentId=" + controlAgentId +
|
||||
", licenseStartTime=" + licenseStartTime +
|
||||
", licenseEndTime=" + licenseEndTime +
|
||||
", isMonitoring=" + isMonitoring +
|
||||
", securityScopeId=" + securityScopeId +
|
||||
", ownerId=" + ownerId +
|
||||
", sshConfigId=" + sshConfigId +
|
||||
", status=" + status +
|
||||
", createdById=" + createdById +
|
||||
", decodeType=" + decodeType +
|
||||
", missPolicy=" + missPolicy +
|
||||
", tenantId='" + tenantId + '\'' +
|
||||
", createTime=" + createTime +
|
||||
", updateTime=" + updateTime +
|
||||
", createBy=" + createBy +
|
||||
", updateBy=" + updateBy +
|
||||
", delFlag='" + delFlag + '\'' +
|
||||
", managerName='" + managerName + '\'' +
|
||||
", todayParseCount=" + todayParseCount +
|
||||
", todayNonLogCount=" + todayNonLogCount +
|
||||
", createDept=" + createDept +
|
||||
", deviceCollectId=" + deviceCollectId +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 联动设备表实体类(防火墙设备信息)
|
||||
* 对应表: device_interlocking
|
||||
*/
|
||||
public class DeviceInterlocking {
|
||||
private Long id;
|
||||
private String deviceName; // 联动安全设备名称(防火墙)
|
||||
private String vendor; // 厂商
|
||||
private String deptId; // 所属组织机构(部门ID)
|
||||
private Integer banLimit; // 封禁上限
|
||||
private String ip; // IP地址
|
||||
private String apiUrl; // API地址
|
||||
private String tenantId;
|
||||
private Long createDept;
|
||||
private Long createBy;
|
||||
private OffsetDateTime createTime;
|
||||
private Long updateBy;
|
||||
private OffsetDateTime updateTime;
|
||||
private String remark;
|
||||
private String authUsername; // 用户名
|
||||
private String authPassword; // 密码
|
||||
|
||||
// Getter and Setter
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public String getDeviceName() { return deviceName; }
|
||||
public void setDeviceName(String deviceName) { this.deviceName = deviceName; }
|
||||
|
||||
public String getVendor() { return vendor; }
|
||||
public void setVendor(String vendor) { this.vendor = vendor; }
|
||||
|
||||
public String getDeptId() { return deptId; }
|
||||
public void setDeptId(String deptId) { this.deptId = deptId; }
|
||||
|
||||
public Integer getBanLimit() { return banLimit; }
|
||||
public void setBanLimit(Integer banLimit) { this.banLimit = banLimit; }
|
||||
|
||||
public String getIp() { return ip; }
|
||||
public void setIp(String ip) { this.ip = ip; }
|
||||
|
||||
public String getApiUrl() { return apiUrl; }
|
||||
public void setApiUrl(String apiUrl) { this.apiUrl = apiUrl; }
|
||||
|
||||
public String getTenantId() { return tenantId; }
|
||||
public void setTenantId(String tenantId) { this.tenantId = tenantId; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public OffsetDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(OffsetDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public OffsetDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(OffsetDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
|
||||
public String getAuthUsername() { return authUsername; }
|
||||
public void setAuthUsername(String authUsername) { this.authUsername = authUsername; }
|
||||
|
||||
public String getAuthPassword() { return authPassword; }
|
||||
public void setAuthPassword(String authPassword) { this.authPassword = authPassword; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceInterlocking{" +
|
||||
"id=" + id +
|
||||
", deviceName='" + deviceName + '\'' +
|
||||
", vendor='" + vendor + '\'' +
|
||||
", ip='" + ip + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package com.common.entity;
|
||||
|
||||
import com.Modules.etl.handler.ArrayIntegerTypeHandler;
|
||||
import com.Modules.etl.handler.ArrayStringTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.TypeHandler;
|
||||
import org.apache.ibatis.type.ArrayTypeHandler;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 封禁指令表实体类
|
||||
* 对应表: device_interlocking_cmd
|
||||
*/
|
||||
public class DeviceInterlockingCmd {
|
||||
private Long id;
|
||||
private Long probeId; // 探针ID
|
||||
private String probeIp; // 探针IP
|
||||
private Integer[] deviceInterlockingId; // 联动设备ID(数组)
|
||||
private String[] deviceInterlockingIp; // 联动设备IP(数组)
|
||||
private String[] banIps; // 封禁IP(数组)
|
||||
private String banMethod; // 封禁方式(0:手工、1:自动)
|
||||
private String banType; // 封禁类型(1:白名单、0:黑名单)
|
||||
private String cmdStatus; // 指令状态(0:未执行、1:已完成、2:执行中)
|
||||
private Integer banDuration; // 封禁时长(秒,-1表示永久)
|
||||
private OffsetDateTime createTime;
|
||||
private OffsetDateTime updateTime;
|
||||
private String tenantId;
|
||||
private Long createDept;
|
||||
private Long createBy;
|
||||
private Long updateBy;
|
||||
private String remark;
|
||||
private Integer banOperationType; // 封禁操作类型(0:新增、1:删除)
|
||||
|
||||
// Getter and Setter
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public Long getProbeId() { return probeId; }
|
||||
public void setProbeId(Long probeId) { this.probeId = probeId; }
|
||||
|
||||
public String getProbeIp() { return probeIp; }
|
||||
public void setProbeIp(String probeIp) { this.probeIp = probeIp; }
|
||||
|
||||
public Integer[] getDeviceInterlockingId() { return deviceInterlockingId; }
|
||||
public void setDeviceInterlockingId(Integer[] deviceInterlockingId) { this.deviceInterlockingId = deviceInterlockingId; }
|
||||
|
||||
public String[] getDeviceInterlockingIp() { return deviceInterlockingIp; }
|
||||
public void setDeviceInterlockingIp(String[] deviceInterlockingIp) { this.deviceInterlockingIp = deviceInterlockingIp; }
|
||||
|
||||
public String[] getBanIps() { return banIps; }
|
||||
public void setBanIps(String[] banIps) { this.banIps = banIps; }
|
||||
|
||||
public String getBanMethod() { return banMethod; }
|
||||
public void setBanMethod(String banMethod) { this.banMethod = banMethod; }
|
||||
|
||||
public String getBanType() { return banType; }
|
||||
public void setBanType(String banType) { this.banType = banType; }
|
||||
|
||||
public String getCmdStatus() { return cmdStatus; }
|
||||
public void setCmdStatus(String cmdStatus) { this.cmdStatus = cmdStatus; }
|
||||
|
||||
public Integer getBanDuration() { return banDuration; }
|
||||
public void setBanDuration(Integer banDuration) { this.banDuration = banDuration; }
|
||||
|
||||
public OffsetDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(OffsetDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public OffsetDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(OffsetDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public String getTenantId() { return tenantId; }
|
||||
public void setTenantId(String tenantId) { this.tenantId = tenantId; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
|
||||
public Integer getBanOperationType() { return banOperationType; }
|
||||
public void setBanOperationType(Integer banOperationType) { this.banOperationType = banOperationType; }
|
||||
|
||||
// ========== 便利方法:数组与List互转 ==========
|
||||
|
||||
/**
|
||||
* 获取设备联动ID列表
|
||||
*/
|
||||
public List<Integer> getDeviceInterlockingIdList() {
|
||||
return deviceInterlockingId != null ? Arrays.asList(deviceInterlockingId) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备联动ID列表
|
||||
*/
|
||||
public void setDeviceInterlockingIdList(List<Integer> list) {
|
||||
this.deviceInterlockingId = list != null ? list.toArray(new Integer[0]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备联动IP列表
|
||||
*/
|
||||
public List<String> getDeviceInterlockingIpList() {
|
||||
return deviceInterlockingIp != null ? Arrays.asList(deviceInterlockingIp) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备联动IP列表
|
||||
*/
|
||||
public void setDeviceInterlockingIpList(List<String> list) {
|
||||
this.deviceInterlockingIp = list != null ? list.toArray(new String[0]) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取封禁IP列表
|
||||
*/
|
||||
public List<String> getBanIpsList() {
|
||||
return banIps != null ? Arrays.asList(banIps) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置封禁IP列表
|
||||
*/
|
||||
public void setBanIpsList(List<String> list) {
|
||||
this.banIps = list != null ? list.toArray(new String[0]) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceInterlockingCmd{" +
|
||||
"id=" + id +
|
||||
", probeId=" + probeId +
|
||||
", probeIp='" + probeIp + '\'' +
|
||||
", banType='" + banType + '\'' +
|
||||
", cmdStatus='" + cmdStatus + '\'' +
|
||||
", banOperationType=" + banOperationType +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 封禁记录表实体类
|
||||
* 对应表: device_interlocking_log
|
||||
*/
|
||||
public class DeviceInterlockingLog {
|
||||
private Long id;
|
||||
private Long deviceInterlockingCmdId; // 封禁指令ID
|
||||
private Long deviceInterlockingId; // 封禁设备ID
|
||||
private String banIp; // 封禁IP地址
|
||||
private String deviceName; // 封禁设备名称
|
||||
private OffsetDateTime banTime; // 封禁时间
|
||||
private String banMethod; // 封禁方式(0.人工、1.自动化封禁)
|
||||
private Integer banResult; // 联动结果(成功:1、失败:0)
|
||||
private String tenantId;
|
||||
private Long createDept;
|
||||
private Long createBy;
|
||||
private OffsetDateTime createTime;
|
||||
private Long updateBy;
|
||||
private OffsetDateTime updateTime;
|
||||
private String remark;
|
||||
private String respBody; // 响应body
|
||||
private String reqBody; // 请求body
|
||||
|
||||
// Getter and Setter
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public Long getDeviceInterlockingCmdId() { return deviceInterlockingCmdId; }
|
||||
public void setDeviceInterlockingCmdId(Long deviceInterlockingCmdId) { this.deviceInterlockingCmdId = deviceInterlockingCmdId; }
|
||||
|
||||
public Long getDeviceInterlockingId() { return deviceInterlockingId; }
|
||||
public void setDeviceInterlockingId(Long deviceInterlockingId) { this.deviceInterlockingId = deviceInterlockingId; }
|
||||
|
||||
public String getBanIp() { return banIp; }
|
||||
public void setBanIp(String banIp) { this.banIp = banIp; }
|
||||
|
||||
public String getDeviceName() { return deviceName; }
|
||||
public void setDeviceName(String deviceName) { this.deviceName = deviceName; }
|
||||
|
||||
public OffsetDateTime getBanTime() { return banTime; }
|
||||
public void setBanTime(OffsetDateTime banTime) { this.banTime = banTime; }
|
||||
|
||||
public String getBanMethod() { return banMethod; }
|
||||
public void setBanMethod(String banMethod) { this.banMethod = banMethod; }
|
||||
|
||||
public Integer getBanResult() { return banResult; }
|
||||
public void setBanResult(Integer banResult) { this.banResult = banResult; }
|
||||
|
||||
public String getTenantId() { return tenantId; }
|
||||
public void setTenantId(String tenantId) { this.tenantId = tenantId; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public OffsetDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(OffsetDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public OffsetDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(OffsetDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public String getRemark() { return remark; }
|
||||
public void setRemark(String remark) { this.remark = remark; }
|
||||
|
||||
public String getRespBody() { return respBody; }
|
||||
public void setRespBody(String respBody) { this.respBody = respBody; }
|
||||
|
||||
public String getReqBody() { return reqBody; }
|
||||
public void setReqBody(String reqBody) { this.reqBody = reqBody; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceInterlockingLog{" +
|
||||
"id=" + id +
|
||||
", deviceInterlockingCmdId=" + deviceInterlockingCmdId +
|
||||
", banIp='" + banIp + '\'' +
|
||||
", deviceName='" + deviceName + '\'' +
|
||||
", banResult=" + banResult +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceReceiveLog {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 记录创建时间(UTC时间)
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
/**
|
||||
* 采集探针ID
|
||||
*/
|
||||
private Integer deviceCollectId;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 设备IP(PostgreSQL inet类型,用String处理)
|
||||
*/
|
||||
private String deviceIp;
|
||||
|
||||
/**
|
||||
* 日志收到时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime receiveTime;
|
||||
|
||||
/**
|
||||
* 接收时间字符串(冗余字段)
|
||||
*/
|
||||
private String receiveTimeStr;
|
||||
|
||||
/**
|
||||
* 原始syslog消息
|
||||
*/
|
||||
private String syslogMessage;
|
||||
|
||||
// 推送是否成功
|
||||
private Boolean pushSuccess;
|
||||
/**
|
||||
* 分页参数(非表字段)
|
||||
*/
|
||||
private Integer pageNum;
|
||||
private Integer pageSize;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class DeviceStatsDTO {
|
||||
private Long deviceId;
|
||||
private LocalDateTime lastReceiveTime;
|
||||
private Integer parseCount;
|
||||
private Integer nonLogCount;
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class DmColumn {
|
||||
private Long id;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
private LocalDateTime deletedAt;
|
||||
private String name;
|
||||
private String displayName;
|
||||
private Long storageDataType;
|
||||
private Long businessDataType;
|
||||
private Boolean isBuiltIn;
|
||||
private Boolean isHidden;
|
||||
private Boolean isNotNormalizable;
|
||||
private Boolean isRequired;
|
||||
private Integer categoryId;
|
||||
private Integer customAssetCategoryId;
|
||||
private Boolean isVirtual;
|
||||
private Integer tableId;
|
||||
private Integer assetTableId;
|
||||
private Integer columnSetId;
|
||||
private Integer baseType;
|
||||
private Integer userTaskId;
|
||||
private Long createdById;
|
||||
private Long createDept;
|
||||
private Long createBy;
|
||||
private LocalDateTime createTime;
|
||||
private Long updateBy;
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
// 构造方法
|
||||
public DmColumn() {}
|
||||
|
||||
public DmColumn(String name, String displayName) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
// getter 和 setter 方法
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public LocalDateTime getUpdatedAt() { return updatedAt; }
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
|
||||
|
||||
public LocalDateTime getDeletedAt() { return deletedAt; }
|
||||
public void setDeletedAt(LocalDateTime deletedAt) { this.deletedAt = deletedAt; }
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public String getDisplayName() { return displayName; }
|
||||
public void setDisplayName(String displayName) { this.displayName = displayName; }
|
||||
|
||||
public Long getStorageDataType() { return storageDataType; }
|
||||
public void setStorageDataType(Long storageDataType) { this.storageDataType = storageDataType; }
|
||||
|
||||
public Long getBusinessDataType() { return businessDataType; }
|
||||
public void setBusinessDataType(Long businessDataType) { this.businessDataType = businessDataType; }
|
||||
|
||||
public Boolean getIsBuiltIn() { return isBuiltIn; }
|
||||
public void setIsBuiltIn(Boolean isBuiltIn) { this.isBuiltIn = isBuiltIn; }
|
||||
|
||||
public Boolean getIsHidden() { return isHidden; }
|
||||
public void setIsHidden(Boolean isHidden) { this.isHidden = isHidden; }
|
||||
|
||||
public Boolean getIsNotNormalizable() { return isNotNormalizable; }
|
||||
public void setIsNotNormalizable(Boolean isNotNormalizable) { this.isNotNormalizable = isNotNormalizable; }
|
||||
|
||||
public Boolean getIsRequired() { return isRequired; }
|
||||
public void setIsRequired(Boolean isRequired) { this.isRequired = isRequired; }
|
||||
|
||||
public Integer getCategoryId() { return categoryId; }
|
||||
public void setCategoryId(Integer categoryId) { this.categoryId = categoryId; }
|
||||
|
||||
public Integer getCustomAssetCategoryId() { return customAssetCategoryId; }
|
||||
public void setCustomAssetCategoryId(Integer customAssetCategoryId) { this.customAssetCategoryId = customAssetCategoryId; }
|
||||
|
||||
public Boolean getIsVirtual() { return isVirtual; }
|
||||
public void setIsVirtual(Boolean isVirtual) { this.isVirtual = isVirtual; }
|
||||
|
||||
public Integer getTableId() { return tableId; }
|
||||
public void setTableId(Integer tableId) { this.tableId = tableId; }
|
||||
|
||||
public Integer getAssetTableId() { return assetTableId; }
|
||||
public void setAssetTableId(Integer assetTableId) { this.assetTableId = assetTableId; }
|
||||
|
||||
public Integer getColumnSetId() { return columnSetId; }
|
||||
public void setColumnSetId(Integer columnSetId) { this.columnSetId = columnSetId; }
|
||||
|
||||
public Integer getBaseType() { return baseType; }
|
||||
public void setBaseType(Integer baseType) { this.baseType = baseType; }
|
||||
|
||||
public Integer getUserTaskId() { return userTaskId; }
|
||||
public void setUserTaskId(Integer userTaskId) { this.userTaskId = userTaskId; }
|
||||
|
||||
public Long getCreatedById() { return createdById; }
|
||||
public void setCreatedById(Long createdById) { this.createdById = createdById; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public LocalDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public LocalDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DmColumn{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", displayName='" + displayName + '\'' +
|
||||
", isBuiltIn=" + isBuiltIn +
|
||||
", isHidden=" + isHidden +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class DmNormalizeRule {
|
||||
private Long id;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
private LocalDateTime deletedAt;
|
||||
private String name;
|
||||
private String displayName;
|
||||
private String description;
|
||||
private Boolean isBuiltIn;
|
||||
private Boolean isRunning;
|
||||
private LocalDateTime firstDataSavedAt;
|
||||
private String dataType;
|
||||
private Integer fieldCateId;
|
||||
private String logParsed;
|
||||
private String[] sampleLogs;
|
||||
private Boolean isDataMergeEnabled;
|
||||
private Long dataMergeInterval;
|
||||
private String dataMergeTimeUnit;
|
||||
private Long dataMergeRowLimit;
|
||||
private String dataMergeColumns;
|
||||
private Short dataStorageMedium;
|
||||
private Integer createdById;
|
||||
private Integer groupId;
|
||||
private String ruleContent;
|
||||
private String builtInVersion;
|
||||
private String tenantId;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
private Long createBy;
|
||||
private Long updateBy;
|
||||
private String delFlag;
|
||||
private Long createDept;
|
||||
|
||||
// getters and setters
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
|
||||
public LocalDateTime getCreatedAt() { return createdAt; }
|
||||
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
||||
|
||||
public LocalDateTime getUpdatedAt() { return updatedAt; }
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) { this.updatedAt = updatedAt; }
|
||||
|
||||
public LocalDateTime getDeletedAt() { return deletedAt; }
|
||||
public void setDeletedAt(LocalDateTime deletedAt) { this.deletedAt = deletedAt; }
|
||||
|
||||
public String getName() { return name; }
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
public String getDisplayName() { return displayName; }
|
||||
public void setDisplayName(String displayName) { this.displayName = displayName; }
|
||||
|
||||
public String getDescription() { return description; }
|
||||
public void setDescription(String description) { this.description = description; }
|
||||
|
||||
public Boolean getIsBuiltIn() { return isBuiltIn; }
|
||||
public void setIsBuiltIn(Boolean isBuiltIn) { this.isBuiltIn = isBuiltIn; }
|
||||
|
||||
public Boolean getIsRunning() { return isRunning; }
|
||||
public void setIsRunning(Boolean isRunning) { this.isRunning = isRunning; }
|
||||
|
||||
public LocalDateTime getFirstDataSavedAt() { return firstDataSavedAt; }
|
||||
public void setFirstDataSavedAt(LocalDateTime firstDataSavedAt) { this.firstDataSavedAt = firstDataSavedAt; }
|
||||
|
||||
public String getDataType() { return dataType; }
|
||||
public void setDataType(String dataType) { this.dataType = dataType; }
|
||||
|
||||
public Integer getFieldCateId() { return fieldCateId; }
|
||||
public void setFieldCateId(Integer fieldCateId) { this.fieldCateId = fieldCateId; }
|
||||
|
||||
public String getLogParsed() { return logParsed; }
|
||||
public void setLogParsed(String logParsed) { this.logParsed = logParsed; }
|
||||
|
||||
public String[] getSampleLogs() { return sampleLogs; }
|
||||
public void setSampleLogs(String[] sampleLogs) { this.sampleLogs = sampleLogs; }
|
||||
|
||||
public Boolean getIsDataMergeEnabled() { return isDataMergeEnabled; }
|
||||
public void setIsDataMergeEnabled(Boolean isDataMergeEnabled) { this.isDataMergeEnabled = isDataMergeEnabled; }
|
||||
|
||||
public Long getDataMergeInterval() { return dataMergeInterval; }
|
||||
public void setDataMergeInterval(Long dataMergeInterval) { this.dataMergeInterval = dataMergeInterval; }
|
||||
|
||||
public String getDataMergeTimeUnit() { return dataMergeTimeUnit; }
|
||||
public void setDataMergeTimeUnit(String dataMergeTimeUnit) { this.dataMergeTimeUnit = dataMergeTimeUnit; }
|
||||
|
||||
public Long getDataMergeRowLimit() { return dataMergeRowLimit; }
|
||||
public void setDataMergeRowLimit(Long dataMergeRowLimit) { this.dataMergeRowLimit = dataMergeRowLimit; }
|
||||
|
||||
public String getDataMergeColumns() { return dataMergeColumns; }
|
||||
public void setDataMergeColumns(String dataMergeColumns) { this.dataMergeColumns = dataMergeColumns; }
|
||||
|
||||
public Short getDataStorageMedium() { return dataStorageMedium; }
|
||||
public void setDataStorageMedium(Short dataStorageMedium) { this.dataStorageMedium = dataStorageMedium; }
|
||||
|
||||
public Integer getCreatedById() { return createdById; }
|
||||
public void setCreatedById(Integer createdById) { this.createdById = createdById; }
|
||||
|
||||
public Integer getGroupId() { return groupId; }
|
||||
public void setGroupId(Integer groupId) { this.groupId = groupId; }
|
||||
|
||||
public String getRuleContent() { return ruleContent; }
|
||||
public void setRuleContent(String ruleContent) { this.ruleContent = ruleContent; }
|
||||
|
||||
public String getBuiltInVersion() { return builtInVersion; }
|
||||
public void setBuiltInVersion(String builtInVersion) { this.builtInVersion = builtInVersion; }
|
||||
|
||||
public String getTenantId() { return tenantId; }
|
||||
public void setTenantId(String tenantId) { this.tenantId = tenantId; }
|
||||
|
||||
public LocalDateTime getCreateTime() { return createTime; }
|
||||
public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
|
||||
|
||||
public LocalDateTime getUpdateTime() { return updateTime; }
|
||||
public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; }
|
||||
|
||||
public Long getCreateBy() { return createBy; }
|
||||
public void setCreateBy(Long createBy) { this.createBy = createBy; }
|
||||
|
||||
public Long getUpdateBy() { return updateBy; }
|
||||
public void setUpdateBy(Long updateBy) { this.updateBy = updateBy; }
|
||||
|
||||
public String getDelFlag() { return delFlag; }
|
||||
public void setDelFlag(String delFlag) { this.delFlag = delFlag; }
|
||||
|
||||
public Long getCreateDept() { return createDept; }
|
||||
public void setCreateDept(Long createDept) { this.createDept = createDept; }
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.common.entity;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class GroupedSyslogData {
|
||||
private String logDate;
|
||||
private String srcIp;
|
||||
private String destIp;
|
||||
private String[] attackIps;
|
||||
private String originEventName;
|
||||
private Integer attackResult; // 单个attack_result值
|
||||
private LocalDateTime minLogTime;
|
||||
private LocalDateTime maxLogTime;
|
||||
private Long logCount;
|
||||
private String[] victimIps;
|
||||
private String[] victimWebUrls;
|
||||
private Integer[] deviceIds;
|
||||
private String[] originLogIds;
|
||||
private Integer maxEventLevel;
|
||||
private String firstEventType;
|
||||
private String eventType;
|
||||
private String minEventType;
|
||||
private Integer[] attackPorts;
|
||||
private Integer[] victimPorts;
|
||||
private String[] httpStatusCodes;
|
||||
private byte[][] payloadSamples;
|
||||
private String[] httpReqHeaders;
|
||||
private String[] httpReqBodys;
|
||||
private String[] httpRespHeaders;
|
||||
private String[] httpRespBodys;
|
||||
private String dnsInfo;
|
||||
private String victimIpsStr;
|
||||
private Integer[] allAttackResults; // 所有不同的attack_result值
|
||||
private Integer mostCommonAttackResult; // 最常见的attack_result值
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.common.entity;
|
||||
|
||||
public class RFC3164Message extends SyslogMessage {
|
||||
private String tag;
|
||||
|
||||
public String getTag() { return tag; }
|
||||
public void setTag(String tag) { this.tag = tag; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("RFC3164 [Facility: %d, Severity: %d, Host: %s, Tag: %s, Time: %s, Msg: %s]",
|
||||
facility, severity, hostname, tag, timestamp, message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class RFC5424Message extends SyslogMessage {
|
||||
private int version;
|
||||
private Map<String, Map<String, String>> structuredData;
|
||||
|
||||
public RFC5424Message() {
|
||||
this.structuredData = new HashMap<>();
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Map<String, Map<String, String>> getStructuredData() {
|
||||
return structuredData;
|
||||
}
|
||||
|
||||
public void setStructuredData(Map<String, Map<String, String>> structuredData) {
|
||||
this.structuredData = structuredData;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
public class ActionType {
|
||||
private String type;
|
||||
private String relation_parser_id;
|
||||
private Object sparser_param;
|
||||
private Object param;
|
||||
|
||||
// Constructors
|
||||
public ActionType() {}
|
||||
|
||||
// Getters and Setters
|
||||
public String gettype() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void settype(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getrelation_parser_id() {
|
||||
return relation_parser_id;
|
||||
}
|
||||
|
||||
public void setrelation_parser_id(String relation_parser_id) {
|
||||
this.relation_parser_id = relation_parser_id;
|
||||
}
|
||||
|
||||
public Object getsparser_param() {
|
||||
return sparser_param;
|
||||
}
|
||||
|
||||
public void setsparser_param(Object sparser_param) {
|
||||
this.sparser_param = sparser_param;
|
||||
}
|
||||
|
||||
public Object getparam() {
|
||||
return param;
|
||||
}
|
||||
|
||||
public void setparam(Object param) {
|
||||
this.param = param;
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CompleteColumn {
|
||||
private String columnName; // 要补全的字段名
|
||||
private Object value; // 补全的值
|
||||
private String filtersRelation; // 条件关系: "and" 或 "or"
|
||||
private List<Condition> conditions; // 条件列表
|
||||
|
||||
// 导入数据相关字段(扩展功能)
|
||||
private String importedDataTableName;
|
||||
private String filtersImportedRelation;
|
||||
private List<Condition> importedConditions;
|
||||
private List<CompleteColumn> completeImportedColumns;
|
||||
}
|
||||
|
||||
@Data
|
||||
class Condition {
|
||||
private String columnName; // 条件字段名
|
||||
private String op; // 操作符: =, !=, in, zero_len, contain, regexp
|
||||
private Object value; // 条件值
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
public class Complete_paramsType {
|
||||
private String name;
|
||||
private String value;
|
||||
private FiltersType filters;
|
||||
|
||||
// Constructors
|
||||
public Complete_paramsType() {}
|
||||
|
||||
// Getters and Setters
|
||||
public String getname() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setname(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getvalue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setvalue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public FiltersType getfilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public void setfilters(FiltersType filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
public class Cropper_paramsType {
|
||||
private String head_key;
|
||||
private Integer head_offset;
|
||||
private String tail_key;
|
||||
private Integer tail_offset;
|
||||
|
||||
// Constructors
|
||||
public Cropper_paramsType() {}
|
||||
|
||||
// Getters and Setters
|
||||
public String gethead_key() {
|
||||
return head_key;
|
||||
}
|
||||
|
||||
public void sethead_key(String head_key) {
|
||||
this.head_key = head_key;
|
||||
}
|
||||
|
||||
public Integer gethead_offset() {
|
||||
return head_offset;
|
||||
}
|
||||
|
||||
public void sethead_offset(Integer head_offset) {
|
||||
this.head_offset = head_offset;
|
||||
}
|
||||
|
||||
public String gettail_key() {
|
||||
return tail_key;
|
||||
}
|
||||
|
||||
public void settail_key(String tail_key) {
|
||||
this.tail_key = tail_key;
|
||||
}
|
||||
|
||||
public Integer gettail_offset() {
|
||||
return tail_offset;
|
||||
}
|
||||
|
||||
public void settail_offset(Integer tail_offset) {
|
||||
this.tail_offset = tail_offset;
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class FilterParam {
|
||||
private List<FilterGroup> filtersParams;
|
||||
}
|
||||
|
||||
@Data
|
||||
class FilterGroup {
|
||||
private List<FilterExpression> expressions;
|
||||
private String filtersRelation; // "and" 或 "or"
|
||||
}
|
||||
|
||||
@Data
|
||||
class FilterExpression {
|
||||
private String columnName; // 字段名
|
||||
private String op; // 操作符: =, !=, in, zero_len, contain, regexp
|
||||
private Object value; // 值,可能是字符串、数组等
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
public class FiltersType {
|
||||
|
||||
// Constructors
|
||||
public FiltersType() {}
|
||||
|
||||
// Getters and Setters
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
|
||||
public class MappersType {
|
||||
private Integer capture_group_index;
|
||||
private String origin_field;
|
||||
private String src_field;
|
||||
private String dest_field;
|
||||
private String value;
|
||||
private String assigned_value;
|
||||
private Integer strategy;
|
||||
private String mapping_rule_name;
|
||||
private ActionType action;
|
||||
|
||||
// Constructors
|
||||
public MappersType() {}
|
||||
|
||||
// Getters and Setters
|
||||
public Integer getcapture_group_index() {
|
||||
return capture_group_index;
|
||||
}
|
||||
|
||||
public void setcapture_group_index(Integer capture_group_index) {
|
||||
this.capture_group_index = capture_group_index;
|
||||
}
|
||||
|
||||
public String getorigin_field() {
|
||||
return origin_field;
|
||||
}
|
||||
|
||||
public void setorigin_field(String origin_field) {
|
||||
this.origin_field = origin_field;
|
||||
}
|
||||
|
||||
public String getsrc_field() {
|
||||
return src_field;
|
||||
}
|
||||
|
||||
public void setsrc_field(String src_field) {
|
||||
this.src_field = src_field;
|
||||
}
|
||||
|
||||
public String getdest_field() {
|
||||
return dest_field;
|
||||
}
|
||||
|
||||
public void setdest_field(String dest_field) {
|
||||
this.dest_field = dest_field;
|
||||
}
|
||||
|
||||
public String getvalue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setvalue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getassigned_value() {
|
||||
return assigned_value;
|
||||
}
|
||||
|
||||
public void setassigned_value(String assigned_value) {
|
||||
this.assigned_value = assigned_value;
|
||||
}
|
||||
|
||||
public Integer getstrategy() {
|
||||
return strategy;
|
||||
}
|
||||
|
||||
public void setstrategy(Integer strategy) {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
public String getmapping_rule_name() {
|
||||
return mapping_rule_name;
|
||||
}
|
||||
|
||||
public void setmapping_rule_name(String mapping_rule_name) {
|
||||
this.mapping_rule_name = mapping_rule_name;
|
||||
}
|
||||
|
||||
public ActionType getaction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setaction(ActionType action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
package com.common.entity.RuleContent;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.common.entity.RuleContent.*;
|
||||
|
||||
|
||||
public class Root {
|
||||
private Integer field_cate_id;
|
||||
private Integer field_cate_table_name;
|
||||
private String rule_name;
|
||||
private String data_type;
|
||||
private String decode;
|
||||
private List<String> keywords;
|
||||
private Cropper_paramsType cropper_params;
|
||||
private Object second_parsers;
|
||||
private Object second_parsers_v2;
|
||||
private List<MappersType> mappers;
|
||||
private String filters_params;
|
||||
private List<Complete_paramsType> complete_params;
|
||||
private String complete_columns;
|
||||
private Integer data_storage_medium;
|
||||
|
||||
// Constructors
|
||||
public Root() {}
|
||||
|
||||
// Getters and Setters
|
||||
public Integer getfield_cate_id() {
|
||||
return field_cate_id;
|
||||
}
|
||||
|
||||
public void setfield_cate_id(Integer field_cate_id) {
|
||||
this.field_cate_id = field_cate_id;
|
||||
}
|
||||
|
||||
public Integer getfield_cate_table_name() {
|
||||
return field_cate_table_name;
|
||||
}
|
||||
|
||||
public void setfield_cate_table_name(Integer field_cate_table_name) {
|
||||
this.field_cate_table_name = field_cate_table_name;
|
||||
}
|
||||
|
||||
public String getrule_name() {
|
||||
return rule_name;
|
||||
}
|
||||
|
||||
public void setrule_name(String rule_name) {
|
||||
this.rule_name = rule_name;
|
||||
}
|
||||
|
||||
public String getdata_type() {
|
||||
return data_type;
|
||||
}
|
||||
|
||||
public void setdata_type(String data_type) {
|
||||
this.data_type = data_type;
|
||||
}
|
||||
|
||||
public String getdecode() {
|
||||
return decode;
|
||||
}
|
||||
|
||||
public void setdecode(String decode) {
|
||||
this.decode = decode;
|
||||
}
|
||||
|
||||
public List<String> getkeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setkeywords(List<String> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public Cropper_paramsType getcropper_params() {
|
||||
return cropper_params;
|
||||
}
|
||||
|
||||
public void setcropper_params(Cropper_paramsType cropper_params) {
|
||||
this.cropper_params = cropper_params;
|
||||
}
|
||||
|
||||
public Object getsecond_parsers() {
|
||||
return second_parsers;
|
||||
}
|
||||
|
||||
public void setsecond_parsers(Object second_parsers) {
|
||||
this.second_parsers = second_parsers;
|
||||
}
|
||||
|
||||
public Object getsecond_parsers_v2() {
|
||||
return second_parsers_v2;
|
||||
}
|
||||
|
||||
public void setsecond_parsers_v2(Object second_parsers_v2) {
|
||||
this.second_parsers_v2 = second_parsers_v2;
|
||||
}
|
||||
|
||||
public List<MappersType> getmappers() {
|
||||
return mappers;
|
||||
}
|
||||
|
||||
public void setmappers(List<MappersType> mappers) {
|
||||
this.mappers = mappers;
|
||||
}
|
||||
|
||||
public String getfilters_params() {
|
||||
return filters_params;
|
||||
}
|
||||
|
||||
public void setfilters_params(String filters_params) {
|
||||
this.filters_params = filters_params;
|
||||
}
|
||||
|
||||
public List<Complete_paramsType> getcomplete_params() {
|
||||
return complete_params;
|
||||
}
|
||||
|
||||
public void setcomplete_params(List<Complete_paramsType> complete_params) {
|
||||
this.complete_params = complete_params;
|
||||
}
|
||||
|
||||
public String getcomplete_columns() {
|
||||
return complete_columns;
|
||||
}
|
||||
|
||||
public void setcomplete_columns(String complete_columns) {
|
||||
this.complete_columns = complete_columns;
|
||||
}
|
||||
|
||||
public Integer getdata_storage_medium() {
|
||||
return data_storage_medium;
|
||||
}
|
||||
|
||||
public void setdata_storage_medium(Integer data_storage_medium) {
|
||||
this.data_storage_medium = data_storage_medium;
|
||||
}
|
||||
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package com.common.entity.RuleContent;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.common.entity.RuleContent.*;
|
||||
public class RuleContent {
|
||||
|
||||
private Integer field_cate_id;
|
||||
private Integer field_cate_table_name;
|
||||
private String rule_name;
|
||||
private String data_type;
|
||||
private String decode;
|
||||
private List<String> keywords;
|
||||
private Cropper_paramsType cropper_params;
|
||||
private Object second_parsers;
|
||||
private Object second_parsers_v2;
|
||||
private List<MappersType> mappers;
|
||||
private String filters_params;
|
||||
private List<Complete_paramsType> complete_params;
|
||||
private String complete_columns;
|
||||
private Integer data_storage_medium;
|
||||
|
||||
// Constructors
|
||||
public RuleContent() {}
|
||||
|
||||
// Getters and Setters
|
||||
public Integer getfield_cate_id() {
|
||||
return field_cate_id;
|
||||
}
|
||||
|
||||
public void setfield_cate_id(Integer field_cate_id) {
|
||||
this.field_cate_id = field_cate_id;
|
||||
}
|
||||
|
||||
public Integer getfield_cate_table_name() {
|
||||
return field_cate_table_name;
|
||||
}
|
||||
|
||||
public void setfield_cate_table_name(Integer field_cate_table_name) {
|
||||
this.field_cate_table_name = field_cate_table_name;
|
||||
}
|
||||
|
||||
public String getrule_name() {
|
||||
return rule_name;
|
||||
}
|
||||
|
||||
public void setrule_name(String rule_name) {
|
||||
this.rule_name = rule_name;
|
||||
}
|
||||
|
||||
public String getdata_type() {
|
||||
return data_type;
|
||||
}
|
||||
|
||||
public void setdata_type(String data_type) {
|
||||
this.data_type = data_type;
|
||||
}
|
||||
|
||||
public String getdecode() {
|
||||
return decode;
|
||||
}
|
||||
|
||||
public void setdecode(String decode) {
|
||||
this.decode = decode;
|
||||
}
|
||||
|
||||
public List<String> getkeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public void setkeywords(List<String> keywords) {
|
||||
this.keywords = keywords;
|
||||
}
|
||||
|
||||
public Cropper_paramsType getcropper_params() {
|
||||
return cropper_params;
|
||||
}
|
||||
|
||||
public void setcropper_params(Cropper_paramsType cropper_params) {
|
||||
this.cropper_params = cropper_params;
|
||||
}
|
||||
|
||||
public Object getsecond_parsers() {
|
||||
return second_parsers;
|
||||
}
|
||||
|
||||
public void setsecond_parsers(Object second_parsers) {
|
||||
this.second_parsers = second_parsers;
|
||||
}
|
||||
|
||||
public Object getsecond_parsers_v2() {
|
||||
return second_parsers_v2;
|
||||
}
|
||||
|
||||
public void setsecond_parsers_v2(Object second_parsers_v2) {
|
||||
this.second_parsers_v2 = second_parsers_v2;
|
||||
}
|
||||
|
||||
public List<MappersType> getmappers() {
|
||||
return mappers;
|
||||
}
|
||||
|
||||
public void setmappers(List<MappersType> mappers) {
|
||||
this.mappers = mappers;
|
||||
}
|
||||
|
||||
public String getfilters_params() {
|
||||
return filters_params;
|
||||
}
|
||||
|
||||
public void setfilters_params(String filters_params) {
|
||||
this.filters_params = filters_params;
|
||||
}
|
||||
|
||||
public List<Complete_paramsType> getcomplete_params() {
|
||||
return complete_params;
|
||||
}
|
||||
|
||||
public void setcomplete_params(List<Complete_paramsType> complete_params) {
|
||||
this.complete_params = complete_params;
|
||||
}
|
||||
|
||||
public String getcomplete_columns() {
|
||||
return complete_columns;
|
||||
}
|
||||
|
||||
public void setcomplete_columns(String complete_columns) {
|
||||
this.complete_columns = complete_columns;
|
||||
}
|
||||
|
||||
public Integer getdata_storage_medium() {
|
||||
return data_storage_medium;
|
||||
}
|
||||
|
||||
public void setdata_storage_medium(Integer data_storage_medium) {
|
||||
this.data_storage_medium = data_storage_medium;
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.common.entity.RuleContent;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class kv_paramsType {
|
||||
private String internal;
|
||||
private String external;
|
||||
private String l_trim;
|
||||
private String r_trim;
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RuleHitTimeDTO {
|
||||
/**
|
||||
* 泛化规则ID
|
||||
*/
|
||||
private Long normalizeRuleId;
|
||||
|
||||
/**
|
||||
* 最大命中时间(从标准化表中统计)
|
||||
*/
|
||||
private LocalDateTime maxLogTime;
|
||||
|
||||
/**
|
||||
* 数据来源表
|
||||
*/
|
||||
private String sourceTable;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SecExceptionAlgorithm {
|
||||
private Long id;
|
||||
private String algorithmName;
|
||||
private String exceptionType;
|
||||
private String dataSource;
|
||||
private Integer status; // 1启用
|
||||
private String description;
|
||||
private String configInfo;
|
||||
private String operatorZipUrl;
|
||||
private String remark;
|
||||
private String createBy;
|
||||
private LocalDateTime createTime;
|
||||
private String updateBy;
|
||||
private LocalDateTime updateTime;
|
||||
private String tenantId;
|
||||
private String delFlag;
|
||||
private Long createDept;
|
||||
private String apiUrl; // API URL
|
||||
private String apiMethod; // GET/POST
|
||||
private String respUrl;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// 基础 Syslog 消息类
|
||||
public abstract class SyslogMessage {
|
||||
protected int priority;
|
||||
protected int facility;
|
||||
protected int severity;
|
||||
protected String hostname;
|
||||
protected String appName;
|
||||
protected String procId;
|
||||
protected String msgId;
|
||||
protected String message;
|
||||
protected OffsetDateTime timestamp;
|
||||
|
||||
// Getters and Setters
|
||||
public int getPriority() { return priority; }
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
this.facility = priority / 8;
|
||||
this.severity = priority % 8;
|
||||
}
|
||||
|
||||
public int getFacility() { return facility; }
|
||||
public int getSeverity() { return severity; }
|
||||
public String getHostname() { return hostname; }
|
||||
public void setHostname(String hostname) { this.hostname = hostname; }
|
||||
public String getAppName() { return appName; }
|
||||
public void setAppName(String appName) { this.appName = appName; }
|
||||
public String getProcId() { return procId; }
|
||||
public void setProcId(String procId) { this.procId = procId; }
|
||||
public String getMsgId() { return msgId; }
|
||||
public void setMsgId(String msgId) { this.msgId = msgId; }
|
||||
public String getMessage() { return message; }
|
||||
public void setMessage(String message) { this.message = message; }
|
||||
public OffsetDateTime getTimestamp() { return timestamp; }
|
||||
public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Facility: %d, Severity: %d, Host: %s, App: %s, Time: %s, Msg: %s",
|
||||
facility, severity, hostname, appName, timestamp, message);
|
||||
}
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
package com.common.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
/**
|
||||
* 非标日志实体类
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("syslog_non_normal_message")
|
||||
public class SyslogNonNormalMessage {
|
||||
|
||||
/**
|
||||
* 非标ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 记录时间(UTC时区)
|
||||
*/
|
||||
@TableField("created_at")
|
||||
private OffsetDateTime createdAt;
|
||||
|
||||
/**
|
||||
* log处理时间
|
||||
*/
|
||||
@TableField("log_time")
|
||||
private LocalDateTime logTime;
|
||||
|
||||
/**
|
||||
* 设备ID
|
||||
*/
|
||||
@TableField("device_id")
|
||||
private Integer deviceId;
|
||||
|
||||
/**
|
||||
* 原始日志
|
||||
*/
|
||||
@TableField("syslog_message")
|
||||
private String syslogMessage;
|
||||
|
||||
/**
|
||||
* 安全日志ID
|
||||
*/
|
||||
@TableField("syslog_uuid")
|
||||
private String syslogUuid;
|
||||
|
||||
/**
|
||||
* kafka topic
|
||||
*/
|
||||
@TableField("syslog_topic")
|
||||
private String syslogTopic;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField("tenant_id")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 创建部门
|
||||
*/
|
||||
@TableField("create_dept")
|
||||
private Long createDept;
|
||||
|
||||
/**
|
||||
* 采集头部消息
|
||||
*/
|
||||
@TableField("header_message")
|
||||
private String headerMessage;
|
||||
|
||||
/**
|
||||
* 接收时间
|
||||
*/
|
||||
@TableField("receive_time")
|
||||
private LocalDateTime receiveTime;
|
||||
|
||||
/**
|
||||
* 泛化时间
|
||||
*/
|
||||
@TableField("rule_time")
|
||||
private LocalDateTime ruleTime;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* ETL处理节点
|
||||
*/
|
||||
@TableField("etl_node")
|
||||
private String etlNode;
|
||||
|
||||
/**
|
||||
* 采集任务ID
|
||||
*/
|
||||
@TableField("collect_task_id")
|
||||
private Integer collectTaskId;
|
||||
|
||||
/**
|
||||
* 采集任务名称
|
||||
*/
|
||||
@TableField("collect_task_name")
|
||||
private String collectTaskName;
|
||||
|
||||
/**
|
||||
* 非标原因
|
||||
*/
|
||||
@TableField("reason")
|
||||
private String reason;
|
||||
|
||||
/**
|
||||
* 详细原因
|
||||
*/
|
||||
@TableField("reason_detail")
|
||||
private String reasonDetail;
|
||||
|
||||
/**
|
||||
* 泛化结果
|
||||
*/
|
||||
@TableField("rule_result")
|
||||
private String ruleResult;
|
||||
|
||||
/**
|
||||
* 删除标志
|
||||
*/
|
||||
@TableField("del_flag")
|
||||
private String delFlag;
|
||||
}
|
||||
+383
@@ -0,0 +1,383 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SyslogNormalAlarm {
|
||||
private String id;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime logTime;
|
||||
private Integer deviceId;
|
||||
private String webshellType;
|
||||
private String vuirsType;
|
||||
private String vuirsUrl;
|
||||
private String classFilename;
|
||||
private String classPath;
|
||||
private String parentClass;
|
||||
private String jarPath;
|
||||
private String classMd5;
|
||||
private String classLoader;
|
||||
private String classHashcode;
|
||||
private String classLoaderHashcode;
|
||||
private String tcNameip;
|
||||
private String performSql;
|
||||
private String tcAccount;
|
||||
private String tcAppname;
|
||||
private String processUname;
|
||||
private String pProcessUname;
|
||||
private String containerName;
|
||||
private String containerId;
|
||||
private String httpRespServer;
|
||||
private Long srcipId;
|
||||
private String cdnip;
|
||||
private String natip;
|
||||
private String mailSender;
|
||||
private String mailReceiver;
|
||||
private String vpnMac;
|
||||
private String vpnOs;
|
||||
private String vpnUser;
|
||||
private String vpnGroupname;
|
||||
private String vpnAccessIp;
|
||||
private Boolean destIpApt;
|
||||
private String originAttackResult;
|
||||
private String description;
|
||||
private String solution;
|
||||
private String attackCause;
|
||||
private String username;
|
||||
private String tcFlowId;
|
||||
private String loginResult;
|
||||
private String cmdline;
|
||||
private String originAttackAction;
|
||||
private String victimDomain;
|
||||
private String vpnDeviceid;
|
||||
private String vpnAccessAction;
|
||||
private Long fileAccessTime;
|
||||
private String fileName;
|
||||
private String tcClass;
|
||||
private String tcName2;
|
||||
private Long loginLasttime;
|
||||
private String originPermissions;
|
||||
private String beginPermissions;
|
||||
private Long printTime;
|
||||
private String printer;
|
||||
private String printerType;
|
||||
private Long printPages;
|
||||
private Long printCopies;
|
||||
private String srcDevice;
|
||||
private String dstDevice;
|
||||
private String srcFile;
|
||||
private String srcFileType;
|
||||
private String srcFilePath;
|
||||
private String dstFile;
|
||||
private String dstFileType;
|
||||
private String dstFilePath;
|
||||
private String dlpPolicyName;
|
||||
private String dlpPolicyType;
|
||||
private String dstUploadUrl;
|
||||
private String processUuid;
|
||||
private String pProcessUuid;
|
||||
private String env;
|
||||
private String bruteForceService;
|
||||
private String vuirsName;
|
||||
private Long httpReqLength;
|
||||
private String httpReqContentType;
|
||||
private String tcScanPort;
|
||||
private String tcLabels;
|
||||
private String httpRespContentType;
|
||||
private String dnsMsgType;
|
||||
private String dnsAnswerLength;
|
||||
private Boolean dnsIoc;
|
||||
private BigDecimal txBytes;
|
||||
private BigDecimal rxBytes;
|
||||
private BigDecimal allBytes;
|
||||
private Long durationTime;
|
||||
private String mailAttachName;
|
||||
private String mailSubject;
|
||||
private String mailMessage;
|
||||
private String mailSendServer;
|
||||
private String mailAgent;
|
||||
private String tlsVersion;
|
||||
private String tlsServerCert;
|
||||
private String tlsServerSuite;
|
||||
private String tlsClientSuitesLen;
|
||||
private String tlsJa3;
|
||||
private String tlsJa3s;
|
||||
private String vpnAccessPort;
|
||||
private String logTopic;
|
||||
private Long collectTime;
|
||||
private Boolean srcIsIntranetip;
|
||||
private Boolean srcIpIoc;
|
||||
private Boolean srcIpApt;
|
||||
private String srcipName;
|
||||
private String tcClient;
|
||||
private Long srcipOrganizationId;
|
||||
private Boolean destIpIntranetip;
|
||||
private Boolean destIpIoc;
|
||||
private Long desipId;
|
||||
private String desipName;
|
||||
private String tcHostip;
|
||||
private Long desipOrganizationId;
|
||||
private String originConfidence;
|
||||
private String originMalscore;
|
||||
private String attackerIcampaign;
|
||||
private Long attackerHostAssetId;
|
||||
private Long attackerOrganizationId;
|
||||
private Long victimHostAssetId;
|
||||
private Long victimOrganizationId;
|
||||
private Long logoutTime;
|
||||
private String httpReqLine;
|
||||
private String desipSecurityScopeId;
|
||||
private String srcipSecurityScopeId;
|
||||
private Long httpRespLength;
|
||||
private String tcAttackType;
|
||||
private String tcRealip;
|
||||
private String attackerIpLists;
|
||||
private String loginPassword;
|
||||
private String detail;
|
||||
private String attackerCountryCode;
|
||||
private String attackerRegionCode;
|
||||
private String victimRegionCode;
|
||||
private String payload;
|
||||
private String httpReferer;
|
||||
private String httpUserAgent;
|
||||
private String httpSession;
|
||||
private String httpQueryString;
|
||||
private String filePath;
|
||||
private String filePermission;
|
||||
private String loginAbnormalType;
|
||||
private String fileTag;
|
||||
private String filePlatform;
|
||||
private String targetIp;
|
||||
private String collectDate;
|
||||
private String tcClientIp;
|
||||
private String tcServerIp;
|
||||
private String tcExternalip;
|
||||
private Long httpStatusCode;
|
||||
private String deviceDomian;
|
||||
private String srcIpStr;
|
||||
private String srcPortStr;
|
||||
private String destIpStr;
|
||||
private String destPortStr;
|
||||
private String pcap;
|
||||
private String ioc;
|
||||
private String maliciousFamily;
|
||||
private String vulnCve;
|
||||
private String aliyunType;
|
||||
private String attackerHostAssetName;
|
||||
private String attackerOrganizationName;
|
||||
private String ctId;
|
||||
private String cveList;
|
||||
private String desipOrganizationName;
|
||||
private String destIpGroup;
|
||||
private String fileGid;
|
||||
private String fileOwner;
|
||||
private String fileOwnergroup;
|
||||
private String fileUid;
|
||||
private String httpRespCookie;
|
||||
private String originRuleId;
|
||||
private String originRuleName;
|
||||
private String serviceName;
|
||||
private String srcIpAssetGroup;
|
||||
private String srcipOrganizationName;
|
||||
private String victimHostAssetName;
|
||||
private Long httpRespCodes;
|
||||
private String victimOrganizationName;
|
||||
private String tcType;
|
||||
private String direction;
|
||||
private String httpReqCookie;
|
||||
private String httpReqProtocol;
|
||||
private String httpReqHeaderRaw;
|
||||
private String httpUrl;
|
||||
private String uname;
|
||||
private String originHostname;
|
||||
private String originOs;
|
||||
private String originAgentMac;
|
||||
private String originHostId;
|
||||
private String originAgentVersion;
|
||||
private String originAgentId;
|
||||
private String originAgentName;
|
||||
private String originWorkGroup;
|
||||
private String originAssetGroup;
|
||||
private Long originLocalPort;
|
||||
private String originAgentIp;
|
||||
private String originInternalIp;
|
||||
private String originExternalIp;
|
||||
private String originLocalAddr;
|
||||
private Long agentId;
|
||||
private String agentName;
|
||||
private String tcTitle;
|
||||
private String logId;
|
||||
private LocalDateTime eventDate;
|
||||
private Long eventTimeTs;
|
||||
private Integer eventLevel;
|
||||
private String srcIp;
|
||||
private Long srcPort;
|
||||
private String destIp;
|
||||
private Long destPort;
|
||||
private Long eventTime;
|
||||
private String attackerCountry;
|
||||
private String srcMac;
|
||||
private String destMac;
|
||||
private String proto;
|
||||
private Long devId;
|
||||
private Long createdTime;
|
||||
private String srcCountry;
|
||||
private String srcCountryCode;
|
||||
private String srcRegion;
|
||||
private String srcRegionCode;
|
||||
private String srcCity;
|
||||
private String srcLon;
|
||||
private String httpMethod;
|
||||
private String httpHost;
|
||||
private String httpReqHeader;
|
||||
private String httpReqBody;
|
||||
private String httpRespHeader;
|
||||
private String httpRespBody;
|
||||
private String fileType;
|
||||
private String fileMd5;
|
||||
private String fileSize;
|
||||
private String process;
|
||||
private Long startTime;
|
||||
private String action;
|
||||
private String attackerRegion;
|
||||
private Long endTime;
|
||||
private Long fileCreatedTime;
|
||||
private Long fileModifiedTime;
|
||||
private String tcMiguanScanPort;
|
||||
private String processPath;
|
||||
private String parentProcessPath;
|
||||
private String gname;
|
||||
private String exeName;
|
||||
private String exePath;
|
||||
private Long loginTime;
|
||||
private Long loginTimes;
|
||||
private String checkItem;
|
||||
private String checkType;
|
||||
private String attackerIp;
|
||||
private Long attackerPort;
|
||||
private String victimIp;
|
||||
private Long victimPort;
|
||||
private String attackerCity;
|
||||
private String attackerLon;
|
||||
private String attackerLat;
|
||||
private String victimCountry;
|
||||
private String victimRegion;
|
||||
private String victimCity;
|
||||
private String victimLon;
|
||||
private String victimLat;
|
||||
private String originEventId;
|
||||
private String originEventName;
|
||||
private String originEventCategory;
|
||||
private String originEventLevel;
|
||||
private String originAttackChain;
|
||||
private String engineType;
|
||||
private String evilPayload;
|
||||
private String httpRespStatus;
|
||||
private String dnsQuery;
|
||||
private String dnsQueryType;
|
||||
private String dnsTtl;
|
||||
private String dnsAnswer;
|
||||
private String dnsSubdomains;
|
||||
private String fileSha256;
|
||||
private String fileSsdeep;
|
||||
private String victimCountryCode;
|
||||
private String httpXffIp;
|
||||
private String tcMiguanClass;
|
||||
private String pid;
|
||||
private String ppid;
|
||||
private String processName;
|
||||
private String backdoorType;
|
||||
private String tty;
|
||||
private String sudoUser;
|
||||
private String sudoGroup;
|
||||
private String originEventType;
|
||||
private String destDomain;
|
||||
private String shellCmdline;
|
||||
private String parentCmdline;
|
||||
private String attackChain;
|
||||
private String processTree;
|
||||
private String hostFileSha256;
|
||||
private String hostFileMd5;
|
||||
private String hostFileSize;
|
||||
private String hostFileType;
|
||||
private String destCountry;
|
||||
private String destCountryCode;
|
||||
private String logOrigin;
|
||||
private String destRegion;
|
||||
private String srcLat;
|
||||
private String destRegionCode;
|
||||
private String destCity;
|
||||
private String destLon;
|
||||
private String destLat;
|
||||
private Integer eventCategory;
|
||||
private Integer attackResult;
|
||||
private String probeIp;
|
||||
private String deviceIp;
|
||||
private String deviceManufacturer;
|
||||
private String deviceName;
|
||||
private String productName;
|
||||
private String id1;
|
||||
private Long count;
|
||||
private String countReason;
|
||||
private Integer eventType;
|
||||
private String protocol;
|
||||
private String shellCmd;
|
||||
private String parentName;
|
||||
private String hostFilePath;
|
||||
private String uid;
|
||||
private Integer fall;
|
||||
private String tcMiguanServerIp;
|
||||
private Integer devType;
|
||||
private Integer collectMethod;
|
||||
private Integer fieldCateId;
|
||||
private Integer deviceType;
|
||||
private String tcMiguanClientIp;
|
||||
private String tcMiguanName;
|
||||
private Long originTotalPackages;
|
||||
private Long originTotalBytes;
|
||||
private Long originPeakPackagesRate;
|
||||
private Long originPeakBytesRate;
|
||||
private Long originPeakFlowsRate;
|
||||
private String aptOrgname;
|
||||
private String aptOrgmsg;
|
||||
private String mailMessageId;
|
||||
private String mailBcc;
|
||||
private String mailSize;
|
||||
private String mailAttachHashcode;
|
||||
private String mailUrl;
|
||||
private String mailCc;
|
||||
private String algorithm;
|
||||
private String miningpoolIp;
|
||||
private String processMd5;
|
||||
private String pprocessMd5;
|
||||
private String sourceServername;
|
||||
private String originSourceServername;
|
||||
private String mailFilename;
|
||||
private String dstUploadAppname;
|
||||
private Long targetPort;
|
||||
private String gid;
|
||||
private String originUid;
|
||||
private String originGid;
|
||||
private Long targetPorts;
|
||||
private String tcMiguanName1;
|
||||
private String tcMiguanClass1;
|
||||
private Long etlTime;
|
||||
private String tcMiguanScanPort2;
|
||||
private String desipSecurityScope;
|
||||
private String srcipSecurityScope;
|
||||
private Long collectTimeTs;
|
||||
private String tcMiguanScanPort1;
|
||||
private String srcDevName;
|
||||
private String collectProtocol;
|
||||
private String destinationSystemType;
|
||||
private String destinationSystem;
|
||||
private String etlHost;
|
||||
private Integer normalizeRuleId;
|
||||
private String normalizeRuleName;
|
||||
private String syslogUuid;
|
||||
private String syslogTopic;
|
||||
|
||||
}
|
||||
+381
@@ -0,0 +1,381 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class SyslogNormalData {
|
||||
private String id;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime logTime;
|
||||
private Integer deviceId;
|
||||
private String webshellType;
|
||||
private String vuirsType;
|
||||
private String vuirsUrl;
|
||||
private String classFilename;
|
||||
private String classPath;
|
||||
private String parentClass;
|
||||
private String jarPath;
|
||||
private String classMd5;
|
||||
private String classLoader;
|
||||
private String classHashcode;
|
||||
private String classLoaderHashcode;
|
||||
private String tcNameip;
|
||||
private String performSql;
|
||||
private String tcAccount;
|
||||
private String tcAppname;
|
||||
private String processUname;
|
||||
private String pProcessUname;
|
||||
private String containerName;
|
||||
private String containerId;
|
||||
private String httpRespServer;
|
||||
private Long srcipId;
|
||||
private String cdnip;
|
||||
private String natip;
|
||||
private String mailSender;
|
||||
private String mailReceiver;
|
||||
private String vpnMac;
|
||||
private String vpnOs;
|
||||
private String vpnUser;
|
||||
private String vpnGroupname;
|
||||
private String vpnAccessIp;
|
||||
private Boolean destIpApt;
|
||||
private String originAttackResult;
|
||||
private String description;
|
||||
private String solution;
|
||||
private String attackCause;
|
||||
private String username;
|
||||
private String tcFlowId;
|
||||
private String loginResult;
|
||||
private String cmdline;
|
||||
private String originAttackAction;
|
||||
private String victimDomain;
|
||||
private String vpnDeviceid;
|
||||
private String vpnAccessAction;
|
||||
private Long fileAccessTime;
|
||||
private String fileName;
|
||||
private String tcClass;
|
||||
private String tcName2;
|
||||
private Long loginLasttime;
|
||||
private String originPermissions;
|
||||
private String beginPermissions;
|
||||
private Long printTime;
|
||||
private String printer;
|
||||
private String printerType;
|
||||
private Long printPages;
|
||||
private Long printCopies;
|
||||
private String srcDevice;
|
||||
private String dstDevice;
|
||||
private String srcFile;
|
||||
private String srcFileType;
|
||||
private String srcFilePath;
|
||||
private String dstFile;
|
||||
private String dstFileType;
|
||||
private String dstFilePath;
|
||||
private String dlpPolicyName;
|
||||
private String dlpPolicyType;
|
||||
private String dstUploadUrl;
|
||||
private String processUuid;
|
||||
private String pProcessUuid;
|
||||
private String env;
|
||||
private String bruteForceService;
|
||||
private String vuirsName;
|
||||
private Long httpReqLength;
|
||||
private String httpReqContentType;
|
||||
private String tcScanPort;
|
||||
private String tcLabels;
|
||||
private String httpRespContentType;
|
||||
private String dnsMsgType;
|
||||
private String dnsAnswerLength;
|
||||
private Boolean dnsIoc;
|
||||
private BigDecimal txBytes;
|
||||
private BigDecimal rxBytes;
|
||||
private BigDecimal allBytes;
|
||||
private Long durationTime;
|
||||
private String mailAttachName;
|
||||
private String mailSubject;
|
||||
private String mailMessage;
|
||||
private String mailSendServer;
|
||||
private String mailAgent;
|
||||
private String tlsVersion;
|
||||
private String tlsServerCert;
|
||||
private String tlsServerSuite;
|
||||
private String tlsClientSuitesLen;
|
||||
private String tlsJa3;
|
||||
private String tlsJa3s;
|
||||
private String vpnAccessPort;
|
||||
private String logTopic;
|
||||
private Long collectTime;
|
||||
private Boolean srcIsIntranetip;
|
||||
private Boolean srcIpIoc;
|
||||
private Boolean srcIpApt;
|
||||
private String srcipName;
|
||||
private String tcClient;
|
||||
private Long srcipOrganizationId;
|
||||
private Boolean destIpIntranetip;
|
||||
private Boolean destIpIoc;
|
||||
private Long desipId;
|
||||
private String desipName;
|
||||
private String tcHostip;
|
||||
private Long desipOrganizationId;
|
||||
private String originConfidence;
|
||||
private String originMalscore;
|
||||
private String attackerIcampaign;
|
||||
private Long attackerHostAssetId;
|
||||
private Long attackerOrganizationId;
|
||||
private Long victimHostAssetId;
|
||||
private Long victimOrganizationId;
|
||||
private Long logoutTime;
|
||||
private String httpReqLine;
|
||||
private String desipSecurityScopeId;
|
||||
private String srcipSecurityScopeId;
|
||||
private Long httpRespLength;
|
||||
private String tcAttackType;
|
||||
private String tcRealip;
|
||||
private String attackerIpLists;
|
||||
private String loginPassword;
|
||||
private String detail;
|
||||
private String attackerCountryCode;
|
||||
private String attackerRegionCode;
|
||||
private String victimRegionCode;
|
||||
private String payload;
|
||||
private String httpReferer;
|
||||
private String httpUserAgent;
|
||||
private String httpSession;
|
||||
private String httpQueryString;
|
||||
private String filePath;
|
||||
private String filePermission;
|
||||
private String loginAbnormalType;
|
||||
private String fileTag;
|
||||
private String filePlatform;
|
||||
private String targetIp;
|
||||
private String collectDate;
|
||||
private String tcClientIp;
|
||||
private String tcServerIp;
|
||||
private String tcExternalip;
|
||||
private Long httpStatusCode;
|
||||
private String deviceDomian;
|
||||
private String srcIpStr;
|
||||
private String srcPortStr;
|
||||
private String destIpStr;
|
||||
private String destPortStr;
|
||||
private String pcap;
|
||||
private String ioc;
|
||||
private String maliciousFamily;
|
||||
private String vulnCve;
|
||||
private String aliyunType;
|
||||
private String attackerHostAssetName;
|
||||
private String attackerOrganizationName;
|
||||
private String ctId;
|
||||
private String cveList;
|
||||
private String desipOrganizationName;
|
||||
private String destIpGroup;
|
||||
private String fileGid;
|
||||
private String fileOwner;
|
||||
private String fileOwnergroup;
|
||||
private String fileUid;
|
||||
private String httpRespCookie;
|
||||
private String originRuleId;
|
||||
private String originRuleName;
|
||||
private String serviceName;
|
||||
private String srcIpAssetGroup;
|
||||
private String srcipOrganizationName;
|
||||
private String victimHostAssetName;
|
||||
private Long httpRespCodes;
|
||||
private String victimOrganizationName;
|
||||
private String tcType;
|
||||
private String direction;
|
||||
private String httpReqCookie;
|
||||
private String httpReqProtocol;
|
||||
private String httpReqHeaderRaw;
|
||||
private String httpUrl;
|
||||
private String uname;
|
||||
private String originHostname;
|
||||
private String originOs;
|
||||
private String originAgentMac;
|
||||
private String originHostId;
|
||||
private String originAgentVersion;
|
||||
private String originAgentId;
|
||||
private String originAgentName;
|
||||
private String originWorkGroup;
|
||||
private String originAssetGroup;
|
||||
private Long originLocalPort;
|
||||
private String originAgentIp;
|
||||
private String originInternalIp;
|
||||
private String originExternalIp;
|
||||
private String originLocalAddr;
|
||||
private Long agentId;
|
||||
private String agentName;
|
||||
private String tcTitle;
|
||||
private String logId;
|
||||
private LocalDateTime eventDate;
|
||||
private Long eventTimeTs;
|
||||
private Integer eventLevel;
|
||||
private String srcIp;
|
||||
private Long srcPort;
|
||||
private String destIp;
|
||||
private Long destPort;
|
||||
private Long eventTime;
|
||||
private String attackerCountry;
|
||||
private String srcMac;
|
||||
private String destMac;
|
||||
private String proto;
|
||||
private Long devId;
|
||||
private Long createdTime;
|
||||
private String srcCountry;
|
||||
private String srcCountryCode;
|
||||
private String srcRegion;
|
||||
private String srcRegionCode;
|
||||
private String srcCity;
|
||||
private String srcLon;
|
||||
private String httpMethod;
|
||||
private String httpHost;
|
||||
private String httpReqHeader;
|
||||
private String httpReqBody;
|
||||
private String httpRespHeader;
|
||||
private String httpRespBody;
|
||||
private String fileType;
|
||||
private String fileMd5;
|
||||
private String fileSize;
|
||||
private String process;
|
||||
private Long startTime;
|
||||
private String action;
|
||||
private String attackerRegion;
|
||||
private Long endTime;
|
||||
private Long fileCreatedTime;
|
||||
private Long fileModifiedTime;
|
||||
private String tcMiguanScanPort;
|
||||
private String processPath;
|
||||
private String parentProcessPath;
|
||||
private String gname;
|
||||
private String exeName;
|
||||
private String exePath;
|
||||
private Long loginTime;
|
||||
private Long loginTimes;
|
||||
private String checkItem;
|
||||
private String checkType;
|
||||
private String attackerIp;
|
||||
private Long attackerPort;
|
||||
private String victimIp;
|
||||
private Long victimPort;
|
||||
private String attackerCity;
|
||||
private String attackerLon;
|
||||
private String attackerLat;
|
||||
private String victimCountry;
|
||||
private String victimRegion;
|
||||
private String victimCity;
|
||||
private String victimLon;
|
||||
private String victimLat;
|
||||
private String originEventId;
|
||||
private String originEventName;
|
||||
private String originEventCategory;
|
||||
private String originEventLevel;
|
||||
private String originAttackChain;
|
||||
private String engineType;
|
||||
private String evilPayload;
|
||||
private String httpRespStatus;
|
||||
private String dnsQuery;
|
||||
private String dnsQueryType;
|
||||
private String dnsTtl;
|
||||
private String dnsAnswer;
|
||||
private String dnsSubdomains;
|
||||
private String fileSha256;
|
||||
private String fileSsdeep;
|
||||
private String victimCountryCode;
|
||||
private String httpXffIp;
|
||||
private String tcMiguanClass;
|
||||
private String pid;
|
||||
private String ppid;
|
||||
private String processName;
|
||||
private String backdoorType;
|
||||
private String tty;
|
||||
private String sudoUser;
|
||||
private String sudoGroup;
|
||||
private String originEventType;
|
||||
private String destDomain;
|
||||
private String shellCmdline;
|
||||
private String parentCmdline;
|
||||
private String attackChain;
|
||||
private String processTree;
|
||||
private String hostFileSha256;
|
||||
private String hostFileMd5;
|
||||
private String hostFileSize;
|
||||
private String hostFileType;
|
||||
private String destCountry;
|
||||
private String destCountryCode;
|
||||
private String logOrigin;
|
||||
private String destRegion;
|
||||
private String srcLat;
|
||||
private String destRegionCode;
|
||||
private String destCity;
|
||||
private String destLon;
|
||||
private String destLat;
|
||||
private Integer eventCategory;
|
||||
private Integer attackResult;
|
||||
private String probeIp;
|
||||
private String deviceIp;
|
||||
private String deviceManufacturer;
|
||||
private String deviceName;
|
||||
private String productName;
|
||||
private String id1;
|
||||
private Long count;
|
||||
private String countReason;
|
||||
private Integer eventType;
|
||||
private String protocol;
|
||||
private String shellCmd;
|
||||
private String parentName;
|
||||
private String hostFilePath;
|
||||
private String uid;
|
||||
private Integer fall;
|
||||
private String tcMiguanServerIp;
|
||||
private Integer devType;
|
||||
private Integer collectMethod;
|
||||
private Integer fieldCateId;
|
||||
private Integer deviceType;
|
||||
private String tcMiguanClientIp;
|
||||
private String tcMiguanName;
|
||||
private Long originTotalPackages;
|
||||
private Long originTotalBytes;
|
||||
private Long originPeakPackagesRate;
|
||||
private Long originPeakBytesRate;
|
||||
private Long originPeakFlowsRate;
|
||||
private String aptOrgname;
|
||||
private String aptOrgmsg;
|
||||
private String mailMessageId;
|
||||
private String mailBcc;
|
||||
private String mailSize;
|
||||
private String mailAttachHashcode;
|
||||
private String mailUrl;
|
||||
private String mailCc;
|
||||
private String algorithm;
|
||||
private String miningpoolIp;
|
||||
private String processMd5;
|
||||
private String pprocessMd5;
|
||||
private String sourceServername;
|
||||
private String originSourceServername;
|
||||
private String mailFilename;
|
||||
private String dstUploadAppname;
|
||||
private Long targetPort;
|
||||
private String gid;
|
||||
private String originUid;
|
||||
private String originGid;
|
||||
private Long targetPorts;
|
||||
private String tcMiguanName1;
|
||||
private String tcMiguanClass1;
|
||||
private Long etlTime;
|
||||
private String tcMiguanScanPort2;
|
||||
private String desipSecurityScope;
|
||||
private String srcipSecurityScope;
|
||||
private Long collectTimeTs;
|
||||
private String tcMiguanScanPort1;
|
||||
private String srcDevName;
|
||||
private String collectProtocol;
|
||||
private String destinationSystemType;
|
||||
private String destinationSystem;
|
||||
private String etlHost;
|
||||
private Integer normalizeRuleId;
|
||||
private String normalizeRuleName;
|
||||
private String syslogUuid;
|
||||
private String syslogTopic;
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package com.common.entity;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class SyslogRequest {
|
||||
|
||||
@NotBlank(message = "IP地址不能为空")
|
||||
private String ip;
|
||||
|
||||
@NotNull(message = "端口号不能为空")
|
||||
private Integer port;
|
||||
|
||||
@NotBlank(message = "日志内容不能为空")
|
||||
private String logContent;
|
||||
|
||||
private String protocol = "UDP"; // 默认UDP协议
|
||||
private String facility = "USER"; // 设施
|
||||
private String severity = "INFO"; // 严重级别
|
||||
|
||||
// 构造函数
|
||||
public SyslogRequest() {}
|
||||
|
||||
public SyslogRequest(String ip, Integer port, String logContent) {
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
this.logContent = logContent;
|
||||
}
|
||||
|
||||
// Getter和Setter方法
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getLogContent() {
|
||||
return logContent;
|
||||
}
|
||||
|
||||
public void setLogContent(String logContent) {
|
||||
this.logContent = logContent;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public String getFacility() {
|
||||
return facility;
|
||||
}
|
||||
|
||||
public void setFacility(String facility) {
|
||||
this.facility = facility;
|
||||
}
|
||||
|
||||
public String getSeverity() {
|
||||
return severity;
|
||||
}
|
||||
|
||||
public void setSeverity(String severity) {
|
||||
this.severity = severity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SyslogRequest{" +
|
||||
"ip='" + ip + '\'' +
|
||||
", port=" + port +
|
||||
", logContent='" + logContent + '\'' +
|
||||
", protocol='" + protocol + '\'' +
|
||||
", facility='" + facility + '\'' +
|
||||
", severity='" + severity + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.common.entity;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 微信通知实体类
|
||||
* 对应表: wecom_notification
|
||||
*/
|
||||
@Data
|
||||
public class WecomNotification {
|
||||
|
||||
/** 企微通知id */
|
||||
private Long wecomNotificationId;
|
||||
|
||||
/** 用户信息 */
|
||||
private String userId;
|
||||
|
||||
/** 通知名称 */
|
||||
private String wecomNotificationName;
|
||||
|
||||
/** 通知IP */
|
||||
private String wecomNotificationIp;
|
||||
|
||||
/** 通知类型 */
|
||||
private String wecomNotificationType;
|
||||
|
||||
/** 通知等级 */
|
||||
private String wecomNotificationLevel;
|
||||
|
||||
/** 通知内容 */
|
||||
private String wecomNotificationContent;
|
||||
|
||||
/** 告警通知时间 */
|
||||
private LocalDateTime wecomNotificationTime;
|
||||
|
||||
/** 租户编号 */
|
||||
private String tenantId;
|
||||
|
||||
/** 创建部门 */
|
||||
private Long createDept;
|
||||
|
||||
/** 创建者 */
|
||||
private Long createBy;
|
||||
|
||||
/** 创建时间 */
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/** 更新者 */
|
||||
private Long updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 通知状态(0:已发送, 1:未发送) */
|
||||
private String wecomNotificationStatus;
|
||||
|
||||
public WecomNotification() {
|
||||
}
|
||||
|
||||
public WecomNotification(String wecomNotificationName, String wecomNotificationType,
|
||||
String wecomNotificationLevel, String wecomNotificationContent) {
|
||||
this.wecomNotificationName = wecomNotificationName;
|
||||
this.wecomNotificationType = wecomNotificationType;
|
||||
this.wecomNotificationLevel = wecomNotificationLevel;
|
||||
this.wecomNotificationContent = wecomNotificationContent;
|
||||
this.wecomNotificationTime = LocalDateTime.now();
|
||||
this.wecomNotificationStatus = "1"; // 默认未发送
|
||||
this.createTime = LocalDateTime.now();
|
||||
}
|
||||
}
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
package com.common.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* XDR Honeypot 实体类
|
||||
* 对应数据库表 xdr_honeypot
|
||||
*/
|
||||
public class XdrHoneypot {
|
||||
private Long id;
|
||||
private String vcsource;
|
||||
private String dstartTime;
|
||||
private String dtime;
|
||||
private String riskLevel;
|
||||
private String vcconnection;
|
||||
private String fileInfo;
|
||||
private String extra;
|
||||
private String vctype;
|
||||
private String agentSn;
|
||||
private String agentName;
|
||||
private String honeypotId;
|
||||
private String honeypotName;
|
||||
private String srcIp;
|
||||
private String srcPort;
|
||||
private String srcMac;
|
||||
private String destIp;
|
||||
private String destPort;
|
||||
private String proxyIp;
|
||||
private String node;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
// 默认构造函数
|
||||
public XdrHoneypot() {
|
||||
this.createTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
// 带参构造函数
|
||||
public XdrHoneypot(String vcsource, String dstartTime, String dtime, String riskLevel,
|
||||
String vcconnection, String fileInfo, String extra, String vctype,
|
||||
String agentSn, String agentName, String honeypotId, String honeypotName,
|
||||
String srcIp, String srcPort, String srcMac, String destIp,
|
||||
String destPort, String proxyIp, String node) {
|
||||
this();
|
||||
this.vcsource = vcsource;
|
||||
this.dstartTime = dstartTime;
|
||||
this.dtime = dtime;
|
||||
this.riskLevel = riskLevel;
|
||||
this.vcconnection = vcconnection;
|
||||
this.fileInfo = fileInfo;
|
||||
this.extra = extra;
|
||||
this.vctype = vctype;
|
||||
this.agentSn = agentSn;
|
||||
this.agentName = agentName;
|
||||
this.honeypotId = honeypotId;
|
||||
this.honeypotName = honeypotName;
|
||||
this.srcIp = srcIp;
|
||||
this.srcPort = srcPort;
|
||||
this.srcMac = srcMac;
|
||||
this.destIp = destIp;
|
||||
this.destPort = destPort;
|
||||
this.proxyIp = proxyIp;
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
// Getter 和 Setter 方法
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getVcsource() {
|
||||
return vcsource;
|
||||
}
|
||||
|
||||
public void setVcsource(String vcsource) {
|
||||
this.vcsource = vcsource;
|
||||
}
|
||||
|
||||
public String getDstartTime() {
|
||||
return dstartTime;
|
||||
}
|
||||
|
||||
public void setDstartTime(String dstartTime) {
|
||||
this.dstartTime = dstartTime;
|
||||
}
|
||||
|
||||
public String getDtime() {
|
||||
return dtime;
|
||||
}
|
||||
|
||||
public void setDtime(String dtime) {
|
||||
this.dtime = dtime;
|
||||
}
|
||||
|
||||
public String getRiskLevel() {
|
||||
return riskLevel;
|
||||
}
|
||||
|
||||
public void setRiskLevel(String riskLevel) {
|
||||
this.riskLevel = riskLevel;
|
||||
}
|
||||
|
||||
public String getVcconnection() {
|
||||
return vcconnection;
|
||||
}
|
||||
|
||||
public void setVcconnection(String vcconnection) {
|
||||
this.vcconnection = vcconnection;
|
||||
}
|
||||
|
||||
public String getFileInfo() {
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
public void setFileInfo(String fileInfo) {
|
||||
this.fileInfo = fileInfo;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public String getVctype() {
|
||||
return vctype;
|
||||
}
|
||||
|
||||
public void setVctype(String vctype) {
|
||||
this.vctype = vctype;
|
||||
}
|
||||
|
||||
public String getAgentSn() {
|
||||
return agentSn;
|
||||
}
|
||||
|
||||
public void setAgentSn(String agentSn) {
|
||||
this.agentSn = agentSn;
|
||||
}
|
||||
|
||||
public String getAgentName() {
|
||||
return agentName;
|
||||
}
|
||||
|
||||
public void setAgentName(String agentName) {
|
||||
this.agentName = agentName;
|
||||
}
|
||||
|
||||
public String getHoneypotId() {
|
||||
return honeypotId;
|
||||
}
|
||||
|
||||
public void setHoneypotId(String honeypotId) {
|
||||
this.honeypotId = honeypotId;
|
||||
}
|
||||
|
||||
public String getHoneypotName() {
|
||||
return honeypotName;
|
||||
}
|
||||
|
||||
public void setHoneypotName(String honeypotName) {
|
||||
this.honeypotName = honeypotName;
|
||||
}
|
||||
|
||||
public String getSrcIp() {
|
||||
return srcIp;
|
||||
}
|
||||
|
||||
public void setSrcIp(String srcIp) {
|
||||
this.srcIp = srcIp;
|
||||
}
|
||||
|
||||
public String getSrcPort() {
|
||||
return srcPort;
|
||||
}
|
||||
|
||||
public void setSrcPort(String srcPort) {
|
||||
this.srcPort = srcPort;
|
||||
}
|
||||
|
||||
public String getSrcMac() {
|
||||
return srcMac;
|
||||
}
|
||||
|
||||
public void setSrcMac(String srcMac) {
|
||||
this.srcMac = srcMac;
|
||||
}
|
||||
|
||||
public String getDestIp() {
|
||||
return destIp;
|
||||
}
|
||||
|
||||
public void setDestIp(String destIp) {
|
||||
this.destIp = destIp;
|
||||
}
|
||||
|
||||
public String getDestPort() {
|
||||
return destPort;
|
||||
}
|
||||
|
||||
public void setDestPort(String destPort) {
|
||||
this.destPort = destPort;
|
||||
}
|
||||
|
||||
public String getProxyIp() {
|
||||
return proxyIp;
|
||||
}
|
||||
|
||||
public void setProxyIp(String proxyIp) {
|
||||
this.proxyIp = proxyIp;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
public void setNode(String node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "XdrHoneypot{" +
|
||||
"id=" + id +
|
||||
", vcsource='" + vcsource + '\'' +
|
||||
", dstartTime='" + dstartTime + '\'' +
|
||||
", dtime='" + dtime + '\'' +
|
||||
", riskLevel='" + riskLevel + '\'' +
|
||||
", vcconnection='" + vcconnection + '\'' +
|
||||
", fileInfo='" + fileInfo + '\'' +
|
||||
", extra='" + extra + '\'' +
|
||||
", vctype='" + vctype + '\'' +
|
||||
", agentSn='" + agentSn + '\'' +
|
||||
", agentName='" + agentName + '\'' +
|
||||
", honeypotId='" + honeypotId + '\'' +
|
||||
", honeypotName='" + honeypotName + '\'' +
|
||||
", srcIp='" + srcIp + '\'' +
|
||||
", srcPort='" + srcPort + '\'' +
|
||||
", srcMac='" + srcMac + '\'' +
|
||||
", destIp='" + destIp + '\'' +
|
||||
", destPort='" + destPort + '\'' +
|
||||
", proxyIp='" + proxyIp + '\'' +
|
||||
", node='" + node + '\'' +
|
||||
", createTime=" + createTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.Alarm;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface AlarmMapper {
|
||||
|
||||
/**
|
||||
* 批量插入告警数据
|
||||
*/
|
||||
@Insert({"<script>",
|
||||
"INSERT INTO alarm (",
|
||||
"id, created_at, alarm_name, alarm_level, alarm_type, ",
|
||||
"alarm_major_type, alarm_minor_type,alarm_area_id, attack_ip, victim_ip, victim_web_url, ",
|
||||
"device_id, comment,origin_log_ids,log_start_at, log_end_at, window_time, http_status, ",
|
||||
"attack_port, victim_port, attack_method, etl_time, log_count, ",
|
||||
"attack_chain_phase, disposition_advice, attack_direction, ",
|
||||
"judged_state, disposed_state, attack_result, fall, payload, dns_info, engine_type, " ,
|
||||
"http_req_header , http_req_body,http_resp_header , http_resp_body ",
|
||||
") VALUES ",
|
||||
"<foreach collection='list' item='item' separator=','>",
|
||||
"( #{item.id}, #{item.createdAt}, #{item.alarmName}, #{item.alarmLevel}, ",
|
||||
"#{item.alarmType}, #{item.alarmMajorType}, #{item.alarmMinorType}, #{item.alarmAreaId}, ",
|
||||
"#{item.attackIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.victimIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.victimWebUrl, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.deviceId, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.comment}, " ,
|
||||
"#{item.originLogIds, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.logStartAt}, #{item.logEndAt}, #{item.windowTime}, #{item.httpStatus}, ",
|
||||
"#{item.attackPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.victimPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.attackMethod}, #{item.etlTime}, #{item.logCount}, ",
|
||||
"#{item.attackChainPhase, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.dispositionAdvice}, #{item.attackDirection}, ",
|
||||
"#{item.judgedState}, #{item.disposedState}, #{item.attackResult}, #{item.fall}, ",
|
||||
"#{item.payload},#{item.dnsInfo}, #{item.engineType}, ",
|
||||
"#{item.httpReqHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpReqBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpRespHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpRespBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler})",
|
||||
"</foreach>",
|
||||
"</script>"})
|
||||
void batchInsert(@Param("list") List<Alarm> alarmList);
|
||||
|
||||
/**
|
||||
* 单条插入告警数据
|
||||
*/
|
||||
@Insert("INSERT INTO alarm (" +
|
||||
"id, created_at, alarm_name, alarm_level, alarm_type, " +
|
||||
"alarm_major_type, alarm_minor_type,alarm_area_id, attack_ip, victim_ip, victim_web_url, " +
|
||||
"device_id, comment,origin_log_ids, log_start_at, log_end_at, window_time, http_status, " +
|
||||
"attack_port, victim_port, attack_method, etl_time, log_count, " +
|
||||
"attack_chain_phase, disposition_advice, attack_direction, " +
|
||||
"judged_state, disposed_state, attack_result, fall, payload, dns_info, engine_type, " +
|
||||
"http_req_header , http_req_body,http_resp_header , http_resp_body " +
|
||||
") VALUES (" +
|
||||
"#{id}, #{createdAt}, #{alarmName}, #{alarmLevel}, " +
|
||||
"#{alarmType}, #{alarmMajorType}, #{alarmMinorType}, #{alarmAreaId}, " +
|
||||
"#{attackIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{victimIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{victimWebUrl, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, "+
|
||||
"#{deviceId, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{comment}, " +
|
||||
"#{originLogIds, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{logStartAt}, #{logEndAt}, #{windowTime},#{httpStatus}, " +
|
||||
"#{attackPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{victimPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{attackMethod}, #{etlTime}, #{logCount}, " +
|
||||
"#{attackChainPhase, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{dispositionAdvice}, #{attackDirection}, " +
|
||||
"#{judgedState}, #{disposedState}, #{attackResult}, #{fall}, #{payload}, #{dnsInfo},#{engineType}, " +
|
||||
"#{httpReqHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpReqBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpRespHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpRespBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler} " +
|
||||
")")
|
||||
void insert(Alarm alarm);
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.Alarm;
|
||||
import com.common.entity.AlarmVisit;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface AlarmVisitMapper {
|
||||
|
||||
/**
|
||||
* 批量插入告警数据
|
||||
*/
|
||||
@Insert({"<script>",
|
||||
"INSERT INTO alarm_visit (",
|
||||
"id, created_at, alarm_name, alarm_level, alarm_type, ",
|
||||
"alarm_major_type, alarm_minor_type,alarm_area_id, attack_ip, victim_ip, victim_web_url, ",
|
||||
"device_id, comment,origin_log_ids,log_start_at, log_end_at,window_time, http_status, ",
|
||||
"attack_port, victim_port, attack_method, etl_time, log_count, ",
|
||||
"attack_chain_phase, disposition_advice, attack_direction, ",
|
||||
"judged_state, disposed_state, attack_result, fall, payload, dns_info, engine_type, " ,
|
||||
"http_req_header , http_req_body,http_resp_header , http_resp_body ",
|
||||
") VALUES ",
|
||||
"<foreach collection='list' item='item' separator=','>",
|
||||
"(#{item.id}, #{item.createdAt}, #{item.alarmName}, #{item.alarmLevel}, ",
|
||||
"#{item.alarmType}, #{item.alarmMajorType}, #{item.alarmMinorType}, #{item.alarmAreaId}, ",
|
||||
"#{item.attackIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.victimIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.victimWebUrl, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.deviceId, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.comment}, " ,
|
||||
"#{item.originLogIds, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.logStartAt}, #{item.logEndAt},, #{item.windowTime} #{item.httpStatus}, ",
|
||||
"#{item.attackPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.victimPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.attackMethod}, #{item.etlTime}, #{item.logCount}, ",
|
||||
"#{item.attackChainPhase, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, ",
|
||||
"#{item.dispositionAdvice}, #{item.attackDirection}, ",
|
||||
"#{item.judgedState}, #{item.disposedState}, #{item.attackResult}, #{item.fall}, ",
|
||||
"#{item.payload},#{item.dnsInfo}, #{item.engineType}, ",
|
||||
"#{item.httpReqHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpReqBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpRespHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, ",
|
||||
"#{item.httpRespBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}) ",
|
||||
"</foreach>",
|
||||
"</script>"})
|
||||
void batchInsert(@Param("list") List<AlarmVisit> alarmList);
|
||||
|
||||
/**
|
||||
* 单条插入告警数据
|
||||
*/
|
||||
@Insert("INSERT INTO alarm_visit (" +
|
||||
"id, created_at, alarm_name, alarm_level, alarm_type, " +
|
||||
"alarm_major_type, alarm_minor_type,alarm_area_id, attack_ip, victim_ip, victim_web_url, " +
|
||||
"device_id, comment,origin_log_ids, log_start_at, log_end_at, window_time,http_status, " +
|
||||
"attack_port, victim_port, attack_method, etl_time, log_count, " +
|
||||
"attack_chain_phase, disposition_advice, attack_direction, " +
|
||||
"judged_state, disposed_state, attack_result, fall, payload, dns_info,engine_type, " +
|
||||
"http_req_header , http_req_body,http_resp_header , http_resp_body " +
|
||||
") VALUES (" +
|
||||
"#{id}, #{createdAt}, #{alarmName}, #{alarmLevel}, " +
|
||||
"#{alarmType}, #{alarmMajorType}, #{alarmMinorType}, #{alarmAreaId}, " +
|
||||
"#{attackIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{victimIp, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{victimWebUrl, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, "+
|
||||
"#{deviceId, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{comment}, " +
|
||||
"#{originLogIds, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{logStartAt}, #{logEndAt}, #{windowTime}, #{httpStatus}, " +
|
||||
"#{attackPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{victimPort, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{attackMethod}, #{etlTime}, #{logCount}, " +
|
||||
"#{attackChainPhase, typeHandler=com.Modules.etl.handler.ArrayIntegerTypeHandler}, " +
|
||||
"#{dispositionAdvice}, #{attackDirection}, " +
|
||||
"#{judgedState}, #{disposedState}, #{attackResult}, #{fall}, #{payload},#{dnsInfo} ,#{engineType}, " +
|
||||
"#{httpReqHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpReqBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpRespHeader, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler}, " +
|
||||
"#{httpRespBody, typeHandler=com.Modules.etl.handler.ArrayStringTypeHandler} " +
|
||||
")")
|
||||
void insert(AlarmVisit alarm);
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisAnalysisRule;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
/**
|
||||
* 分析规则Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisAnalysisRuleMapper {
|
||||
|
||||
/**
|
||||
* 查询指定运行模式的活动规则
|
||||
*
|
||||
* @param runMode 运行模式:realtime-实时/offline-离线
|
||||
* @return 规则列表
|
||||
*/
|
||||
List<AnalysisAnalysisRule> selectActiveRulesByRunMode(@Param("runMode") String runMode);
|
||||
|
||||
/**
|
||||
* 根据规则ID查询规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 规则信息
|
||||
*/
|
||||
AnalysisAnalysisRule selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 更新规则任务状态
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @param taskStatus 任务状态
|
||||
* @param updateBy 更新人ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
int updateTaskStatus(@Param("ruleId") String ruleId,
|
||||
@Param("taskStatus") String taskStatus,
|
||||
@Param("updateBy") Long updateBy);
|
||||
|
||||
/**
|
||||
* 根据ID查询规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 规则信息
|
||||
*/
|
||||
AnalysisAnalysisRule selectById(@Param("ruleId") String ruleId);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisField;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
/**
|
||||
* 分析字段配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisFieldMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询字段配置
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 字段列表
|
||||
*/
|
||||
List<AnalysisField> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 查询规则中用于SELECT的字段
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 字段列表
|
||||
*/
|
||||
List<AnalysisField> selectSelectFieldsByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 查询规则中用于GROUP BY的字段
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 字段列表
|
||||
*/
|
||||
List<AnalysisField> selectGroupByFieldsByRuleId(@Param("ruleId") String ruleId);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisFilter;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分析过滤条件Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisFilterMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询过滤条件
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 过滤条件列表
|
||||
*/
|
||||
List<AnalysisFilter> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 根据字段ID查询过滤条件
|
||||
*
|
||||
* @param fieldId 字段ID
|
||||
* @return 过滤条件列表
|
||||
*/
|
||||
List<AnalysisFilter> selectByFieldId(@Param("fieldId") Long fieldId);
|
||||
|
||||
/**
|
||||
* 根据条件ID查询过滤条件(与where_condition表关联)
|
||||
*
|
||||
* @param condId 条件ID
|
||||
* @return 过滤条件列表
|
||||
*/
|
||||
List<AnalysisFilter> selectByCondId(@Param("condId") Integer condId);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisGroupByColumn;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分组字段配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisGroupByColumnMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询分组字段配置
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 分组字段列表
|
||||
*/
|
||||
List<AnalysisGroupByColumn> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 根据分组ID查询分组字段配置
|
||||
*
|
||||
* @param groupById 分组ID
|
||||
* @return 分组字段列表
|
||||
*/
|
||||
List<AnalysisGroupByColumn> selectByGroupById(@Param("groupById") Integer groupById);
|
||||
|
||||
/**
|
||||
* 根据用户组ID查询分组字段配置
|
||||
*
|
||||
* @param groupId 用户组ID
|
||||
* @return 分组字段列表
|
||||
*/
|
||||
List<AnalysisGroupByColumn> selectByGroupId(@Param("groupId") Long groupId);
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisGroupByHaving;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分析分组聚合条件Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisGroupByHavingMapper {
|
||||
|
||||
/**
|
||||
* 根据分组ID查询HAVING条件
|
||||
*
|
||||
* @param groupById 分组ID
|
||||
* @return HAVING条件列表
|
||||
*/
|
||||
List<AnalysisGroupByHaving> selectByGroupById(@Param("groupById") Integer groupById);
|
||||
|
||||
/**
|
||||
* 根据规则ID查询HAVING条件(通过关联分组表)
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return HAVING条件列表
|
||||
*/
|
||||
List<AnalysisGroupByHaving> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisGroupBy;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分组规则配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisGroupByMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询分组配置
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 分组配置列表
|
||||
*/
|
||||
List<AnalysisGroupBy> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisGroupByWindow;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 分析时间窗口配置Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisGroupByWindowMapper {
|
||||
|
||||
/**
|
||||
* 根据分组ID查询窗口配置
|
||||
*
|
||||
* @param groupById 分组ID
|
||||
* @return 窗口配置
|
||||
*/
|
||||
AnalysisGroupByWindow selectByGroupById(@Param("groupById") Integer groupById);
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisTaskHistory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分析任务历史Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisTaskHistoryMapper {
|
||||
|
||||
/**
|
||||
* 插入任务历史记录
|
||||
*
|
||||
* @param history 任务历史
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(AnalysisTaskHistory history);
|
||||
|
||||
/**
|
||||
* 更新任务历史记录
|
||||
*
|
||||
* @param history 任务历史
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(AnalysisTaskHistory history);
|
||||
|
||||
/**
|
||||
* 根据规则ID查询最近的任务历史
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @param limit 查询数量
|
||||
* @return 任务历史列表
|
||||
*/
|
||||
List<AnalysisTaskHistory> selectRecentByRuleId(@Param("ruleId") String ruleId,
|
||||
@Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 根据规则ID和状态查询任务历史
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @param status 状态
|
||||
* @return 任务历史
|
||||
*/
|
||||
AnalysisTaskHistory selectByRuleIdAndStatus(@Param("ruleId") String ruleId,
|
||||
@Param("status") String status);
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.AnalysisWhereCondition;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* WHERE条件Mapper
|
||||
*/
|
||||
@Mapper
|
||||
public interface AnalysisWhereConditionMapper {
|
||||
|
||||
/**
|
||||
* 根据规则ID查询WHERE条件
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return WHERE条件列表
|
||||
*/
|
||||
List<AnalysisWhereCondition> selectByRuleId(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 查询根节点条件(无父节点)
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 根条件列表
|
||||
*/
|
||||
List<AnalysisWhereCondition> selectRootConditions(@Param("ruleId") String ruleId);
|
||||
|
||||
/**
|
||||
* 查询指定条件的子条件
|
||||
*
|
||||
* @param parentCondId 父条件ID
|
||||
* @return 子条件列表
|
||||
*/
|
||||
List<AnalysisWhereCondition> selectChildConditions(@Param("parentCondId") String parentCondId);
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.AppLogEntity;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AppLogMapper {
|
||||
|
||||
/**
|
||||
* 插入日志
|
||||
*/
|
||||
@Insert("INSERT INTO applog (es_index, es_type, es_id, es_score, dt_time, collect_time, log_type, " +
|
||||
"trace_id, method, app_name, ip, class_name, env, content, thread_name, log_level, seq, " +
|
||||
"indexed_at, log_date, created_at, updated_at) " +
|
||||
"VALUES (#{esIndex}, #{esType}, #{esId}, #{esScore}, #{dtTime}, #{collectTime}, #{logType}, " +
|
||||
"#{traceId}, #{method}, #{appName}, #{ip}, #{className}, #{env}, #{content}, #{threadName}, " +
|
||||
"#{logLevel}, #{seq}, #{indexedAt}, #{logDate}, #{createdAt}, #{updatedAt})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(AppLogEntity appLog);
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*/
|
||||
int batchInsert(@Param("list") List<AppLogEntity> appLogs);
|
||||
|
||||
/**
|
||||
* 根据ES ID检查是否存在
|
||||
*/
|
||||
@Select("SELECT COUNT(1) FROM applog WHERE es_id = #{esId}")
|
||||
boolean existsByEsId(String esId);
|
||||
|
||||
/**
|
||||
* 根据ES ID和索引检查是否存在
|
||||
*/
|
||||
@Select("SELECT COUNT(1) FROM applog WHERE es_id = #{esId} AND es_index = #{esIndex}")
|
||||
boolean existsByEsIdAndIndex(@Param("esId") String esId, @Param("esIndex") String esIndex);
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceCollectHeartbeatHistory;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 探针心跳历史 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceCollectHeartbeatHistoryMapper {
|
||||
|
||||
/**
|
||||
* 插入心跳历史记录
|
||||
*/
|
||||
@Insert("INSERT INTO device_collect_heartbeat_history (" +
|
||||
"collect_id, heartbeat_time, device_ip, app_version, created_at " +
|
||||
") VALUES (" +
|
||||
"#{collectId}, #{heartbeatTime}, #{deviceIp}, #{appVersion}, #{createdAt} " +
|
||||
")")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceCollectHeartbeatHistory history);
|
||||
|
||||
/**
|
||||
* 批量插入心跳历史记录
|
||||
*/
|
||||
@Insert("<script>" +
|
||||
"INSERT INTO device_collect_heartbeat_history " +
|
||||
"(collect_id, heartbeat_time, device_ip, app_version, created_at ) " +
|
||||
"VALUES " +
|
||||
"<foreach collection='list' item='item' separator=','>" +
|
||||
"(#{item.collectId}, #{item.heartbeatTime}, #{item.deviceIp}, #{item.appVersion}, " +
|
||||
"#{item.createdAt} )" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int batchInsert(@Param("list") List<DeviceCollectHeartbeatHistory> histories);
|
||||
|
||||
/**
|
||||
* 根据探针ID查询历史记录
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat_history " +
|
||||
"WHERE collect_id = #{collectId} ORDER BY heartbeat_time DESC LIMIT #{limit}")
|
||||
List<DeviceCollectHeartbeatHistory> selectByCollectId(@Param("collectId") String collectId,
|
||||
@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 删除指定日期之前的记录
|
||||
*/
|
||||
@Delete("DELETE FROM device_collect_heartbeat_history WHERE created_at < #{beforeTime}")
|
||||
int deleteBeforeTime(@Param("beforeTime") LocalDateTime beforeTime);
|
||||
|
||||
/**
|
||||
* 统计指定日期之前的记录数
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM device_collect_heartbeat_history WHERE created_at < #{beforeTime}")
|
||||
long countBeforeTime(@Param("beforeTime") LocalDateTime beforeTime);
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceCollectHeartbeat;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 探针心跳状态 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceCollectHeartbeatMapper {
|
||||
|
||||
/**
|
||||
* 根据探针ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat WHERE collect_id = #{collectId}")
|
||||
DeviceCollectHeartbeat selectByCollectId(@Param("collectId") String collectId);
|
||||
|
||||
/**
|
||||
* 查询所有探针
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat ORDER BY update_time DESC")
|
||||
List<DeviceCollectHeartbeat> selectAll();
|
||||
|
||||
/**
|
||||
* 查询所有在线探针
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat WHERE status = 'online' ORDER BY update_time DESC")
|
||||
List<DeviceCollectHeartbeat> selectAllOnline();
|
||||
|
||||
/**
|
||||
* 查询所有离线探针
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat WHERE status = 'offline' ORDER BY update_time DESC")
|
||||
List<DeviceCollectHeartbeat> selectAllOffline();
|
||||
|
||||
/**
|
||||
* 插入或更新(根据collect_id)
|
||||
*/
|
||||
@Insert("INSERT INTO device_collect_heartbeat (" +
|
||||
"collect_id, collect_name, device_ip, app_version, last_heartbeat, " +
|
||||
"heartbeat_count, status, fail_count, update_time " +
|
||||
") VALUES (" +
|
||||
"#{collectId}, #{collectName}, #{deviceIp}, #{appVersion}, #{lastHeartbeat}, " +
|
||||
"#{heartbeatCount}, #{status}, #{failCount}, #{updateTime} " +
|
||||
") ON CONFLICT (collect_id) DO UPDATE SET " +
|
||||
"collect_name = EXCLUDED.collect_name, " +
|
||||
"device_ip = EXCLUDED.device_ip, " +
|
||||
"app_version = EXCLUDED.app_version, " +
|
||||
"last_heartbeat = EXCLUDED.last_heartbeat, " +
|
||||
"heartbeat_count = EXCLUDED.heartbeat_count, " +
|
||||
"status = EXCLUDED.status, " +
|
||||
"fail_count = EXCLUDED.fail_count, " +
|
||||
"update_time = EXCLUDED.update_time")
|
||||
int upsert(DeviceCollectHeartbeat heartbeat);
|
||||
|
||||
/**
|
||||
* 更新探针状态
|
||||
*/
|
||||
@Update("UPDATE device_collect_heartbeat SET " +
|
||||
"status = #{status}, fail_count = #{failCount}, update_time = #{updateTime} " +
|
||||
"WHERE collect_id = #{collectId}")
|
||||
int updateStatus(@Param("collectId") String collectId,
|
||||
@Param("status") String status,
|
||||
@Param("failCount") Integer failCount,
|
||||
@Param("updateTime") java.time.LocalDateTime updateTime);
|
||||
|
||||
/**
|
||||
* 查询超过指定时间未心跳的探针(用于检测离线)
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_heartbeat " +
|
||||
"WHERE status = 'online' AND last_heartbeat < #{thresholdTime} " +
|
||||
"ORDER BY last_heartbeat ASC")
|
||||
List<DeviceCollectHeartbeat> selectOfflineCandidates(@Param("thresholdTime") java.time.LocalDateTime thresholdTime);
|
||||
|
||||
/**
|
||||
* 删除指定日期之前的记录
|
||||
*/
|
||||
@Delete("DELETE FROM device_collect_heartbeat WHERE update_time < #{beforeTime}")
|
||||
int deleteBeforeTime(@Param("beforeTime") java.time.LocalDateTime beforeTime);
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceCollectTask;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceCollectTaskMapper extends BaseMapper<DeviceCollectTask>{
|
||||
|
||||
/**
|
||||
* 根据ID查询采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE id = #{id}")
|
||||
DeviceCollectTask selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task")
|
||||
List<DeviceCollectTask> selectAll();
|
||||
|
||||
/**
|
||||
* 根据设备ID查询采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE device_id = #{deviceId}")
|
||||
List<DeviceCollectTask> selectByDeviceId(Integer deviceId);
|
||||
|
||||
/**
|
||||
* 根据方法类型查询采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE method = #{method}")
|
||||
List<DeviceCollectTask> selectByMethod(Integer method);
|
||||
|
||||
/**
|
||||
* 根据任务名称模糊查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE task_name LIKE CONCAT('%', #{taskName}, '%')")
|
||||
List<DeviceCollectTask> selectByTaskNameLike(String taskName);
|
||||
|
||||
/**
|
||||
* 查询成功的采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE last_success_time IS NOT NULL")
|
||||
List<DeviceCollectTask> selectSuccessTasks();
|
||||
|
||||
/**
|
||||
* 查询失败的采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE last_failed_time IS NOT NULL")
|
||||
List<DeviceCollectTask> selectFailedTasks();
|
||||
|
||||
/**
|
||||
* 多条件组合查询
|
||||
*/
|
||||
List<DeviceCollectTask> selectByCondition(DeviceCollectTask condition);
|
||||
|
||||
/**
|
||||
* 插入采集任务
|
||||
*/
|
||||
@Insert("INSERT INTO device_collect_task (created_at, updated_at, device_id, method, task_name, " +
|
||||
"first_time, last_success_time, last_failed_time, detail_id, epm, epm_peak, " +
|
||||
"process_architecture, task_count, recent_discover_time, epm_upper_limit) " +
|
||||
"VALUES (NOW(), NOW(), #{deviceId}, #{method}, #{taskName}, #{firstTime}, " +
|
||||
"#{lastSuccessTime}, #{lastFailedTime}, #{detailId}, #{epm}, #{epmPeak}, " +
|
||||
"#{processArchitecture}, #{taskCount}, #{recentDiscoverTime}, #{epmUpperLimit})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceCollectTask task);
|
||||
|
||||
/**
|
||||
* 更新采集任务
|
||||
*/
|
||||
@Update("UPDATE device_collect_task SET " +
|
||||
"updated_at = NOW(), " +
|
||||
"device_id = #{deviceId}, " +
|
||||
"method = #{method}, " +
|
||||
"task_name = #{taskName}, " +
|
||||
"first_time = #{firstTime}, " +
|
||||
"last_success_time = #{lastSuccessTime}, " +
|
||||
"last_failed_time = #{lastFailedTime}, " +
|
||||
"detail_id = #{detailId}, " +
|
||||
"epm = #{epm}, " +
|
||||
"epm_peak = #{epmPeak}, " +
|
||||
"process_architecture = #{processArchitecture}, " +
|
||||
"task_count = #{taskCount}, " +
|
||||
"recent_discover_time = #{recentDiscoverTime}, " +
|
||||
"epm_upper_limit = #{epmUpperLimit} " +
|
||||
"WHERE id = #{id}")
|
||||
int update(DeviceCollectTask task);
|
||||
|
||||
/**
|
||||
* 删除采集任务
|
||||
*/
|
||||
@Delete("DELETE FROM device_collect_task WHERE id = #{id}")
|
||||
int deleteById(Integer id);
|
||||
|
||||
/**
|
||||
* 根据设备ID删除采集任务
|
||||
*/
|
||||
@Delete("DELETE FROM device_collect_task WHERE device_id = #{deviceId}")
|
||||
int deleteByDeviceId(Integer deviceId);
|
||||
|
||||
/**
|
||||
* 更新任务成功状态
|
||||
*/
|
||||
@Update("UPDATE device_collect_task SET " +
|
||||
"last_success_time = NOW(), " +
|
||||
"updated_at = NOW(), " +
|
||||
"task_count = COALESCE(task_count, 0) + 1 " +
|
||||
"WHERE id = #{id}")
|
||||
int updateSuccessStatus(Integer id);
|
||||
|
||||
/**
|
||||
* 更新任务失败状态
|
||||
*/
|
||||
@Update("UPDATE device_collect_task SET " +
|
||||
"last_failed_time = NOW(), " +
|
||||
"updated_at = NOW() " +
|
||||
"WHERE id = #{id}")
|
||||
int updateFailedStatus(Integer id);
|
||||
|
||||
/**
|
||||
* 更新EPM指标
|
||||
*/
|
||||
@Update("UPDATE device_collect_task SET " +
|
||||
"epm = #{epm}, " +
|
||||
"epm_peak = GREATEST(COALESCE(epm_peak, 0), #{epm}), " +
|
||||
"updated_at = NOW() " +
|
||||
"WHERE id = #{id}")
|
||||
int updateEpm(@Param("id") Integer id, @Param("epm") Integer epm);
|
||||
|
||||
/**
|
||||
* 统计设备采集任务数量
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM device_collect_task WHERE device_id = #{deviceId}")
|
||||
int countByDeviceId(Integer deviceId);
|
||||
|
||||
/**
|
||||
* 获取设备的最新采集任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task WHERE device_id = #{deviceId} ORDER BY updated_at DESC LIMIT 1")
|
||||
DeviceCollectTask selectLatestByDeviceId(Integer deviceId);
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新设备采集任务的时间
|
||||
*/
|
||||
@Update("<script>" +
|
||||
"<foreach collection='tasks' item='task' separator=';'>" +
|
||||
"UPDATE device_collect_task SET " +
|
||||
" first_time = CASE " +
|
||||
" WHEN first_time IS NULL AND #{task.firstTime}::TIMESTAMP IS NOT NULL THEN #{task.firstTime}::TIMESTAMP " +
|
||||
" ELSE first_time " +
|
||||
" END, " +
|
||||
" last_success_time = #{task.lastSuccessTime}::TIMESTAMP, " +
|
||||
" last_failed_time = #{task.lastFailedTime}::TIMESTAMP, " +
|
||||
" updated_at = #{task.updatedAt}::TIMESTAMP " +
|
||||
"WHERE id = #{task.id}" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int batchUpdateTimes(@Param("tasks") List<DeviceCollectTask> tasks);
|
||||
|
||||
/**
|
||||
* 更新单个任务的时间
|
||||
*/
|
||||
@Update("UPDATE device_collect_task " +
|
||||
"SET first_time = CASE " +
|
||||
" WHEN first_time IS NULL AND #{firstTime}::TIMESTAMP IS NOT NULL THEN #{firstTime}::TIMESTAMP " +
|
||||
" ELSE first_time " +
|
||||
" END, " +
|
||||
" last_success_time = #{lastSuccessTime}::TIMESTAMP, " +
|
||||
" last_failed_time = #{lastFailTime}::TIMESTAMP, " +
|
||||
" updated_at = #{updateTime}::TIMESTAMP " +
|
||||
"WHERE id = #{deviceCollectId}")
|
||||
int updateTaskTime(@Param("deviceCollectId") String deviceCollectId,
|
||||
@Param("firstTime") LocalDateTime firstTime,
|
||||
@Param("lastSuccessTime") LocalDateTime lastSuccessTime,
|
||||
@Param("lastFailTime") LocalDateTime lastFailTime,
|
||||
@Param("updateTime") LocalDateTime updateTime);
|
||||
|
||||
/**
|
||||
* 查询所有设备任务
|
||||
*/
|
||||
@Select("SELECT * FROM device_collect_task")
|
||||
List<DeviceCollectTask> selectAllTasks();
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.DeviceDevice;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceDeviceMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询设备
|
||||
*/
|
||||
DeviceDevice selectById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询所有设备
|
||||
*/
|
||||
List<DeviceDevice> selectAll();
|
||||
|
||||
/**
|
||||
* 根据IP地址查询设备
|
||||
*/
|
||||
List<DeviceDevice> selectByIp(String ip);
|
||||
|
||||
/**
|
||||
* 根据设备名称模糊查询
|
||||
*/
|
||||
List<DeviceDevice> selectByNameLike(String name);
|
||||
|
||||
/**
|
||||
* 根据设备组查询
|
||||
*/
|
||||
List<DeviceDevice> selectByDeviceGroup(Integer deviceGroup);
|
||||
|
||||
/**
|
||||
* 根据设备类型查询
|
||||
*/
|
||||
List<DeviceDevice> selectByDeviceType(Integer deviceType);
|
||||
|
||||
/**
|
||||
* 根据组织ID查询
|
||||
*/
|
||||
List<DeviceDevice> selectByOrganizationId(Integer organizationId);
|
||||
|
||||
/**
|
||||
* 根据状态查询设备
|
||||
*/
|
||||
List<DeviceDevice> selectByStatus(Short status);
|
||||
|
||||
/**
|
||||
* 多条件组合查询
|
||||
*/
|
||||
List<DeviceDevice> selectByCondition(DeviceDevice condition);
|
||||
|
||||
/**
|
||||
* 动态条件查询
|
||||
*/
|
||||
List<DeviceDevice> selectByMap(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
List<DeviceDevice> selectByPage(@Param("offset") int offset, @Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 统计设备数量
|
||||
*/
|
||||
Long count();
|
||||
|
||||
/**
|
||||
* 根据条件统计数量
|
||||
*/
|
||||
Long countByCondition(DeviceDevice condition);
|
||||
|
||||
/**
|
||||
* 查询监控中的设备
|
||||
*/
|
||||
List<DeviceDevice> selectMonitoringDevices();
|
||||
|
||||
/**
|
||||
* 查询未删除的设备(del_flag = '0')
|
||||
*/
|
||||
List<DeviceDevice> selectActiveDevices();
|
||||
|
||||
/**
|
||||
* 根据厂商查询设备
|
||||
*/
|
||||
List<DeviceDevice> selectByVendor(String vendor);
|
||||
}
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.Modules.etl.handler.ArrayIntegerTypeHandler;
|
||||
import com.Modules.etl.handler.ArrayStringTypeHandler;
|
||||
import com.common.entity.DeviceInterlockingCmd;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceInterlockingCmdMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_cmd WHERE id = #{id}")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
DeviceInterlockingCmd selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询待执行的指令
|
||||
* @param probeId 探针ID
|
||||
* @return 待执行指令列表
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_cmd WHERE probe_id = #{probeId} AND cmd_status = '0' ORDER BY create_time ASC")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
List<DeviceInterlockingCmd> selectPendingCommands(@Param("probeId") Long probeId);
|
||||
|
||||
/**
|
||||
* 根据探针ID和状态查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_cmd WHERE probe_id = #{probeId} AND cmd_status = #{cmdStatus}")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
List<DeviceInterlockingCmd> selectByProbeIdAndStatus(@Param("probeId") Long probeId, @Param("cmdStatus") String cmdStatus);
|
||||
|
||||
/**
|
||||
* 插入指令
|
||||
*/
|
||||
@Insert("INSERT INTO device_interlocking_cmd (probe_id, probe_ip, device_interlocking_id, device_interlocking_ip, " +
|
||||
"ban_ips, ban_method, ban_type, cmd_status, ban_duration, create_time, update_time, " +
|
||||
"tenant_id, create_dept, create_by, remark, ban_operation_type) " +
|
||||
"VALUES (#{probeId}, #{probeIp}, ARRAY[:ids], ARRAY[:ips], ARRAY[:banIps], " +
|
||||
"#{banMethod}, #{banType}, #{cmdStatus}, #{banDuration}, NOW(), NOW(), " +
|
||||
"#{tenantId}, #{createDept}, #{createBy}, #{remark}, #{banOperationType})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceInterlockingCmd cmd);
|
||||
|
||||
/**
|
||||
* 更新指令状态
|
||||
* @param id 指令ID
|
||||
* @param cmdStatus 新状态
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE device_interlocking_cmd SET cmd_status = #{cmdStatus}, update_time = NOW() WHERE id = #{id}")
|
||||
int updateStatus(@Param("id") Long id, @Param("cmdStatus") String cmdStatus);
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行中
|
||||
*/
|
||||
@Update("UPDATE device_interlocking_cmd SET cmd_status = '2', update_time = NOW() WHERE id = #{id}")
|
||||
int updateStatusToExecuting(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行完成
|
||||
*/
|
||||
@Update("UPDATE device_interlocking_cmd SET cmd_status = '1', update_time = NOW() WHERE id = #{id}")
|
||||
int updateStatusToCompleted(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 更新指令状态为执行失败
|
||||
*/
|
||||
@Update("UPDATE device_interlocking_cmd SET cmd_status = '3', update_time = NOW() WHERE id = #{id}")
|
||||
int updateStatusToFailed(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据多个ID查询
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT * FROM device_interlocking_cmd WHERE id IN " +
|
||||
"<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
|
||||
"#{id}" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
List<DeviceInterlockingCmd> selectByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 查询所有指令
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_cmd ORDER BY create_time DESC")
|
||||
@Results({
|
||||
@Result(column = "device_interlocking_id", property = "deviceInterlockingId",
|
||||
typeHandler = ArrayIntegerTypeHandler.class),
|
||||
@Result(column = "device_interlocking_ip", property = "deviceInterlockingIp",
|
||||
typeHandler = ArrayStringTypeHandler.class),
|
||||
@Result(column = "ban_ips", property = "banIps",
|
||||
typeHandler = ArrayStringTypeHandler.class)
|
||||
})
|
||||
List<DeviceInterlockingCmd> selectAll();
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceInterlockingLog;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceInterlockingLogMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_log WHERE id = #{id}")
|
||||
DeviceInterlockingLog selectById(Long id);
|
||||
|
||||
/**
|
||||
* 根据指令ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_log WHERE device_interlocking_cmd_id = #{cmdId}")
|
||||
List<DeviceInterlockingLog> selectByCmdId(@Param("cmdId") Long cmdId);
|
||||
|
||||
/**
|
||||
* 插入记录
|
||||
*/
|
||||
@Insert("INSERT INTO device_interlocking_log (device_interlocking_cmd_id, device_interlocking_id, ban_ip, " +
|
||||
"device_name, ban_time, ban_method, ban_result, tenant_id, create_dept, create_by, " +
|
||||
"create_time, remark, resp_body, req_body) " +
|
||||
"VALUES (#{deviceInterlockingCmdId}, #{deviceInterlockingId}, #{banIp}, #{deviceName}, " +
|
||||
"#{banTime}, #{banMethod}, #{banResult}, #{tenantId}, #{createDept}, #{createBy}, " +
|
||||
"NOW(), #{remark}, #{respBody}, #{reqBody})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceInterlockingLog log);
|
||||
|
||||
/**
|
||||
* 批量插入记录
|
||||
*/
|
||||
@Insert("<script>" +
|
||||
"INSERT INTO device_interlocking_log (device_interlocking_cmd_id, device_interlocking_id, ban_ip, " +
|
||||
"device_name, ban_time, ban_method, ban_result, tenant_id, create_dept, create_by, " +
|
||||
"create_time, remark, resp_body, req_body) VALUES " +
|
||||
"<foreach collection='logs' item='item' separator=','>" +
|
||||
"(#{item.deviceInterlockingCmdId}, #{item.deviceInterlockingId}, #{item.banIp}, " +
|
||||
"#{item.deviceName}, #{item.banTime}, #{item.banMethod}, #{item.banResult}, " +
|
||||
"#{item.tenantId}, #{item.createDept}, #{item.createBy}, NOW(), " +
|
||||
"#{item.remark}, #{item.respBody}, #{item.reqBody})" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int batchInsert(@Param("logs") List<DeviceInterlockingLog> logs);
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking_log ORDER BY create_time DESC")
|
||||
List<DeviceInterlockingLog> selectAll();
|
||||
|
||||
/**
|
||||
* 统计某指令的成功/失败数量
|
||||
*/
|
||||
@Select("SELECT ban_result, COUNT(*) as count FROM device_interlocking_log " +
|
||||
"WHERE device_interlocking_cmd_id = #{cmdId} GROUP BY ban_result")
|
||||
List<java.util.Map<String, Object>> countByCmdId(@Param("cmdId") Long cmdId);
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.DeviceInterlocking;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceInterlockingMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking WHERE id = #{id}")
|
||||
DeviceInterlocking selectById(Long id);
|
||||
|
||||
/**
|
||||
* 根据部门ID查询联动设备
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking WHERE dept_id = #{deptId}")
|
||||
List<DeviceInterlocking> selectByDeptId(@Param("deptId") String deptId);
|
||||
|
||||
/**
|
||||
* 根据厂商查询
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking WHERE vendor = #{vendor}")
|
||||
List<DeviceInterlocking> selectByVendor(@Param("vendor") String vendor);
|
||||
|
||||
/**
|
||||
* 插入记录
|
||||
*/
|
||||
@Insert("INSERT INTO device_interlocking (device_name, vendor, dept_id, ban_limit, ip, api_url, " +
|
||||
"tenant_id, create_dept, create_by, create_time, update_time, remark, auth_username, auth_password) " +
|
||||
"VALUES (#{deviceName}, #{vendor}, #{deptId}, #{banLimit}, #{ip}, #{apiUrl}, " +
|
||||
"#{tenantId}, #{createDept}, #{createBy}, NOW(), NOW(), #{remark}, #{authUsername}, #{authPassword})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DeviceInterlocking device);
|
||||
|
||||
/**
|
||||
* 更新记录
|
||||
*/
|
||||
@Update("UPDATE device_interlocking SET device_name = #{deviceName}, vendor = #{vendor}, " +
|
||||
"dept_id = #{deptId}, ban_limit = #{banLimit}, ip = #{ip}, api_url = #{apiUrl}, " +
|
||||
"update_time = NOW(), remark = #{remark}, auth_username = #{authUsername}, " +
|
||||
"auth_password = #{authPassword} WHERE id = #{id}")
|
||||
int update(DeviceInterlocking device);
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*/
|
||||
@Select("SELECT * FROM device_interlocking ORDER BY create_time DESC")
|
||||
List<DeviceInterlocking> selectAll();
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.DeviceCollectTaskTime;
|
||||
import com.common.entity.DeviceReceiveLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@Mapper
|
||||
public interface DeviceReceiveLogMapper {
|
||||
|
||||
/**
|
||||
* 插入单条记录
|
||||
*/
|
||||
int insert(DeviceReceiveLog log);
|
||||
|
||||
/**
|
||||
* 批量插入记录
|
||||
*/
|
||||
int batchInsert(@Param("list") List<DeviceReceiveLog> logs);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*/
|
||||
DeviceReceiveLog selectById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据设备ID查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByDeviceId(@Param("deviceId") Integer deviceId);
|
||||
|
||||
/**
|
||||
* 根据采集探针ID查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByCollectId(@Param("collectId") Integer collectId);
|
||||
|
||||
/**
|
||||
* 根据IP地址查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByDeviceIp(@Param("deviceIp") String deviceIp);
|
||||
|
||||
/**
|
||||
* 根据时间范围查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByTimeRange(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 多条件组合查询
|
||||
*/
|
||||
List<DeviceReceiveLog> selectByCondition(DeviceReceiveLog condition);
|
||||
|
||||
/**
|
||||
* 统计设备接收日志数量
|
||||
*/
|
||||
Long countByCondition(DeviceReceiveLog condition);
|
||||
|
||||
/**
|
||||
* 根据时间范围删除旧数据
|
||||
*/
|
||||
int deleteByTimeRange(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 获取最近N条记录
|
||||
*/
|
||||
List<DeviceReceiveLog> selectRecent(@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 按设备分组统计日志数量
|
||||
*/
|
||||
List<Map<String, Object>> countByDeviceGroup();
|
||||
|
||||
|
||||
/**
|
||||
* 查询当天每个设备的最新成功时间
|
||||
*/
|
||||
@Select("SELECT device_collect_id, MAX(created_at) AS last_success_time " +
|
||||
"FROM device_receive_log " +
|
||||
"WHERE push_success = true " +
|
||||
"AND created_at >= CURRENT_DATE " +
|
||||
"GROUP BY device_collect_id")
|
||||
List<DeviceCollectTaskTime> selectDailySuccessTimes();
|
||||
|
||||
/**
|
||||
* 查询当天每个设备的最新失败时间
|
||||
*/
|
||||
@Select("SELECT device_collect_id, MAX(created_at) AS last_fail_time " +
|
||||
"FROM device_receive_log " +
|
||||
"WHERE push_success = false " +
|
||||
"AND created_at >= CURRENT_DATE " +
|
||||
"GROUP BY device_collect_id")
|
||||
List<DeviceCollectTaskTime> selectDailyFailTimes();
|
||||
|
||||
/**
|
||||
* 查询每个设备的首次成功时间(历史最早)
|
||||
*/
|
||||
@Select("SELECT device_collect_id, MIN(created_at) AS first_success_time " +
|
||||
"FROM device_receive_log " +
|
||||
"WHERE push_success = true " +
|
||||
"GROUP BY device_collect_id")
|
||||
List<DeviceCollectTaskTime> selectFirstSuccessTimes();
|
||||
|
||||
/**
|
||||
* 查询指定时间范围内的成功记录
|
||||
*/
|
||||
@Select("SELECT device_collect_id, MIN(created_at) AS first_time, " +
|
||||
"MAX(created_at) AS last_success_time " +
|
||||
"FROM device_receive_log " +
|
||||
"WHERE push_success = true " +
|
||||
"AND created_at >= #{startTime} " +
|
||||
"AND created_at < #{endTime} " +
|
||||
"GROUP BY device_collect_id")
|
||||
List<DeviceCollectTaskTime> selectSuccessTimesByRange(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.DmColumn;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface DmColumnMapper {
|
||||
|
||||
// 查询所有列
|
||||
@Select("SELECT * FROM dm_column WHERE deleted_at IS NULL")
|
||||
List<DmColumn> findAll();
|
||||
|
||||
// 根据ID查询
|
||||
// @Select("SELECT * FROM dm_column WHERE id = #{id} AND deleted_at IS NULL")
|
||||
DmColumn findById(Long id);
|
||||
|
||||
// 根据名称查询
|
||||
@Select("SELECT * FROM dm_column WHERE name = #{name} AND deleted_at IS NULL")
|
||||
DmColumn findByName(String name);
|
||||
|
||||
// 根据显示名称模糊查询
|
||||
@Select("SELECT * FROM dm_column WHERE display_name LIKE CONCAT('%', #{displayName}, '%') AND deleted_at IS NULL")
|
||||
List<DmColumn> findByDisplayName(String displayName);
|
||||
|
||||
// 根据是否内置查询
|
||||
@Select("SELECT * FROM dm_column WHERE is_built_in = #{isBuiltIn} AND deleted_at IS NULL")
|
||||
List<DmColumn> findByIsBuiltIn(Boolean isBuiltIn);
|
||||
|
||||
// 插入数据
|
||||
@Insert("INSERT INTO dm_column (created_at, updated_at, name, display_name, storage_data_type, " +
|
||||
"business_data_type, is_built_in, is_hidden, is_not_normalizable, is_required, category_id, " +
|
||||
"custom_asset_category_id, is_virtual, table_id, asset_table_id, column_set_id, base_type, " +
|
||||
"user_task_id, created_by_id, create_dept, create_by, create_time, update_by, update_time) " +
|
||||
"VALUES (NOW(), NOW(), #{name}, #{displayName}, #{storageDataType}, #{businessDataType}, " +
|
||||
"#{isBuiltIn}, #{isHidden}, #{isNotNormalizable}, #{isRequired}, #{categoryId}, " +
|
||||
"#{customAssetCategoryId}, #{isVirtual}, #{tableId}, #{assetTableId}, #{columnSetId}, " +
|
||||
"#{baseType}, #{userTaskId}, #{createdById}, #{createDept}, #{createBy}, #{createTime}, " +
|
||||
"#{updateBy}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(DmColumn dmColumn);
|
||||
|
||||
// 批量插入
|
||||
@Insert("<script>" +
|
||||
"INSERT INTO dm_column (created_at, updated_at, name, display_name, is_built_in, is_hidden) " +
|
||||
"VALUES " +
|
||||
"<foreach collection='list' item='item' separator=','>" +
|
||||
"(NOW(), NOW(), #{item.name}, #{item.displayName}, #{item.isBuiltIn}, #{item.isHidden})" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int batchInsert(List<DmColumn> dmColumns);
|
||||
|
||||
// 查询条件构造(使用XML方式)
|
||||
List<DmColumn> findByCondition(DmColumn condition);
|
||||
|
||||
// 统计数量
|
||||
@Select("SELECT COUNT(*) FROM dm_column WHERE deleted_at IS NULL")
|
||||
Long count();
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有数据标准化字段
|
||||
* @param
|
||||
* @return 数据标准化字段
|
||||
*/
|
||||
List<Map<String, Object>> selectAllNormal();
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.common.mapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.common.entity.DmNormalizeRule;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface DmNormalizeRuleMapper {
|
||||
|
||||
/**
|
||||
* 根据ID查询数据标准化规则
|
||||
* @param id 主键ID
|
||||
* @return 数据标准化规则对象
|
||||
*/
|
||||
DmNormalizeRule selectById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据Device ID查询数据标准化规则
|
||||
* @param id 主键device ID
|
||||
* @return 数据标准化规则对象
|
||||
*/
|
||||
List<Map<String, Object>> selectByDeviceId(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据ID更新数据标准化规则
|
||||
* @param rule 数据标准化规则对象
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateById(DmNormalizeRule rule);
|
||||
|
||||
/**
|
||||
* 根据ID和租户ID查询(带租户隔离)
|
||||
* @param id 主键ID
|
||||
* @param tenantId 租户ID
|
||||
* @return 数据标准化规则对象
|
||||
*/
|
||||
DmNormalizeRule selectByIdAndTenant(@Param("id") Long id, @Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 根据ID和租户ID更新(带租户隔离)
|
||||
* @param rule 数据标准化规则对象
|
||||
* @return 更新影响的行数
|
||||
*/
|
||||
int updateByIdAndTenant(DmNormalizeRule rule);
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.common.entity.RuleHitTimeDTO;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface NormalizeRuleStatsMapper {
|
||||
|
||||
@Select("SELECT normalize_rule_id AS normalizeRuleId, " +
|
||||
" MAX(log_time) AS maxLogTime " +
|
||||
"FROM syslog_normal_data " +
|
||||
"WHERE created_at >= #{startDate} " +
|
||||
"GROUP BY normalize_rule_id")
|
||||
List<RuleHitTimeDTO> selectMaxHitTimeFromNormalData(
|
||||
@Param("startDate") LocalDateTime startDate
|
||||
);
|
||||
|
||||
@Select("SELECT normalize_rule_id AS normalizeRuleId, " +
|
||||
" MAX(log_time) AS maxLogTime " +
|
||||
"FROM syslog_normal_alarm " +
|
||||
"WHERE created_at >= #{startDate} " +
|
||||
"GROUP BY normalize_rule_id")
|
||||
List<RuleHitTimeDTO> selectMaxHitTimeFromNormalAlarm(
|
||||
@Param("startDate") LocalDateTime startDate
|
||||
);
|
||||
|
||||
@Select("SELECT id FROM dm_normalize_rule " +
|
||||
"WHERE del_flag = '0' " +
|
||||
"ORDER BY id")
|
||||
List<Long> selectActiveRuleIds();
|
||||
|
||||
@Update("UPDATE dm_normalize_rule " +
|
||||
"SET updated_at = NOW(), " +
|
||||
" first_data_saved_at = #{hitTime} " +
|
||||
"WHERE id = #{ruleId} " +
|
||||
" AND (first_data_saved_at IS NULL OR first_data_saved_at < #{hitTime})")
|
||||
int updateRuleHitTime(
|
||||
@Param("ruleId") Long ruleId,
|
||||
@Param("hitTime") LocalDateTime hitTime
|
||||
);
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// SecExceptionAlgorithmMapper.java
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.SecExceptionAlgorithm;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SecExceptionAlgorithmMapper {
|
||||
|
||||
@Select("SELECT * FROM sec_exception_algorithm WHERE status = 1 AND del_flag = '0'")
|
||||
List<SecExceptionAlgorithm> findEnabledAlgorithms();
|
||||
|
||||
@Select("SELECT * FROM sec_exception_algorithm WHERE id = #{id}")
|
||||
SecExceptionAlgorithm findById(@Param("id") Long id);
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package com.common.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.common.entity.SyslogNonNormalMessage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 非标日志Mapper接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface SyslogNonNormalMessageMapper extends BaseMapper<SyslogNonNormalMessage> {
|
||||
|
||||
/**
|
||||
* 批量插入非标日志
|
||||
* @param list 日志列表
|
||||
* @return 插入数量
|
||||
*/
|
||||
int batchInsert(@Param("list") List<SyslogNonNormalMessage> list);
|
||||
|
||||
/**
|
||||
* 根据时间段查询非标日志
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 日志列表
|
||||
*/
|
||||
@Select("SELECT * FROM syslog_non_normal_message WHERE log_time BETWEEN #{startTime} AND #{endTime} AND del_flag = '0'")
|
||||
List<SyslogNonNormalMessage> findByTimeRange(@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 根据设备ID和状态统计
|
||||
* @param deviceId 设备ID
|
||||
* @param ruleResult 规则结果
|
||||
* @return 统计结果
|
||||
*/
|
||||
@Select("SELECT COUNT(*) as count FROM syslog_non_normal_message " +
|
||||
"WHERE device_id = #{deviceId} AND rule_result = #{ruleResult} AND del_flag = '0'")
|
||||
Map<String, Object> countByDeviceAndResult(@Param("deviceId") Integer deviceId,
|
||||
@Param("ruleResult") String ruleResult);
|
||||
|
||||
/**
|
||||
* 逻辑删除非标日志
|
||||
* @param id 日志ID
|
||||
* @return 更新数量
|
||||
*/
|
||||
@Select("UPDATE syslog_non_normal_message SET del_flag = '1', update_time = NOW() WHERE id = #{id}")
|
||||
int logicalDelete(@Param("id") String id);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID和创建时间批量查询非标日志
|
||||
* @param ids ID列表
|
||||
* @param createdAts 创建时间列表
|
||||
* @return 非标日志列表
|
||||
*/
|
||||
List<SyslogNonNormalMessage> getMessagesByIdsAndCreatedAts(
|
||||
@Param("ids") List<String> ids,
|
||||
@Param("createdAts") List<String> createdAts);
|
||||
|
||||
/**
|
||||
* 根据ID列表批量查询非标日志
|
||||
* @param ids ID列表
|
||||
* @return 非标日志列表
|
||||
*/
|
||||
List<SyslogNonNormalMessage> getMessagesByIds(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* 批量更新del_flag字段
|
||||
* @param messages 需要更新的非标日志列表
|
||||
* @return 更新记录数
|
||||
*/
|
||||
int updateBatchDelFlag(@Param("messages") List<SyslogNonNormalMessage> messages);
|
||||
|
||||
/**
|
||||
* 批量更新记录
|
||||
* @param messages 需要更新的非标日志列表
|
||||
* @return 更新记录数
|
||||
*/
|
||||
int updateBatch(@Param("messages") List<SyslogNonNormalMessage> messages);
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.GroupedSyslogData;
|
||||
import com.common.entity.SyslogNormalData;
|
||||
import com.common.entity.SyslogNormalAlarm;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface SyslogNormalAlarmMapper {
|
||||
|
||||
/**
|
||||
* 动态插入数据 - 使用 Map
|
||||
*/
|
||||
int insertDynamic(@Param("dataMap") Map<String, Object> dataMap);
|
||||
|
||||
/**
|
||||
* 动态插入数据 - 使用实体类
|
||||
*/
|
||||
int insertByEntity(SyslogNormalAlarm entity);
|
||||
|
||||
/**
|
||||
* 批量插入数据
|
||||
*/
|
||||
int batchInsert(@Param("dataList") List<Map<String, Object>> dataList);
|
||||
|
||||
|
||||
/**
|
||||
* 统计24小时内分组数据量
|
||||
*/
|
||||
@Select("SELECT count(1) as group_count from ( select " +
|
||||
"to_char(log_time, 'YYYYMMDD') || '_' || " +
|
||||
"dest_ip || '_' || " +
|
||||
"origin_event_name " +
|
||||
"FROM syslog_normal_alarm " +
|
||||
"WHERE log_time >= #{startTime} AND log_time < #{endTime} " +
|
||||
"AND event_level >= 1 AND src_ip NOT IN ('127.0.0.1', '127.0.0.2') " +
|
||||
"GROUP BY to_char(log_time, 'YYYYMMDD'),src_ip, dest_ip, origin_event_name )" )
|
||||
Long count24HoursGroupedData(@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 分页查询分组数据
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"to_char(log_time, 'YYYYMMDD') as log_date, " +
|
||||
"ARRAY_AGG(DISTINCT host(src_ip)::text) as attack_ips, " +
|
||||
"origin_event_name, " +
|
||||
"MAX(attack_result) as attack_result, " +
|
||||
"MIN(log_time) as min_log_time, " +
|
||||
"MAX(log_time) as max_log_time, " +
|
||||
"COUNT(1) as log_count, " +
|
||||
"ARRAY_AGG(DISTINCT host(dest_ip)::text) as victim_ips, " +
|
||||
"ARRAY_AGG(DISTINCT http_url) as victim_web_urls, " +
|
||||
"ARRAY_AGG(DISTINCT device_id) as device_ids, " +
|
||||
"ARRAY_AGG(DISTINCT id) as origin_log_ids, " +
|
||||
"MAX(event_level) as max_event_level, " +
|
||||
"MIN(origin_event_type) AS first_event_type, " +
|
||||
"MAX(origin_event_type) as event_type, " +
|
||||
"MIN(event_type) as min_event_type, " +
|
||||
"ARRAY_AGG(DISTINCT src_port::int4) as attack_ports, " +
|
||||
"ARRAY_AGG(DISTINCT dest_port::int4) as victim_ports, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_codes::text) as http_status_codes, " +
|
||||
"ARRAY_AGG(DISTINCT payload::BYTEA) as payload_samples, " +
|
||||
"ARRAY_AGG(DISTINCT http_req_header) as httpReqHeaders, " +
|
||||
"ARRAY_AGG(DISTINCT http_req_body) as httpReqBodys, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_header) as httpRespHeaders, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_body) as httpRespBodys, " +
|
||||
"MODE() WITHIN GROUP (ORDER BY dest_domain) as dns_info, " +
|
||||
"STRING_AGG(DISTINCT COALESCE(host(dest_ip)::text, ''), ',') as victim_ips_str " +
|
||||
"FROM syslog_normal_alarm " +
|
||||
"WHERE log_time >= #{startTime} AND log_time < #{endTime} " +
|
||||
"AND event_level >= 1 AND src_ip NOT IN ('127.0.0.1', '127.0.0.2') " +
|
||||
"GROUP BY to_char(log_time, 'YYYYMMDD'), src_ip, dest_ip, origin_event_name " +
|
||||
"ORDER BY log_date, dest_ip, origin_event_name " +
|
||||
"LIMIT #{pageSize} OFFSET #{offset}")
|
||||
List<GroupedSyslogData> select24HoursGroupedDataByPage(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.GroupedSyslogData;
|
||||
import com.common.entity.SyslogNormalData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import java.util.Map;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@Mapper
|
||||
public interface SyslogNormalDataMapper {
|
||||
|
||||
/**
|
||||
* 动态插入数据 - 使用 Map
|
||||
*/
|
||||
int insertDynamic(@Param("dataMap") Map<String, Object> dataMap);
|
||||
|
||||
/**
|
||||
* 动态插入数据 - 使用实体类
|
||||
*/
|
||||
int insertByEntity(SyslogNormalData entity);
|
||||
|
||||
/**
|
||||
* 批量插入数据
|
||||
*/
|
||||
int batchInsert(@Param("dataList") java.util.List<Map<String, Object>> dataList);
|
||||
|
||||
|
||||
/**
|
||||
* 统计24小时内分组数据量
|
||||
*/
|
||||
@Select("SELECT count(1) as group_count from ( select " +
|
||||
"to_char(log_time, 'YYYYMMDD') || '_' || " +
|
||||
"dest_ip || '_' || " +
|
||||
"origin_event_name " +
|
||||
"FROM syslog_normal_data " +
|
||||
"WHERE log_time >= #{startTime} AND log_time < #{endTime} " +
|
||||
"AND http_resp_codes =200 and origin_event_type <> '' and origin_event_name='访问日志' AND src_ip NOT IN ('127.0.0.1', '127.0.0.2') " +
|
||||
"GROUP BY to_char(log_time, 'YYYYMMDD'),src_ip, dest_ip, origin_event_name )" )
|
||||
Long count24HoursGroupedData(@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime);
|
||||
|
||||
/**
|
||||
* 分页查询分组数据
|
||||
*/
|
||||
@Select("SELECT " +
|
||||
"to_char(log_time, 'YYYYMMDD') as log_date, " +
|
||||
"ARRAY_AGG(DISTINCT host(src_ip)::text) as attack_ips, " +
|
||||
"origin_event_name, " +
|
||||
"MAX(attack_result) as attack_result, " +
|
||||
"MIN(log_time) as min_log_time, " +
|
||||
"MAX(log_time) as max_log_time, " +
|
||||
"COUNT(1) as log_count, " +
|
||||
"ARRAY_AGG(DISTINCT host(dest_ip)::text) as victim_ips, " +
|
||||
"ARRAY_AGG(DISTINCT http_url) as victim_web_urls, " +
|
||||
"ARRAY_AGG(DISTINCT device_id) as device_ids, " +
|
||||
"ARRAY_AGG(DISTINCT id) as origin_log_ids, " +
|
||||
"MAX(event_level) as max_event_level, " +
|
||||
"MIN(origin_event_type) AS first_event_type, " +
|
||||
"MAX(origin_event_type) as event_type, " +
|
||||
"MIN(event_type) as min_event_type, " +
|
||||
"ARRAY_AGG(DISTINCT src_port::int4) as attack_ports, " +
|
||||
"ARRAY_AGG(DISTINCT dest_port::int4) as victim_ports, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_codes::text) as http_status_codes, " +
|
||||
"ARRAY_AGG(DISTINCT payload::BYTEA) as payload_samples, " +
|
||||
"ARRAY_AGG(DISTINCT http_req_header) as httpReqHeaders, " +
|
||||
"ARRAY_AGG(DISTINCT http_req_body) as httpReqBodys, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_header) as httpRespHeaders, " +
|
||||
"ARRAY_AGG(DISTINCT http_resp_body) as httpRespBodys, " +
|
||||
"MODE() WITHIN GROUP (ORDER BY dest_domain) as dns_info, " +
|
||||
"STRING_AGG(DISTINCT COALESCE(host(dest_ip)::text, ''), ',') as victim_ips_str " +
|
||||
"FROM syslog_normal_data " +
|
||||
"WHERE log_time >= #{startTime} AND log_time < #{endTime} " +
|
||||
"AND http_resp_codes =200 and origin_event_type <> '' and origin_event_name='访问日志' AND src_ip NOT IN ('127.0.0.1', '127.0.0.2') " +
|
||||
"GROUP BY to_char(log_time, 'YYYYMMDD'), src_ip, dest_ip, origin_event_name " +
|
||||
"ORDER BY log_date, dest_ip, origin_event_name " +
|
||||
"LIMIT #{pageSize} OFFSET #{offset}")
|
||||
List<GroupedSyslogData> select24HoursGroupedDataByPage(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("endTime") LocalDateTime endTime,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* 查询指定时间后的所需字段(使用XML映射)
|
||||
* 注意:参数类型保持为LocalDateTime,但实际映射时使用类型处理器转换
|
||||
*/
|
||||
List<SyslogNormalData> findRequiredFieldsAfterTime(@Param("startTime") LocalDateTime startTime);
|
||||
|
||||
/**
|
||||
* 分页查询所需字段
|
||||
*/
|
||||
List<SyslogNormalData> findRequiredFieldsByPage(
|
||||
@Param("startTime") LocalDateTime startTime,
|
||||
@Param("limit") int limit,
|
||||
@Param("offset") int offset
|
||||
);
|
||||
@Select("SELECT * FROM syslog_normal_data WHERE created_at >= #{startTime, jdbcType=TIMESTAMP} ORDER BY created_at ASC")
|
||||
List<SyslogNormalData> findAfterTime(@Param("startTime") LocalDateTime startTime);
|
||||
|
||||
@Select("SELECT * FROM syslog_normal_data WHERE id = #{id}")
|
||||
SyslogNormalData findById(@Param("id") String id);
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.WecomNotification;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
/**
|
||||
* 微信通知 Mapper 接口
|
||||
*/
|
||||
@Mapper
|
||||
public interface WecomNotificationMapper {
|
||||
|
||||
/**
|
||||
* 插入单条记录(使用序列生成ID)
|
||||
*/
|
||||
@Insert("INSERT INTO wecom_notification (" +
|
||||
"wecom_notification_id, user_id, wecom_notification_name, wecom_notification_ip, " +
|
||||
"wecom_notification_type, wecom_notification_level, wecom_notification_content, " +
|
||||
"wecom_notification_time, tenant_id, create_dept, create_by, create_time, " +
|
||||
"update_by, update_time, remark, wecom_notification_status" +
|
||||
") VALUES (" +
|
||||
"nextval('seq_wecom_notification'), #{userId}, #{wecomNotificationName}, #{wecomNotificationIp}, " +
|
||||
"#{wecomNotificationType}, #{wecomNotificationLevel}, #{wecomNotificationContent}, " +
|
||||
"#{wecomNotificationTime}, #{tenantId}, #{createDept}, #{createBy}, #{createTime}, " +
|
||||
"#{updateBy}, #{updateTime}, #{remark}, #{wecomNotificationStatus}" +
|
||||
")")
|
||||
@SelectKey(statement = "SELECT currval('seq_wecom_notification')", keyProperty = "wecomNotificationId", resultType = Long.class, before = false)
|
||||
int insert(WecomNotification notification);
|
||||
|
||||
/**
|
||||
* 根据通知ID查询
|
||||
*/
|
||||
@Select("SELECT * FROM wecom_notification WHERE wecom_notification_id = #{wecomNotificationId}")
|
||||
WecomNotification selectById(@Param("wecomNotificationId") Long wecomNotificationId);
|
||||
|
||||
/**
|
||||
* 查询未发送的通知列表
|
||||
*/
|
||||
@Select("SELECT * FROM wecom_notification WHERE wecom_notification_status = '1' ORDER BY create_time DESC")
|
||||
java.util.List<WecomNotification> selectUnsentNotifications();
|
||||
|
||||
/**
|
||||
* 更新通知状态
|
||||
*/
|
||||
@Update("UPDATE wecom_notification SET wecom_notification_status = #{status}, update_time = NOW() " +
|
||||
"WHERE wecom_notification_id = #{wecomNotificationId}")
|
||||
int updateStatus(@Param("wecomNotificationId") Long wecomNotificationId, @Param("status") String status);
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package com.common.mapper;
|
||||
|
||||
import com.common.entity.XdrHoneypot;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* XDR Honeypot Mapper 接口
|
||||
*/
|
||||
public interface XdrHoneypotMapper {
|
||||
|
||||
/**
|
||||
* 插入单条记录
|
||||
*/
|
||||
@Insert("INSERT INTO xdr_honeypot (vcsource, dstart_time, dtime, risk_level, vcconnection, " +
|
||||
"file_info, extra, vctype, agent_sn, agent_name, honeypot_id, honeypot_name, " +
|
||||
"src_ip, src_port, src_mac, dest_ip, dest_port, proxy_ip, node) " +
|
||||
"VALUES (#{vcsource}, #{dstartTime}, #{dtime}, #{riskLevel}, #{vcconnection}, " +
|
||||
"#{fileInfo}, #{extra}, #{vctype}, #{agentSn}, #{agentName}, #{honeypotId}, #{honeypotName}, " +
|
||||
"#{srcIp}, #{srcPort}, #{srcMac}, #{destIp}, #{destPort}, #{proxyIp}, #{node})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(XdrHoneypot xdrHoneypot);
|
||||
|
||||
/**
|
||||
* 批量插入记录
|
||||
*/
|
||||
int batchInsert(List<XdrHoneypot> xdrHoneypotList);
|
||||
|
||||
/**
|
||||
* 根据ID查询记录
|
||||
*/
|
||||
@Select("SELECT * FROM xdr_honeypot WHERE id = #{id}")
|
||||
@Results({
|
||||
@Result(property = "id", column = "id"),
|
||||
@Result(property = "vcsource", column = "vcsource"),
|
||||
@Result(property = "dstartTime", column = "dstart_time"),
|
||||
@Result(property = "dtime", column = "dtime"),
|
||||
@Result(property = "riskLevel", column = "risk_level"),
|
||||
@Result(property = "vcconnection", column = "vcconnection"),
|
||||
@Result(property = "fileInfo", column = "file_info"),
|
||||
@Result(property = "extra", column = "extra"),
|
||||
@Result(property = "vctype", column = "vctype"),
|
||||
@Result(property = "agentSn", column = "agent_sn"),
|
||||
@Result(property = "agentName", column = "agent_name"),
|
||||
@Result(property = "honeypotId", column = "honeypot_id"),
|
||||
@Result(property = "honeypotName", column = "honeypot_name"),
|
||||
@Result(property = "srcIp", column = "src_ip"),
|
||||
@Result(property = "srcPort", column = "src_port"),
|
||||
@Result(property = "srcMac", column = "src_mac"),
|
||||
@Result(property = "destIp", column = "dest_ip"),
|
||||
@Result(property = "destPort", column = "dest_port"),
|
||||
@Result(property = "proxyIp", column = "proxy_ip"),
|
||||
@Result(property = "node", column = "node")
|
||||
})
|
||||
XdrHoneypot selectById(Long id);
|
||||
|
||||
/**
|
||||
* 查询所有记录
|
||||
*/
|
||||
@Select("SELECT * FROM xdr_honeypot ORDER BY id DESC")
|
||||
@Results({
|
||||
@Result(property = "dstartTime", column = "dstart_time"),
|
||||
@Result(property = "riskLevel", column = "risk_level"),
|
||||
@Result(property = "fileInfo", column = "file_info"),
|
||||
@Result(property = "agentSn", column = "agent_sn"),
|
||||
@Result(property = "agentName", column = "agent_name"),
|
||||
@Result(property = "honeypotId", column = "honeypot_id"),
|
||||
@Result(property = "honeypotName", column = "honeypot_name"),
|
||||
@Result(property = "srcIp", column = "src_ip"),
|
||||
@Result(property = "srcPort", column = "src_port"),
|
||||
@Result(property = "srcMac", column = "src_mac"),
|
||||
@Result(property = "destIp", column = "dest_ip"),
|
||||
@Result(property = "destPort", column = "dest_port"),
|
||||
@Result(property = "proxyIp", column = "proxy_ip")
|
||||
})
|
||||
List<XdrHoneypot> selectAll();
|
||||
|
||||
/**
|
||||
* 根据源IP查询记录
|
||||
*/
|
||||
@Select("SELECT * FROM xdr_honeypot WHERE src_ip = #{srcIp} ORDER BY dtime DESC")
|
||||
List<XdrHoneypot> selectBySrcIp(String srcIp);
|
||||
|
||||
/**
|
||||
* 根据风险等级查询记录
|
||||
*/
|
||||
@Select("SELECT * FROM xdr_honeypot WHERE risk_level = #{riskLevel} ORDER BY dtime DESC")
|
||||
List<XdrHoneypot> selectByRiskLevel(String riskLevel);
|
||||
|
||||
/**
|
||||
* 更新记录
|
||||
*/
|
||||
@Update("UPDATE xdr_honeypot SET risk_level = #{riskLevel}, extra = #{extra} WHERE id = #{id}")
|
||||
int update(XdrHoneypot xdrHoneypot);
|
||||
|
||||
/**
|
||||
* 根据ID删除记录
|
||||
*/
|
||||
@Delete("DELETE FROM xdr_honeypot WHERE id = #{id}")
|
||||
int delete(Long id);
|
||||
|
||||
/**
|
||||
* 统计总记录数
|
||||
*/
|
||||
@Select("SELECT COUNT(*) FROM xdr_honeypot")
|
||||
long count();
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.AnalysisAnalysisRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 分析引擎接口
|
||||
*/
|
||||
public interface AnalysisEngine {
|
||||
|
||||
/**
|
||||
* 执行分析规则
|
||||
*
|
||||
* @param rule 规则
|
||||
* @return 处理结果
|
||||
*/
|
||||
Map<String, Object> executeRule(AnalysisAnalysisRule rule);
|
||||
|
||||
/**
|
||||
* 批量执行规则
|
||||
*
|
||||
* @param rules 规则列表
|
||||
* @return 处理结果列表
|
||||
*/
|
||||
List<Map<String, Object>> executeRules(List<AnalysisAnalysisRule> rules);
|
||||
|
||||
/**
|
||||
* 停止指定规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
*/
|
||||
void stopRule(String ruleId);
|
||||
|
||||
/**
|
||||
* 获取引擎运行模式
|
||||
*
|
||||
* @return 运行模式
|
||||
*/
|
||||
String getRunMode();
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.common.service;
|
||||
|
||||
import com.common.entity.AnalysisAnalysisRule;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 分析规则服务接口
|
||||
*/
|
||||
public interface AnalysisRuleService {
|
||||
|
||||
/**
|
||||
* 执行实时分析
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
List<Map<String, Object>> executeRealtimeAnalysis();
|
||||
|
||||
/**
|
||||
* 执行离线分析
|
||||
*
|
||||
* @return 执行结果
|
||||
*/
|
||||
List<Map<String, Object>> executeOfflineAnalysis();
|
||||
|
||||
/**
|
||||
* 查询活动规则
|
||||
*
|
||||
* @param runMode 运行模式
|
||||
* @return 规则列表
|
||||
*/
|
||||
List<AnalysisAnalysisRule> getActiveRules(String runMode);
|
||||
|
||||
/**
|
||||
* 停止规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
*/
|
||||
void stopRule(String ruleId);
|
||||
|
||||
|
||||
/**
|
||||
* 执行单个实时分析规则
|
||||
*
|
||||
* @param ruleId 规则ID
|
||||
* @return 执行结果
|
||||
*/
|
||||
Map<String, Object> executeRealtimeRule(String ruleId);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
import com.common.entity.AppLog;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//@Repository
|
||||
public interface AppLogRepository extends ElasticsearchRepository<AppLog, String> {
|
||||
|
||||
/**
|
||||
* 根据应用名称和日志级别查询
|
||||
*/
|
||||
List<AppLog> findByAppNameAndLogLevel(String appName, String logLevel);
|
||||
|
||||
/**
|
||||
* 根据时间范围查询
|
||||
*/
|
||||
List<AppLog> findByDtTimeBetween(Long startTime, Long endTime);
|
||||
|
||||
/**
|
||||
* 根据索引名称查询
|
||||
*/
|
||||
List<AppLog> findByIndex(String index);
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.common.service;
|
||||
|
||||
|
||||
import com.common.entity.AppLogEntity;
|
||||
import com.common.mapper.AppLogMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ApplogService {
|
||||
|
||||
@Autowired
|
||||
private AppLogMapper appLogMapper;
|
||||
|
||||
/**
|
||||
* 保存日志到数据库(去重)
|
||||
*/
|
||||
@Transactional
|
||||
public void saveAppLogWithDeduplication(AppLogEntity appLog) {
|
||||
// 检查是否已存在
|
||||
boolean exists = appLogMapper.existsByEsIdAndIndex(appLog.getEsId(), appLog.getEsIndex());
|
||||
|
||||
if (!exists) {
|
||||
appLog.setCreatedAt(LocalDateTime.now());
|
||||
appLog.setUpdatedAt(LocalDateTime.now());
|
||||
appLogMapper.insert(appLog);
|
||||
log.info("保存日志到数据库, ES ID: {}", appLog.getEsId());
|
||||
} else {
|
||||
log.debug("日志已存在,跳过保存, ES ID: {}", appLog.getEsId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存日志到数据库(去重)
|
||||
*/
|
||||
@Transactional
|
||||
public int batchSaveAppLogsWithDeduplication(List<AppLogEntity> appLogs) {
|
||||
if (appLogs == null || appLogs.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 过滤已存在的记录
|
||||
List<AppLogEntity> newLogs = appLogs.stream()
|
||||
.filter(log -> !appLogMapper.existsByEsIdAndIndex(log.getEsId(), log.getEsIndex()))
|
||||
.peek(log -> {
|
||||
log.setCreatedAt(LocalDateTime.now());
|
||||
log.setUpdatedAt(LocalDateTime.now());
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
if (!newLogs.isEmpty()) {
|
||||
appLogMapper.batchInsert(newLogs);
|
||||
log.info("批量保存 {} 条日志到数据库,跳过 {} 条重复数据",
|
||||
newLogs.size(), appLogs.size() - newLogs.size());
|
||||
} else {
|
||||
log.info("所有 {} 条日志均已存在,跳过保存", appLogs.size());
|
||||
}
|
||||
|
||||
return newLogs.size();
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user