Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,32 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max


# DO NOT PUBLISH THE WHITEBOX VERSION FOR NOW
# # Extract metadata (tags, labels) for Docker Whitebox variant
# - name: Extract Docker metadata (Whitebox)
# id: meta-whitebox
# uses: docker/metadata-action@v5
# with:
# images: ${{ env.IMAGE_NAME }}
# flavor: |
# latest=auto
# suffix=-whitebox,onlatest=true
# tags: |
# type=raw,value=latest,enable={{is_default_branch}}
# type=ref,event=branch
# type=ref,event=tag
# type=sha

# - name: Build and push Docker image (Whitebox)
# uses: docker/build-push-action@v5
# with:
# context: .
# push: ${{ github.event_name != 'pull_request' }} # Don't push on PRs, just build
# tags: ${{ steps.meta-whitebox.outputs.tags }}
# labels: ${{ steps.meta-whitebox.outputs.labels }}
# build-args: |
# GAME_MODULE=netsecgame.game.worlds.WhiteBoxNetSecGame
# cache-from: type=gha
# cache-to: type=gha,mode=max
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ WORKDIR ${DESTINATION_DIR}
# If a requirements.txt file is in the repository
RUN if [ -f pyproject.toml ]; then pip install .[server] ; fi

ARG GAME_MODULE="netsecgame.game.worlds.NetSecGame"
# Pass the build argument to an environment variable so CMD can use it
ENV ENV_GAME_MODULE=$GAME_MODULE

# Expose the port the coordinator will run on
EXPOSE 9000

# Run the Python script when the container launches (with default arguments --task_config=netsecenv_conf.yaml --game_port=9000 --game_host=0.0.0.0)
ENTRYPOINT ["python3", "-m", "netsecgame.game.worlds.NetSecGame", "--task_config=netsecenv_conf.yaml", "--game_port=9000", "--game_host=0.0.0.0"]
ENTRYPOINT ["sh", "-c", "exec python3 -m ${ENV_GAME_MODULE} --task_config=netsecenv_conf.yaml --game_port=9000 --game_host=0.0.0.0 \"$@\"", "--"]

# Default command arguments (can be overridden at runtime)
CMD ["--debug_level=INFO"]
2 changes: 1 addition & 1 deletion NetSecGameAgents
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ Optionally, you can build the image locally with:
docker build -t netsecgame:local .
```

To build a Whitebox version of the game image locally, you can use the `--build-arg` flag to override the default module path:
> [!WARNING]
> The Whitebox variant is currently experimental.
```bash
docker build --build-arg GAME_MODULE="netsecgame.game.worlds.WhiteBoxNetSecGame" -t netsecgame:local-whitebox .
```

### Installing from source
In case you need to modify the envirment and run directly, we recommed to insall it in a virtual environemnt (Python vevn or Conda):
#### Python venv
Expand Down
2 changes: 1 addition & 1 deletion examples/example_task_configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
coordinator:
agents:
Attacker: # Configuration of 'Attacker' agents
max_steps: 25
max_steps: 50
goal:
description: "Exfiltrate data from Samba server to remote C&C server."
is_any_part_of_goal_random: True
Expand Down
4 changes: 2 additions & 2 deletions netsecgame/game/worlds/WhiteBoxNetSecGame.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class WhiteBoxNetSecGame(NetSecGame):
WhiteBoxNetSecGame is an extension for the NetSecGame environment
that provides list of all possible actions to each agent that registers in the game.
"""
def __init__(self, game_host, game_port, task_config, allowed_roles=["Attacker", "Defender", "Benign"], seed=42, include_block_action=False):
super().__init__(game_host, game_port, task_config, allowed_roles, seed)
def __init__(self, game_host, game_port, task_config, seed=None, include_block_action=True):
super().__init__(game_host, game_port, task_config, seed)
self._all_actions = None
self._include_block_action = include_block_action

Expand Down