|
@@ -7,6 +7,7 @@ import com.jd.mapper.*;
|
|
|
import com.jd.service.SafetyInfoService;
|
|
|
import com.jd.util.Blank;
|
|
|
import com.jd.util.SendUtil;
|
|
|
+import com.netflix.discovery.converters.Auto;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import zipkin2.reporter.Sender;
|
|
@@ -45,6 +46,18 @@ public class SafetyInfoServiceImpl implements SafetyInfoService {
|
|
|
@Autowired
|
|
|
private AttackEventMapper attackEventMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WebAttackTypeMapper webAttackTypeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OfficeVirusMapper officeVirusMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private VirusTypeMapper virusTypeMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BasicDataMapper basicDataMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> getSafetyInfo(Map<String, Object> param) {
|
|
|
Integer count = safetyInfoMapper.getCountSafetyInfo(param);
|
|
@@ -153,20 +166,20 @@ public class SafetyInfoServiceImpl implements SafetyInfoService {
|
|
|
//受攻击总次数
|
|
|
Map<String, Object> safetyInfo = safetyInfoMapper.getSafetyInfoByMonth(paramMap);
|
|
|
if(Blank.isEmpty(safetyInfo)){
|
|
|
- return SendUtil.send(false);
|
|
|
+ return SendUtil.send(false, "无数据");
|
|
|
}
|
|
|
if(Blank.isEmpty(safetyInfo.get("month_attack_count")) || Blank.isEmpty(safetyInfo.get("id"))){
|
|
|
- return SendUtil.send(false);
|
|
|
+ return SendUtil.send(false, "无数据");
|
|
|
}
|
|
|
Integer monthAttackCount = Convert.toInt(safetyInfo.get("month_attack_count").toString());
|
|
|
Integer infoId = Convert.toInt(safetyInfo.get("id").toString());
|
|
|
//低中度危险系统数
|
|
|
Map<String, Object> sysStatus = systemRiskMapper.countSysStatus(infoId);
|
|
|
if(Blank.isEmpty(sysStatus)){
|
|
|
- return SendUtil.send(false);
|
|
|
+ return SendUtil.send(false, "无数据");
|
|
|
}
|
|
|
if(Blank.isEmpty(sysStatus.get("safe")) || Blank.isEmpty(sysStatus.get("middle"))){
|
|
|
- return SendUtil.send(false);
|
|
|
+ return SendUtil.send(false, "无数据");
|
|
|
}
|
|
|
Integer safeSystemCount = Convert.toInt(sysStatus.get("safe").toString());
|
|
|
Integer middleSystemCount = Convert.toInt(sysStatus.get("middle").toString());
|
|
@@ -179,6 +192,107 @@ public class SafetyInfoServiceImpl implements SafetyInfoService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Map<String, Object> analysisSafetyStatus(String orgType) {
|
|
|
+ //获取当前月份
|
|
|
+ //返回参数
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ //请求参数
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ //时间
|
|
|
+ Calendar calender = Calendar.getInstance();
|
|
|
+ Integer year = calender.get(calender.YEAR);
|
|
|
+ Integer month = (calender.get(Calendar.MONTH)==0?12:calender.get(Calendar.MONTH)+1);
|
|
|
+ paramMap.put("createYear", year);
|
|
|
+ paramMap.put("createMonth", month);
|
|
|
+ paramMap.put("orgType", orgType);
|
|
|
+ //计算安全等级
|
|
|
+ //查询当月漏洞数
|
|
|
+ Map<String, Object> safetyInfo = safetyInfoMapper.getSafetyInfoByMonth(paramMap);
|
|
|
+ if(Blank.isEmpty(safetyInfo)){
|
|
|
+ return SendUtil.send(false, "无数据");
|
|
|
+ }
|
|
|
+ if(Blank.isEmpty(safetyInfo.get("middle_risk_number")) || Blank.isEmpty(safetyInfo.get("high_risk_number"))){
|
|
|
+ return SendUtil.send(false, "无数据");
|
|
|
+ }
|
|
|
+ Integer safetyLevel = 0;
|
|
|
+ Integer highRiskNumber = Convert.toInt(safetyInfo.get("high_risk_number").toString());
|
|
|
+ Integer middleRiskNumber = Convert.toInt(safetyInfo.get("middle_risk_number").toString());
|
|
|
+ // 高危漏洞规则分割值1
|
|
|
+ Integer safetyHighFlag_1 = 0;
|
|
|
+ // 高危漏洞规则分割值2
|
|
|
+ Integer safetyHighFlag_2 = 0;
|
|
|
+ // 中危漏洞规则分割值1
|
|
|
+ Integer safetyMiddleFlag_1 = 0;
|
|
|
+ // 中危漏洞规则分割值2
|
|
|
+ Integer safetyMiddleFlag_2 = 0;
|
|
|
+ //获取安全等级计算规则
|
|
|
+ List<Map<String, Object>> basicMap = basicDataMapper.vagBasicDataByType("AQDJ");
|
|
|
+ for (Map<String, Object> map : basicMap) {
|
|
|
+ if (map.get("data_key").equals("AQDJ_HIGH_001")){
|
|
|
+ safetyHighFlag_1 = Convert.toInt(map.get("data_value").toString());
|
|
|
+ }else if (map.get("data_key").equals("AQDJ_HIGH_002")){
|
|
|
+ safetyHighFlag_2 = Convert.toInt(map.get("data_value").toString());
|
|
|
+ }else if (map.get("data_key").equals("AQDJ_MIDDLE_001")){
|
|
|
+ safetyMiddleFlag_1 = Convert.toInt(map.get("data_value").toString());
|
|
|
+ }else if (map.get("data_key").equals("AQDJ_MIDDLE_002")){
|
|
|
+ safetyMiddleFlag_2 = Convert.toInt(map.get("data_value").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //安全等级 差
|
|
|
+ if (highRiskNumber > safetyHighFlag_2 || middleRiskNumber > safetyMiddleFlag_2) {
|
|
|
+ safetyLevel = 3;
|
|
|
+ }else if ((safetyHighFlag_1 <= highRiskNumber && highRiskNumber <= safetyHighFlag_2)
|
|
|
+ || (middleRiskNumber > safetyMiddleFlag_1 && middleRiskNumber <= safetyMiddleFlag_2)) {
|
|
|
+ safetyLevel = 2;
|
|
|
+ }else {
|
|
|
+ safetyLevel = 1;
|
|
|
+ }
|
|
|
+ //计算风险系数
|
|
|
+ resultMap.put("safetyLevel", safetyLevel);
|
|
|
+ return SendUtil.send(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getWebSafetyStatusByOrg(String orgType) {
|
|
|
+ //查询网络安全态势
|
|
|
+ //返回参数
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ //查询参数
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ //当前时间
|
|
|
+ Calendar calender = Calendar.getInstance();
|
|
|
+ Integer year = calender.get(calender.YEAR);
|
|
|
+ Integer month = (calender.get(Calendar.MONTH)==0?12:calender.get(Calendar.MONTH)+1);
|
|
|
+ paramMap.put("createYear", year);
|
|
|
+ paramMap.put("createMonth", month);
|
|
|
+ paramMap.put("orgType", orgType);
|
|
|
+ //定位安全信息
|
|
|
+ Map<String, Object> safetyInfo = safetyInfoMapper.getSafetyInfoByMonth(paramMap);
|
|
|
+ if(Blank.isEmpty(safetyInfo)){
|
|
|
+ return SendUtil.send(false, "无数据");
|
|
|
+ }
|
|
|
+ if(Blank.isEmpty(safetyInfo.get("id")) || Blank.isEmpty(safetyInfo.get("safety_status_first"))
|
|
|
+ || Blank.isEmpty(safetyInfo.get("high_risk_number_first")) || Blank.isEmpty(safetyInfo.get("safety_status_second"))
|
|
|
+ || Blank.isEmpty(safetyInfo.get("high_risk_number_second"))){
|
|
|
+ return SendUtil.send(false, "无数据");
|
|
|
+ }
|
|
|
+ Integer safetyStatusFirst = Convert.toInt(safetyInfo.get("safety_status_first").toString());
|
|
|
+ Integer highRiskNumberFirst = Convert.toInt(safetyInfo.get("high_risk_number_first").toString());
|
|
|
+ Integer safetyStatusSecond = Convert.toInt(safetyInfo.get("safety_status_second").toString());
|
|
|
+ Integer highRiskNumberSecond = Convert.toInt(safetyInfo.get("high_risk_number_second").toString());
|
|
|
+ Integer infoId = Convert.toInt(safetyInfo.get("id").toString());
|
|
|
+ Map<String, Object> webMap = new HashMap<>();
|
|
|
+ webMap.put("infoId", infoId);
|
|
|
+ List webAttackTypeList = webAttackTypeMapper.getAttackTypeById(webMap);
|
|
|
+ resultMap.put("safetyStatusFirst", safetyStatusFirst);
|
|
|
+ resultMap.put("highRiskNumberFirst", highRiskNumberFirst);
|
|
|
+ resultMap.put("safetyStatusSecond", safetyStatusSecond);
|
|
|
+ resultMap.put("highRiskNumberSecond", highRiskNumberSecond);
|
|
|
+ resultMap.put("webAttackTypeList", webAttackTypeList);
|
|
|
+ return SendUtil.send(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Map<String, Object> updateSafetyInfo(SafetyInfo safetyInfo) {
|
|
|
//判断每月只插入一条数据
|
|
|
if(safetyInfoMapper.CountSafetyInfoByMoth(safetyInfo) > 0){
|
|
@@ -196,6 +310,9 @@ public class SafetyInfoServiceImpl implements SafetyInfoService {
|
|
|
systemAttackedMapper.deleteSystemAttackedInfoByInfo(InfoId);
|
|
|
riskNewsMapper.deleteRiskNewsByInfo(InfoId);
|
|
|
attackEventMapper.deleteAttackEventByInfo(InfoId);
|
|
|
+ webAttackTypeMapper.deleteAttackTypeByInfo(InfoId);
|
|
|
+ officeVirusMapper.deleteOfficeVirusByInfo(InfoId);
|
|
|
+ virusTypeMapper.deleteVirusTypeByInfo(InfoId);
|
|
|
|
|
|
//删除安全信息
|
|
|
return SendUtil.send(safetyInfoMapper.deleteSafetyInfo(InfoId));
|