microsoft / CyberBattleSim

An experimentation and research platform to investigate the interaction of automated agents in an abstract simulated network environments.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example agent doesn't work with conda install

Beauxrel opened this issue · comments

@beauxel Could you share the repro steps and the error you get?

landon@landon:~/Desktop/gitRepos/CyberBattleSim$ bash install-conda.sh

/home/landon/minico 100%[===================>] 98.44M 93.0MB/s in 1.1s

2023-09-02 09:13:57 (93.0 MB/s) - ‘/home/landon/miniconda3/miniconda.sh’ saved [103219356/103219356]

  • bash /home/landon/miniconda3/miniconda.sh -b -u -p /home/landon/miniconda3
    PREFIX=/home/landon/miniconda3
    Unpacking payload ...

Installing base environment...

Downloading and Extracting Packages

Preparing transaction: done
Executing transaction: done
installation finished.

  • rm -rf /home/landon/miniconda3/miniconda.sh
  • /home/landon/miniconda3/bin/conda init bash
    no change /home/landon/miniconda3/condabin/conda
    no change /home/landon/miniconda3/bin/conda
    no change /home/landon/miniconda3/bin/conda-env
    no change /home/landon/miniconda3/bin/activate
    no change /home/landon/miniconda3/bin/deactivate
    no change /home/landon/miniconda3/etc/profile.d/conda.sh
    no change /home/landon/miniconda3/etc/fish/conf.d/conda.fish
    no change /home/landon/miniconda3/shell/condabin/Conda.psm1
    no change /home/landon/miniconda3/shell/condabin/conda-hook.ps1
    no change /home/landon/miniconda3/lib/python3.11/site-packages/xontrib/conda.xsh
    no change /home/landon/miniconda3/etc/profile.d/conda.csh
    no change /home/landon/.bashrc
    No action taken.
  • /home/landon/miniconda3/bin/conda init zsh
    no change /home/landon/miniconda3/condabin/conda
    no change /home/landon/miniconda3/bin/conda
    no change /home/landon/miniconda3/bin/conda-env
    no change /home/landon/miniconda3/bin/activate
    no change /home/landon/miniconda3/bin/deactivate
    no change /home/landon/miniconda3/etc/profile.d/conda.sh
    no change /home/landon/miniconda3/etc/fish/conf.d/conda.fish
    no change /home/landon/miniconda3/shell/condabin/Conda.psm1
    no change /home/landon/miniconda3/shell/condabin/conda-hook.ps1
    no change /home/landon/miniconda3/lib/python3.11/site-packages/xontrib/conda.xsh
    no change /home/landon/miniconda3/etc/profile.d/conda.csh
    no change /home/landon/.zshrc
    No action taken.
    landon@landon:/Desktop/gitRepos/CyberBattleSim$ ls
    CODE_OF_CONDUCT.md cyberbattle docs init.ps1 install-conda.sh notebooks README.md requirements.txt SECURITY.md setup.py
    createstubs.sh Dockerfile env.yml init.sh LICENSE pyrightconfig.json requirements.dev.txt scripts setup.cfg SUPPORT.md
    landon@landon:
    /Desktop/gitRepos/CyberBattleSim$ bash init.sh
    ++ dirname init.sh
  • pushd .
    ~/Desktop/gitRepos/CyberBattleSim ~/Desktop/gitRepos/CyberBattleSim
  • conda info --envs

conda environments:

base /home/landon/miniconda3
esp /home/landon/miniconda3/envs/esp
nvdl /home/landon/miniconda3/envs/nvdl

++ conda shell.bash hook

  • eval 'export CONDA_EXE='''/home/landon/miniconda3/bin/conda'''
    export _CE_M=''''''
    export _CE_CONDA=''''''
    export CONDA_PYTHON_EXE='''/home/landon/miniconda3/bin/python'''

Copyright (C) 2012 Anaconda, Inc

SPDX-License-Identifier: BSD-3-Clause

__conda_exe() (
"$CONDA_EXE" $_CE_M $_CE_CONDA "$@"
)

__conda_hashr() {
if [ -n "${ZSH_VERSION:+x}" ]; then
\rehash
elif [ -n "${POSH_VERSION:+x}" ]; then
: # pass
else
\hash -r
fi
}

__conda_activate() {
if [ -n "${CONDA_PS1_BACKUP:+x}" ]; then
# Handle transition from shell activated with conda <= 4.3 to a subsequent activation
# after conda updated to >= 4.4. See issue #6173.
PS1="$CONDA_PS1_BACKUP"
\unset CONDA_PS1_BACKUP
fi
\local ask_conda
ask_conda="$(PS1="${PS1:-}" __conda_exe shell.posix "$@")" || \return
\eval "$ask_conda"
__conda_hashr
}

__conda_reactivate() {
\local ask_conda
ask_conda="$(PS1="${PS1:-}" __conda_exe shell.posix reactivate)" || \return
\eval "$ask_conda"
__conda_hashr
}

conda() {
\local cmd="${1-missing}"
case "$cmd" in
activate|deactivate)
__conda_activate "$@"
;;
install|update|upgrade|remove|uninstall)
__conda_exe "$@" || \return
__conda_reactivate
;;
*)
__conda_exe "$@"
;;
esac
}

if [ -z "${CONDA_SHLVL+x}" ]; then
\export CONDA_SHLVL=0
# In dev-mode CONDA_EXE is python.exe and on Windows
# it is in a different relative location to condabin.
if [ -n "${_CE_CONDA:+x}" ] && [ -n "${WINDIR+x}" ]; then
PATH="$(\dirname "$CONDA_EXE")/condabin${PATH:+":${PATH}"}"
else
PATH="$(\dirname "$(\dirname "$CONDA_EXE")")/condabin${PATH:+":${PATH}"}"
fi
\export PATH

# We'\''re not allowing PS1 to be unbound. It must at least be set.
# However, we'\''re not exporting it, which can cause problems when starting a second shell
# via a first shell (i.e. starting zsh from bash).
if [ -z "${PS1+x}" ]; then
    PS1=
fi

fi'
++ export CONDA_EXE=/home/landon/miniconda3/bin/conda
++ CONDA_EXE=/home/landon/miniconda3/bin/conda
++ export _CE_M=
++ _CE_M=
++ export _CE_CONDA=
++ _CE_CONDA=
++ export CONDA_PYTHON_EXE=/home/landon/miniconda3/bin/python
++ CONDA_PYTHON_EXE=/home/landon/miniconda3/bin/python
++ '[' -z x ']'

  • conda info --envs
  • local cmd=info
  • case "$cmd" in
  • __conda_exe info --envs
  • grep -q cybersim
  • /home/landon/miniconda3/bin/conda info --envs
  • conda env create -f env.yml
  • local cmd=env
  • case "$cmd" in
  • __conda_exe env create -f env.yml
  • /home/landon/miniconda3/bin/conda env create -f env.yml
    Traceback (most recent call last):
    File "/home/landon/miniconda3/lib/python3.11/site-packages/requests/compat.py", line 11, in
    import chardet
    ModuleNotFoundError: No module named 'chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/landon/miniconda3/bin/conda-env", line 6, in
from conda_env.cli.main import main
File "/home/landon/miniconda3/lib/python3.11/site-packages/conda_env/cli/main.py", line 17, in
from . import main_config, main_create, main_export, main_list, main_remove, main_update
File "/home/landon/miniconda3/lib/python3.11/site-packages/conda_env/cli/main_create.py", line 21, in
from conda.notices import notices
File "/home/landon/miniconda3/lib/python3.11/site-packages/conda/notices/init.py", line 3, in
from .core import notices # noqa: F401
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/landon/miniconda3/lib/python3.11/site-packages/conda/notices/core.py", line 13, in
from . import cache, fetch, views
File "/home/landon/miniconda3/lib/python3.11/site-packages/conda/notices/fetch.py", line 9, in
import requests
File "/home/landon/miniconda3/lib/python3.11/site-packages/requests/init.py", line 45, in
from .exceptions import RequestsDependencyWarning
File "/home/landon/miniconda3/lib/python3.11/site-packages/requests/exceptions.py", line 9, in
from .compat import JSONDecodeError as CompatJSONDecodeError
File "/home/landon/miniconda3/lib/python3.11/site-packages/requests/compat.py", line 13, in
import charset_normalizer as chardet
ModuleNotFoundError: No module named 'charset_normalizer'

When I run bash init.sh is the issue missing modules.
also the conda environment doesnt get made correctly

@blumu Unrelated to this issue I did get this to work with another method on 20.04 without conda. I was attempting to make a tree and star pattern topology. The readme says use cyberbattlechain as a starting point for different topologies, Do you guys just mean longer chains of Linux Windows Linux[Flag]. Or can I break from that pattern and make the tree and start pattern?

I did create the graph using simpleenv, but I wasnt sure how to run the agent on that or specify which is my flag.

@Beauxrel Have you tried setting up your conda environment using anaconda instead of miniconda? Also which distirbution and version of Linux are you using?

No, I did not try that. Also I've destroyed that VM since Im not working with CyberBattleSim anymore, but I believe it was 22.04. That's usually what I use.

Thank you @Beauxrel for your answer and past contributions to CyberBattleSim! I am closing this issue for now as I could not repro on WSL2 nor docker with the most recent main branch.