forked from p15670423/monkey
Project: Fix travis build
This commit is contained in:
parent
bd40ca79bf
commit
1bfffb0bfd
|
@ -52,4 +52,3 @@ repos:
|
||||||
rev: v2.3
|
rev: v2.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: vulture
|
- id: vulture
|
||||||
exclude: "monkey/monkey_island/docs/source/conf.py"
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ jobs:
|
||||||
# check python code
|
# check python code
|
||||||
## check syntax errors and fail the build if any are found.
|
## check syntax errors and fail the build if any are found.
|
||||||
- flake8 .
|
- flake8 .
|
||||||
|
|
||||||
## check import order
|
## check import order
|
||||||
- python -m isort ./monkey --check-only
|
- python -m isort ./monkey --check-only
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ from typing import Mapping, Sequence
|
||||||
# might require more complex casting logic
|
# might require more complex casting logic
|
||||||
@dataclass
|
@dataclass
|
||||||
class NetworkMap:
|
class NetworkMap:
|
||||||
nodes: Mapping[str, Sequence[Arc]]
|
nodes: Mapping[str, Sequence[Arc]] # noqa: F821
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Arc:
|
class Arc:
|
||||||
dst_machine: Machine
|
dst_machine: Machine # noqa: F821
|
||||||
status: str
|
status: str
|
||||||
|
|
|
@ -4,10 +4,10 @@ from typing import Optional, Sequence
|
||||||
|
|
||||||
class ILogRepository(ABC):
|
class ILogRepository(ABC):
|
||||||
# Define log object
|
# Define log object
|
||||||
def get_logs(self, agent_id: Optional[str] = None) -> Sequence[Log]:
|
def get_logs(self, agent_id: Optional[str] = None) -> Sequence[Log]: # noqa: F821
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def save_log(self, log: Log):
|
def save_log(self, log: Log): # noqa: F821
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete_log(self, agent_id: str):
|
def delete_log(self, agent_id: str):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from typing import Optional, Sequence
|
||||||
|
|
||||||
class IMachineRepository(ABC):
|
class IMachineRepository(ABC):
|
||||||
# TODO define Machine object(ORM model)
|
# TODO define Machine object(ORM model)
|
||||||
def save_machine(self, machine: Machine):
|
def save_machine(self, machine: Machine): # noqa: F821
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# TODO define Machine object(ORM model)
|
# TODO define Machine object(ORM model)
|
||||||
|
@ -14,7 +14,7 @@ class IMachineRepository(ABC):
|
||||||
self,
|
self,
|
||||||
id: Optional[str] = None,
|
id: Optional[str] = None,
|
||||||
ips: Optional[Sequence[str]] = None,
|
ips: Optional[Sequence[str]] = None,
|
||||||
state: Optional[MachineState] = None,
|
state: Optional[MachineState] = None, # noqa: F821
|
||||||
is_island: Optional[bool] = None,
|
is_island: Optional[bool] = None,
|
||||||
) -> Sequence[Machine]:
|
) -> Sequence[Machine]: # noqa: F821
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -4,8 +4,8 @@ from abc import ABC
|
||||||
class INetworkMapRepository(ABC):
|
class INetworkMapRepository(ABC):
|
||||||
|
|
||||||
# TODO Define NetMap object
|
# TODO Define NetMap object
|
||||||
def get_map(self) -> NetMap:
|
def get_map(self) -> NetMap: # noqa: F821
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def save_netmap(self, netmap: NetMap):
|
def save_netmap(self, netmap: NetMap): # noqa: F821
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -4,7 +4,7 @@ from abc import ABC
|
||||||
class ISimulationRepository(ABC):
|
class ISimulationRepository(ABC):
|
||||||
# TODO define simulation object. It should contain metadata about simulation,
|
# TODO define simulation object. It should contain metadata about simulation,
|
||||||
# like start, end times, mode and last forced stop of all monkeys
|
# like start, end times, mode and last forced stop of all monkeys
|
||||||
def save_simulation(self, simulation: Simulation):
|
def save_simulation(self, simulation: Simulation): # noqa: F821
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_simulation(self):
|
def get_simulation(self):
|
||||||
|
|
|
@ -14,7 +14,7 @@ class ITelemetryRepository(ABC):
|
||||||
def get_telemetries(
|
def get_telemetries(
|
||||||
self,
|
self,
|
||||||
id: Optional[str] = None,
|
id: Optional[str] = None,
|
||||||
type: Optional[TelemetryType] = None,
|
type: Optional[TelemetryType] = None, # noqa: F821
|
||||||
monkey_id: Optional[str] = None,
|
monkey_id: Optional[str] = None,
|
||||||
) -> Sequence[Telemetry]:
|
) -> Sequence[Telemetry]:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -15,6 +15,7 @@ MAX_SAME_CATEGORY_TELEMS = 10000
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# TODO this will break with the IRepository implementation. Remove it
|
# TODO this will break with the IRepository implementation. Remove it
|
||||||
class TestTelemStore:
|
class TestTelemStore:
|
||||||
TELEMS_EXPORTED = False
|
TELEMS_EXPORTED = False
|
||||||
|
|
|
@ -188,15 +188,15 @@ class NodeService:
|
||||||
tunnel_host_id = NodeService.get_monkey_by_ip(tunnel_host_ip)["_id"]
|
tunnel_host_id = NodeService.get_monkey_by_ip(tunnel_host_ip)["_id"]
|
||||||
NodeService.unset_all_monkey_tunnels(monkey_id)
|
NodeService.unset_all_monkey_tunnels(monkey_id)
|
||||||
mongo.db.monkey.update(
|
mongo.db.monkey.update(
|
||||||
{"_id": monkey_id}, {"$set": {"tunnel": tunnel_host_id}}, upsert=False
|
{"_id": monkey_id}, {"$set": {"tunnel": tunnel_host_id}}, upsert=False
|
||||||
)
|
)
|
||||||
monkey_label = NodeService.get_label_for_endpoint(monkey_id)
|
monkey_label = NodeService.get_label_for_endpoint(monkey_id)
|
||||||
tunnel_host_label = NodeService.get_label_for_endpoint(tunnel_host_id)
|
tunnel_host_label = NodeService.get_label_for_endpoint(tunnel_host_id)
|
||||||
tunnel_edge = EdgeService.get_or_create_edge(
|
tunnel_edge = EdgeService.get_or_create_edge(
|
||||||
src_node_id=monkey_id,
|
src_node_id=monkey_id,
|
||||||
dst_node_id=tunnel_host_id,
|
dst_node_id=tunnel_host_id,
|
||||||
src_label=monkey_label,
|
src_label=monkey_label,
|
||||||
dst_label=tunnel_host_label,
|
dst_label=tunnel_host_label,
|
||||||
)
|
)
|
||||||
tunnel_edge.tunnel = True
|
tunnel_edge.tunnel = True
|
||||||
tunnel_edge.ip_address = tunnel_host_ip
|
tunnel_edge.ip_address = tunnel_host_ip
|
||||||
|
@ -205,13 +205,13 @@ class NodeService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def insert_node(ip_address, domain_name=""):
|
def insert_node(ip_address, domain_name=""):
|
||||||
new_node_insert_result = mongo.db.node.insert_one(
|
new_node_insert_result = mongo.db.node.insert_one(
|
||||||
{
|
{
|
||||||
"ip_addresses": [ip_address],
|
"ip_addresses": [ip_address],
|
||||||
"domain_name": domain_name,
|
"domain_name": domain_name,
|
||||||
"exploited": False,
|
"exploited": False,
|
||||||
"propagated": False,
|
"propagated": False,
|
||||||
"os": {"type": "unknown", "version": "unknown"},
|
"os": {"type": "unknown", "version": "unknown"},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return mongo.db.node.find_one({"_id": new_node_insert_result.inserted_id})
|
return mongo.db.node.find_one({"_id": new_node_insert_result.inserted_id})
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ class NodeService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_monkey_modify_time(monkey_id):
|
def update_monkey_modify_time(monkey_id):
|
||||||
mongo.db.monkey.update(
|
mongo.db.monkey.update(
|
||||||
{"_id": monkey_id}, {"$set": {"modifytime": datetime.now()}}, upsert=False
|
{"_id": monkey_id}, {"$set": {"modifytime": datetime.now()}}, upsert=False
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -268,7 +268,7 @@ class NodeService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def add_communication_info(monkey, info):
|
def add_communication_info(monkey, info):
|
||||||
mongo.db.monkey.update(
|
mongo.db.monkey.update(
|
||||||
{"guid": monkey["guid"]}, {"$set": {"command_control_channel": info}}, upsert=False
|
{"guid": monkey["guid"]}, {"$set": {"command_control_channel": info}}, upsert=False
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO this returns a mock island agent
|
# TODO this returns a mock island agent
|
||||||
|
@ -343,7 +343,7 @@ class NodeService:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_hostname_by_id(node_id):
|
def get_hostname_by_id(node_id):
|
||||||
return NodeService.get_node_hostname(
|
return NodeService.get_node_hostname(
|
||||||
mongo.db.monkey.find_one({"_id": node_id}, {"hostname": 1})
|
mongo.db.monkey.find_one({"_id": node_id}, {"hostname": 1})
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -25,5 +25,5 @@ norecursedirs = "node_modules dist"
|
||||||
markers = ["slow: mark test as slow"]
|
markers = ["slow: mark test as slow"]
|
||||||
|
|
||||||
[tool.vulture]
|
[tool.vulture]
|
||||||
exclude = ["monkey/monkey_island/cc/ui/", "monkey/tests/"]
|
exclude = ["monkey/monkey_island/cc/ui/", "monkey/tests/", "monkey/monkey_island/docs/"]
|
||||||
paths = ["."]
|
paths = ["."]
|
||||||
|
|
Loading…
Reference in New Issue