cr_api_client 5.1.2__tar.gz → 5.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/PKG-INFO +2 -2
  2. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/core_api.py +56 -3
  3. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/provisioning_api.py +1 -1
  4. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/topology/TopologyNodeGenerator.py +3 -2
  5. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/topology/TopologyNodesGenerator.py +2 -1
  6. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/pyproject.toml +2 -2
  7. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/AUTHORS +0 -0
  8. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/LICENSE +0 -0
  9. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/README.md +0 -0
  10. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/__init__.py +0 -0
  11. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/cli_parser/provisioning_parser.py +0 -0
  12. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/config.py +0 -0
  13. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/cyber_range.py +0 -0
  14. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/logger.py +0 -0
  15. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/redteam_api.py +0 -0
  16. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/topology/TopologyElements.py +0 -0
  17. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/topology/TopologyGenerator.py +0 -0
  18. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/topology/TopologyLinksGenerator.py +0 -0
  19. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/user_activity_api.py +0 -0
  20. {cr_api_client-5.1.2 → cr_api_client-5.1.7}/cr_api_client/yaml_helper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cr_api_client
3
- Version: 5.1.2
3
+ Version: 5.1.7
4
4
  Summary: M&NTIS Cyber Range client API
5
5
  License: MIT
6
6
  License-File: AUTHORS
@@ -21,7 +21,7 @@ Requires-Dist: humanize (>=3.13.1,<4.0.0)
21
21
  Requires-Dist: jsonschema (==3.0.2)
22
22
  Requires-Dist: mantis-catalog (>=0.2.3,<0.3.0)
23
23
  Requires-Dist: mantis-logger (>=0.2.0,<0.3.0)
24
- Requires-Dist: mantis-models (>=3.4.23,<4.0.0)
24
+ Requires-Dist: mantis-models (==3.4.27)
25
25
  Requires-Dist: markupsafe (==2.0.1)
26
26
  Requires-Dist: omegaconf (>=2.2.2,<3.0.0)
27
27
  Requires-Dist: pydantic (>=2.10.3,<3.0.0)
@@ -821,7 +821,19 @@ def create_simulation_from_basebox(
821
821
  f"Cannot find basebox in database from basebox ID '{basebox_id}'"
822
822
  )
823
823
 
824
- node_name = "basebox"
824
+ # Get dependent baseboxes
825
+ depends_on = basebox.get("depends_on") or [] # Fallback if field is set to None
826
+ dependent_baseboxes = []
827
+ for dep_id in depends_on:
828
+ try:
829
+ dep_basebox = fetch_basebox(dep_id)
830
+ dependent_baseboxes.append(dep_basebox)
831
+ except Exception:
832
+ raise Exception(
833
+ f"Cannot find dependent basebox in database from basebox ID '{dep_id}'"
834
+ )
835
+
836
+ node_name = basebox.get("hostname") or "basebox" # Fallback if field is set to None
825
837
  role = basebox["role"]
826
838
  nb_proc = basebox["nb_proc"]
827
839
  memory_size = basebox["memory_size"]
@@ -847,6 +859,26 @@ nodes:
847
859
  roles: ["{role}"]
848
860
  """
849
861
 
862
+ # Add dependent baseboxes as nodes
863
+ ip_offset = 3 # Start at 192.168.2.3 (2 is used by main basebox)
864
+ for dep_basebox in dependent_baseboxes:
865
+ dep_id = dep_basebox["id"]
866
+ dep_name = (
867
+ dep_basebox.get("hostname") or dep_id.split("/")[-1].replace("_", "")
868
+ ) # Fallback if field is set to None, and ensure the derived name is consistent (we only keep the last part of the basebox ID, withouth the underscore)
869
+ dep_role = dep_basebox["role"]
870
+ dep_nb_proc = dep_basebox["nb_proc"]
871
+ dep_memory_size = dep_basebox["memory_size"]
872
+ yaml_content += f"""
873
+ - &depends_{dep_id.replace("/", "_").replace(".", "_")}
874
+ type: virtual_machine
875
+ name: "{dep_name}"
876
+ basebox_id: "{dep_id}"
877
+ nb_proc: {dep_nb_proc}
878
+ memory_size: {dep_memory_size}
879
+ roles: ["{dep_role}"]
880
+ """
881
+
850
882
  if add_host:
851
883
  yaml_content += """
