This commit is contained in:
HuangXin 2020-09-16 14:35:52 +08:00
commit 63debfca1d
6 changed files with 25 additions and 23 deletions

View File

@ -9,6 +9,8 @@ import com.dispose.pojo.vo.DeviceFirewareInfo;
import com.haohan.dispose.common.HaoHanStartCleanResp; import com.haohan.dispose.common.HaoHanStartCleanResp;
import com.haohan.dispose.common.HaoHanStopCleanResp; import com.haohan.dispose.common.HaoHanStopCleanResp;
import com.haohan.dispose.protocol.RestfulInterface; import com.haohan.dispose.protocol.RestfulInterface;
import inet.ipaddr.IPAddress;
import inet.ipaddr.IPAddressString;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -71,7 +73,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
} }
HaoHanStartCleanResp resp = restfulInterface.startClean(this.urlRootPath, ip, Math.max(duration.intValue(), 0), HaoHanStartCleanResp resp = restfulInterface.startClean(this.urlRootPath, ip, Math.max(duration.intValue(), 0),
DISPOSE_PLATFORM_NAME); DISPOSE_PLATFORM_NAME);
if (resp == null) { if (resp == null) {
log.error("----Error Haohan start clean {} server return error", ip); log.error("----Error Haohan start clean {} server return error", ip);
@ -109,7 +111,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
} }
HaoHanStopCleanResp resp = restfulInterface.stopClean(this.urlRootPath, taskId.intValue(), HaoHanStopCleanResp resp = restfulInterface.stopClean(this.urlRootPath, taskId.intValue(),
DISPOSE_PLATFORM_NAME); DISPOSE_PLATFORM_NAME);
if (resp == null) { if (resp == null) {
log.error("----Error Haohan stop task{} server return error", taskId); log.error("----Error Haohan stop task{} server return error", taskId);
@ -139,18 +141,18 @@ public class HaoHanAbilityImpl implements DisposeAbility {
@Override @Override
public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() { public MulReturnType<ErrorCode, DeviceFirewareInfo> getAbilityDeviceFireware() {
return new MulReturnType<>(ErrorCode.ERR_OK, return new MulReturnType<>(ErrorCode.ERR_OK,
DeviceFirewareInfo.builder() DeviceFirewareInfo.builder()
.vendor("HaoHan") .vendor("HaoHan")
.model("Unknown") .model("Unknown")
.firmware("Unknown") .firmware("Unknown")
.os("Linux Server") .os("Linux Server")
.kernel("Linux") .kernel("Linux")
.arch("x86_64") .arch("x86_64")
.version("Unknown") .version("Unknown")
.memory(-1) .memory(-1)
.freeMemory(-1) .freeMemory(-1)
.cpuUsed(-1) .cpuUsed(-1)
.build()); .build());
} }
/** /**
@ -179,6 +181,7 @@ public class HaoHanAbilityImpl implements DisposeAbility {
*/ */
@Override @Override
public boolean isCarryProtectIp(String ipAddr) { public boolean isCarryProtectIp(String ipAddr) {
return true; IPAddress addr = new IPAddressString(ipAddr).getAddress();
return addr.isIPv4();
} }
} }

View File

@ -62,7 +62,7 @@ public class DisposeDeviceManagerImpl implements DisposeDeviceManager {
if (tDev.getStatus() == ObjectStatus.DELETED) { if (tDev.getStatus() == ObjectStatus.DELETED) {
// 重置状态 // 重置状态
tDev.setStatus(ObjectStatus.NORMAL); tDev.setStatus(ObjectStatus.NORMAL);
return upgradeDisposeDevice(tDev); return upgradeDisposeDevice(dev);
} }
return new MulReturnType<>(ErrorCode.ERR_DEVICEEXISTS, tDev.getId()); return new MulReturnType<>(ErrorCode.ERR_DEVICEEXISTS, tDev.getId());

View File

@ -29,7 +29,7 @@ public class P2TaskList {
private static final QATestItem[] testItemArray = new QATestItem[]{ private static final QATestItem[] testItemArray = new QATestItem[]{
QATestItem.builder() QATestItem.builder()
.id(BASE_P2_TASK_LIST_ID) .id(BASE_P2_TASK_LIST_ID)
.name("获取第二页20个设备信息") .name("获取第二页20个处置任务信息")
.priority(TestPriority.P2_PRIORITY) .priority(TestPriority.P2_PRIORITY)
.urlPath("/task/taskList") .urlPath("/task/taskList")
.method(RequestMethod.POST) .method(RequestMethod.POST)

View File

@ -93,7 +93,7 @@ public class P2TaskStart {
.priority(TestPriority.P2_PRIORITY) .priority(TestPriority.P2_PRIORITY)
.urlPath("/task/start") .urlPath("/task/start")
.method(RequestMethod.POST) .method(RequestMethod.POST)
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":1," + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":2," +
"\"disposeIp\":\"192.168.50.3\",\"disposeTime\":10,\"flowDirection\":2," + "\"disposeIp\":\"192.168.50.3\",\"disposeTime\":10,\"flowDirection\":2," +
"\"attackType\":[-1]}}") "\"attackType\":[-1]}}")
.rspClass(TaskStartRsp.class) .rspClass(TaskStartRsp.class)
@ -108,7 +108,7 @@ public class P2TaskStart {
.priority(TestPriority.P2_PRIORITY) .priority(TestPriority.P2_PRIORITY)
.urlPath("/task/start") .urlPath("/task/start")
.method(RequestMethod.POST) .method(RequestMethod.POST)
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":2," + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":1," +
"\"disposeIp\":\"192.168.50.2\",\"disposeTime\":10,\"flowDirection\":2," + "\"disposeIp\":\"192.168.50.2\",\"disposeTime\":10,\"flowDirection\":2," +
"\"attackType\":[-1]}}") "\"attackType\":[-1]}}")
.rspClass(TaskStartRsp.class) .rspClass(TaskStartRsp.class)

View File

@ -30,7 +30,7 @@ public class P2TaskStartMulIp {
private static final QATestItem[] testItemArray = new QATestItem[]{ private static final QATestItem[] testItemArray = new QATestItem[]{
QATestItem.builder() QATestItem.builder()
.id(BASE_P2_TASK_START_MUL_ID) .id(BASE_P2_TASK_START_MUL_ID)
.name("一个IP全部攻击类型进行清洗") .name("多个IP指定攻击类型进行清洗")
.priority(TestPriority.P2_PRIORITY) .priority(TestPriority.P2_PRIORITY)
.urlPath("/task/startMulIp") .urlPath("/task/startMulIp")
.method(RequestMethod.POST) .method(RequestMethod.POST)
@ -173,7 +173,7 @@ public class P2TaskStartMulIp {
.priority(TestPriority.P2_PRIORITY) .priority(TestPriority.P2_PRIORITY)
.urlPath("/task/startMulIp") .urlPath("/task/startMulIp")
.method(RequestMethod.POST) .method(RequestMethod.POST)
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":1," + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":2," +
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," + "\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
"\"flowDirection\":2,\"attackType\":[-1]}}") "\"flowDirection\":2,\"attackType\":[-1]}}")
.rspClass(TaskStartMulRsp.class) .rspClass(TaskStartMulRsp.class)
@ -190,7 +190,7 @@ public class P2TaskStartMulIp {
.priority(TestPriority.P2_PRIORITY) .priority(TestPriority.P2_PRIORITY)
.urlPath("/task/startMulIp") .urlPath("/task/startMulIp")
.method(RequestMethod.POST) .method(RequestMethod.POST)
.caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":2," + .caseJsonValue("{\"ver\":3,\"cryptoType\":0,\"timeStamp\":1598597142580,\"msgContent\":{\"type\":1," +
"\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," + "\"mulDisposeIp\":[\"192.168.50.4\",\"192.168.50.3\"],\"disposeTime\":10," +
"\"flowDirection\":2,\"attackType\":[-1]}}") "\"flowDirection\":2,\"attackType\":[-1]}}")
.rspClass(TaskStartMulRsp.class) .rspClass(TaskStartMulRsp.class)

View File

@ -50,7 +50,6 @@ public class P2TaskStop {
Assert.assertNotEquals(k.getDisposeIp().length(), 0); Assert.assertNotEquals(k.getDisposeIp().length(), 0);
Assert.assertNotNull(k.getLeftTime()); Assert.assertNotNull(k.getLeftTime());
} }
}); });
}) })