Skip to content

[Bug]: GlobalDefender never detects ActionType.BlockIP. #471

@AlyaGomaa

Description

@AlyaGomaa

Bug Description

In netsecgame/game/global_defender.py, BlockIP has a default detection probability and a TW ratio threshold, but stochastic_with_threshold only runs detection logic for action types listed in _TW_CONSECUTIVE_TYPE_THRESHOLD or _EPISODE_REPEATED_ACTION_THRESHOLD. BlockIP is in neither list, so the function always falls through to return False for BlockIP. This lets any agent repeatedly issue BlockIP actions (including attackers) with zero chance of detection, effectively disabling the GlobalDefender for a high‑impact action.

Steps to Reproduce

Steps to Reproduce:

  1. Open netsecgame/game/global_defender.py and note ActionType.BlockIP is present in _DEFAULT_DETECTION_PROBS and _TW_TYPE_RATIOS_THRESHOLD but missing from _TW_CONSECUTIVE_TYPE_THRESHOLD and _EPISODE_REPEATED_ACTION_THRESHOLD.
  2. Run the following in a Python REPL from the repo root:
    from netsecgame.game.global_defender import GlobalDefender
    from netsecgame.game_components import Action, ActionType, IP
    
    defender = GlobalDefender()
    action = Action(ActionType.BlockIP, {
        "source_host": IP("10.0.0.1"),
        "target_host": IP("10.0.0.1"),
        "blocked_host": IP("10.0.0.2"),
    })
    episode_actions = [action.as_dict] * 10
    print(defender.stochastic_with_threshold(action, episode_actions, tw_size=5))
    

Expected Behavior

Expected Behavior:
BlockIP should trigger stochastic detection when its TW ratio (and/or a defined threshold for repeated/consecutive actions) is exceeded, similar to other action types. At minimum, BlockIP should not be hard‑coded to “never detect” when it already has configured detection probabilities and thresholds.

Version

Version: 1.1

Installation / Deployment Method

Running locally from source

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions