jedha-cli 3.4.0__tar.gz → 3.5.0__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 (81) hide show
  1. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/PKG-INFO +1 -1
  2. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/pyproject.toml +1 -1
  3. jedha_cli-3.5.0/src/labs/hello/docker-compose.prod.yaml +15 -0
  4. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/intro-to-ethical-hacking-workshop/docker-compose.prod.yaml +2 -5
  5. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs.yaml +5 -0
  6. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/main.py +95 -46
  7. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/misc.py +11 -0
  8. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/LICENSE +0 -0
  9. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/README.md +0 -0
  10. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/__init__.py +0 -0
  11. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M01D01-cron-and-more/docker-compose.prod.yaml +0 -0
  12. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M01D01-my-first-ctf/docker-compose.prod.yaml +0 -0
  13. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M01D01-processes/docker-compose.prod.yaml +0 -0
  14. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M01D01-user-management/docker-compose.prod.yaml +0 -0
  15. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M01D02-cron-jobs/docker-compose.prod.yaml +0 -0
  16. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M01D02-permission-ctf/docker-compose.prod.yaml +0 -0
  17. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M02D01-osi-i-to-iv/docker-compose.prod.yaml +0 -0
  18. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M02D02-nmap-ctf/docker-compose.prod.yaml +0 -0
  19. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M03D01-imdb-db/docker-compose.prod.yaml +0 -0
  20. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M03D01-weblab/docker-compose.prod.yaml +0 -0
  21. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M03D02-vuln-web-app/docker-compose.prod.yaml +0 -0
  22. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M04-little-big-ctf/docker-compose.prod.yaml +0 -0
  23. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBE-M05-rs6092/docker-compose.prod.yaml +0 -0
  24. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M04-sql-ex/docker-compose.prod.yaml +0 -0
  25. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M04D02-sql-misconf/docker-compose.prod.yaml +0 -0
  26. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M05-dvwa/docker-compose.prod.yaml +0 -0
  27. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M05D02-template-injection/docker-compose.prod.yaml +0 -0
  28. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M05D03-csrf-demo/docker-compose.prod.yaml +0 -0
  29. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M05D03-csrf-password-change/docker-compose.prod.yaml +0 -0
  30. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M05D03-jwt-auth-bypass/docker-compose.prod.yaml +0 -0
  31. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M05D03-jwt-integrity/docker-compose.prod.yaml +0 -0
  32. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M08D01-exploit-user/docker-compose.prod.yaml +0 -0
  33. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M08D01-sudo1/docker-compose.prod.yaml +0 -0
  34. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M08D01-suid2/docker-compose.prod.yaml +0 -0
  35. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M08D02-linux-privesc/docker-compose.prod.yaml +0 -0
  36. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M08D02-suid/docker-compose.prod.yaml +0 -0
  37. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M08D05-docker-evasion/docker-compose.prod.yaml +0 -0
  38. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M08D07-ldap-compromission/docker-compose.prod.yaml +0 -0
  39. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M09D01-manual-audit/docker-compose.prod.yaml +0 -0
  40. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M09D04-windows-box/docker-compose.prod.yaml +0 -0
  41. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M15D01-msf1/docker-compose.prod.yaml +0 -0
  42. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBFS-M15D01-msf2/docker-compose.prod.yaml +0 -0
  43. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBL-M03D02-ariake-technologies/docker-compose.prod.yaml +0 -0
  44. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBL-M03D03-alterra-api/docker-compose.prod.yaml +0 -0
  45. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBL-M03D03-alterra-biometrics/docker-compose.prod.yaml +0 -0
  46. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBL-M03D03-ibc-web-app/docker-compose.prod.yaml +0 -0
  47. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBL-M03D04-decima-idor/docker-compose.prod.yaml +0 -0
  48. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBL-M03D05-ibc-news/docker-compose.prod.yaml +0 -0
  49. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBL-M03D06-ibc-ci-cd/docker-compose.prod.yaml +0 -0
  50. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/CYBL-M04D01-rocicorp/docker-compose.prod.yaml +0 -0
  51. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/decrypt-the-death-star-plans/docker-compose.prod.yaml +0 -0
  52. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/gash/docker-compose.prod.yaml +0 -0
  53. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/idor/docker-compose.prod.yaml +0 -0
  54. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/insecure_design/docker-compose.prod.yaml +0 -0
  55. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/nfs_server/docker-compose.prod.yaml +0 -0
  56. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/nfs_server/nfs_server_volume/YOUNEVERGOTME/flag.txt +0 -0
  57. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/path_traversal/docker-compose.prod.yaml +0 -0
  58. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/pentesting_network_services/docker-compose.prod.yaml +0 -0
  59. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/pivoting/docker-compose.prod.yaml +0 -0
  60. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/pivoting-introduction/docker-compose.prod.yaml +0 -0
  61. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/proxmark/docker-compose.prod.yaml +0 -0
  62. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/reverse/docker-compose.prod.yaml +0 -0
  63. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/sambacry/docker-compose.prod.yaml +0 -0
  64. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/security_misconfiguration/docker-compose.prod.yaml +0 -0
  65. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/shellshock/docker-compose.prod.yaml +0 -0
  66. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/smb_server/docker-compose.prod.yaml +0 -0
  67. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/smb_server/smb_server_volume/.gitignore +0 -0
  68. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/smb_server/smb_server_volume/share/flag1.txt +0 -0
  69. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/smb_server/smb_server_volume/share/goes/flag4.txt +0 -0
  70. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/smb_server/smb_server_volume/share/sherclock/flag2.txt +0 -0
  71. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/smb_server/smb_server_volume/share/time/flag3.txt +0 -0
  72. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/smb_server/smb_server_volume/smb.conf +0 -0
  73. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/sqli/docker-compose.prod.yaml +0 -0
  74. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/ssrf/docker-compose.prod.yaml +0 -0
  75. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/sudo_2/docker-compose.prod.yaml +0 -0
  76. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/sudo_3/docker-compose.prod.yaml +0 -0
  77. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/the-lost-lightsaber/docker-compose.prod.yaml +0 -0
  78. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/vim_fu/docker-compose.prod.yaml +0 -0
  79. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/vulnerable_and_outdated_software/docker-compose.prod.yaml +0 -0
  80. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/wifi_wpa2_cracking/docker-compose.prod.yaml +0 -0
  81. {jedha_cli-3.4.0 → jedha_cli-3.5.0}/src/labs/xss/docker-compose.prod.yaml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jedha-cli
