parent
c250fd01b2
commit
6501d1b150
|
@ -7,12 +7,9 @@ import com.dispose.common.ErrorCode;
|
||||||
import com.dispose.common.Helper;
|
import com.dispose.common.Helper;
|
||||||
import com.dispose.common.IpAddrType;
|
import com.dispose.common.IpAddrType;
|
||||||
import com.dispose.common.NetflowDirection;
|
import com.dispose.common.NetflowDirection;
|
||||||
import com.dispose.common.DisposeDeviceType;
|
|
||||||
import com.dispose.manager.DisposeTaskManager;
|
import com.dispose.manager.DisposeTaskManager;
|
||||||
import com.dispose.mapper.DisposeDeviceMapper;
|
import com.dispose.mapper.DisposeDeviceMapper;
|
||||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||||
import com.dispose.pojo.entity.DeviceTask;
|
|
||||||
import com.dispose.pojo.entity.DisposeTask;
|
|
||||||
import com.dispose.pojo.po.MulReturnType;
|
import com.dispose.pojo.po.MulReturnType;
|
||||||
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
import com.dispose.pojo.vo.DeviceFirewareInfo;
|
||||||
import com.pengxin.dispose.common.PengXinDisposeAbilityRsp;
|
import com.pengxin.dispose.common.PengXinDisposeAbilityRsp;
|
||||||
|
@ -33,7 +30,6 @@ import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type Peng xin ability.
|
* The type Peng xin ability.
|
||||||
|
@ -42,18 +38,6 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PengXinAbilityImpl implements DisposeAbility {
|
public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
/**
|
|
||||||
* The Dispose task manager.
|
|
||||||
*/
|
|
||||||
@Resource
|
|
||||||
private DisposeTaskManager disposeTaskManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Dispose device mapper.
|
|
||||||
*/
|
|
||||||
@Resource
|
|
||||||
private DisposeDeviceMapper disposeDeviceMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Protect ip v 4.
|
* The Protect ip v 4.
|
||||||
*/
|
*/
|
||||||
|
@ -62,48 +46,51 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
* The Protect ip v 6.
|
* The Protect ip v 6.
|
||||||
*/
|
*/
|
||||||
private final List<String> protectIpV6 = new ArrayList<>();
|
private final List<String> protectIpV6 = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Restful interface.
|
* The Restful interface.
|
||||||
*/
|
*/
|
||||||
private final PengXinInterface restfulInterface = new PengXinInterface();
|
private final PengXinInterface restfulInterface = new PengXinInterface();
|
||||||
|
/**
|
||||||
|
* The Peng xin dispose type.
|
||||||
|
*/
|
||||||
|
private final Integer[] pengXinDisposeType = new Integer[]{0, 4, 1, 3};
|
||||||
|
/**
|
||||||
|
* The Dispose task manager.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private DisposeTaskManager disposeTaskManager;
|
||||||
|
/**
|
||||||
|
* The Dispose device mapper.
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private DisposeDeviceMapper disposeDeviceMapper;
|
||||||
/**
|
/**
|
||||||
* The Task req id.
|
* The Task req id.
|
||||||
*/
|
*/
|
||||||
private Long taskReqId = System.currentTimeMillis();
|
private Long taskReqId = System.currentTimeMillis();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Url root path.
|
* The Url root path.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String urlRootPath;
|
private String urlRootPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Username.
|
* The Username.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Password.
|
* The Password.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Token.
|
* The Token.
|
||||||
*/
|
*/
|
||||||
private String token;
|
private String token;
|
||||||
|
|
||||||
/**
|
|
||||||
* The Peng xin dispose type.
|
|
||||||
*/
|
|
||||||
private final Integer[] pengXinDisposeType = new Integer[]{0, 4, 1, 3};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets peng xin task type.
|
* Gets peng xin task type.
|
||||||
*
|
*
|
||||||
|
@ -160,7 +147,8 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
* @return the mul return type
|
* @return the mul return type
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MulReturnType<ErrorCode, String> runDispose(String disposeObject, DisposeObjectType objectType, DisposeCapacityType capType,
|
public MulReturnType<ErrorCode, String> runDispose(String disposeObject, DisposeObjectType objectType,
|
||||||
|
DisposeCapacityType capType,
|
||||||
@Nullable NetflowDirection nfDirection,
|
@Nullable NetflowDirection nfDirection,
|
||||||
@Nullable Integer attackType,
|
@Nullable Integer attackType,
|
||||||
@Nullable Long duration) {
|
@Nullable Long duration) {
|
||||||
|
@ -441,25 +429,14 @@ public class PengXinAbilityImpl implements DisposeAbility {
|
||||||
try {
|
try {
|
||||||
String url = urlRootPath + "dispose_device/task/get";
|
String url = urlRootPath + "dispose_device/task/get";
|
||||||
|
|
||||||
DisposeTask task = disposeTaskManager.getDisposeTaskById(taskId);
|
|
||||||
|
|
||||||
if (task == null) {
|
|
||||||
return new MulReturnType<>(ErrorCode.ERR_NOSUCHTASK, -1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
//根据设备ID获取设备信息,判断任务列表中的设备为鹏信,获取externId
|
|
||||||
List<DeviceTask> dev = task.getDeviceTask().stream().
|
|
||||||
filter(v -> disposeDeviceMapper.getDeviceById(v.getDeviceId()).getDeviceType() == DisposeDeviceType.PENGXIN_PLATFORM).collect(Collectors.toList());
|
|
||||||
|
|
||||||
ProtocolRespDTO<PengXinTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
ProtocolRespDTO<PengXinTaskStatusRsp> rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
||||||
new String[]{String.valueOf(dev.get(0).getExternId())});
|
new String[]{taskId});
|
||||||
|
|
||||||
// 判断是否token过期
|
// 判断是否token过期
|
||||||
if (rspInfo != null && rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
if (rspInfo != null && rspInfo.getCode() == HttpServletResponse.SC_UNAUTHORIZED) {
|
||||||
// 重新登录获取 token
|
// 重新登录获取 token
|
||||||
upgradeToken();
|
upgradeToken();
|
||||||
rspInfo = restfulInterface.getDeviceTaskStatus(url, token,
|
rspInfo = restfulInterface.getDeviceTaskStatus(url, token, new String[]{taskId});
|
||||||
new String[]{String.valueOf(dev.get(0).getExternId())});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
|
if (rspInfo != null && rspInfo.getCode() == ErrorCode.ERR_OK.getHttpCode()) {
|
||||||
|
|
|
@ -88,12 +88,12 @@ public interface DeviceTaskMapper {
|
||||||
/**
|
/**
|
||||||
* Change task dev status int.
|
* Change task dev status int.
|
||||||
*
|
*
|
||||||
* @param id the id
|
* @param externId the extern id
|
||||||
* @param status the status
|
* @param devStatus the dev status
|
||||||
* @return the int
|
* @return the int
|
||||||
*/
|
*/
|
||||||
int changeTaskDevStatus(@Param("id") String id,
|
int changeTaskDevStatus(@Param("externId") String externId,
|
||||||
@Param("status") Long status);
|
@Param("devStatus") Long devStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change exec attack type in value int.
|
* Change exec attack type in value int.
|
||||||
|
|
|
@ -715,7 +715,7 @@ public class DeviceTaskManagerServiceImpl implements DeviceTaskManagerService {
|
||||||
|
|
||||||
// 任务预计结束5分钟内,
|
// 任务预计结束5分钟内,
|
||||||
if (Helper.getTimestampDiffNow(task.getPlanEndTime()) < 5 * 60) {
|
if (Helper.getTimestampDiffNow(task.getPlanEndTime()) < 5 * 60) {
|
||||||
if (v.getEndTime() == null && Helper.getTimestampDiffNow(v.getEndTime()) < 5 * 60) {
|
if (v.getEndTime() == null || Helper.getTimestampDiffNow(v.getEndTime()) < 5 * 60) {
|
||||||
|
|
||||||
if (v.getExternId() != null && v.getExternId().length() > 0) {
|
if (v.getExternId() != null && v.getExternId().length() > 0) {
|
||||||
MulReturnType<ErrorCode, Long> ret = ai.getDb().taskStatus(v.getExternId());
|
MulReturnType<ErrorCode, Long> ret = ai.getDb().taskStatus(v.getExternId());
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
<update id="changeTaskDevStatus">
|
<update id="changeTaskDevStatus">
|
||||||
UPDATE device_task
|
UPDATE device_task
|
||||||
SET devStatus = #{devStatus}
|
SET devStatus = #{devStatus}
|
||||||
WHERE id = #{id}
|
WHERE externId = #{externId} AND devStatus != #{devStatus}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="changeExecAttackTypeInValue">
|
<update id="changeExecAttackTypeInValue">
|
||||||
|
|
Loading…
Reference in New Issue