ThePorgs / Exegol

Fully featured and community-driven hacking environment
https://exegol.readthedocs.io/
GNU General Public License v3.0
1.95k stars 191 forks source link

TypeError on Custom network mode VPN #202

Closed ShutdownRepo closed 9 months ago

ShutdownRepo commented 9 months ago

Describe the bug

TypeError: unsupported operand type(s) for +=: 'bool' and 'str' when --vpn

Steps To Reproduce

exegol start forest nightly --vpn ~/Downloads/lab_Shutdown.ovpn --disable-X11 --desktop

[...]

[?] Are you sure you want to configure a VPN container based on the host's network? [y/N]:N

[...]

[*] Press enter to continue or Ctrl+C to cancel the operation

[ENTER]

[...]

[ERROR]

Exegol Wrapper Version

$ exegol start forest nightly --vpn ~/Downloads/lab_Shutdown.ovpn --disable-X11 --desktop
[*] Exegol is currently in version v4.3.2b1 [7caf4787]
[*] Exegol Discord serv.: https://discord.gg/cXThyp7D6P
[*] Exegol documentation: https://exegol.rtfd.io/
[+] We thank Capgemini for supporting the project (helping with dev) 🙏
[+] We thank HackTheBox for sponsoring the multi-arch support 💚

[!] You are currently using a Beta version of Exegol, which may be unstable.
[*] Starting exegol
[*] Arguments supplied with the command, skipping interactive mode
[-] The host's timezone could not be shared: Orbstack doesn't support sharing /etc files with the container
[!] Using the host network mode with a VPN profile is not recommended.
[?] Are you sure you want to configure a VPN container based on the host's network? [y/N]:N
[*] Changing network mode to custom
[!] Some OpenVPN config are missing to support VPN dynamic DNS servers! Please add the following line to your configuration file:

script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

[*] Press enter to continue or Ctrl+C to cancel the operation

[-] The current network mode doesn't support the desktop feature.
[-] It seems that something unexpected happened ...
[-] To draw our attention to the problem and allow us to fix it, you can share your error with us (by copying and pasting it with this syntax: ``` <error> ```) by creating a GitHub issue at this address: https://github.com/ThePorgs/Exegol/issues
[+] Thank you for your collaboration!
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/charlie/Projects/Exegol/exegol/manager/ExegolManager.py:396 in __loadOrCreateContainer    │
│                                                                                                  │
│   393 │   │   │   │   │   │   │   │   raise NotImplemented                                       │
│   394 │   │   │   │   else:                                                                      │
│   395 │   │   │   │   │   assert container_tag is not None                                       │
│ ❱ 396 │   │   │   │   │   cls.__container = DockerUtils.getContainer(container_tag)              │
│   397 │   │   except (ObjectNotFound, IndexError):                                               │
│   398 │   │   │   # ObjectNotFound is raised when the container_tag provided by the user does    │
│   399 │   │   │   # IndexError is raise when no container exist (raised from TUI interactive s   │
│                                                                                                  │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮                    │
│ │                cls = <class 'exegol.manager.ExegolManager.ExegolManager'> │                    │
│ │      container_tag = 'forest'                                             │                    │
│ │     container_tags = None                                                 │                    │
│ │           multiple = False                                                │                    │
│ │         must_exist = False                                                │                    │
│ │ override_container = None                                                 │                    │
│ ╰───────────────────────────────────────────────────────────────────────────╯                    │
│                                                                                                  │
│ /Users/charlie/Projects/Exegol/exegol/utils/DockerUtils.py:185 in getContainer                   │
│                                                                                                  │
│   182 │   │   │   │   lowered_tag = tag.lower()                                                  │
│   183 │   │   │   │   if lowered_tag != tag:                                                     │
│   184 │   │   │   │   │   return cls.getContainer(lowered_tag)                                   │
│ ❱ 185 │   │   │   raise ObjectNotFound                                                           │
│   186 │   │   # Filter results with exact name matching                                          │
│   187 │   │   for c in container:                                                                │
│   188 │   │   │   if c.name == f"exegol-{tag}":                                                  │
│                                                                                                  │
│ ╭─────────────────────────── locals ───────────────────────────╮                                 │
│ │         cls = <class 'exegol.utils.DockerUtils.DockerUtils'> │                                 │
│ │   container = []                                             │                                 │
│ │ lowered_tag = 'forest'                                       │                                 │
│ │         tag = 'forest'                                       │                                 │
│ ╰──────────────────────────────────────────────────────────────╯                                 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ObjectNotFound