3
- Version: 3.4.0
3
+ Version: 3.5.0
4
4
  Summary: A CLI to start cybersecurity labs and practice your skills
5
5
  License-File: LICENSE
6
6
  Author: ademenet
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "jedha-cli"
3
- version = "3.4.0"
3
+ version = "3.5.0"
4
4
  description = "A CLI to start cybersecurity labs and practice your skills"
5
5
  authors = ["ademenet <alain@jedha.co>"]
6
6
  readme = "README.md"
@@ -0,0 +1,15 @@
1
+ services:
2
+ hello:
3
+ container_name: hello
4
+ image: jedha/lab-hello
5
+ networks:
6
+ lab-network:
7
+ ipv4_address: 11.10.10.99
8
+
9
+ networks:
10
+ lab-network:
11
+ driver: bridge
12
+ ipam:
13
+ driver: default
14
+ config:
15
+ - subnet: 11.10.10.0/24
@@ -1,13 +1,10 @@
1
1
  services:
2
2
  lab_intro_to_ethical_hacking:
3
3
  container_name: lab-intro-to-ethical-hacking
4
- image: jedha/introduction-to-ethical-hacking-lab
4
+ image: jedha/lab-intro-to-ethical-hacking-workshop
5
5
  networks:
6
6
  lab-network:
7
7
  ipv4_address: 64.10.11.12
8
- ports:
9
- - "22:22"
10
- - "80:80"
11
8
 
12
9
  networks:
13
10
  lab-network:
@@ -15,4 +12,4 @@ networks:
15
12
  ipam:
16
13
  driver: default
17
14
  config:
18
- - subnet: 64.10.11.0/24
15
+ - subnet: 64.10.11.0/24
@@ -1,3 +1,8 @@
1
+ - name: hello
2
+ ip: "11.10.10.99"
3
+ description: "Test that your jedha-cli installation works!"
4
+ folder: hello
5
+
1
6
  - name: cron-and-more
2
7
  ip: "10.10.10.16"
3
8
  description: 'Find the 6 flags (username: "root", password: "password")'
@@ -2,7 +2,7 @@
2
2
 
3
3
  import os