852
884
  - &host_machine
@@ -893,12 +925,33 @@ links:
893
925
  ip: "192.168.2.2/24"
894
926
  """
895
927
 
928
+ # Add links for dependent baseboxes
929
+ ip_offset = 3
930
+ for dep_basebox in dependent_baseboxes:
931
+ dep_name = dep_basebox["id"]
932
+ anchor_name = f"depends_{dep_name.replace('/', '_').replace('.', '_')}"
933
+ yaml_content += f"""
934
+ - switch: *switch
935
+ node: *{anchor_name}
936
+ params:
937
+ ip: "192.168.2.{ip_offset}/24"
938
+ """
939
+ ip_offset += 1
940
+
941
+ # Calculate IP for host machine (after all dependent baseboxes if any)
942
+ host_ip_offset = (
943
+ ip_offset if add_host and dependent_baseboxes else (3 if add_host else None)
944
+ )
945
+
896
946
  if add_host:
897
- yaml_content += """
947
+ host_ip = (
948
+ f"192.168.2.{host_ip_offset}/24" if host_ip_offset else "192.168.2.3/24"
949
+ )
950
+ yaml_content += f"""
898
951
  - switch: *switch
899
952
  node: *host_machine
900
953
  params:
901
- ip: "192.168.2.3/24"
954
+ ip: "{host_ip}"
902
955
  """
903
956
 
904
957
  if add_internet:
@@ -62,7 +62,7 @@ def _post(route: str, **kwargs: Any) -> Any:
62
62
  f"{cr_api_client_config.provisioning_api_url}{route}",
63
63
  verify=cr_api_client_config.cacert,
64
64
  cert=(cr_api_client_config.cert, cr_api_client_config.key),
65
- timeout=60, # Set 60s to allow transfer of large zip files
65
+ timeout=300, # Set 300s to allow transfer of large zip files
66
66
  **kwargs,
67
67
  )
68
68
 
@@ -9,12 +9,13 @@
9
9
  #
10
10
  from random import choice
11
11
 
12
+ from mantis_scenario_model.common import RoleEnum
13
+ from mantis_scenario_model.node import TypeEnum
14
+
12
15
  from cr_api_client.topology.TopologyElements import PhysicalGateway
13
16
  from cr_api_client.topology.TopologyElements import Router
14
17
  from cr_api_client.topology.TopologyElements import Switch
15
18
  from cr_api_client.topology.TopologyElements import VirtualMachine
16
- from mantis_scenario_model.common import RoleEnum
17
- from mantis_scenario_model.node import TypeEnum
18
19
 
19
20
 
20
21
  MIN_NODE_COUNT = 3 # 1 switch, 1 router and 1 machine (client or server)
@@ -9,10 +9,11 @@
9
9
  #
10
10
  from random import choice
11
11
 
12
- from cr_api_client.topology.TopologyNodeGenerator import NodeGenerator
13
12
  from mantis_scenario_model.common import RoleEnum
14
13
  from mantis_scenario_model.node import TypeEnum
15
14
 
15
+ from cr_api_client.topology.TopologyNodeGenerator import NodeGenerator
16
+
16
17
 
17
18
  class NodesGenerator:
18
19
  def __init__(self, os_container):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cr_api_client"
3
- version = "5.1.2"
3
+ version = "5.1.7"
4
4
  description = "M&NTIS Cyber Range client API"
5
5
  readme = "README.md"
6
6
  authors = ["AMOSSYS"]
@@ -23,7 +23,7 @@ markupsafe = "2.0.1" # Need to fix version
23
23
  omegaconf = "^2.2.2"
24
24
  types-jinja2 = "^2.11.9" # Needed for typing and mypy, remove when updating to Jinja2 version 3 or more
25
25
  jsonschema = "3.0.2" # Needed to fix importlib not found error
26
- mantis-models = { version = "^3.4.23", source = "gitlab" }
26
+ mantis-models = {version = "3.4.27", source = "gitlab"}
27
27
  mantis-logger = { version = "^0.2.0", source = "gitlab" }
28
28
  mantis-catalog = { version = "^0.2.3", source = "gitlab" }
29
29
 
File without changes
File without changes
File without changes