During handling of the above exception, another exception occurred:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/charlie/Projects/Exegol/exegol/manager/ExegolController.py:61 in main                     │
│                                                                                                  │
│   58 │   │   # Set logger verbosity depending on user input                                      │
│   59 │   │   ExeLog.setVerbosity(ParametersManager().verbosity, ParametersManager().quiet)       │
│   60 │   │   # Start Main controller & Executing action selected by user CLI                     │
│ ❱ 61 │   │   ExegolController.call_action()                                                      │
│   62 │   except KeyboardInterrupt:                                                               │
│   63 │   │   logger.empty_line()                                                                 │
│   64 │   │   logger.info("Exiting")                                                              │
│                                                                                                  │
│ /Users/charlie/Projects/Exegol/exegol/manager/ExegolController.py:41 in call_action              │
│                                                                                                  │
│   38 │   │   │   # Fetch main operation function                                                 │
│   39 │   │   │   main_action = cls.__action()                                                    │
│   40 │   │   │   # Execute main function                                                         │
│ ❱ 41 │   │   │   main_action()                                                                   │
│   42 │   │   else:                                                                               │
│   43 │   │   │   # TODO review required parameters                                               │
│   44 │   │   │   logger.error(f"These parameters are mandatory but missing: {','.join(missing    │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │            cls = <class 'exegol.manager.ExegolController.ExegolController'>                  │ │
│ │    main_action = <bound method ExegolManager.start of <class                                 │ │
│ │                  'exegol.manager.ExegolManager.ExegolManager'>>                              │ │
│ │ missing_params = []                                                                          │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /Users/charlie/Projects/Exegol/exegol/manager/ExegolManager.py:77 in start                       │
│                                                                                                  │
│    74 │   │   cls.__interactive_mode = not bool(ParametersManager().containertag)                │
│    75 │   │   if not cls.__interactive_mode:                                                     │
│    76 │   │   │   logger.info("Arguments supplied with the command, skipping interactive mode"   │
│ ❱  77 │   │   container = cls.__loadOrCreateContainer()                                          │
│    78 │   │   assert container is not None and type(container) is ExegolContainer                │
│    79 │   │   if not container.isNew():                                                          │
│    80 │   │   │   # Check and warn user if some parameters don't apply to the current session    │
│                                                                                                  │
│ ╭────────────────────────── locals ──────────────────────────╮                                   │
│ │ cls = <class 'exegol.manager.ExegolManager.ExegolManager'> │                                   │
│ ╰────────────────────────────────────────────────────────────╯                                   │
│                                                                                                  │
│ /Users/charlie/Projects/Exegol/exegol/manager/ExegolManager.py:404 in __loadOrCreateContainer    │
│                                                                                                  │
│   401 │   │   │   if must_exist:                                                                 │
│   402 │   │   │   │   logger.warning(f"The container named '{container_tag}' has not been foun   │
│   403 │   │   │   │   return [] if multiple else None                                            │
│ ❱ 404 │   │   │   return cls.__createContainer(container_tag)                                    │
│   405 │   │   assert cls.__container is not None                                                 │
│   406 │   │   return cast(Union[Optional[ExegolContainer], List[ExegolContainer]], cls.__conta   │
│   407                                                                                            │
│                                                                                                  │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮                    │
│ │                cls = <class 'exegol.manager.ExegolManager.ExegolManager'> │                    │
│ │      container_tag = 'forest'                                             │                    │
│ │     container_tags = None                                                 │                    │
│ │           multiple = False                                                │                    │
│ │         must_exist = False                                                │                    │
│ │ override_container = None                                                 │                    │
│ ╰───────────────────────────────────────────────────────────────────────────╯                    │
│                                                                                                  │
│ /Users/charlie/Projects/Exegol/exegol/manager/ExegolManager.py:503 in __createContainer          │
│                                                                                                  │
│   500 │   │   model = ExegolContainerTemplate(name, config, image, hostname=ParametersManager(   │
│   501 │   │                                                                                      │
│   502 │   │   # Recap                                                                            │
│ ❱ 503 │   │   ExegolTUI.printContainerRecap(model)                                               │
│   504 │   │   if cls.__interactive_mode:                                                         │
│   505 │   │   │   if not model.image.isUpToDate() and \                                          │
│   506 │   │   │   │   │   Confirm("Do you want to [green]update[/green] the selected image?",    │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │    cls = <class 'exegol.manager.ExegolManager.ExegolManager'>                                │ │
│ │ config = <exegol.model.ContainerConfig.ContainerConfig object at 0x10136c650>                │ │
│ │  image = nightly (58d605bb/58d605bb arm64) - 49.8GB - ([green]Up to date                     │ │
│ │          (v.58d605bb)[/green], [bright_black]N/A[/bright_black])                             │ │
│ │  model = <exegol.model.ExegolContainerTemplate.ExegolContainerTemplate object at             │ │
│ │          0x102578590>                                                                        │ │
│ │   name = 'forest'                                                                            │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /Users/charlie/Projects/Exegol/exegol/console/TUI.py:407 in printContainerRecap                  │
│                                                                                                  │
│   404 │   │   # Load the image status if it is not already set.                                  │
│   405 │   │   container.image.autoLoad()                                                         │
│   406 │   │                                                                                      │
│ ❱ 407 │   │   recap = cls.__buildContainerRecapTable(container)                                  │
│   408 │   │                                                                                      │
│   409 │   │   logger.empty_line()                                                                │
│   410 │   │   console.print(recap)                                                               │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │       cls = <class 'exegol.console.TUI.ExegolTUI'>                                           │ │
│ │ container = <exegol.model.ExegolContainerTemplate.ExegolContainerTemplate object at          │ │
│ │             0x102578590>                                                                     │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /Users/charlie/Projects/Exegol/exegol/console/TUI.py:458 in __buildContainerRecapTable           │
│                                                                                                  │
│   455 │   │   if creation_date:                                                                  │
│   456 │   │   │   recap.add_row("[bold blue]Creation date[/bold blue]", creation_date)           │
│   457 │   │   recap.add_row("[bold blue]X11[/bold blue]", boolFormatter(container.config.isGUI   │
│ ❱ 458 │   │   recap.add_row("[bold blue]Network[/bold blue]", container.config.getTextNetworkM   │
│   459 │   │   recap.add_row("[bold blue]Timezone[/bold blue]", boolFormatter(container.config.   │
│   460 │   │   recap.add_row("[bold blue]Exegol resources[/bold blue]", boolFormatter(container   │
│   461 │   │   │   │   │     f"{'[bright_black](/opt/resources)[/bright_black]' if container.co   │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │          capabilities = ['NET_ADMIN']                                                        │ │
│ │               comment = None                                                                 │ │
│ │             container = <exegol.model.ExegolContainerTemplate.ExegolContainerTemplate object │ │
│ │                         at 0x102578590>                                                      │ │
│ │ container_info_header = 'forest\nnightly - v.58d605bb ([green]Up to date[/green])'           │ │
│ │         creation_date = ''                                                                   │ │
│ │               devices = '/dev/net/tun\n'                                                     │ │
│ │                  envs = ''                                                                   │ │
│ │                passwd = 'EeuQGtiRhQKdsjUrKk9qXKOU9T2VbZ'                                     │ │
│ │            path_color = 'magenta'                                                            │ │
│ │                 ports = ''                                                                   │ │
│ │       privilege_color = 'bright_magenta'                                                     │ │
│ │                 recap = <rich.table.Table object at 0x1030bef50>                             │ │
│ │               sysctls = {'net.ipv6.conf.all.disable_ipv6': '0'}                              │ │
│ │               volumes = '/Users/charlie/Downloads/lab_Shutdown.ovpn :right_arrow:            │ │
│ │                         /.exegol/vpn/config/cli'+9                                           │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /Users/charlie/Projects/Exegol/exegol/model/ContainerConfig.py:1345 in getTextNetworkMode        │
│                                                                                                  │
│   1342 │   │   elif network_mode == "none":                                                      │
│   1343 │   │   │   network_mode = "disable"                                                      │
│   1344 │   │   if self.__vpn_path:                                                               │
│ ❱ 1345 │   │   │   network_mode += " with VPN"                                                   │
│   1346 │   │   return network_mode                                                               │
│   1347 │                                                                                         │
│   1348 │   def getTextCreationDate(self) -> str:                                                 │
│                                                                                                  │
│ ╭────────────────────────────────────── locals ───────────────────────────────────────╮          │
│ │ network_mode = False                                                                │          │
│ │         self = <exegol.model.ContainerConfig.ContainerConfig object at 0x10136c650> │          │
│ ╰─────────────────────────────────────────────────────────────────────────────────────╯          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: unsupported operand type(s) for +=: 'bool' and 'str'

### Host OS

None

### Configuration of the concerned container

_No response_

### Execution logs in debug mode

```Text
N/A

Exception

No response

Anything else?

No response

ShutdownRepo commented 9 months ago

Layer 8 problem PBCK, I'm a lama