4
4
  import subprocess
5
- from typing import Annotated, List, Optional
5
+ from typing import Annotated, Optional
6
6
 
7
7
  import typer
8
8
  from rich import print
@@ -10,8 +10,9 @@ from rich.console import Console
10
10
  from rich.table import Table
11
11
  from yaml import safe_load
12
12
 
13
- from .misc import (check_for_updates, cleanup_lab, get_docker_compose_command,
14
- get_lab_config_file, get_lab_folder_name, get_running_labs,
13
+ from .misc import (check_for_updates, cleanup_lab, current_installed_version,
14
+ get_docker_compose_command, get_lab_config_file,
15
+ get_lab_folder_name, get_lab_ip, get_running_labs,
15
16
  get_yaml_labs, is_docker_running, is_lab_already_running)
16
17
 
17
18
  app = typer.Typer(
@@ -19,28 +20,50 @@ app = typer.Typer(
19
20
  help="""
20
21
  A CLI to manage the labs for Cybersecurity Bootcamp at Jedha (https://jedha.co).
21
22
 
22
- ⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n
23
- ⠀⠀⠀⠀⣠⣧⠷⠆⠀⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀\n
24
- ⠀⠀⣐⣢⣤⢖⠒⠪⣭⣶⣿⣦⠀⠀⠀⠀⠀⠀⠀\n
25
- ⠀⢸⣿⣿⣿⣌⠀⢀⣿⠁⢹⣿⡇⠀⠀⠀⠀⠀⠀\n
26
- ⠀⢸⣿⣿⣿⣿⣿⡿⠿⢖⡪⠅⢂⠀⠀⠀⠀⠀⠀\n
27
- ⠀⠀⢀⣔⣒⣒⣂⣈⣉⣄⠀⠺⣿⠿⣦⡀⠀⠀⠀\n
28
- ⠀⡴⠛⣉⣀⡈⠙⠻⣿⣿⣷⣦⣄⠀⠛⠻⠦⠀⠀\n
29
- ⡸⠁⢾⣿⣿⣁⣤⡀⠹⣿⣿⣿⣿⣿⣷⣶⣶⣤⠀\n
30
- ⡇⣷⣿⣿⣿⣿⣿⡇⠀⣿⣿⣿⣿⣿⣿⡿⠿⣿⡀\n
31
- ⡇⢿⣿⣿⣿⣟⠛⠃⠀⣿⣿⣿⡿⠋⠁⣀⣀⡀⠃\n
32
- ⢻⡌⠀⠿⠿⠿⠃⠀⣼⣿⣿⠟⠀⣠⣄⣿⣿⡣⠀\n
33
- ⠈⢿⣶⣤⣤⣤⣴⣾⣿⣿⡏⠀⣼⣿⣿⣿⡿⠁⠀\n
34
- ⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⠀⠀⣩⣿⡿⠋⠀⠀⠀\n
35
- ⠀⠀⠀⠀⠈⠙⠛⠿⠿⠿⠇⠀⠉⠁⠀⠀⠀⠀⠀\n
23
+ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀===========⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n
24
+ ⠀⠀⠀⠀⠀⠀⠀⠀==================⠀⠀⠀⠀⠀⠀⠀⠀\n
25
+ ⠀⠀⠀⠀⠀⠀=======⠀⠀⠀⠀⠀⠀⠀⠀=======⠀⠀⠀⠀⠀⠀\n
26
+ ⠀⠀⠀⠀⠀+++==⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀====⠀⠀⠀⠀⠀\n
27
+ ⠀⠀⠀⠀***+⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀====⠀⠀==\n
28
+ ⠀⠀⠀⠀***⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀=====⠀⠀\n
29
+ ⠀⠀⠀****⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀===========⠀⠀⠀\n
30
+ ⠀⠀⠀****⠀⠀⠀⠀⠀⠀⠀++======⠀⠀⠀⠀⠀====⠀⠀⠀\n
31
+ ⠀⠀⠀⠀⠀⠀⠀********+++⠀⠀⠀⠀⠀⠀⠀⠀⠀====⠀⠀⠀\n
32
+ **************⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀====⠀⠀⠀⠀\n
33
+ ⠀⠀⠀⠀⠀*****⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀====⠀⠀⠀⠀⠀\n
34
+ ⠀⠀⠀⠀⠀⠀*******⠀⠀⠀⠀⠀⠀⠀⠀+++====⠀⠀⠀⠀⠀⠀\n
35
+ ⠀⠀⠀⠀⠀⠀⠀⠀**************++++⠀⠀⠀⠀⠀⠀⠀⠀\n
36
+ ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀***********⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n
36
37
  """,
37
38
  epilog="Made with ❤️ by the Jedha Bootcamp Team",
38
39
  no_args_is_help=True,
40
+ add_completion=False,
39
41
  )
40
42
 
41
43
  console = Console()
42
44
 
43
45
 
46
+ def version_callback(value: bool):
47
+ if value:
48
+ print(f"jedha-cli {current_installed_version()}")
49
+ raise typer.Exit()
50
+
51
+
52
+ @app.callback()
53
+ def main_callback(
54
+ version: Annotated[
55
+ Optional[bool],
56
+ typer.Option(
57
+ "--version",
58
+ callback=version_callback,
59
+ is_eager=True,
60
+ help="Show the jedha-cli version and exit.",
61
+ ),
62
+ ] = None,
63
+ ):
64
+ pass
65
+
66
+
44
67
  # @app.command("config", help="Configure the CLI.")
45
68
  # def config():
46
69
  # """
@@ -61,40 +84,39 @@ def list():
61
84
  console.print(table)
62
85
 
63
86
 
64
- @app.command("dl", help="Download (but not start) one or more lab(s) environment.")
65
- def download(labnames: List[str]):
87
+ @app.command("dl", help="Download (but not start) a lab: useful if it's been updated.")
88
+ def download(labname: str):
66
89
  """
67
90
  Download a lab.
68
91
 
69
92
  Args:
70
- labnames (List[str]): List of the lab names.
93
+ labname (str): Name of the lab.
71
94
  """
72
95
  if not is_docker_running():
73
96
  print("Docker is not running. Please start Docker and try again.")
74
97
  raise typer.Exit(1)
75
98
 
76
- for labname in labnames:
77
- actual_labname = get_lab_folder_name(labname)
99
+ actual_labname = get_lab_folder_name(labname)
78
100
 
79
- lab_config_file_path = get_lab_config_file(actual_labname)
80
- if not lab_config_file_path or not os.path.exists(lab_config_file_path):
81
- print(f"Are you sure about the lab name? We don't know any {labname}... 🤔")
82
- return
101
+ lab_config_file_path = get_lab_config_file(actual_labname)
102
+ if not lab_config_file_path or not os.path.exists(lab_config_file_path):
103
+ print(f"Are you sure about the lab name? We don't know any {labname}... 🤔")
104
+ return
83
105
 
84
- try:
85
- command = get_docker_compose_command(["--file", lab_config_file_path, "pull"])
86
- subprocess.run(
87
- command,
88
- check=True,
89
- )
90
- print(f"Lab {labname} downloaded successfully.")
91
- except subprocess.CalledProcessError as e:
92
- print(f"Failed to download lab {labname}.")
106
+ try:
107
+ command = get_docker_compose_command(["--file", lab_config_file_path, "pull"])
108
+ subprocess.run(
109
+ command,
110
+ check=True,
111
+ )
112
+ print(f"Lab {labname} downloaded successfully.")
113
+ except subprocess.CalledProcessError as e:
114
+ print(f"Failed to download lab {labname}.")
93
115
 
94
116
 
95
117
  @app.command(
96
118
  "status",
97
- help="Show the running labs. If a lab name is provided, it will show the status of that lab.",
119
+ help="Show the running lab. If a lab name is provided, it will show the status of that lab.",
98
120
  )
99
121
  def status(labname: Annotated[Optional[str], typer.Argument()] = None):
100
122
  """
@@ -112,8 +134,11 @@ def status(labname: Annotated[Optional[str], typer.Argument()] = None):
112
134
  if labname is None:
113
135
  running_labs = get_running_labs()
114
136
  if running_labs:
137
+ running_lab = next(iter(running_labs))
138
+ lab_ip = get_lab_ip(running_lab)
139
+ ip_suffix = f" on IP {lab_ip}" if lab_ip else ""
115
140
  print(
116
- f"🔍 You have the following running labs: [b]{', '.join(running_labs)}[/b]."
141
+ f"🔍 You have the following running lab: [b]{running_lab}[/b]{ip_suffix}."
117
142
  )
118
143
  else:
119
144
  print("☕️ No labs are currently running.")
@@ -128,7 +153,10 @@ def status(labname: Annotated[Optional[str], typer.Argument()] = None):
128
153
 
129
154
  with open(lab_config_file_path, "r") as file:
130
155
  docker_compose = safe_load(file)
131
- expected_containers = set(docker_compose["services"].keys())
156
+ expected_containers = set(
157
+ service.get("container_name", key)
158
+ for key, service in docker_compose["services"].items()
159
+ )
132
160
 
133
161
  try:
134
162
  command = get_docker_compose_command(
@@ -140,11 +168,12 @@ def status(labname: Annotated[Optional[str], typer.Argument()] = None):
140
168
  running_containers = set(
141
169
  line.split()[0] for line in container_lines if "Up" in line
142
170
  )
143
-
144
171
  if not running_containers:
145
172
  print(f"😴 {labname} is not running")
146
173
  elif running_containers == expected_containers:
147
- print(f"✅ {labname} is running as expected")
174
+ lab_ip = get_lab_ip(labname)
175
+ ip_suffix = f" on IP {lab_ip}" if lab_ip else ""
176
+ print(f"✅ {labname} is running as expected{ip_suffix}")
148
177
  else:
149
178
  failed_containers = expected_containers - running_containers
150
179
  print(
@@ -179,19 +208,39 @@ def start(labname: str):
179
208
 
180
209
  cleanup_lab(labname, lab_config_file_path)
181
210
 
211
+ # The "hello" lab is a one-shot smoke test: it prints its result straight to
212
+ # the terminal and exits, so it runs in the foreground and is torn down right after.
213
+ is_test_lab = labname == "hello"
214
+
182
215
  try:
183
- command = get_docker_compose_command(
184
- ["--file", lab_config_file_path, "-p", labname, "up", "-d"]
185
- )
216
+ up_args = ["--file", lab_config_file_path, "-p", labname, "up"]
217
+ if not is_test_lab:
218
+ up_args.append("-d")
219
+ command = get_docker_compose_command(up_args)
186
220
  subprocess.run(
187
221
  command,
188
222
  check=True,
189
223
  )
190
- print(f"Lab {labname} started successfully.")
224
+ if not is_test_lab:
225
+ print(f"Lab {labname} started successfully.")
191
226
  except subprocess.CalledProcessError as e:
192
227
  print(
193
228
  f"Failed to start lab {labname}: Error with the docker compose file or Docker itself"
194
229
  )
230
+ finally:
231
+ if is_test_lab:
232
+ down_command = get_docker_compose_command(
233
+ [
234
+ "--file",
235
+ lab_config_file_path,
236
+ "-p",
237
+ labname,
238
+ "down",
239
+ "--remove-orphans",
240
+ "--volumes",
241
+ ]
242
+ )
243
+ subprocess.run(down_command, check=False)
195
244
 
196
245
 
197
246
  @app.command("restart", help="Restart a lab.")
@@ -230,7 +279,7 @@ def restart(labname: str):
230
279
  )
231
280
 
232
281
 
233
- @app.command("stop", help="Stop and clean up a specific lab environment.")
282
+ @app.command("stop", help="Stop a specific lab environment.")
234
283
  def stop(
235
284
  labname: str,
236
285
  force: Annotated[
@@ -282,7 +331,7 @@ def stop(
282
331
 
283
332
  @app.command(
284
333
  "remove",
285
- help="Remove definitively a specific lab environment. Do it to free your disk space.",
334
+ help="Remove definitively a specific lab environment: useful to free some disk space.",
286
335
  )
287
336
  def remove(
288
337
  labname: str,
@@ -200,6 +200,17 @@ def get_lab_folder_name(labname: str) -> str:
200
200
  return None
201
201
 
202
202
 
203
+ def get_lab_ip(labname: str) -> Optional[str]:
204
+ """
205
+ Get the IP address of the lab as defined in labs.yaml.
206
+ """
207
+ yaml_labs = get_yaml_labs()
208
+ for lab in yaml_labs:
209
+ if lab["name"] == labname:
210
+ return lab.get("ip")
211
+ return None
212
+
213
+
203
214
  def get_running_labs() -> set[str]:
204
215
  """
205
216
  Get the list of running labs.
File without changes
File without changes
File without changes