891 Commits
v3.1.0 ... main

Author SHA1 Message Date
Marek Wolan
98617981d7 Merged PR 636: Release 4.0.0
# PrimAITE 4.0.0 Release Note

## 📰 Headlines 📰

* **Major Release** - This is the first major release of PrimAITE that has been published since PrimAITE 2.0.0. Users are encouraged to also familiarise themselves with [what's new in PrimAITE 3.0.0](todo: 3.0 release note link).
* **Plugins** - PrimAITE now supports external plugins to extend existing functionality, such as new node types, services, applications, agent types, observations, actions, and rewards.
* **Improved config schema** - The YAML config files have a new schema which simplifies the definition of agents by using named references in actions and observations instead of id references.
* **Use Case 7** - Introduction of much larger UC7 network with example notebooks and config files.

##  What's new 

- **Use Case 7** is a new pre-defined scenario in PrimAITE with a more complex set of nodes that demonstrates some of the new capabilities of PrimAITE 4.
- **Threat Actor Profiles** are a new type of malicious scripted agent:
  - Extensible base class that allows defining a multi-stage kill chain with success conditions and network knowledge tracking.
  - TAP001 agent - agent that exfiltrates and corrupts data from a database.
  - TAP003 agent - agent that maliciously introduces ACL rules to a network to disrupt normal users.
- **Users, Terminals, SSH, and Command&Control** were [introduced in PrimAITE 3.3]().
- **Determinism** Support for determinism by setting and logging randomness seeds.
- **Action Masking** (introduced in 3.2.0).
- **MARL support** (introduced in 3.0.0).
- **Logging** was improved by adding the following:
  - detailed information about agent actions, decisions, and rewards.
  - the full state of the simulation after each environment step.
  - sys logs for each node.
  - pcap logs for each network interface.
- **Domain Randomisation** - the Gym environment can use different variations of the same scenario, alternating between them each episode by providing a folder of YAML files instead of a single file at initialisation.

## 👍 General Improvements 👍
- The organisation of the codebase has been improved by splitting long files into smaller ones.
- Agent logs can now show observation history and more detail about the reward.
- Some classes' `.show()` methods now show more useful or correct information (like agents, and networks).
- More example notebooks and introduction of how-to guides in the Sphinx docs.
- Ability to set scenario-wide default values for certain actions like scan, node power-off, node start-up, etc.
- It's now easier to build complex networks with the new, extensible `NetworkNodeAdder` class.
- NMAP application.
- The YAML config files:
  - support extended classes from plugins
  - information has been deduplicated - actions no longer rely on IDs, instead users can specify meaningful labels.
  - more objects have default values so there is less boilerplate.
  - the way agent settings are defined has been standardised.
  - more data va...
2025-03-18 11:26:08 +00:00
Marek Wolan
ac4d7e9ecc Merged PR 634: Merge final doc updates into prerelease branch
Related work items: #2936, #3110
2025-03-17 09:20:14 +00:00
Archer Bowen
b48ed25b23 Merged PR 633: #3110 Final user guide comments.
## Summary
Feedback following James' comments

## Test process

## Checklist
- [x ] PR is linked to a **work item**
- [x] **acceptance criteria** of linked ticket are met
- [x] performed **self-review** of the code
- [x] written **tests** for any new functionality added with this PR
- [x] updated the **documentation** if this PR changes or adds functionality
- [x] written/updated **design docs** if this PR implements new functionality
- [x] updated the **change log**
- [x] ran **pre-commit** checks for code style
- [x] attended to any **TO-DOs** left in the code

#3110 Final user guide comments.

Related work items: #3110
2025-03-17 09:09:59 +00:00
Charlie Crane
e9e49ab5f9 Fix some issues with sphinx rendering text in jupyter notebooks 2025-03-14 16:07:08 +00:00
Charlie Crane
e94d7b0b3f Revert "Formatting changes to correct issues with sphinx rendering of documentation"
This reverts commit 42512a2fc2.
2025-03-14 16:01:55 +00:00
Charlie Crane
42512a2fc2 Formatting changes to correct issues with sphinx rendering of documentation 2025-03-14 16:00:30 +00:00
Charlie Crane
b2a097a1cc Merge branch 'bugfix/user-guide-comments' of https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE into bugfix/user-guide-comments 2025-03-14 14:58:36 +00:00
Charlie Crane
67814893e1 Updates to Licence table in primaite-dependencies.rst 2025-03-14 14:57:33 +00:00
Archer Bowen
b5a2234a24 Apply suggestions from code review 2025-03-14 14:38:39 +00:00
Charlie Crane
7f7fa36f14 Merged PR 632: CI pipeline Updates
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2936
2025-03-14 14:11:06 +00:00
Archer Bowen
a8e64a63f8 #3110 Final user guide comments. 2025-03-14 14:06:03 +00:00
Charlie Crane
cd2da383bf Standardise how python version is declared in ADO pipelines to prevent python version weirdness 2025-03-14 09:59:58 +00:00
Charlie Crane
d1a66c14ae Testing a resolution for pipeline failure seen with using python v3.10 2025-03-14 09:51:59 +00:00
Marek Wolan
20dcc0a987 Updated VERSION 2025-03-13 18:19:49 +00:00
Charlie Crane
062926abd2 Merged PR 629: Minor Userguide changes (Charlie)
## Summary
Minor userguide changes, working from the "bottom" of the comments from 3110

## Test process
User Guide continues to successfully render.

## Checklist
- [X] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #3110
2025-03-13 18:19:06 +00:00
Marek Wolan
0ccf350766 Merge remote-tracking branch 'origin/dev' into feature/3110-userguide-fixes-Charlie 2025-03-13 18:13:07 +00:00
Nick Todd
13fe8f4681 Merged PR 631: #3113: Fix incorrect hostname.
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
Tested affected notebook.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#3113: Fix incorrect hostname.

Related work items: #3113
2025-03-13 18:12:42 +00:00
Marek Wolan
f4f99d3e67 Merge remote-tracking branch 'origin/dev' into feature/3113_snagging 2025-03-13 18:02:01 +00:00
Marek Wolan
237965823e Merged PR 630: Documentation changes.
Update docs

Related work items: #3110, #3111
2025-03-13 18:01:17 +00:00
Marek Wolan
ec7ee245d9 3110 - appease precommit 2025-03-13 15:59:56 +00:00
Marek Wolan
36a78cc565 Apply suggestions from code review 2025-03-13 15:57:16 +00:00
Charlie Crane
0c2c6bad5d Merge branch 'feature/#3110-userguide-fixes' into feature/3110-userguide-fixes-Charlie 2025-03-13 15:55:31 +00:00
Archer Bowen
6d4be8a653 #3110 UC7 notebook updates:
- Improve clarity of some code cells (narrowed output)
- Reworded some questionably worded sections
- Updated some of the util functionality that using old action names
- Updated a lot of old names into kebab-case
- General tidy up and consistency changes.
2025-03-13 15:21:07 +00:00
Charlie Crane
c3d88c0ce5 #3110 - Merge in changes on target branch 2025-03-13 15:09:49 +00:00
Marek Wolan
7d37ddbb67 3110 - Add some more module level docstrings. 2025-03-13 15:07:38 +00:00
Nick Todd
aca3ff76db Merge branch 'feature/#3110-userguide-fixes' of ssh.dev.azure.com:v3/ma-dev-uk/PrimAITE/PrimAITE into feature/#3110-userguide-fixes 2025-03-13 15:01:33 +00:00
Nick Todd
a43c660a83 #3110: pre-commit fixes. 2025-03-13 15:01:23 +00:00
Marek Wolan
8ddb6916fb 3110 - Add module-level docstrings 2025-03-13 14:57:34 +00:00
Nick Todd
8ad350de84 Merge branch 'feature/#3110-userguide-fixes' of ssh.dev.azure.com:v3/ma-dev-uk/PrimAITE/PrimAITE into feature/#3110-userguide-fixes 2025-03-13 14:56:20 +00:00
Nick Todd
618e2a2caf #3110: Updates to data_manipulation_bot text. 2025-03-13 14:56:10 +00:00
Charlie Crane
61afaaf8e7 #3110 - Correct some YAML formatting of agent_settings in agents.rst 2025-03-13 14:46:37 +00:00
Marek Wolan
864016b893 3110 - Fix code example and broken references to ipprotocol in c2 suite docs 2025-03-13 14:36:48 +00:00
Marek Wolan
128b459c04 3110 - comment out not-yet-implemented TCP description 2025-03-13 14:21:56 +00:00
Marek Wolan
d4287d6690 3110 Fix formatting and code examples in docs 2025-03-13 14:18:26 +00:00
Marek Wolan
dc65681f2c 3110 Add generated notebooks folder to makefile clean command 2025-03-13 14:18:03 +00:00
Charlie Crane
1433ee08f0 #3110 - Address some incorrect comments in PrimAITE documentation and sort outstanding TODO comments 2025-03-13 13:06:45 +00:00
Marek Wolan
ba3d855b4c 3110 - change notebook title to deduplicate 2025-03-13 11:54:16 +00:00
Marek Wolan
00364c3a9f 3110 - Fix naming schema for rewards in docs 2025-03-13 11:53:44 +00:00
Marek Wolan
9ffd5b90d9 3110 - Remove empty customising scenarios doc page 2025-03-13 11:53:44 +00:00
Nick Todd
e8e8ad7681 Merge branch 'feature/#3110-userguide-fixes' of ssh.dev.azure.com:v3/ma-dev-uk/PrimAITE/PrimAITE into feature/#3110-userguide-fixes 2025-03-13 11:36:36 +00:00
Nick Todd
dc3dc5d9c1 #3110: Correct config YAML snippets. 2025-03-13 11:36:24 +00:00
Marek Wolan
3cb9e51084 3110 - docs formatting fixes and updating text 2025-03-13 11:29:03 +00:00
Charlie Crane
2107e2f166 Merge branch 'feature/#3110-userguide-fixes' into feature/3110-userguide-fixes-Charlie 2025-03-13 09:24:02 +00:00
Marek Wolan
8b91c280cb 3110 - remove outdated todos 2025-03-12 17:13:03 +00:00
Charlie Crane
3fa1104d2e #3110 - Amend Documentation pages that have out of date material following updates 2025-03-12 17:10:51 +00:00
Nick Todd
ea7898ce33 #3110: More example config file and domain name changes 2025-03-12 15:47:26 +00:00
Nick Todd
c54007daec Merge branch 'feature/#3110-userguide-fixes' of ssh.dev.azure.com:v3/ma-dev-uk/PrimAITE/PrimAITE into feature/#3110-userguide-fixes 2025-03-12 15:23:33 +00:00
Nick Todd
af025d45ff #3110: config file example changes. 2025-03-12 15:23:17 +00:00
Marek Wolan
19d7989c4a Add extra detail and examples to YAML migration guide 2025-03-12 15:21:35 +00:00
Nick Todd
907294992c #3110: Update example schema in terminal.rst 2025-03-12 14:53:34 +00:00
Nick Todd
58de350941 #3110: Remove HTTPS reference. 2025-03-12 14:04:46 +00:00
Nick Todd
283273babe #3110: Fixed code snippet and added text. 2025-03-12 13:50:46 +00:00
Nick Todd
96014962f0 #3110: Update code snippet in state_system. 2025-03-12 13:22:43 +00:00
Nick Todd
5d21bed557 Merge branch 'feature/#3110-userguide-fixes' of ssh.dev.azure.com:v3/ma-dev-uk/PrimAITE/PrimAITE into feature/#3110-userguide-fixes 2025-03-12 12:54:21 +00:00
Nick Todd
9d800b6c45 #3110: update code snippets and text in request_system. 2025-03-12 12:54:08 +00:00
Archer Bowen
68db549217 #3110 Notebook update changes:
- All agent training demo notebooks now reference UC2.
- Terminal-Processing Notebook now includes a few extra markdown cells for extra context. Additionally yaml snippets have been updated to reflect 4.0.0 schema
- Request-and-Response notebook now includes a few more markdown cells for extra context as well as updated software names
- General notebook cell clean up and tidying.
2025-03-12 12:42:38 +00:00
Marek Wolan
62812749d5 3110 - change docs custom class template to remove things inherited from basemodel 2025-03-12 12:01:25 +00:00
Nick Todd
747fe72065 Merge branch 'feature/#3110-userguide-fixes' of ssh.dev.azure.com:v3/ma-dev-uk/PrimAITE/PrimAITE into feature/#3110-userguide-fixes 2025-03-12 10:22:26 +00:00
Nick Todd
f19422e1f0 #3110: Replace "identifier" with "discriminator". 2025-03-12 10:22:14 +00:00
Archer Bowen
213ed045ee #3110 Notebook Changes:
**How-To-Use-Primaite-Dev-Mode**
- Neatened up titles and general formatting

**Privilege-Escalation-and-Data-Loss-Example**
- Added new text which gives more context to the scenario (smaller UC7 with a focus on simulation demonstration rather than agent training)
- Fixed Broken terminal commands
- general misc tidying (bolding etc)
2025-03-11 17:51:57 +00:00
Nick Todd
3f74031dc7 #3110: Fix references to list of ports and protocols. 2025-03-11 17:40:43 +00:00
Nick Todd
99d4e228c9 Merge branch 'feature/#3110-userguide-fixes' of ssh.dev.azure.com:v3/ma-dev-uk/PrimAITE/PrimAITE into feature/#3110-userguide-fixes 2025-03-11 16:42:46 +00:00
Nick Todd
d2b5097dce #3110: update port and protocol descriptions 2025-03-11 16:41:32 +00:00
Archer Bowen
678a500c5e #3111 yaml migration guide comments. 2025-03-11 16:07:34 +00:00
Nick Todd
dab261da0b #3110: Update URLs 2025-03-11 15:29:57 +00:00
Nick Todd
b13d6ebd03 #3110: Fix mangled license. 2025-03-11 14:58:19 +00:00
Archer Bowen
cb91e13fe7 #3110 Getting-information-out-of-PrimAITE changes:
- New text that explains that this notebook uses UC2
- New text which informs users that sys_logs slow down training a lot
- New code snippet for the .describe_method()
2025-03-11 13:05:44 +00:00
Archer Bowen
a71ded8ecf #3110 UC2 Notebook changes:
- YAML obs nest dict updated
- `friendly_output_red_action` updated
- `NMNE` section moved into the same timestep that the attack takes place.
- General OBS print is neater and less bloated
- ACL's code snippets assumed that ACL's indexed at 1 (as they did previously). However, this is no longer the case. (Updated config to reflect this)
- Remove un-necessary env.reset(). (We already reset at the start of the notebook - users can just run-run the notebook)
2025-03-11 12:58:59 +00:00
Nick Todd
42f7925748 #3110: fix links in how-to guides 2025-03-11 12:27:45 +00:00
Archer Bowen
b4df227af3 #3111 & initial notebook fixes. 2025-03-10 16:19:54 +00:00
Nick Todd
56f8c53be2 #3113: Fix incorrect hostname. 2025-03-10 11:35:33 +00:00
Nick Todd
b467292edd Merged PR 624: CHANGELOG updates
## Summary
Updates to CHANGELOG.md for 4.0.0.

## Test process
Checked that document rendered correctly.

## Checklist
- [X] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #3105
2025-03-07 13:41:13 +00:00
Archer Bowen
282f76caa0 Merged PR 623: TAP003 Local Host index error causing index error.
## Summary

Adds an additional if statement to catch the edge case.

This bug came out of another bug-fix made in !612 in which the manipulation stage logic was altered (the last host was being skipped over).

## Test process
Ran the pre-existing tests (in milpac as well)

## Checklist
- [x] PR is linked to a **work item**
- [x] **acceptance criteria** of linked ticket are met
- [x] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [x] ran **pre-commit** checks for code style
- [x] attended to any **TO-DOs** left in the code

Fixing an issue where if tap-003 were to attempt to change the password of it's starting node an index error would cause a crash. (only if the starting host was the last host in the `account_changes` config option)

Related work items: #3107
2025-03-07 13:41:13 +00:00
Nick Todd
65dee930b1 #3105: Further PR comments. 2025-03-07 13:41:13 +00:00
Nick Todd
7775403067 #3105: Code review changes. 2025-03-07 13:41:13 +00:00
Nick Todd
d9191abd0f #3105: Pre-commit changes. 2025-03-07 13:41:13 +00:00
Charlie Crane
1b0183f689 Merged PR 622: Addition of How-To Guides
## Summary
Port of How-To guides from an old PR to PrimAITE v4.0, alongside updates for the extensible pages created to be visible in navigation pane.

## Test process
Locally generated Documentation has working links

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2893
2025-03-07 13:41:12 +00:00
Archer Bowen
4fbcd511b3 #3107 Reduce dense commenting 2025-03-07 13:41:12 +00:00
Nick Todd
995bcd7170 #3105: Updated and corrected entries. 2025-03-07 13:41:12 +00:00
Archer Bowen
dd5571359a Merged PR 612: #2925 Use Case 7 Scenario Modelling
## Summary
This PR contains the entirety of the #2925 UC7 implementation and updated to work with 4.0.0.

Specifically, this PR contains the following:

- New UC7 Scenario config (#2483)
- New UC7 TAP001 Config #2909
- New UC7 TAP003 Config #2910
- New UC7 default blue agent #3070
- New UC7 green agent POL #3067
- Multiple UC7 detailed diagrams #3068
- Multiple new UC7 notebooks #3069

## Test process

Pre-existing tests have been re-modelled to use UC7 as well as a few more new UC7 specific tests that ensure all of the expected default behaviour is working.

Additionally, multiple notebooks exist which utilise a large amount of the UC7 scenario and thus also act as tests.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2483, #2909, #2910, #3067, #3068, #3069, #3070, #3071, #3086
2025-03-07 13:41:12 +00:00
Marek Wolan
fd2ad45059 Merge remote-tracking branch 'origin/dev' into feature/Updated-How-To-Guides 2025-03-07 13:41:12 +00:00
Archer Bowen
3690b61be5 Fixing an issue where if tap-003 were to attempt to change the password of it's starting node an index error would cause a crash. (only if the starting host was the last host in the account_changes config option) 2025-03-07 13:41:12 +00:00
Archer Bowen
83c9a90c0a #20925 fixing failing notebook pipeline. 2025-03-07 13:41:12 +00:00
Archer Bowen
7b928696f6 #2725 Remove borked reload 2025-03-07 13:41:12 +00:00
Archer Bowen
be51d039c2 Moved red_scan_countdown into node class attributes. ( 2025-03-07 13:41:12 +00:00
Marek Wolan
f3cc4e8409 Fix red scan not happening 2025-03-07 13:41:12 +00:00
Archer Bowen
7f3d166de0 #2925 Replace try catch logic with a more elegant solution. 2025-03-07 13:41:12 +00:00
Archer Bowen
f532b5e0da #2925 Fixed TAP003 error and failing tests. 2025-03-07 13:41:12 +00:00
Marek Wolan
908dbe4722 fix show history 2025-03-07 13:41:12 +00:00
Archer Bowen
4e03d436ac Merge remote-tracking branch 'origin/dev' into UC7-migration 2025-03-07 13:41:12 +00:00
Archer Bowen
36aecdea37 #2925 Updating more tests based on PR comments. (Mainly clean-up and improving comment clarity) 2025-03-07 13:41:12 +00:00
Archer Bowen
6a0d28bf5f #2825 Updated all tests to use a constants rather than a magic num. 2025-03-07 13:41:12 +00:00
Archer Bowen
72a06ea001 #2925 Further clean up to tap kill chain repeat test. 2025-03-07 13:41:12 +00:00
Archer Bowen
5cc885f6e9 #2925 PR TAP Test comments. 2025-03-07 13:41:12 +00:00
Archer Bowen
0b7cdd451b Merge branch 'dev' into UC7-migration 2025-03-07 13:41:12 +00:00
Archer Bowen
2662540965 Reviewing PR comments - #2925 !612 2025-03-07 13:41:12 +00:00
Archer Bowen
e45c2742cc #2925 Responding to a few more pr comments (general notebook clean up and improvement). 2025-03-07 13:41:12 +00:00
Archer Bowen
eec73deae7 #2925 Responding to PR comments. 2025-03-07 13:41:12 +00:00
Archer Bowen
43d58a7ca6 #2925 General Config fixes and node-os-scan bug fix implemented in the UC7-E2E-Demo notebook. 2025-03-07 13:41:12 +00:00
Marek Wolan
da60833abd Fix os scan action 2025-03-07 13:41:12 +00:00
Archer Bowen
d8b52012f5 #2925 Addressing PR comments. General config clean up and typos. 2025-03-07 13:41:12 +00:00
Archer Bowen
f6a6c3dde5 #2483 Addressed inconsistent naming schema. Now all some tech networks will be referenced using a underscore. E.g "ST-PROJ-A-PRV-PC-1" has now been changed to "ST_PROJ-A-PRV-PC-1". 2025-03-07 13:41:12 +00:00
Archer Bowen
80be1d5418 #2483- Slight updates to UC7 config and e2e notebook 2025-03-07 13:41:12 +00:00
Archer Bowen
6769bc917f Merge branch '4.0.0a1-dev' into UC7-migration 2025-03-07 13:41:12 +00:00
Marek Wolan
d8c8aa40a4 3086 UC7 Migration - All YAMLS, tests and notebooks. A few lingering issues such as the OS-SCAN not working and agent logs not appearing. 2025-03-07 13:40:50 +00:00
Marek Wolan
92af387e56 Remove buggy autoreload from notebook 2025-02-28 15:35:06 +00:00
Marek Wolan
75eb1050c9 Merged PR 621: Change acl observations to be less confusing
Related work items: #2869, #2887, #3029, #3060, #3062, #3075, #3089
2025-02-28 11:28:14 +00:00
Marek Wolan
5609dc8d07 Appease precommit 2025-02-28 11:13:23 +00:00
Archer Bowen
b7bc39ce1a Merged PR 610: #3087 - TAP001/003 Core Migration (No Tests & Notebook)
## Summary

This PR migrates the TAP003 and TAP001 agents into the core PrimAITE codebase. This choice was made in order to allow for the UC7 network to utilise the TAP agents.

### **This PR does NOT include the TAP tests and notebooks**

The TAP notebooks and tests are included in the #2925 feature.

### **This PR has a sister PR on the milpac repo which removes the TAP agents from milpac**

PR will also needs to be merged and all relevant branches must be updated.

## Test process

The changes made in this PR were preemptively merged into the UC7 migration branch to create the TAP tests & notebooks.

## Checklist
- [x] PR is linked to a **work item**
- [x] **acceptance criteria** of linked ticket are met
- [x] performed **self-review** of the code
- [N/A] written **tests** for any new functionality added with this PR
- [N/A] updated the **documentation** if this PR changes or adds functionality
- [N/A] written/updated **design docs** if this PR implements new functionality
- [N/A] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

#3087 - TAP001/003 Added - **No tests or notebooks migrated**

Related work items: #3087
2025-02-28 09:09:14 +00:00
Charlie Crane
110fc9243f Merge in updates from dev 2025-02-27 18:21:43 +00:00
Charlie Crane
1f6f007941 Updates to documentation and inclusion of how-to guides 2025-02-27 18:16:45 +00:00
Archer Bowen
3b4fb2d27f #3087 Addressing docustring TODO's and a few minor spelling mistakes. 2025-02-27 14:03:18 +00:00
Archer Bowen
f0c46cd90e Merge branch 'dev' into feature/3087-TAP-core-migration 2025-02-27 11:36:38 +00:00
Marek Wolan
98914ecdbb Merge remote-tracking branch 'origin/dev' into bugfix/3089-obs-index 2025-02-27 11:31:02 +00:00
Marek Wolan
7b092158db Merged PR 620: 4.0.0 changes into dev
Related work items: #2869, #2887, #2912, #3029, #3060, #3062, #3075
2025-02-27 11:29:24 +00:00
Marek Wolan
2b04695c2e Apply suggestions from code review 2025-02-27 10:07:17 +00:00
Marek Wolan
a19ceada2c Change ACL observation to 0-index and remove weird off-by-one offset 2025-02-26 19:31:43 +00:00
Marek Wolan
bab4060378 Fix agent config in terminal processing notebook 2025-02-26 18:26:54 +00:00
Marek Wolan
fd367d1f0e Fix typos and duplicate identifiers in docs 2025-02-26 18:21:28 +00:00
Marek Wolan
f1a36cafaa remove outdated information from data manipulation bot doc page 2025-02-26 18:13:45 +00:00
Marek Wolan
cf33dcdcf9 remove outdated information from agents doc page 2025-02-26 18:12:20 +00:00
Marek Wolan
8c399c4f61 Fix mismerge of c2 e2e notebook 2025-02-26 18:11:42 +00:00
Marek Wolan
b4b0f99c23 Fix mismerge of agent show_history method 2025-02-26 17:57:23 +00:00
Charlie Crane
891467d1d3 Revert changes to Command & control and Privilege jupyter notebooks 2025-02-26 15:44:06 +00:00
Marek Wolan
2bf118abc9 Merge remote-tracking branch 'origin/4.0.0a1-dev' into 4.0.0-dev 2025-02-26 15:33:50 +00:00
Charlie Crane
6b796608df Revert commit of output in Command and Control notebook 2025-02-26 15:32:50 +00:00
Archer Bowen
5ffde8a426 Merge branch '4.0.0a1-dev' into feature/3087-TAP-core-migration 2025-02-26 15:32:43 +00:00
Charlie Crane
7fe4915f42 Revisions to make the how-to guides show in navigation pane 2025-02-26 15:31:03 +00:00
Marek Wolan
9bb4442bbe Merge remote-tracking branch 'origin/dev' into 4.0.0-dev 2025-02-26 15:20:05 +00:00
Charlie Crane
0d93981ef8 Updates to documentation pages 2025-02-26 12:03:00 +00:00
Charlie Crane
7ec664ae67 Merge branch '4.0.0a1-dev' into feature/Updated-How-To-Guides 2025-02-26 11:02:51 +00:00
Charlie Crane
4268e387c4 Add custom how-to guides to documentation, additional notebook around how to use dev cli 2025-02-26 11:02:00 +00:00
Nick Todd
502d163818 Merged PR 618: Port core notebooks
## Summary
This PR covers changes made for the core notebooks to run correctly.

## Test process
All notebooks were tested to:

- ensure they run to completion
- the output (rewards etc) matches or is similar to the PrimAITE 3.3.1-internal notebooks

All changes run against test suite and successful pipeline builds.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #3075
2025-02-26 10:49:04 +00:00
Marek Wolan
1605b09899 Apply suggestions from code review 2025-02-26 10:49:01 +00:00
Nick Todd
ea2c018b82 Merge branch 'feature/3075_Migrate_notebooks_to_MilPac_(Core_changes)' of ssh.dev.azure.com:v3/ma-dev-uk/PrimAITE/PrimAITE into feature/3075_Migrate_notebooks_to_MilPac_(Core_changes) 2025-02-25 14:28:17 +00:00
Nick Todd
892cdb82b9 #3075: Code review changes. 2025-02-25 14:25:27 +00:00
Archer Bowen
f5cfaeedab #3075 Cleaned up yaml snippets that were rendering as a strings. It seems that adding '...' to yaml snippets seems to end up causing the snippets to render as strings rather than actual yaml. 2025-02-21 14:57:48 +00:00
Nick Todd
90d7af3ff9 #3075: Remove references to src/primaite/simulator/_package_data after notebook move. 2025-02-18 12:42:33 +00:00
Nick Todd
72f80e55da #3075: Move demo notebook to correct folder. 2025-02-18 11:51:35 +00:00
Nick Todd
f7f46a2a3b Merge branch '4.0.0a1-dev' into feature/3075_Migrate_notebooks_to_MilPac_(Core_changes) 2025-02-18 11:48:26 +00:00
Nick Todd
8c7f8cd0ec #3075: Fix final two demo notebooks 2025-02-18 11:36:22 +00:00
Marek Wolan
5a7caa33f0 Merged PR 609: fix instantiation of network nodes 2025-02-18 11:05:16 +00:00
Charlie Crane
a426cf567b Merged PR 606: Regression Testing Fixes
## Summary
Changes to PrimAITE to resolve bugs found during regression testing.

- Addressed hardcoding of "abstract_agent" as the name used in logging. This should now use the agent's `ref` from config.
- Fixed some failing terminal tests that were attempting to pass through a remote IP for actions where this wasn't needed.
- Corrected some old uses of `self.hostname` instead of `self.config.hostname` following refactoring.
- Removal of `node_types_map` when calling `network.show` to resolve issues with extensability.

## Test process
Tests pass when ran locally.

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code
2025-02-18 10:33:50 +00:00
Charlie Crane
22b197a79a Removal of leftover comment from software.py 2025-02-18 09:13:33 +00:00
Marek Wolan
46240e49a4 update tests and make office lan creation work like previously 2025-02-17 18:46:09 +00:00
Marek Wolan
cc9e73530c Merge remote-tracking branch 'origin/4.0.0a1-dev' into bugfix/network-setup 2025-02-17 18:16:21 +00:00
Marek Wolan
de88974332 Fix airspace hello 2025-02-17 18:14:07 +00:00
Marek Wolan
3651d033d6 fix instantiation of network nodes 2025-02-17 17:34:22 +00:00
Archer Bowen
9768a931ab #3087 - TAP001/003 Added - **No tests or notebooks migrated** 2025-02-17 17:26:50 +00:00
Nick Todd
5f076ba225 #3075: Fix pre-commit errors 2025-02-17 15:12:12 +00:00
Nick Todd
7dafec8517 #3075: Test fix 2025-02-17 15:01:02 +00:00
Nick Todd
7e82de919c #3075: Markdown changes. 2025-02-17 14:19:56 +00:00
Nick Todd
486c797d60 #3075: Change duplicate application_name in config file. 2025-02-17 11:54:13 +00:00
Nick Todd
a3e6bcace0 Merge branch '4.0.0a1-dev' into feature/3075_Migrate_notebooks_to_MilPac_(Core_changes) 2025-02-17 10:48:28 +00:00
Charlie Crane
4f0e612608 Merged PR 604: #3060 - Adding version to YAML files within PrimAITE
## Summary
Configuration YAML's updated to include the version of PrimAITE for which they were written for

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #3060
2025-02-17 10:22:49 +00:00
Charlie Crane
bf30b70bd2 #3060 - Removal of un-necessary check in game.py 2025-02-17 10:09:39 +00:00
Charlie Crane
2830a2aef5 #3060 - Amendment to new version tag in configuration yaml. Now under the metadata tag 2025-02-14 12:36:23 +00:00
Charlie Crane
7b80d15d81 # Pre-commit actions 2025-02-14 11:39:25 +00:00
Charlie Crane
7e138d1d61 #Bug and test fixes 2025-02-14 11:38:15 +00:00
Charlie Crane
56699d2377 Resolve hardcoding of Agent Logger having agent_name as abstract_agent 2025-02-12 16:18:50 +00:00
Charlie Crane
70fc11f4f1 #3060 - Correct change in game.py that caused test failures 2025-02-11 16:20:11 +00:00
Charlie Crane
dadf93bc7f #3060 - Address some missed pre-commit errors 2025-02-11 14:59:25 +00:00
Charlie Crane
56e81a020c #3060 - Adding version to YAML files within PrimAITE 2025-02-11 10:53:41 +00:00
Marek Wolan
e288572e0b Merged PR 601: Fix action schema for change password 2025-02-10 15:28:44 +00:00
Marek Wolan
96549e68aa Merge remote-tracking branch 'origin/dev' into 4.0.0-dev 2025-02-10 14:39:28 +00:00
Marek Wolan
fc66e125d6 Fix action schema for change password 2025-02-07 10:08:18 +00:00
Nick Todd
1a8c3b9471 #3075: Fix notebooks after test changes. 2025-02-06 16:42:26 +00:00
Nick Todd
0d8672cdba Merge branch '4.0.0a1-dev' into feature/3075_Migrate_notebooks_to_MilPac_(Core_changes) 2025-02-06 09:17:34 +00:00
Marek Wolan
0d1edf0362 Merged PR 598: Make Node schemas stricter
## Summary
- Add extra="forbid" to the node ConfigSchema to prevent future bugs.
- Temporarily add dummy variables that are used by the from_config method of nodes until we refactor them out of the codebase.

## Test process
Yes the tests run correctly.

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code
2025-02-06 09:09:18 +00:00
Nick Todd
7b2a9c1d2a #3075: Pre-commit changes. 2025-02-05 16:46:25 +00:00
Nick Todd
b22ba65eb6 #3075: Further notebook updates. 2025-02-05 16:40:59 +00:00
Marek Wolan
09bdfa3ae1 bugfix - Restore wireless networks so they're not broken 2025-02-05 15:11:04 +00:00
Marek Wolan
c1abbfe58c bugfix - Make node schemas stricter 2025-02-05 15:04:41 +00:00
Nick Todd
a4c19608a6 3075: Pre-commit tidy up. 2025-02-05 11:51:22 +00:00
Nick Todd
3a29593f60 3075: Fix bug in notebook helper function. 2025-02-05 11:50:38 +00:00
Marek Wolan
01bf052cc4 Merged PR 597: Standardise discriminator (f.k.a. identifiers) naming convention.
## Summary
I mean I don't expect reviewers to go through every single change. It was painful enough to make all the changes myself, I had to write a script and regex the $*!+ out of the codebase to get this change through

## Test process
Tests pass. Searching through the codebase with regex queries to check for compliant strings.

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #3062
2025-02-05 10:49:40 +00:00
Marek Wolan
4a472c5c75 #3062 - Remove discriminators from abstract classes and fix remaining old discriminator names 2025-02-05 10:12:13 +00:00
Nick Todd
3c84a15d61 Merge branch '4.0.0a1-dev' into feature/3075_Migrate_notebooks_to_MilPac_(Core_changes) 2025-02-05 08:36:59 +00:00
Nick Todd
f7c6ee3df4 #3075: C2C-E2E-Demo wildcard_list changes. 2025-02-04 15:45:19 +00:00
Marek Wolan
0a6b604afd Merge remote-tracking branch 'origin/4.0.0a1-dev' into feature/3062-discriminators 2025-02-04 15:20:56 +00:00
Marek Wolan
f0326f4051 Merge remote-tracking branch 'origin/feature/2887-Align_Node_Types' into feature/3062-discriminators 2025-02-04 15:20:48 +00:00
Charlie Crane
0708c836a3 Merged PR 591: Extensible Nodes
## Summary
Refactor of Node classes within PrimAITE to align with the `ConfigSchema` and `from_config` design implemented for PrimAITE v4.0.
Updates to tests to use the new `from_config` method when creating nodes.
Additional documentation page for how to implement custom Node classes

## Test process
WIP - Updating tests to still pass and prevent regression.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [X] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2887
2025-02-04 15:15:28 +00:00
Charlie Crane
24161bb3fc #2887 - Removal of commented out code 2025-02-04 15:06:23 +00:00
Charlie Crane
51bb3f5b07 #2887 - Removal of un-necessary print statement that was used for debugging 2025-02-04 14:26:55 +00:00
Charlie Crane
99e38fbbc2 #2887 - Removal of un-necessary code and cleanup following review comments 2025-02-04 14:25:26 +00:00
Marek Wolan
7ebe7fa4ef Merge '2887-Align_Node_Types' into 3062-discriminators 2025-02-04 14:04:40 +00:00
Charlie Crane
05946431ca #2887 - Correct type in documentation 2025-02-04 11:19:13 +00:00
Nick Todd
454bd61fb2 #3075: Update internal YAML fragments in C2C-E2E-Demo notebook. 2025-02-04 10:50:53 +00:00
Charlie Crane
961136fb42 #2887 - Updates to extensible_nodes.rst 2025-02-04 10:41:51 +00:00
Charlie Crane
c1a5a26ffc #2887 - Actioning review comments 2025-02-04 10:21:56 +00:00
Nick Todd
d24f9872ff #3075: C2C-E2E-Demo internal YAML changes. 2025-02-03 17:06:12 +00:00
Marek Wolan
a310fb3b64 #3062 - Discriminator bugfixes 2025-02-03 16:29:27 +00:00
Marek Wolan
abccf4afc5 #3062 - First pass at unifying naming convention for discriminators (still errors) [skip ci] 2025-02-03 16:24:03 +00:00
Charlie Crane
f3bbfffe7f #2887 - Update CHANGELOG.md 2025-02-03 14:03:21 +00:00
Nick Todd
32de95917e #3075: Add repeat parameter to config file. 2025-02-03 11:33:21 +00:00
Charlie Crane
0920ec5f5b #2887 - Remove debug print statements 2025-02-03 11:32:07 +00:00
Charlie Crane
3d01f52eea #2887 - Merge in changes on dev to resolve conflicts. All tests should now pass 2025-02-03 11:18:34 +00:00
Charlie Crane
d1e932a57c #2887 - Merge in changes on dev to resolve conflicts. All tests should now pass 2025-02-03 11:16:34 +00:00
Nick Todd
14c9d10aa6 Merge branch '4.0.0a1-dev' into feature/3075_Migrate_notebooks_to_MilPac_(Core_changes) 2025-02-03 09:08:31 +00:00
Charlie Crane
d806391625 #2887 - Test fixes 2025-01-31 18:46:02 +00:00
Marek Wolan
055c853b0f #3062 - rename identifier to discriminator 2025-01-31 16:00:32 +00:00
Marek Wolan
8feb2db954 Fix properties 2025-01-31 15:29:10 +00:00
Marek Wolan
20e5177544 Merged PR 593: Core bugfixes in support of extension tests.
## Summary
- Corrected some validation in observations and actions to use strings (in alignment with 'describe_state' methods.)
- Fixed bug where periodic agent would start on step 0 instead of on the configured start step
- Improved validations on network node adder
- Added database password to config schema of database service
- DNS client lookup no longer requires a DNS server address to be configured if the requested domain exists in the client cache
- DNS client can now inherit the parent node's DNS server address

## Test process
Unit tests and tests against the extension

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#3029 - Add string-ip validator, improve validation, fix minor bugs in pulling schema data

Related work items: #3029
2025-01-31 14:47:16 +00:00
Marek Wolan
a77fa65c39 #3029 - Remove old initialisation of dns server attr that caused a bug 2025-01-31 14:46:43 +00:00
Marek Wolan
3260e1f30b #3029 - make new config items properties as per PR comments 2025-01-31 14:41:49 +00:00
Marek Wolan
037dd8278b #3029 - update changelog 2025-01-31 12:30:08 +00:00
Marek Wolan
4fb54c9492 #3029 - Add string-ip validator, improve validation, fix minor bugs in pulling schema data 2025-01-31 12:18:52 +00:00
Charlie Crane
3d47b9c863 #2887 - Further fixes to unit tests 2025-01-30 17:33:00 +00:00
Charlie Crane
4b42a74ac8 #2887 - Corrected failures seen when generating services from config & syntax issues. Wireless Router tests currently fail due to port 1 being disabled on startup 2025-01-29 16:57:25 +00:00
Charlie Crane
51f1c91e15 #2887 - Fixed Node unit test failures 2025-01-29 11:55:10 +00:00
Charlie Crane
f85aace31b #2887 - Correct networking troubles causing test failures 2025-01-28 19:35:27 +00:00
Nick Todd
4fb4c5e0f9 #3075: Fix error in config file. 2025-01-28 17:18:07 +00:00
Charlie Crane
d5e4d3d2ad Merge branch '4.0.0a1-dev' into feature/2887-Align_Node_Types 2025-01-28 09:40:27 +00:00
Charlie Crane
e1f2f73db0 #2887 - Test changes to correct NodeOperatingState is correct per passed config. 2025-01-28 09:37:58 +00:00
Nick Todd
6422ff8474 Merge branch '4.0.0a1-dev' into feature/3075_Migrate_notebooks_to_MilPac_(Core_changes) 2025-01-28 09:13:26 +00:00
Nick Todd
f4b73057d2 #3075: Update notebooks to reflect extension changes. 2025-01-27 17:08:33 +00:00
Charlie Crane
0570ab984d #2887 - Node class changes to address some test failures. Addressed some inconsistencies around operating_state, amended instantiation of some Nodes in test environments 2025-01-27 16:35:40 +00:00
Marek Wolan
09bfa7b700 Merged PR 592: #2869 - fixes to agents and remove redundant prints
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2869 - fixes to agents and remove redundant prints

Related work items: #2869
2025-01-27 16:19:41 +00:00
Charlie Crane
a7395c466e #2887 - Final test changes before end of day 2025-01-23 17:42:59 +00:00
Charlie Crane
30c177c272 #2887 - Additional test failure fixes 2025-01-23 17:07:15 +00:00
Charlie Crane
b9d2cd25f3 #2887 - Unit test fixes ahead of raising PR. 2025-01-23 15:28:10 +00:00
Nick Todd
8eeba691a9 #3075: Remove unnecessary print statement. 2025-01-23 15:16:49 +00:00
Charlie Crane
65355f83e8 #2887 - Commit before switching branch 2025-01-23 09:52:14 +00:00
Charlie Crane
fbef78db51 #2887 - Resolve conflicts from merge 2025-01-23 09:17:27 +00:00
Charlie Crane
3957142afd #2887 - Updates to Node components to use rom_config and allow for extensibility. Router and Firewall continue to have custom from_config. Some test fixes to reflect changes to functionality. 2025-01-22 17:20:38 +00:00
Marek Wolan
5563b9c62d #2869 - fixes to agents and remove redundant prints 2025-01-22 16:55:59 +00:00
Nick Todd
0aa691752a #3075: Tidy up debug print statements. 2025-01-22 12:20:45 +00:00
Nick Todd
3f94c40434 Fix logger inititialisation in agents 2025-01-22 10:49:42 +00:00
Marek Wolan
d2d09abcb1 Merged PR 590: Backport 3.3.1 fixes into Core
this was already reviewed as part of 3.3.1 release process
2025-01-21 14:42:05 +00:00
Marek Wolan
9263bbf80b Merged PR 589: Extensible Agents and Actions
## Summary
This PR is a follow-on from Charlie's two branches, one for agents and one for actions. This list of changes describes work done by both Charlie and myself

- Agents are now extensible
- Refactored observation manager, action manager, and reward function to inherit from BaseModel
- Added a config schema to observation manager, action manager, and reward function
- Streamlined the way agents are created from config
- Agent config no longer requires a dummy action space if the action space is empty, the same applies for observation space and reward function
- Actions are now extensible
- Actions now support a config schema, to allow yaml data validation and default parameter values
- Action parameters are no longer defined through IDs, instead meaningful data is expected directly in the action map
- Test and example YAMLs have been updated to match the new agent and action schemas, such as:
  - Removed empty action spaces, observation spaces, or reward spaces for agent which didn't use them
  - Relabeled action parameters to match the new action config schemas, and updated the values to no longer rely on indices
  - Removed action space options which were previously used for assigning meaning to action space IDs
- Updated tests that don't use YAMLs to still use the new action and agent schemas

- I haven't checked the notebooks run and there's a couple places where find-and-replace issues persist. I will fix but we can start review in the meantime if you're bored

## Test process
unit test

## Checklist
- [X] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2869, #2912
2025-01-21 14:39:56 +00:00
Marek Wolan
94ee16afa6 Remove todo comments that have been completed 2025-01-21 13:39:06 +00:00
Marek Wolan
dcce678045 update changelog 2025-01-21 13:20:19 +00:00
Marek Wolan
c30c5189be fixes based on PR suggestions 2025-01-21 13:17:42 +00:00
Marek Wolan
66daab3baf Backport 3.3.1 fixes into Core 2025-01-21 13:08:36 +00:00
Marek Wolan
4b79c88ae5 Fix typos and TODOs 2025-01-21 10:42:09 +00:00
Marek Wolan
18a665e562 Update actions and agents to get all tests passing post-refactor 2025-01-20 14:07:51 +00:00
Marek Wolan
c521528a0a Merge remote-tracking branch 'origin/4.0.0a1-dev' into feature/2869-Marek 2025-01-20 10:39:20 +00:00
Marek Wolan
4c0f87e8aa Fix configure actions that were accidentally combined 2025-01-20 10:23:13 +00:00
Nick Todd
8bf841cc62 Merged PR 584: Align core software with registry
## Summary
These changes align core software with the approach that support extensions.

## Test process
Passes test suite.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2888
2025-01-20 09:41:45 +00:00
Marek Wolan
4481d073e4 Fix action config schemas and formrequest method for dos bot action 2025-01-20 08:35:11 +00:00
Marek Wolan
858406c4a3 update more tests to new actions schema 2025-01-17 14:38:59 +00:00
Nick Todd
c82865d630 #2888: Uncomment domain_mapping in test configs. 2025-01-16 16:52:49 +00:00
Nick Todd
dff976b336 #2888: Fix merge test failures. 2025-01-16 16:32:55 +00:00
Marek Wolan
03cab0fcec Update configs to new action naming schema and remove redundant agent config 2025-01-16 15:18:13 +00:00
Marek Wolan
504f4bd134 #2869 - Refactor agent and action config system 2025-01-16 15:17:42 +00:00
Marek Wolan
f8fb052dad #2869 - Make agent schema children work properly 2025-01-15 16:44:17 +00:00
Charlie Crane
70d9fe2fd9 #2887 - End of day commit. Updates to ConfigSchema inheritance, and some initials changes to Router to remove the custom from_config method 2025-01-15 16:33:11 +00:00
Nick Todd
1fe0aea48d Merge remote-tracking branch 'origin/4.0.0a1-dev' into feature/2888_Align_core_software_with_registry 2025-01-15 14:53:46 +00:00
Charlie Crane
582e7cfec7 #2887 - Initial commit of Node refactor for extensibility in version 4.0.0. Addition of ConfigSchema and changes to how Nodes are generated within Game.py 2025-01-15 11:21:18 +00:00
Marek Wolan
b4b6c16872 #2869 - Make observation and action managers use config schemas 2025-01-15 10:08:14 +00:00
Marek Wolan
40d052141c #2869 - Remove outdated parameters from actionmanager (action map achieves the same result) [skip ci] 2025-01-14 13:48:18 +00:00
Marek Wolan
fb5242bd78 Merge agents and actions branches + fix import / subclass errors 2025-01-14 11:34:01 +00:00
Marek Wolan
9f5e16dd85 #2869 - Edit test fixture to work with new agent system 2025-01-14 10:58:34 +00:00
Marek Wolan
e7cfeeafc0 Make data manipulation agent inherit from periodic agent & fix it a bit 2025-01-14 09:57:35 +00:00
Marek Wolan
a447c5f43c #2869 - Make periodic agent timing check stricter 2025-01-14 09:05:13 +00:00
Charlie Crane
1ac562ebc9 #2912 - Initial layout of extensible_actions documentation page 2025-01-13 17:09:03 +00:00
Charlie Crane
3528b712f1 #2912 - Correct instances of verb: str to verb: ClassVar[str] where the parent class uses ClassVar[str] 2025-01-13 16:35:08 +00:00
Charlie Crane
3cca3d4a5c #2912 - Actioning review comments. Identifiers have been removed from AbstractActions, _legacy folder has been deleted and correction to IPV4Address type hints 2025-01-13 16:12:16 +00:00
Charlie Crane
23736f7738 #2869 - Documentation changes 2025-01-13 15:59:10 +00:00
Nick Todd
ea9c13b5f4 #2888: self.X -> self.config.X 2025-01-13 15:38:11 +00:00
Charlie Crane
edd2668ea4 #2869 - Update type hints and ConfigSchema variables in some agent classes 2025-01-13 15:08:48 +00:00
Charlie Crane
32fc970cfe #2869 - Update Config for some agent classes to use pydantic.Field, amend some identifiers and agent_name variables 2025-01-13 10:51:30 +00:00
Charlie Crane
511abea59c #2869 - Actioning review comments 2025-01-13 10:26:48 +00:00
Charlie Crane
c16abdfd30 #2869 - Remove agent_name from ConfigSchema and replace with type 2025-01-10 14:39:03 +00:00
Charlie Crane
e3f4775acb #2869 - Updates to ConfigSchema declaration and addressing some review comments 2025-01-10 14:09:15 +00:00
Charlie Crane
7af9d3724f #2869 - Updates to address test failures. Updated YAML configs to remove redundant start_settings 2025-01-08 14:42:35 +00:00
Nick Todd
0203a8699a #2888: Fixed C2Beacon test failures. 2025-01-07 14:21:07 +00:00
Nick Todd
d0c357355c #2888: Update tests to use config.fixing_duration. 2025-01-07 10:27:41 +00:00
Nick Todd
cb4e10921e #2888: Use fixing_duration from ConfigSchema. 2025-01-06 16:33:57 +00:00
Charlie Crane
66d309871f #2869 - Minor changes trying to make pytest happy 2025-01-06 11:38:07 +00:00
Marek Wolan
695ebb5ec7 #2888 - fix test database class to use correct listener default 2025-01-06 10:13:27 +00:00
Marek Wolan
632201681b #2888 - fix software config issues 2025-01-06 10:08:32 +00:00
Marek Wolan
30d8f14251 #2888 - Put software configuration items in the ConfigSchema 2025-01-03 16:26:12 +00:00
Charlie Crane
a0a5f2ca38 #2912 - Review comment actions following commit revertions 2025-01-03 15:03:01 +00:00
Charlie Crane
0ee454b13e #2912 - Rename actions/config.py to actions/software.py 2025-01-03 14:53:54 +00:00
Charlie Crane
e653afaa4c #2912 - Merge in changes on target branch 2025-01-03 14:48:18 +00:00
Charlie Crane
ab2dd6ca27 Revert "#2912 - Actioning Review Comments"
This reverts commit b11678a128.
2025-01-03 14:41:45 +00:00
Charlie Crane
b11678a128 #2912 - Actioning Review Comments 2025-01-03 14:40:00 +00:00
Charlie Crane
505eab6ed9 #2869 - Changes following review discussion 2025-01-03 14:02:36 +00:00
Marek Wolan
c481847b01 #2888 - Software: align identifiers, tidy up schemas 2025-01-03 13:39:58 +00:00
Marek Wolan
66ca72be79 Merge branch '4.0.0a1-dev' into feature/2888_Align_core_software_with_registry 2025-01-03 12:11:46 +00:00
Nick Todd
eb91721518 Merged PR 567: Extensible Rewards
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [X] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2913
2025-01-03 11:54:20 +00:00
Marek Wolan
c9752f0dc5 #2913 - minor comment cleanup 2025-01-03 11:22:17 +00:00
Charlie Crane
55ddcb7eb4 #2869 - Pull in changes from 4.0.0a1-dev and resolve conflicts 2025-01-03 09:54:11 +00:00
Charlie Crane
2108b914e3 #2869 - New Year, new changes. Actioning review comments and some changes following self-review and catchup 2025-01-02 17:41:24 +00:00
Marek Wolan
c5f81708ce Merge remote-tracking branch 'origin/4.0.0a1-dev' into feature/2913_Extensible_Rewards 2025-01-02 15:11:25 +00:00
Marek Wolan
491de6fc47 Revert pre-commit deleting files 2025-01-02 15:11:02 +00:00
Marek Wolan
41dc7b5b29 Merge remote-tracking branch 'origin/4.0.0a1-dev' into feature/2913_Extensible_Rewards 2025-01-02 15:05:35 +00:00
Marek Wolan
bf32271ddd Change copyright to 2025 2025-01-02 15:05:06 +00:00
Charlie Crane
dc6f2be209 #2869 - pre-commit changes 2024-12-17 12:50:14 +00:00
Charlie Crane
770896200b #2869 - More YAML/test fixes to address failures 2024-12-17 12:47:54 +00:00
Charlie Crane
3b1b74fb3a #2869 - Some additional test updates to amend failures. Pre-commit tbd and some cleanup 2024-12-17 12:21:28 +00:00
Charlie Crane
436a986458 #2869 - Fixed failing tests from agent refactor. Some tests still fail but this is due to updating some action names in anticipation of merging in the extensible actions refactor 2024-12-17 10:51:57 +00:00
Charlie Crane
a4fbd29bb4 #2869 - Updates to agents to make sure they can be generated from a given config. Updates to test suite to reflect code changes 2024-12-16 15:57:00 +00:00
Charlie Crane
d9a1a0e26f 2869 - Addressing some typos in agent declaration, and neatening up the agent structure within PrimAITE. 2024-12-16 11:27:14 +00:00
Charlie Crane
c3a70be8d1 #2869 - Changes to AbstractAgent to address some pydantic issues 2024-12-13 16:37:39 +00:00
Charlie Crane
4c20cd4ac6 #2869 - initial creation of how to section for the new extendable agents. 2024-12-13 15:28:01 +00:00
Charlie Crane
4ac90c3c10 #2869 - Changes to agent refactor config schema, removal of state variables that aren't necessary to be in config 2024-12-13 11:05:24 +00:00
Charlie Crane
3c0a70be71 #2912 - Changes for extensible actions 2024-12-13 09:49:21 +00:00
Nick Todd
6380e01122 #2888: Update some additional services. 2024-12-12 17:01:40 +00:00
Charlie Crane
47ed585ee2 #2912 - Replace DONOTHING reference with do_nothing, tweaks following milpac actions 2024-12-12 16:08:11 +00:00
Nick Todd
4a52054ed6 #2888: Initialise ConfigSchema's and fix type names. 2024-12-12 14:58:48 +00:00
Charlie Crane
86ad872cba #2869 - Committing minor changes to base AbstractAgent class before changing branches 2024-12-12 11:32:59 +00:00
Nick Todd
2ecc142c28 #2888: Changes to Applications and Services previously missed. 2024-12-11 16:50:43 +00:00
Charlie Crane
fe65cef9aa '2869 - Revert deletion of abstract_tap.py as needed for DataManipulationBot 2024-12-11 12:01:07 +00:00
Charlie Crane
feee028485 #2869 - Updates to Probabilistic Agent to follow the defined extensibility schema. 2024-12-11 11:58:42 +00:00
Charlie Crane
e40fd053f7 #2912 - Removing print statements left in from debugging 2024-12-11 10:32:15 +00:00
Nick Todd
4050bd9e85 #2888: Add identifier keyword to services. 2024-12-11 10:12:50 +00:00
Nick Todd
66f775da4d #2888: Add ConfigSchema to Services. 2024-12-10 16:58:28 +00:00
Nick Todd
7dd25f18f6 #2888: Update with ConfigSchema 2024-12-10 12:27:50 +00:00
Nick Todd
ed128fc535 #2888: Add ConfigSchema to Application class. 2024-12-09 16:38:42 +00:00
Charlie Crane
068ad2f1fa #2912 - Updates to get tests to pass. Some ACL rules still misbehaving 2024-12-09 13:56:40 +00:00
Charlie Crane
386717fa41 #2912 - removal of the rom_config method as this shouldn't be needed for the actions refactor 2024-12-09 09:59:47 +00:00
Charlie Crane
a8fbb002e4 #2912 - Updates following review, ACL rules now have validation for ConfigSchema fields 2024-12-09 09:54:35 +00:00
Charlie Crane
be174b6477 #2912 - Actioning review comments 2024-12-06 15:12:31 +00:00
Charlie Crane
1798ec6fe0 #2869 - Commit before switching branches. Changes to make pydantic happy with AgentLog 2024-12-05 14:00:44 +00:00
Charlie Crane
917386d638 #2869 - Agents Refactor 2024-11-27 15:29:51 +00:00
Charlie Crane
7435a4dee8 #2869 - Commit before changing branches. Addition of properties to Agent classes and removal of if/else chain in game.py 2024-11-21 14:45:35 +00:00
Charlie Crane
75d4ef2dfd #2869 - eod commit. Updates to AbstractAgent.from_config, and some minor tweaks to PrimaiteGame 2024-11-20 17:51:05 +00:00
Charlie Crane
a3dc616126 #2869 - Starter changes in refactor of agent classes for refactor to become extensible. Identifiers added to classes and beginning of the inclusion of a ConfigSchema to base AbstractAgentClass 2024-11-20 17:19:35 +00:00
Charlie Crane
8f610a3dd9 #2912 - Minor changes to documentation page for extensible actions 2024-11-19 19:39:23 +00:00
Charlie Crane
d3c52d0d72 #2912 - Remove some debugging print statements and apply pre-commit lint changes 2024-11-19 18:58:51 +00:00
Charlie Crane
b4bc59f633 #2912 - Updates to actions refactor to align with rewards refactor for consistency across codebase. 2024-11-19 18:57:40 +00:00
Charlie Crane
958502d055 #2912 - Removal of todo and updated actions __init__.py 2024-11-15 17:47:58 +00:00
Charlie Crane
0439c3159e #2912 - Minor update to extensible actions documentation and moved old actions into _legacy 2024-11-15 17:40:11 +00:00
Charlie Crane
ce77df00cc #2912 - Updated changelog 2024-11-15 17:22:47 +00:00
Charlie Crane
4e7ca7a88a #2912 - Removal of excess comments 2024-11-15 16:49:16 +00:00
Charlie Crane
95fbe45137 #2912 - Updates so that all tests within test_actions.py pass 2024-11-13 15:32:48 +00:00
Charlie Crane
ed020f005f #2912 - Pre-commit updates ahead of first draft PR. 2024-11-13 10:40:51 +00:00
Charlie Crane
d757bd01f0 #2912 - Updated to include __all__ and some test fixes. New extensible actions documentation page 2024-11-12 14:49:44 +00:00
Nick Todd
02d29f7fb9 #2913: Updates to How-To guide 2024-11-07 16:35:39 +00:00
Nick Todd
e0b885cc79 #2913: Changes to update test_sticky_rewards.py 2024-11-07 13:08:44 +00:00
Nick Todd
9d6536fa6a #2913: Pre-commit fix 2024-11-06 15:08:38 +00:00
Nick Todd
4c2ef6ea2a #2913: Updated tests 2024-11-06 14:52:22 +00:00
Nick Todd
370bcfc476 #2913: Make rewards work with config file. 2024-11-06 11:35:06 +00:00
Nick Todd
b849ea6312 #2913: Remove from_config() and refactor (WIP). 2024-11-04 17:41:43 +00:00
Nick Todd
6b29362bf9 #2913: Tidy up config files. 2024-10-31 14:42:50 +00:00
Nick Todd
eb827f7e0a #2913: How-To guide initial commit. 2024-10-31 14:42:26 +00:00
Charlie Crane
844a3a60fa #2912 - Steps to get test_actions passing the refactored actions. Some linting changes and YAML updates. 2024-10-30 18:34:05 +00:00
Nick Todd
7d977c8095 #2913: Fix config path for test. 2024-10-30 16:33:14 +00:00
Nick Todd
77219db041 #2913: Remove dns_server option from config files. 2024-10-30 16:32:49 +00:00
Nick Todd
97094aba79 #2913: Pre-commit changes. 2024-10-30 11:15:39 +00:00
Nick Todd
9fd862763b #2913: Ensure optional software in config file is enabled. 2024-10-30 11:11:07 +00:00
Nick Todd
3c1bb2d546 #2913: Integration test fixes. 2024-10-29 16:57:11 +00:00
Nick Todd
6f6e4131b4 #2913: Handle case where server_ip_address is None 2024-10-29 16:54:19 +00:00
Charlie Crane
5cd629a821 #2912 - Fixed actionmanager issue and moved abstractaction to solve import error 2024-10-23 18:45:57 +01:00
Charlie Crane
518b934e09 #2912 - Corrections to some actions & fixing some linting. TODO: Action Manager errors 2024-10-22 17:02:54 +01:00
Nick Todd
85216bec94 #2913: Rename notebook to replace '&'. 2024-10-22 16:48:30 +01:00
Nick Todd
c3f266e401 #2913: Remove unneeded import and pre-commit changes. 2024-10-22 16:26:57 +01:00
Nick Todd
37bdbaf0d1 #2913: Fix JSON breakage and old-style PORTS and PROTOCOL usage. 2024-10-22 16:15:04 +01:00
Nick Todd
318f8926f0 #2913: Fix remaining test errors. 2024-10-22 12:14:30 +01:00
Nick Todd
f95ba8cbbc #2913: Fix remaining pydantic errors. 2024-10-22 11:01:35 +01:00
Charlie Crane
11357f87ca #2912 - eod commit. Addressing test and lint errors for refactored actions 2024-10-21 17:51:55 +01:00
Nick Todd
0cf8e20e6d #2913: Update reward classes to work with pydantic. 2024-10-21 17:11:11 +01:00
Nick Todd
bbcbb26f5e #2913: Fix ActionPenalty. 2024-10-21 14:43:51 +01:00
Charlie Crane
a5c7565f0e #2912 - eod commit. Gutted ActionManager and corrected some identifiers. 2024-10-18 16:28:15 +01:00
Charlie Crane
83d3120b04 #2912 - Additional actions added to config.py, refactor of HostNIC 2024-10-18 14:52:50 +01:00
Charlie Crane
1b1f3e4f71 #2912 - Updates to remaining action refactoring 2024-10-18 12:07:53 +01:00
Charlie Crane
a90aec2bcd #2912 - End of day commit 2024-10-17 16:59:44 +01:00
Nick Todd
419a86114d #2913: Now with ConfigSchemas. 2024-10-17 16:35:13 +01:00
Nick Todd
fe6a8e6e97 #2913: Initial commit of new AbstractReward class. 2024-10-17 13:24:57 +01:00
Charlie Crane
cd30e2d084 #2912 - Mid-day commit. Actions moving across from actions.py to game.agent.actions 2024-10-17 12:22:30 +01:00
Marek Wolan
861cfe2c0a #2912 - scaffold of action changes 2024-10-11 15:00:26 +01:00
Marek Wolan
6844bd692a bump version to 4.0.0a1 2024-10-11 13:02:44 +01:00
Marek Wolan
9626cfc990 Merge remote-tracking branch 'origin/release/3.3.0' into 4.0.0a1 2024-10-11 12:42:32 +01:00
Marek Wolan
43ec85a669 #2755 - refix some air space frequency issues 2024-10-11 09:52:16 +01:00
Marek Wolan
8419fd751a Merged PR 561: Make it possible to add sets of nodes to the network
## Summary
* Changed the office LAN convenience function to a class with a registry. Now, plugin can register custom node adders.
* Added ability to define `node_sets` in the config that map to `NetworkNodeAdder` subclasses
* Made airspacefrequency into a DTO class again to make management simpler.
* Moved the node registry out of `HostNode` and `NetworkNode` into `Node`
* Changed game.py to check the hardcoded node types before the node registry (this will change once I add ConfigSchema to all node subclasses)
* Made `show` method of the network container show all nodes, including ones registered at runtime.

## Test process
* Existing tests passed.
* Added unit tests for node adders

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code
2024-10-09 14:56:57 +00:00
Marek Wolan
611b34e29f remove outdated comment 2024-10-09 14:16:23 +01:00
Marek Wolan
a42398ac09 Fix typos and improve validation 2024-10-09 14:15:53 +01:00
Marek Wolan
56a17c3fea Update typos and comments according to PR comments 2024-10-08 13:40:40 +01:00
Marek Wolan
39c190e5f4 add documentation for node seta and update changelog 2024-10-04 12:46:29 +01:00
Marek Wolan
07c4860059 Add more tests for office lan creation 2024-10-04 11:36:48 +01:00
Marek Wolan
b4cc1b4379 Add tests for office lan creation 2024-10-04 11:07:49 +01:00
Marek Wolan
b5b7fc6a8d Give node types their own identifiers and make the network show method use them 2024-10-04 09:20:07 +01:00
Marek Wolan
5fde945fac rename identifier back to type 2024-10-02 14:24:59 +01:00
Marek Wolan
a838cc6ce1 Convert office lan adder to a class and make it extendable 2024-10-02 13:56:39 +01:00
Charlie Crane
8209424e97 Merged PR 560: #2900 - Terminal last response
## Summary
This PR introduces the `last_response` attribute within Terminal, similar to that seen within the C2 suite. The aim of this is to resolve the bug seen when using Terminal, in that when sending remote commands to execute, the RequestResponse does not indicate whether the command was successfully actioned, just that it was sent.

## Test process
New test to check that `last_response` contains the correct ReqestResponse following remote command execution

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

#2900 - Changes to terminal to include a last_response attribute, for use in obtaining RequestResponse from remote command executions

Related work items: #2900
2024-10-01 11:26:32 +00:00
Charlie Crane
fcfea3474f #2900 - typo in test_ftp_client and expanded test_terminal_last_response_updates to include a failure scenario 2024-10-01 11:41:42 +01:00
Charlie Crane
1e1d152481 #2900 - Updates to Terminal-Processing jupyter notebook to include a mention of last_response 2024-10-01 11:02:23 +01:00
Charlie Crane
3dafad71b3 #2900 - New test to show that last_response updates as expected. Changelog updated. 2024-10-01 10:45:03 +01:00
Charlie Crane
ac921749a7 #2900 - Changes to terminal to include a last_response attribute, for use in obtaining RequestResponse from remote command executions 2024-09-30 17:38:24 +01:00
Czar Echavez
33c020e671 Merged PR 557: #2897: How to guide on dev mode
## Summary
Added a how to guide which shows the example of the primaite dev-mode commands being run and how to effectively use the commands

## Test process
n/a the notebook is a test itself

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2897: How to guide on dev mode

Related work items: #2897
2024-09-30 10:10:13 +00:00
Marek Wolan
2bd6c69343 Merged PR 549: Align main and dev histories
Related work items: #1847, #2438, #2457, #2472, #2502, #2536, #2552, #2560, #2561, #2563, #2570, #2588, #2606, #2610, #2618, #2620, #2623, #2625, #2626, #2628, #2637, #2639, #2641, #2646, #2656, #2658, #2659, #2660, #2661, #2681, #2682, #2686, #2688, #2689, #2697, #2700, #2701, #2702, #2705, #2716, #2718, #2720, #2721, #2725, #2734, #2736, #2739, #2740, #2745, #2747, #2748, #2757, #2768, #2769, #2772, #2779, #2781, #2799, #2826, #2837, #2844
2024-09-30 09:32:50 +00:00
Marek Wolan
d26fcf01a2 Merged PR 558: Make software manager show method always show all software.
DataFusionService didn't show in software list, because it uses the port_protocol_mapping as the source of truth for installed software instead of the software list itself.

This fixes that :)

Related work items: #2899
2024-09-30 08:16:46 +00:00
Marek Wolan
221e09ba51 Turn AirSpaceFrequency to a schema instead of a dict for validation 2024-09-27 15:06:19 +01:00
Marek Wolan
5282cb0294 #2899 - Make software manager always show() all software 2024-09-27 10:56:48 +01:00
Czar Echavez
17fe5cb043 #2897: How to guide on dev mode 2024-09-27 10:47:38 +01:00
Marek Wolan
521580ea12 Merged PR 555: Refactor Ports and Airspace to be extensible
## Summary
* Ports are no longer enums, they are now plain integers
* Ports are no longer validated against a list of pre-defined ports, any integer from 0-65535 can be used now.
* Port enum was replaced with a convenience port lookup. For example any expression in the form `Port.HTTP` was replaced with `PORT_LOOKUP["HTTP"]` which resolves to the integer 80.
* Some tests were adjusted to use the new syntax for ports
* Backwards compatibility for YAML configs has been retained by adding pydantic validators to automatically convert named ports to integer counterparts, however defining action/observation spaces in code now requires users to specify ports as integers instead of port enum objects. For instance, monitored_ports in the ACL observation space will now look like this: `[53, 80]` instead of `[Port.DNS, Port.HTTP]`
* Plugins can extend the port lookup, however it is not necessary because it's possible to use integer literals.
* Airspace has been treated similarly, except airspace frequencies have multiple attributes, namely max_data_rate_bps. Therefore, the lookup for named Frequencies resolves to a dictionary of freq_hz (float), and max_data_rate_bps (float)
* Airspace logic has been adjusted accordingly to use the new dictionary for tracking bandwidth limits
* A new method for registering new airspace frequencies has been added. Plugins that add new frequencies can call `register_default_frequency`, after which any new airspace will have access to that frequency.

* For consistency, `IPProtocol` was also changed to be a lookup instead of an enum. It is not extendable by plugins as so far we have not needed to model additional protocols in our plugin.

These changes were necessary as it's not possible to extend enums in python, therefore plugins would not have been able to add new ports. There is an added benefit that this is a stepping stone towards support communication on dynamic and ephemeral ports.

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code
2024-09-27 09:19:17 +00:00
Marek Wolan
c74d5ac227 Fix changelog typo and remove repitition in ACL show method 2024-09-27 09:28:26 +01:00
Marek Wolan
203ec5ec85 Add tests for port and protocol validation and update changelog 2024-09-26 16:00:59 +01:00
Marek Wolan
f2b6d68b14 Fix Port scan 2024-09-26 15:35:50 +01:00
Czar Echavez
e7c30d5c8b Merged PR 548: #2445: added the ability to pass the game options thresholds to observations...
## Summary
Added ability to pass the game options thresholds into observation classes

This will allow for NICObservation, FileObservation (and FolderObservation) and ApplicationObservation to be able to get the thresholds for the training session. i.e. Allows for the thresholds for NMNE, file access and application executions to be configurable for training.

## Test process
https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/548?_a=files&path=/tests/integration_tests/configuration_file_parsing/test_game_options_config.py

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2445: added the ability to pass the game options thresholds to observations so that relevant observation items can retrieve the thresholds from config

Related work items: #2445
2024-09-26 08:46:36 +00:00
Czar Echavez
603c68acf9 #2445: grammar in changelog 2024-09-26 08:51:30 +01:00
Marek Wolan
50e2234a69 Remove commented out code 2024-09-25 16:51:58 +01:00
Marek Wolan
c3eb093144 remove temporary notebook 2024-09-25 16:50:01 +01:00
Marek Wolan
f1b911bc65 Change port and protocol to annotated validators 2024-09-25 16:28:22 +01:00
Czar Echavez
b9df2bd6a8 #2445: apply PR suggestions 2024-09-25 10:50:26 +01:00
Czar Echavez
171dd83f2f Merge remote-tracking branch 'origin/dev' into feature/2445-make-observation-thresholds-configurable 2024-09-25 09:04:18 +01:00
Archer Bowen
b0363a6b48 Merged PR 534: #2840 NODE_SEND_LOCAL_COMMAND
## Summary
Enables agents to use a new CAOS action ``NODE_SEND_LOCAL_COMMAND``.

## Test process

Added a new unit test as well as tested manually via sandbox notebooks.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [X] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2840
2024-09-24 10:47:08 +00:00
Archer Bowen
e29815305d #2840 Addressing PR comments. 2024-09-24 11:06:38 +01:00
Archer Bowen
88cbb783bc #2840 Fixed sphinx user guide formatting issues. 2024-09-20 13:54:13 +01:00
Archer Bowen
710a4d0e55 Merge remote-tracking branch 'origin/dev' into feature/2840_LOCAL_TERMINAL_COMMAND 2024-09-20 12:38:22 +01:00
Marek Wolan
695891f55c Add port and protocol custom validators 2024-09-20 11:21:28 +01:00
Marek Wolan
08f1cf1fbd Fix airspace and remaining port problems from refactor 2024-09-19 15:06:29 +01:00
Nick Todd
1a800ff83d Merged PR 552: Increment PrimAITE version.
## Summary
Increment PrimAITE version.

## Test process
Ran test suite.

## Checklist
- [X] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2896: Bump version.

Related work items: #2896
2024-09-19 11:27:48 +00:00
Nick Todd
0c576746aa #2896: Bump version. 2024-09-19 11:07:00 +01:00
Marek Wolan
dd931d900b port refactor - eod commit, airspace still broken 2024-09-18 16:02:25 +01:00
Marek Wolan
8c8b3c498a Merged PR 545: Merge release/3.3 into main
Related work items: #2681, #2686, #2689, #2718, #2720, #2721, #2736, #2748, #2768, #2769, #2772, #2779, #2781, #2799, #2826, #2837, #2844
2024-09-18 08:21:58 +00:00
Charlie Crane
6a177caadb Merged PR 544: #2871 - Add show functions to Agents
## Summary
This PR introduces a `show_history` function that can be used to view what actions have been taken by an agent over a training session. Be default, this won't show any `DONOTHING` actions.

## Test process
![image.png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/544/attachments/image.png)

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2871
2024-09-18 07:30:18 +00:00
Charlie Crane
8d3760b5a7 #2871 - Fix notebook failure 2024-09-17 16:19:43 +01:00
Nick Todd
d50c0c8911 Merged PR 538: NMNE config issues
## Summary
Update NMNE and NICObservation code to handle all four permutations of include_nmne and capture_nmne set to True/False.

## Test process
Updated existing NMNE and NICObservation tests.
All existing tests pass.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2829

Related work items: #2829
2024-09-17 15:06:06 +00:00
Nick Todd
335ca9a02f Merged PR 546: Log the random seed used on each run
## Summary
Added changes so that the value of the random number seed is recorded in a log file when it's specified or the user asks for a RNG seed to be automatically generated.

## Test process
Updated existing RNG tests; added new test.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2879
2024-09-17 13:06:10 +00:00
Czar Echavez
4f172634d0 Merge remote-tracking branch 'origin/dev' into feature/2445-make-observation-thresholds-configurable 2024-09-17 12:42:57 +01:00
Czar Echavez
4391d7cdd5 #2445: added the ability to pass the game options thresholds to observations so that relevant observation items can retrieve the thresholds from config 2024-09-17 12:19:35 +01:00
Charlie Crane
3a5b75239d #2871 - Typo in Changelog 2024-09-17 12:05:40 +01:00
Czar Echavez
c589c3d3c2 Merged PR 543: #2880: fix action shape for num_ports + test
## Summary
Resolved a bug where the array for protocols is used to determine the num_ports instead of the array for ports

## Test process
Added a test that checks the shape of the RouterAddACLRule action

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2880: fix action shape for num_ports + test

Related work items: #2880
2024-09-17 09:38:05 +00:00
Charlie Crane
ccb91869c4 #2871 - Minor wording change to description in agents.rst 2024-09-17 10:17:18 +01:00
Nick Todd
67a7142221 Merge branch 'dev' into feature/2879-log-random-seed-value 2024-09-17 10:11:15 +01:00
Charlie Crane
c8f6459af6 #2871 - Changelog and documentation updates, corrected changes in Data manipulation demo notebook 2024-09-17 10:09:10 +01:00
Charlie Crane
cf9646a183 Merge branch 'dev' into feature/2871-Add_show_methods_agents 2024-09-17 09:46:27 +01:00
Charlie Crane
5d7935cde0 #2871 - Changes to notebooks following updates to action history 2024-09-17 09:39:32 +01:00
Nick Todd
078b898565 #2879: Update changelog. 2024-09-17 09:30:14 +01:00
Charlie Crane
78014cd54e Merged PR 540: Sync User Guide updates back into Dev
## Summary
Syncing Dev with release/3.3.0 following changes to the User Guide after review.

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2837
2024-09-17 08:28:06 +00:00
Nick Todd
f3ca9c55c9 #2879: Update tests 2024-09-16 16:38:19 +01:00
Nick Todd
215ceaa6e8 #2879: Fix call to set_random_seed() in reset(). 2024-09-16 10:08:45 +01:00
Nick Todd
e0a1092834 #2879: Pre-commit fix. 2024-09-16 09:04:17 +01:00
Charlie Crane
5006e41546 #2871 - Updated the show_history() function to receive a list of actions to ignore when printing the history. Defaults to ignoring DONOTHING actions 2024-09-13 15:47:59 +01:00
Nick Todd
01a2c834ce #2879: Write seed value to log file. 2024-09-13 14:53:15 +01:00
Charlie Crane
f2a0eeaca2 #2871 - Updated show_history() method to use boolean 'include_nothing' for whether to include DONOTHING actions 2024-09-13 14:11:13 +01:00
Charlie Crane
7e1561924a Merged PR 542: Update arp.show() to include port_num
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [X] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

#2456 - Minor change to arp.show() to include port number

Related work items: #2456
2024-09-13 13:01:47 +00:00
Nick Todd
08fcf1df19 #2879: Add generate_seed_value to global options. 2024-09-13 12:59:41 +01:00
Nick Todd
6ebe50c331 #2879: Reduce max seed value to comply with python random seed limit 2024-09-13 12:58:37 +01:00
Nick Todd
cd8fc6d42d #2879: Handle generate_seed_value option 2024-09-13 12:10:49 +01:00
Charlie Crane
59e1ca6615 #2456 - Merging in updates on Dev and resolving merge conflicts 2024-09-13 11:55:26 +01:00
Charlie Crane
c924b9ea46 #2871 - Initial commit of a show_history() function in AbstractAgent 2024-09-13 11:54:17 +01:00
Czar Echavez
519fb98e25 Merged PR 541: Config item that allows services and applications to return actual health states without the need to scan
## Summary
Added:
- services_requires_scan
- applications_requires_scan

To allow the agents to get the actual health state of services and applications without the need to scan

## Test process
https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/541?_a=files&path=/tests/unit_tests/_primaite/_game/_agent/test_observations.py

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2864
2024-09-13 10:24:31 +00:00
Charlie Crane
17035be028 #2456 - Actioning review comment 2024-09-13 11:13:55 +01:00
Czar Echavez
9a2fb2a084 #2880: fix action shape for num_ports + test 2024-09-13 11:11:58 +01:00
Charlie Crane
94b30909ee #2456 - Updated Changelog 2024-09-13 10:56:12 +01:00
Charlie Crane
d8c85058ed #2456 - Minor change to arp.show() to include port number 2024-09-13 10:32:09 +01:00
Czar Echavez
454789f494 #2864: add to changelog 2024-09-13 09:34:09 +01:00
Czar Echavez
f1ff1f13cf #2864: added applications_requires_scan test 2024-09-13 09:08:44 +01:00
Czar Echavez
1f937a4c96 #2864: config not being passed correctly 2024-09-12 18:54:18 +01:00
Czar Echavez
7c26ca9d79 #2864: add configuration for services_requires_scan and applications_requires_scan 2024-09-12 16:07:14 +01:00
Czar Echavez
eb24d1270b Merged PR 529: #2842 and #2843: implement add user and disable user actions + tests
## Summary
Added actions which allow a user to be added and disabled

## Test process
https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/529?_a=files&path=/tests/integration_tests/game_layer/actions/test_user_account_actions.py

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2842 and #2843: implement add user and disable user actions + tests

Related work items: #2842, #2843
2024-09-12 09:45:05 +00:00
Czar Echavez
8bd20275d0 #2842: fix test 2024-09-12 10:01:12 +01:00
Charlie Crane
31a820f021 Merged PR 539: ACL rules don't apply to ARP
## Summary
Updates to `router.py` to allow ARP layer-2 traffic to not be held up by ACL rules, as they now only handle layer-3 traffic.
An explicit ACL rule to permit ARP traffic is no longer needed.
Documentation updates to reflect change.

## Test process
All tests still pass.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [X] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2775
2024-09-12 08:17:45 +00:00
Charlie Crane
f908f9b23e #2775 - Actioning review comments 2024-09-11 15:50:14 +01:00
Charlie Crane
85863b1972 #2775 - Removed a print statement committed in error and updated the checks done in subject_to_acl following review 2024-09-11 15:36:51 +01:00
Charlie Crane
f95501f2a8 #2775 - Purging of more instances where the ARP acl rule is set and no longer necessary. Added a new test to show ARP is unaffected by ACL rules and actioned review comments 2024-09-11 15:12:36 +01:00
Charlie Crane
d5f1d0fda1 #2775 - Updated Changelog and bring up to date with dev 2024-09-11 11:28:27 +01:00
Charlie Crane
e9531bc392 Merge branch 'dev' into feature/2775-Refactor_Networking_Nodes 2024-09-11 11:27:26 +01:00
Charlie Crane
a2005df9f0 #2775 - Documentation updates 2024-09-11 10:56:44 +01:00
Charlie Crane
19d6fa2174 #2775 - Updated to look neater 2024-09-11 10:12:07 +01:00
Czar Echavez
1cdf9edffb Merged PR 536: #2345: remove try catch + todo - figure out why db connection cannot be made
## Summary
Remove try catch in webserver to prevent difficult to debug problems

## Test process
Used existing tests - this is because webserver should still act as before - only the try catch block is removed

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2345: remove try catch + todo - figure out why db connection cannot be made

Related work items: #2345
2024-09-10 12:39:18 +00:00
Charlie Crane
1c6e8b2a95 #2775 - Removed default ARP rule for routers and added logic when handling ARP traffic 2024-09-10 11:39:04 +01:00
Czar Echavez
82887bdb17 #2842: apply PR suggestions 2024-09-10 10:52:00 +01:00
Nick Todd
3cecf169ba #2829: Update and add nmne tests 2024-09-09 16:30:36 +01:00
Czar Echavez
4a48a8d054 #2345: return error if db connection cannot be made 2024-09-09 10:54:42 +01:00
Nick Todd
3c8f21c666 Merge branch 'dev' into feature/2829-handle-NMNE-configs 2024-09-09 09:13:37 +01:00
Nick Todd
5ab42ead27 #2829: Add check for capture_nmne 2024-09-09 09:12:20 +01:00
Archer.Bowen
974aee90b3 #2842 Added additional tests to confirm terminal functionality 2024-09-06 14:09:30 +01:00
Charlie Crane
5e5fbf50c3 Merged PR 532: Actioning review comments following second review
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2837 - Actioning review comments following second review [skip ci]

Related work items: #2837
2024-09-06 09:10:20 +00:00
Charlie Crane
731982b698 #2837 - Adding some additional wording to the README.md [skip ci] 2024-09-06 10:05:10 +01:00
Archer Bowen
7562f6fc5c Merge remote-tracking branch 'origin/dev' into feature/2840_LOCAL_TERMINAL_COMMAND 2024-09-06 10:04:49 +01:00
Czar Echavez
a998b8e22b #2345: remove try catch + todo - figure out why db connection cannot be made 2024-09-05 16:47:17 +01:00
Charlie Crane
f6d793196d #2837 - Actioning review comments following second review [skip ci] 2024-09-05 16:44:29 +01:00
Czar Echavez
1234b2dc4a Merged PR 523: #2782: initial impl of files in nodes
## Summary
Added ability to add folders and files to nodes via configuration

## Test process
https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/523?_a=files&path=/tests/integration_tests/configuration_file_parsing/test_node_file_system_config.py

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2782: initial impl of files in nodes

Related work items: #2782
2024-09-05 13:57:42 +00:00
Czar Echavez
e809d89c30 #2842 and #2843: implement add user and disable user actions + tests 2024-09-05 13:47:59 +01:00
Charlie Crane
31f5e5c07b Merged PR 526: User Guide Review Comments
## Summary

Minor changes to the User Guide documentation following review. These changes should encompass all core documentation comments.

## Test process
TBD

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [X] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2837
2024-09-05 11:09:13 +00:00
Charlie Crane
60e2225a2c #2837 - Correcting formatting on action masking table [skip ci] 2024-09-05 12:03:20 +01:00
Charlie Crane
9fe48bb241 #2837 - Commiting a typo correction in Using Episode Schedules notebook [skip ci] 2024-09-05 11:32:39 +01:00
Charlie Crane
a5e75f9fed #2837 - Actioning notebook review comments 2024-09-05 11:24:52 +01:00
Charlie Crane
fcbde31dad #2837 - Actioning review comments and fixing a bug with links to the common attributes within software documents 2024-09-05 11:23:52 +01:00
Czar Echavez
2391c48569 #2782: apply suggestions 2024-09-05 10:18:35 +01:00
Charlie Crane
3feb908900 #2837 - Added a description of how some rewards can be made sticky/instantaneous. [skip ci] 2024-09-05 09:02:07 +01:00
Charlie Crane
e18ac0914f #2837 - Correcting date on changelog v3.3 release 2024-09-05 08:42:38 +01:00
Charlie Crane
0140982d5e #2837 - Updating link to common attributes within Software components following Review comments. [skip ci] 2024-09-05 08:41:04 +01:00
Charlie Crane
ba737c57a8 #2837 - Minor structure reshuffle to address confusion around the listen_on_ports variable [skip ci] 2024-09-04 20:46:35 +01:00
=
310876cd3b 2755 Add ability to extend HostNode, NetworkNode, Service and Application outside PrimAITE. 2024-09-04 15:49:37 +01:00
Nick Todd
78c36f20a0 Merged PR 525: Log observation space data for each episode and step.
## Summary
Updated `AgentHistoryItem` class so that it stores observation space data for every step of each episode. This means that `write_agent_log()` will log the additional data to file provided that `save_agent_actions` is set to `true` in the config file.

## Test process
Tested on following notebooks on Linux and Windows:

- Data-Manipulation-E2E-Demonstration
- Training-an-SB3-Agent
- Training-an-RLLib-Agent
- Training-an-RLLIB-MARL-System.

Wrote and passed new test: `test_obs_data_capture`.
Passes all existing tests.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2845
2024-09-04 14:26:53 +00:00
Nick Todd
5608ad5ed5 #2845: Change 'obs_space_data' to 'observation'. 2024-09-04 14:25:08 +01:00
Charlie Crane
16e0df5cfc #2837 - Updates to some more documentation files to cover new features [skip ci] 2024-09-04 14:12:39 +01:00
Charlie Crane
f0cc821ff8 #2837 - Updates to some more documentation files to cover new features [skip ci] 2024-09-04 14:12:10 +01:00
Charlie Crane
b3080100fd #2837 - Updating the User Guide as per review comments. [skip ci] 2024-09-04 12:08:12 +01:00
Charlie Crane
d282575467 #2837 - Updating the User Guide as per review comments. [skip ci] 2024-09-04 12:07:32 +01:00
Czar Echavez
1374a23e14 #2782: fix spacing in data_manipulation yaml + documentation 2024-09-04 10:17:33 +01:00
Nick Todd
f4b1d9a91c #2845: Update CHANGELOG. 2024-09-03 17:26:01 +01:00
Nick Todd
1822e85eec #2845: Pre-commit fixes 2024-09-03 17:24:21 +01:00
Nick Todd
61add769c4 #2845: Add test for obs_data_space capture. 2024-09-03 17:16:48 +01:00
Nick Todd
8e57e707b3 #2845: Changed to store obs data within AgentHistoryItem 2024-09-03 14:38:19 +01:00
Czar Echavez
26a56bf360 #2782: documentation + adding example to data_manipulation.yaml 2024-09-03 12:37:39 +01:00
Czar Echavez
8e6b9f3970 #2782: added ability to create empty folders + create files with size and types + tests 2024-09-03 11:53:23 +01:00
Archer Bowen
fd3d3812f6 #2840 Documentation and minor bug fixes found in terminal and session manager. 2024-09-02 16:55:43 +01:00
Nick Todd
5cacbf0337 #2845: Changes to write observation space data to log file. 2024-09-02 16:54:13 +01:00
Czar Echavez
a7f00c668d #2782: initial impl of files in nodes 2024-09-02 15:15:45 +01:00
Archer Bowen
987546f77f Merge remote-tracking branch 'origin/dev' into feature/2840_LOCAL_TERMINAL_COMMAND 2024-09-02 11:51:28 +01:00
Archer Bowen
0ff88e3672 #2840 Initial Implementation completed and tested. 2024-09-02 11:50:49 +01:00
Marek Wolan
a5d84c1254 Reduce evaluation on Ray notebooks and fix precommit issues [skip ci] 2024-09-02 11:40:39 +01:00
Defence Science and Technology Laboratory UK
a6dd9b850b Automated benchmark output commit for version 3.3.0 [skip ci] 2024-09-02 09:53:06 +00:00
Marek Wolan
3a6e10b772 Updated VERSION 2024-09-02 07:46:03 +00:00
Marek Wolan
049f7b7647 Update action masking to inlcude new actions 2024-08-30 15:22:05 +01:00
Nick Todd
08f742b3ec Merged PR 522: #2844: Added evaluation stage to Ray notebooks.
## Summary
Added evaluation stage to Training-an-RLLib-Agent and Training-an-RLLIB-MARL-System notebooks.

## Test process
Tested individual notebooks.
Ran all PrimAITE tests.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2844: Added evaluation stage to Ray notebooks.

Related work items: #2844
2024-08-30 10:18:31 +00:00
Nick Todd
d3200f70e1 #2844: Added evaluation stage to Ray notebooks. 2024-08-30 10:23:34 +01:00
Marek Wolan
3de12573d3 Merged PR 520: Backport core changes from internal 2024-08-28 09:56:56 +00:00
Marek Wolan
a1553fb1b4 Backport core changes from internal 2024-08-28 10:20:32 +01:00
Marek Wolan
90cfe2f22b Merged PR 518: Fixed incorrect formatting on .rst and new priv esc notebook 2024-08-23 11:26:10 +00:00
Archer Bowen
9a6b1d374a Fixed incorrect formatting on .rst and new priv esc notebook 2024-08-23 12:22:56 +01:00
Marek Wolan
0e0fc96cd3 Merged PR 517: create doc page on rewards 2024-08-23 08:54:47 +00:00
Marek Wolan
fbbaf65aab create doc page on rewards 2024-08-22 18:12:37 +01:00
Christopher McCarthy
ff5a2e1bbe Merged PR 510: Privilege Escalation & Data Loss Example Notebook
## Summary
- Added a new Privilege-Escalation-and Data-Loss-Example.ipynb notebook with a more realistic scenario.
- Made some minor changes to multi_lan_internet_network_example.yaml to enable the new scenario.

## Test process
Manual end-to-end run of the notebook.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2686
2024-08-22 10:12:38 +00:00
Chris McCarthy
4a7a4fd571 #2686 - typo changes in jupyter notebook 2024-08-22 09:53:27 +01:00
Marek Wolan
c4eb60deda Merged PR 511: Fix incorrect removal of last_query_response from database client
oopsie

Related work items: #2736
2024-08-20 19:49:14 +00:00
Marek Wolan
71ec71e400 Fix incorrect removal of last_query_response from database client 2024-08-20 15:46:54 +00:00
Chris McCarthy
5d209e4ff9 #2686 - Added a new Privilege-Escalation-and Data-Loss-Example.ipynb notebook with a more realistic scenario. Made some minor changes to multi_lan_internet_network_example.yaml to enable the new scenario. 2024-08-20 15:33:39 +01:00
Archer Bowen
bceedbf72d Merged PR 504: Command and Control Full PR
## Summary
Implements the Command and Control applications to the quality and capability needed for the TAP001 expansion and lays the foundations for all the features required for TAP002 (Next Release).

The C2C suite contains three new applications:

**1. Abstract C2**

Base class for the C2 Server and the C2 Beacon. Controls the main internal logic of both applications but with a couple of abstract methods which each class defines differently.

**2. C2 Server**

The C2 Server takes red agent actions and converts the action options into C2 Commands which are then passed to the C2 Beacon.
The output of these commands is sent back to the C2 Server and then returned back to the red agent.

**3. C2 Beacon**

The C2 beacon uses the Terminal and the Ransomware Applications to perform different commands which it receives these commands and executes them and returns the output.

The C2 beacon can also be configured by the Red Agent to configure the current networking behaviour.

For a much more detailed description please refer to the .rst documentation and the notebook which demonstrate and describe the functionality very explicitly.

Lastly the wiki page also provides more information around the design work for this feature.

[Command and Control](/Welcome-to-PrimAITE!/Design/[~In-Progress~]/Command-and-Control)

Worth noting that some changes were needed that were unseen during the design page but the overall goals of the feature have been accomplished.

## Test process
Tested via notebooks and a series of e2e tests.

## Checklist
- [x] PR is linked to a **work item**
- [x] **acceptance criteria** of linked ticket are met
- [x] performed **self-review** of the code
- [x] written **tests** for any new functionality added with this PR
- [x] updated the **documentation** if this PR changes or adds functionality
- [x] written/updated **design docs** if this PR implements new functionality
- [x] updated the **change log**
- [x] ran **pre-commit** checks for code style
- [x] attended to any **TO-DOs** left in the code (One remaining but unsure if it should be handled in this PR)

Related work items: #2689, #2720, #2721, #2779
2024-08-20 13:16:22 +00:00
Marek Wolan
23194e1ba8 Merged PR 508: Add option for rewards to be instantaneous
## Summary
* Changed how `GreenAdminDatabaseUnreachablePenalty`, `WebpageUnavailablePenalty`, and `WebServer404Penalty` work.
* They can now be configured with `sticky: false` in the yaml
* which means they no longer retain a positive/negative value after a successful/failed request, if the agent goes on to do nothing the next step
* refactored the calculate methods to better align with those rewards depending the previous action
* changed what is returned by some of the `describe_state` methods of sim components. They had legacy methods of returning the most recent success code which is no longer needed since the introduction of agent history

## Test process
Existing tests pass, new tests added

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2736
2024-08-20 10:40:43 +00:00
Archer Bowen
c9d62d512c #2689 fixed mismerge 2024-08-20 11:15:04 +01:00
Archer Bowen
b8767da61e #2689 Fixed merging errors with actions.py 2024-08-20 10:51:29 +01:00
Marek Wolan
1833dc3946 #2736 - typo fixes 2024-08-20 10:41:40 +01:00
Marek Wolan
98f5454f04 Merge remote-tracking branch 'origin/dev' into feature/2736-instantaneous-rewards 2024-08-20 10:40:48 +01:00
Archer Bowen
5bba4ed20e Merge remote-tracking branch 'origin/dev' into feature/2689-command-and-control 2024-08-20 09:30:43 +01:00
Nick Todd
b7ef538942 Merged PR 507: #2748: Port of PrimAITE Internal changes.
## Summary
This a port of the AgentHistoryItem DB Admin (GreenAdminDatabaseUnreachablePenalty reward) changes that were made to the PrimAITE Internal repo.
See also #2826.

## Test process
Updated tests/integration_tests/game_layer/test_rewards.py.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2748: Port of PrimAITE Internal changes.

Related work items: #2748
2024-08-19 16:09:52 +00:00
Marek Wolan
15b7334f05 #2736 - Update changelog 2024-08-19 15:34:50 +01:00
Marek Wolan
538e853f26 #2736 - Add sticky reward tests and fix sticky reward behaviour 2024-08-19 15:32:25 +01:00
Czar Echavez
01f1569cc4 Merged PR 484: #2769: initial commit of user account actions
## Summary
Adding the Action Space for remote login and remote log out + change password

Updated ray to 2.32.0

## Test process
https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/484?_a=files&path=/tests/integration_tests/game_layer/actions/user_account_actions/test_remote_user_account_actions.py

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2769: initial commit of user account actions

Related work items: #2769
2024-08-19 14:31:44 +00:00
Archer Bowen
7b1584ccb7 #2689 Updated following PR 2024-08-19 15:24:24 +01:00
Marek Wolan
f344d292db #2736 - Fix up broken reward tests 2024-08-19 13:59:35 +01:00
Archer Bowen
2413a2f6a8 #2689 Fixing oversight on method call 2024-08-19 13:10:35 +01:00
Archer Bowen
f595f44ce9 #2689 Implemented fixes to _check_connection following PR 2024-08-19 13:08:31 +01:00
Nick Todd
2c71958c91 #2748: Port of PrimAITE Internal changes. 2024-08-19 12:55:45 +01:00
Marek Wolan
a997cebbc6 Apply suggestions from code review [skip ci] 2024-08-19 11:14:53 +00:00
Marek Wolan
aeca5fb6a2 #2769 - Clean up incorrect names and commented out code [skip ci] 2024-08-19 10:28:39 +01:00
Marek Wolan
05f9751fa8 #2736 - implement instantaneous rewards 2024-08-19 10:17:39 +01:00
Archer Bowen
87332873d2 #2689 Fixed issues with .rst (fixed terminal as well) 2024-08-16 15:47:41 +01:00
Archer Bowen
83b8206ce0 #2689 Added C2 Sequence diagram to docs and added additional ftp_client request tests. 2024-08-16 11:51:38 +01:00
Archer Bowen
849cb20f35 #2689 Addressed more PR comments & fixed an bug with command parsing in _command_terminal (c2 beacon) 2024-08-16 10:24:53 +01:00
Marek Wolan
d74227e34f #2769 - update changelog 2024-08-16 10:10:26 +01:00
Marek Wolan
21c0b02ff7 #2769 - update observation tests with new parameter 2024-08-16 09:21:27 +01:00
Marek Wolan
1d2705eb1b #2769 - Add user login observations 2024-08-15 20:16:11 +01:00
Archer Bowen
e5be392ea8 #2689 Updated documentation and docustrings following PR comments. 2024-08-15 17:47:33 +01:00
Archer Bowen
7d086ec35e #2689 Implemented pydantic model validation on C2 Server setup method + updated E2E notebook with data exfiltration. 2024-08-15 17:08:10 +01:00
Archer Bowen
f32b3a931f #2689 Addressed failing tests + updated c2_suite.rst to include the Data exfil command. 2024-08-15 14:41:35 +01:00
Archer Bowen
c50b005c37 #2689 Improved terminal session handling. 2024-08-15 13:10:47 +01:00
Archer Bowen
e53ac84666 #2689 Fixed small bugs, added pydantic class validation and divided the data_Exfil command on c2 beacon into two separate methods. 2024-08-15 11:36:55 +01:00
Archer Bowen
6a28f17f1b #2689 Initial draft of File exfiltration. 2024-08-14 19:49:58 +01:00
Archer Bowen
192ca814e0 Apply suggestions from code review 2024-08-13 15:49:52 +00:00
Archer Bowen
559f480062 #2689 Fixed .rst formatting issues and removed unnecessary comments. 2024-08-13 16:47:40 +01:00
Archer Bowen
d6e2994d6b Apply suggestions from code review 2024-08-13 15:43:21 +00:00
Marek Wolan
7b7adc20f9 Merge remote-tracking branch 'origin/dev' into feature/2769-implement-user-account-action-space 2024-08-13 13:15:47 +01:00
Archer Bowen
ead302c95d #2689 Added Tests for the C2 actions (Was previously covered via the notebook - now explicitly in a test.) 2024-08-13 12:33:41 +01:00
Archer Bowen
57dcd325a0 #2689 missed the hostname... 2024-08-13 10:49:10 +01:00
Archer Bowen
1138605e2b #2689 Fixing mistakenly altered test file. 2024-08-13 10:48:17 +01:00
Archer Bowen
c36af13a66 #2689 Updated changelog 2024-08-13 10:30:44 +01:00
Archer Bowen
845a4c6bd6 #2689 Final docustring updates before PR. 2024-08-13 10:18:56 +01:00
Archer Bowen
6c7376ab4b #2681 Updated to include yaml file tests + include listening on multiports. 2024-08-13 09:37:11 +01:00
Archer Bowen
27ec06658f #2689 Majorly updated the command and control notebook to demonstrate more configuration options and more text to explain the code cells. 2024-08-12 19:25:30 +01:00
Archer Bowen
cbf02ebf32 #2689 Updated documentation and moved _craft_packet into abstract C2 2024-08-12 14:16:21 +01:00
Marek Wolan
929bd46d6d #2769 - Make changing password disconnect remote sessions 2024-08-12 14:16:04 +01:00
Archer Bowen
ce3805cd15 #2689 Updated c2 tests significantly and improved quality of debug logging. 2024-08-12 10:47:56 +01:00
Marek Wolan
c886d4b014 Merged PR 501: #2799 - Fix folder scan not being required and make it configurable
## Summary
Make folder and file requiring scanning configurable. By default it's true and the new option can be omitted to ensure compatibility with old configs.

## Test process
New tests to verify that the actual or visible file/folder states are shown when configured.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

#2799 - Fix folder scan not being required and make it configurable

Related work items: #2799
2024-08-12 08:57:14 +00:00
Marek Wolan
5956721804 Merge remote-tracking branch 'origin/dev' into feature/2769-implement-user-account-action-space 2024-08-12 09:23:55 +01:00
Marek Wolan
5800334dc0 Merge dev into feature branch 2024-08-12 09:02:11 +01:00
Marek Wolan
3df55a708d #2769 - add actions and tests for terminal 2024-08-11 23:24:29 +01:00
Archer Bowen
53433ce7b6 #2689 General improvements.
1. Abstract TAP now handles .apply_timestep
2. Expanded tests
3. Added pydantic model for c2 configuration.
2024-08-09 17:53:47 +01:00
Marek Wolan
31c46950ad Merged PR 502: Add PDF benchmark output
## Summary
Uses md2pdf (MIT License) to convert the markdown file to html then to PDF.
I updated the formatting of the charts to be more legible too.
This requires WeasyPrint which is a system package available on linux, mac and windows.

## Test process
installed weasyprint on our build machine and tried the benchmark script and it worked.

https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE?version=GBrelease/fake-release-for-testing-purposes&path=/benchmark/results/v3/v3.3.0-dev0/PrimAITE%20v3.3.0-dev0%20Benchmark%20Report.pdf

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2772
2024-08-09 12:21:26 +00:00
Archer Bowen
ab91f993a5 #2689 Initial Implementation of multi-port listeners. 2024-08-09 12:45:15 +01:00
Archer Bowen
0e8e8c5681 Merge remote-tracking branch 'origin/dev' into feature/2689-command-and-control 2024-08-09 12:15:43 +01:00
Archer Bowen
4241118d26 #2689 Adding slight changes to c2_Beacon & terminal that appeared when merging from dev. 2024-08-09 12:14:57 +01:00
Christopher McCarthy
ca2aef7343 Merged PR 503: Enable Multi-Port Listening for Services and Applications
## Summary
- Added a `listen_on_ports` set in the `IOSoftware` class to enable software listening on ports in addition to the main port they're assigned.
- Also added something I missed in the `CHANGELOG.md` from user login ticket 🙃

## Test process
- Tested listening on ports with a dummy listener software class and counted frames snooped on.
- Also tested that the actual software that the posts being snooped in on still works as expected.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [X] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2768
2024-08-09 10:25:33 +00:00
Marek Wolan
f92a57cfc4 Merge remote-tracking branch 'origin/dev' into feature/2769-implement-user-account-action-space 2024-08-09 11:12:40 +01:00
Archer Bowen
507abe46c2 Merge remote-tracking branch 'origin/dev' into feature/2689-command-and-control 2024-08-09 11:12:09 +01:00
Archer Bowen
ddc9acd03a #2689 Fix notebook blue agent actions not functioning correctly. 2024-08-09 11:04:12 +01:00
Marek Wolan
bf44ceaeac Apply suggestions from code review 2024-08-09 09:26:37 +00:00
Archer Bowen
6ec575d18e #2689 Updated actions E2E notebook and other additions 2024-08-09 09:58:44 +01:00
Chris McCarthy
72e6e78ed7 #2768 - Removed debugging print statement 2024-08-09 09:32:13 +01:00
Charlie Crane
c4281f513f Merged PR 500: #2781 - Integrate Terminal and User Session manager
## Summary
Changes to Terminal to use the user_session_manager to validate user credentials.

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2781 - Initial commit with changes to Terminal to integrate with user_session_manager. Login and logout are now talking to the monitored user session

Related work items: #2781
2024-08-09 08:14:40 +00:00
Marek Wolan
df9ab13209 #2799 - Fix docstring 2024-08-09 09:11:54 +01:00
Chris McCarthy
a3a9ca9963 #2768 - Fixed issue causing main port to not be included in list of open ports. documented the configuration of listen_on_ports. added test that tests listen_on_ports configuration from yaml. 2024-08-08 21:20:20 +01:00
Charlie Crane
665c53d880 #2781 - Actioning review comments 2024-08-08 15:48:44 +01:00
Chris McCarthy
a5652ae4b2 Merge branch 'refs/heads/dev' into feature/2768_enable-multi-port-listening-for-services-and-applications 2024-08-08 14:26:35 +01:00
Charlie Crane
116ac725b0 #2718 - making terminal rm _login() and _remote_login() consistent in their RequestResponse 2024-08-08 14:23:10 +01:00
Charlie Crane
5f5ea5e524 #2718 - Updates to Terminal following discussion about implementation with actions. 2024-08-08 14:20:23 +01:00
Charlie Crane
ff054830bc #2781 - Correcting some typos in Terminal notebook and elaborating the data in _remote_login request 2024-08-08 11:57:30 +01:00
Charlie Crane
93ef3076f5 #2781 - user_session_manager._timeout_session() now sends a user_timeout command when closing remote sessions. Corrected source_ip in Terminal.receive() 2024-08-08 11:33:42 +01:00
Archer Bowen
9249447ea6 Merge branch 'dev' into feature/2689-command-and-control 2024-08-07 14:18:40 +01:00
Marek Wolan
d2693d974f Fix relative path to primaite benchmark to align with build pipeline step 2024-08-07 13:18:20 +00:00
Archer Bowen
b1baf023d6 #2689 Fixed up Pytests and confirmed functionality before merging from dev. 2024-08-07 14:16:50 +01:00
Marek Wolan
b193b46b7b #2799 - Update observation tests 2024-08-07 13:43:11 +01:00
Marek Wolan
fe599f7745 #2799 - Fix folder scan not being required and make it configurable 2024-08-07 12:09:44 +01:00
Charlie Crane
9fea34bb43 #2781 - Correcting terminal tests and fixing a typo in base.py 2024-08-07 11:58:17 +01:00
Charlie Crane
1802648436 #2781 - Initial commit with changes to Terminal to integrate with user_session_manager. Login and logout are now talking to the monitored user session 2024-08-07 11:31:51 +01:00
Archer.Bowen
afa4d2b946 #2689 Address a couple of TODOs and other misc changes. 2024-08-07 10:34:30 +01:00
Marek Wolan
0ad34caf1e Merge remote-tracking branch 'origin/dev' into feature/2772-pdf-benchmark 2024-08-07 10:09:16 +01:00
Charlie Crane
23816b0056 Merged PR 489: #2706 - Terminal Simulation Component
## Summary
This PR introduces the Terminal service simulation component to PrimAITE.

The full design details can be found at https://dev.azure.com/ma-dev-uk/PrimAITE/_wiki/wikis/PrimAITE.wiki/707/Terminals, and details how the terminal can be used, and does a better job of explaining it than I can in a PR.
There are some TODO comments within the code - these are  for #2781 , so will be picked up in the following terminal PR.

## Test process
13 Unit tests to cover functionality

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2706, #2710, #2711, #2712, #2713, #2714, #2735
2024-08-07 09:08:20 +00:00
Marek Wolan
368e846c8b 2772 - Generate pdf benchmark from 2024-08-07 10:07:19 +01:00
Charlie Crane
bd91b4be1d #2706 - Merge branch 'dev' into feature/2706-Terminal_Sim_Component 2024-08-07 09:08:43 +01:00
Nick Todd
61fa109ecc Merged PR 498: RNG seed setting.
## Summary
Add support for setting random number seed in config file.

## Test process
Tested on all notebooks in PrimAITE Internal except Training-an-Ray-RLLIB-MARL-System.
Added specific test for seed setting.
## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2777
2024-08-07 08:04:49 +00:00
Charlie Crane
6d6f21a20a #2706 - Additional assert on new test and a guard clause on LocalTerminalConnection.execute() to check that the Terminal service is running before sending a command 2024-08-06 19:14:53 +01:00
Charlie Crane
d05fd00594 #2706 - Resolving an issue that saw disconnected terminal connections still able to send execute commands that were also then processed by the target node. Created a new class: LocalterminalConnection, for local connection objects to terminal. Calling terminal.show() when there is a local connection will have 'Local Connection' as the IP address. Receive and execute will check that the provided connection uuid is valid before actioning any commands. TerminalClientConnection objects now have an is_active flag similar to DatabaseClientConnection. Added a new test to check that terminals will reject commands from disconnected clientconnection objects. 2024-08-06 19:09:23 +01:00
Archer.Bowen
9c68cd4bd0 #2689 Agent Actions Implemented, E2E Demo notebook started and a couple of general fixes and improvements. 2024-08-06 17:05:00 +01:00
Charlie Crane
de14dfdc48 #2706 - Updated Changelog 2024-08-06 16:22:08 +01:00
Charlie Crane
dd7e466104 #2706 - Fixing pipeline failure 2024-08-06 15:01:53 +01:00
Charlie Crane
df49b3b5bb #2706 - Actioning Review Comments 2024-08-06 14:10:10 +01:00
Charlie Crane
68621f172b #2706 - xfail on test_ray_multi_agent_action_masking as this is causing pipeline failures. Bugticket raised as 2812 2024-08-06 12:10:14 +01:00
Christopher McCarthy
462ff40278 Merged PR 499: #2811 - Fix Logging and Connection Validation in DatabaseService and DatabaseClient
## Summary
Updated syslog messaging around `DatabaseClient` and `DatabaseServic` connection request and password authentication

## Test process
Manual checks:

### Before:
![image (2).png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/499/attachments/image%20%282%29.png)

### After:
![image (3).png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/499/attachments/image%20%283%29.png)

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2811 - Updated syslog messaging around DatabaseClient and DatabaseService connection request and password authentication

Related work items: #2811
2024-08-06 11:04:49 +00:00
Charlie Crane
89107f2c4b #2706 - Type-hint changes following review 2024-08-06 10:37:11 +01:00
Charlie Crane
457395baee #2706 - Correcting wording on documentation titles 2024-08-06 09:33:41 +01:00
Charlie Crane
1e64e87798 #2706 - Actioning Review comments 2024-08-06 09:30:27 +01:00
Chris McCarthy
d2011ff327 #2811 - Updated syslog messaging around DatabaseClient and DatabaseService connection request and password authentication 2024-08-05 22:23:54 +01:00
Nick Todd
3441dd2509 #2777: Code review changes. 2024-08-05 17:45:01 +01:00
Archer.Bowen
4ae0275dc9 #2689 Implemented initial agent actions and started on documentations. A few TODO's left to do such as validation and expanding unit tests. 2024-08-05 16:53:48 +01:00
Nick Todd
3253dd8054 #2777: Update test 2024-08-05 16:27:54 +01:00
Marek Wolan
b4893c4498 #2769 - Add remote ip as action parameter 2024-08-05 16:27:53 +01:00
Charlie Crane
63a689d94a #2706 - correcting test failures 2024-08-05 16:25:35 +01:00
Charlie Crane
4fe9753fcf #2706 - Updated terminal.receive() to work with SSHPacket class, fixed some tests and updated RemoteTerminalConnection to hold Source_IP for easier reading 2024-08-05 15:44:52 +01:00
Nick Todd
d059ddceab #2777: Remove debug print statement 2024-08-05 15:11:57 +01:00
Nick Todd
966542c2ca #2777: Add determinism to torch backends when seed set. 2024-08-05 15:08:31 +01:00
Charlie Crane
972b0b9712 #2706 - Added another test demonstrating an SSH connection across a network. Actioned some review comments and a minor change to other ACL Terminal tests 2024-08-05 11:19:27 +01:00
Nick Todd
7d7117e624 #2777: Merge with dev 2024-08-05 11:13:32 +01:00
Nick Todd
0e21137874 Merge branch 'dev' into feature/2777_set_RNG_seed 2024-08-05 11:12:30 +01:00
Charlie Crane
ca8e568734 #2706 - Additional tests to check terminal login to/from networknodes. Redo of test to check that a router will block SSH traffic if no ACL rule. 2024-08-05 10:58:23 +01:00
Nick Todd
2e4a1c37d1 #2777: Pre-commit fixes to test 2024-08-05 10:34:06 +01:00
Marek Wolan
99a5119dac Merge remote-tracking branch 'origin/dev' into feature/2769-implement-user-account-action-space 2024-08-05 10:30:17 +01:00
Marek Wolan
2859681f01 Merged PR 497: merge release into main 2024-08-05 09:17:59 +00:00
Charlie Crane
814663cf2c #2706 - Terminal now installs on a Router 2024-08-05 10:04:23 +01:00
Charlie Crane
22c84d35d7 Merge branch 'dev' into feature/2706-Terminal_Sim_Component 2024-08-05 09:52:53 +01:00
Charlie Crane
4bddf72cd3 #2706 - Initial refactor of Terminal Class following review discussion on Friday. Terminal will now return a TerminalConnection/RemoteTerminalConnection object on login.
The new connection object can then be used to pass commands to the target node, without needing to form a full payload item.
2024-08-05 09:29:17 +01:00
Chris McCarthy
322a691e53 #2768 - Added listen_on_ports attribute to IOSoftware. updated software manager so that it sends copies of payloads to listening ports too. Added integration test that installs a listening service to snoop on DB traffic. 2024-08-02 23:21:35 +01:00
Archer.Bowen
1933522e89 #2689 Updated docustrings and general quality improvements. 2024-08-02 16:13:59 +01:00
Christopher McCarthy
e275a9376b Merged PR 496: Implement User, UserManager, and UserSessionManager
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2735, #2778
2024-08-02 14:45:10 +00:00
Marek Wolan
9d40e95982 precommit json end of file fixes 2024-08-02 13:48:12 +01:00
Marek Wolan
aab47289ac Merged PR 493: Update dev with all 3.2 updates
Related work items: #2625
2024-08-02 12:46:12 +00:00
Charlie Crane
d9faa1a5da Merge branch 'dev' into feature/2706-Terminal_Sim_Component 2024-08-02 13:34:00 +01:00
Charlie Crane
e132c52121 #2706 - Removed the LoginValidator. Will be handled by UserSessionManager. Updated some missing variables in method definitions/ 2024-08-02 13:32:34 +01:00
Archer.Bowen
2339dabac1 #2689 Overhauled .receive method. Keep Alive and initial implementation of commands working. (also Updated docustrings + pre-commit) 2024-08-02 13:25:08 +01:00
Chris McCarthy
71d8c6ea63 #2735 - synced with dev and resolved merge conflicts 2024-08-02 12:55:09 +01:00
Nick Todd
0cc724be60 #2777: Updated CHANGELOG 2024-08-02 12:50:40 +01:00
Nick Todd
a1e1a17c2a #2777: Add RNG test 2024-08-02 12:49:17 +01:00
Chris McCarthy
696236aa61 #2735 - make the disabled/enabled admins/non-admins dynamic properties for simplicity. Added num_of_logins to User. Added additional test for counting user logins. Added all users to the UserManager describe_state function. Refactored model fields with empty dict as default value to have direct instantiation instead of using Field(default_factory=dict) or Field(default_factory=: lambda: {}). 2024-08-02 12:47:02 +01:00
Christopher McCarthy
61c7cc2da3 Apply suggestions from code review 2024-08-02 10:57:51 +00:00
Nick Todd
5dcc0189a0 #2777: Implementation of RNG seed 2024-08-02 11:30:45 +01:00
Nick Todd
3ebad7d7e9 Merged PR 448: Global NMNE variables are incorrectly accessed
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2676
2024-08-02 08:28:08 +00:00
Charlie Crane
ab4931463f #2706 - Minor change following the session_id changes as local_login failed to pass a session_id when creating a new TerminalClientConnection object 2024-08-02 09:21:55 +01:00
Chris McCarthy
c2a19af6fa #2735 - added documentation for users, usermanager and usersessionmanager. Added the ability to add additional users from config and documented this. also tested additional users from config. 2024-08-02 09:20:00 +01:00
Charlie Crane
0fe61576c7 #2706 - Removed source and target ip_address attributes from the SSHPacket Class. Terminal now uses session_id to send login outcome. No more network_interface[1].ip_address. 2024-08-02 09:13:31 +01:00
Czar Echavez
0c66d594f6 Merged PR 490: #2735: fixes to broken items
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2735: fixes to broken items

Related work items: #2735
2024-08-01 22:56:31 +00:00
Archer.Bowen
e554a2d224 #2689 Remote connections now successfully establishing however current issues with keep alive inactivity causing the c2 beacon to close even when it does have connection to the c2 server. 2024-08-01 17:18:10 +01:00
Marek Wolan
78ad95fcef #2735 - fix up node request manager and system software 2024-08-01 13:58:35 +01:00
Marek Wolan
a719b24cfc Merge branch 'dev' into feature/2735-usermanager-fixes 2024-08-01 13:23:03 +01:00
Marek Wolan
ddbbcf66e8 Merge remote-tracking branch 'origin/dev' into backport-3.2 [skip ci] 2024-08-01 13:03:52 +01:00
Marek Wolan
e02907cfb9 [skip ci] 2024-08-01 12:40:36 +01:00
Marek Wolan
9ed333945d [skip ci] 2024-08-01 12:39:52 +01:00
Marek Wolan
a18870049a Merge remote-tracking branch 'origin/release/3.2.0' into backport-3.2 2024-08-01 12:36:27 +01:00
Charlie Crane
19d7774440 #2706 - Changed how Terminal Class handles its connections. Terminal now has a list of TerminalClientConnection objects that holds all active connections. Corrected a typo in ssh.py 2024-08-01 12:34:21 +01:00
Marek Wolan
2a715d8d0a backport 3.2 changes to core 2024-08-01 11:08:41 +01:00
Archer.Bowen
e09c0ad4ac #2689 added test template and fixed class instancing issues. 2024-08-01 10:11:03 +01:00
Marek Wolan
b599257433 #2676 - update configs to use new nmne schema; fix test and warnings 2024-08-01 09:06:35 +01:00
Marek Wolan
fc9bd6fd64 Merged PR 491: #2800 - Consolidate software install and uninstall to a single method
## Summary
Consolidate the two install/uninstall methods so there's only one now. yay

## Test process
Existing tests pass.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

#2800 - Consolidate software install and uninstall to a single method

Related work items: #2800
2024-08-01 08:04:07 +00:00
Charlie Crane
5ef9e78a44 #2706 - Elaborated on terminal login within notebook 2024-08-01 08:37:51 +01:00
Charlie Crane
e4e3e17f51 #2706 - commit minor changes from review comments 2024-08-01 07:57:01 +01:00
Marek Wolan
2648614f97 2800 update changelog 2024-07-31 16:44:25 +01:00
Archer.Bowen
4c7e465f0d #2689 Initial Implementation of C2 Server. 2024-07-31 16:43:17 +01:00
Marek Wolan
2abd1969fe #2800 - Consolidate software install and uninstall to a single method 2024-07-31 16:41:59 +01:00
Charlie Crane
0f3fa79ffe #2706 - Actioning review comments on example notebook and terminal class 2024-07-31 15:47:18 +01:00
Marek Wolan
e57a454b9c Merge remote-tracking branch 'origin/dev' into feature/2735-usermanager-fixes 2024-07-31 15:42:54 +01:00
Marek Wolan
bd1e23db7d 2676 - make ntwk intf use default nmne config 2024-07-31 15:25:02 +01:00
Marek Wolan
9bf8d0f8cb #2676 Put NMNE back into network module 2024-07-31 13:20:15 +01:00
Marek Wolan
5b976c7985 Merge remote-tracking branch 'origin/dev' into bugfix/2676_NMNE_var_access 2024-07-31 12:49:21 +01:00
Archer.Bowen
f097ed575d #2689 minor docustring and type hint change 2024-07-31 10:26:58 +01:00
Archer.Bowen
e4358b02bc #2689 Improving comments in abstract c2 2024-07-30 17:18:28 +01:00
Charlie Crane
06ac127f6b #2706 - Updates to Terminal Processing notebook to highlight utility function and improve formatting 2024-07-30 16:58:40 +01:00
Archer.Bowen
4c03a20154 #2689 C2 Beacon command methods implemented. Additional docustrings also added. 2024-07-30 16:24:36 +01:00
Charlie Crane
0ed61ec79b #2706 - Updates to terminal and host_node documentation, removal of redundant terminal unit test 2024-07-30 15:54:08 +01:00
Charlie Crane
3698e6ff5f #2706 - Commented out references to UserSessionManager to remove the dependency. 2024-07-30 15:24:37 +01:00
Archer.Bowen
8a00a2a29d #2689 Added TODOs for future reference. 2024-07-30 13:10:23 +01:00
Archer.Bowen
8320ec524b #2689 Initial C2 Beacon command handling functionality implemented. 2024-07-30 13:04:20 +01:00
Czar Echavez
5e3a169999 #2735: add usermanager and usersessionmanager into describe_state 2024-07-30 12:48:11 +01:00
Charlie Crane
09084574a8 #2706 - Inclusion of health_state_actual attribute to the Terminal class. Started fleshing out a walkthrough notebook showing how to use the new component. 2024-07-30 12:15:37 +01:00
Czar Echavez
7b523d9450 #2769: added changes which should align with 2735 once merged 2024-07-30 11:33:52 +01:00
Archer.Bowen
556239a535 #2689 Initial base class implementation 2024-07-30 11:17:10 +01:00
Charlie Crane
2f50feb0a0 #2706 - Removing redundant unit test from 2024-07-30 11:11:08 +01:00
Charlie Crane
2b33a6edb4 #2706 - New unit test to show that Terminal is able to send/handle install commands 2024-07-30 11:04:55 +01:00
Czar Echavez
f91800003c Merge remote-tracking branch 'origin/dev' into feature/2769-implement-user-account-action-space 2024-07-30 10:49:59 +01:00
Christopher McCarthy
2c2d140bf0 Merged PR 487: #2778 - fixed the mis-merge that was trying to call the old latex function
## Summary
- Fixed the mis-merge that was trying to call the old latex function instead of the new md function
- Removed the old threshold leftover stuff in the report too

## Test process
- Tested the benchmark report locally and it runs end-to-end

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2778 - fixed the mis-merge that was trying to call the old latex function instead of the new md function. removed the old threshold leftover stuff in the report too

Related work items: #2778
2024-07-30 09:42:10 +00:00
Charlie Crane
ab26798240 #2706 - New test to check that the terminal can receive and process commmands. 2024-07-30 10:23:34 +01:00
Chris McCarthy
2e1d622228 #2778 - pinned Ray version to <2.33 until they fix their bug 2024-07-30 09:57:48 +01:00
Charlie Crane
bb0ecb93a4 #2706 - Correcting whitespace change in database_service.py and actioning some review comments 2024-07-30 09:57:47 +01:00
Czar Echavez
c984d695cc #2735: use ray version 2.32 until 2.33 is fixed 2024-07-29 23:03:26 +01:00
Charlie Crane
e492f19a43 #2706 - Small change to execute method following feedback 2024-07-29 17:10:13 +01:00
Czar Echavez
0fad61eaea #2735: pipeline build fail if test fails 2024-07-29 15:15:15 +01:00
Czar Echavez
3d13669671 #2735: fixes to broken items 2024-07-29 15:12:24 +01:00
Charlie Crane
f78cb24150 #2706 - Removed some un-necessary comments and changes to network used in terminal ACL unit test 2024-07-29 14:20:29 +01:00
Charlie Crane
586e3f6389 Merged PR 488: #2713 - Terminal Request Manager Methods
## Summary
This PR merges the initial implementation of the terminals use of the `RequestManager`. Introducing the ability to send commands to `Login`, `Remote Login` and `Execute`.

## Test process
Unit test written for the request manager.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2713
2024-07-29 09:56:08 +00:00
Charlie Crane
cf7341a4fd #2713 - Minor changes before merging into main Terminal branch 2024-07-29 10:50:32 +01:00
Chris McCarthy
265632669e #2778 - added request managers for USerManager and UserSessionManager classes 2024-07-29 10:29:12 +01:00
Chris McCarthy
8af7fc0ecd #2778 - ran pre-commit 2024-07-29 09:31:50 +01:00
Chris McCarthy
2e35549c95 #2735 - added docstrings to the User, UserManager, and UserSessionManager classes 2024-07-29 09:29:20 +01:00
Chris McCarthy
a0cfe8cdfa #2778 - fixed the mis-merge that was trying to call the old latex function instead of the new md function. removed the old threshold leftover stuff in the report too 2024-07-29 08:52:16 +01:00
Charlie Crane
0ac1c6702c #2713 - eod commit. Initial RequestManager Test implemented, along with an initial setup of the additional Request Manager methods. 2024-07-26 16:56:03 +01:00
Czar Echavez
df50ec8abc #2769: add change password action 2024-07-25 10:02:32 +01:00
Chris McCarthy
d0c8aeae30 #2735 - implemented remote logins. Added action remote sessions to UserSessionManager describe_state. Added suite of tests for UserSessionManager logins 2024-07-24 17:08:18 +01:00
Czar Echavez
173f110fb2 #2769: initial commit of user account actions 2024-07-24 16:38:06 +01:00
Charlie Crane
978e2c5a52 Merged PR 483: Terminal Login Handling
## Summary
This PR updates the new Terminal Component to include logic for handling local/remote login attempts.
The Terminal will use the `UserSessionManager` on it's parent node to validate user credentials when receiving a login request.
`UserSessionManager` will return a connection uuid which can be used to validate remote session and used throughout following terminal commands to authenticate it's login session.
Terminal should now be able to track multiple remote connections to itself by maintaining a dict of `TerminalClientConnection` objects, indexed by their connection uuid.

This PR also broadens the contents of the `SSHPacket` class, introducing `SSHUserCredentials` which hold the username/password being used for login.

## Test process
Unit tests currently fail during the login as this PR does not merge in the `UserSessionManager` implementation as that is still in development.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2712
2024-07-24 12:40:10 +00:00
Charlie Crane
a0e675a09a #2712 - Minor changes to login Validator 2024-07-24 11:20:01 +01:00
Charlie Crane
1cb6ce02e0 #2712 - Correcting the use of TerminalClientConnection for remote connections. Terminal should hold a list of active remote connections to itself with connection uuid for validation 2024-07-24 10:38:12 +01:00
Charlie Crane
26a26a808f Merge branch 'dev' into feature/2706-Terminal_Sim_Component 2024-07-24 08:33:12 +01:00
Charlie Crane
a36e34ee1d #2712 - Prepping ahead of raising PR. 2024-07-24 08:31:24 +01:00
Charlie Crane
9d5b58ce44 Merge branch 'dev' into feature/2712-Terminal_Login_Handling 2024-07-23 15:52:42 +01:00
Charlie Crane
a7f9e4502e #2712 - Updates to the login logic and fixing resultant test failures. Updates to terminal.rst and ssh.py 2024-07-23 15:18:20 +01:00
Chris McCarthy
6976936102 Merge branch 'refs/heads/dev' into feature/2735_Implement-UserManager-class-and-integrate-into-Node 2024-07-22 22:07:59 +01:00
Chris McCarthy
e67b4b54ce bumped version number and ran pre-commit 2024-07-22 14:46:58 +01:00
Christopher McCarthy
db0fc461f4 Merged PR 480: merged 3.2.0 into main for git history alignment
merged 3.2.0 into main for git history alignment

Related work items: #2438, #2620, #2623, #2641, #2656, #2688, #2697, #2700, #2701, #2702, #2705, #2716, #2725, #2734, #2739, #2740, #2745, #2747, #2757
2024-07-22 13:41:03 +00:00
Chris McCarthy
db50a4d457 Merge remote-tracking branch 'refs/remotes/origin/release/3.2.0' into dev
# Conflicts:
#	src/primaite/VERSION
2024-07-22 14:38:01 +01:00
Chris McCarthy
85a530382c merged 3.1.0 into dev for git history alignment [skip ci] 2024-07-22 14:30:33 +01:00
Chris McCarthy
8ce39a09ad merged 3.0.0 into dev for git history alignment [skip ci] 2024-07-22 14:06:08 +01:00
Chris McCarthy
6bfe1510e8 merged 3.1.0 into 3.2.0 for git history alignment [skip ci] 2024-07-22 13:59:28 +01:00
Chris McCarthy
0789244df8 refactored the performance benchmark plot so that there's no benchmark threshold line and all bars are blue [skip ci] 2024-07-22 10:12:43 +01:00
Charlie Crane
3c590a8733 #2712 - Commit before changing branches 2024-07-22 09:58:09 +01:00
Defence Science and Technology Laboratory UK
4631f19e84 Automated benchmark output commit for version 3.2.0 [skip ci] 2024-07-21 09:10:19 +00:00
Chris McCarthy
4ae3573f70 release/3.2.0 2024-07-21 07:44:26 +01:00
Archer.Bowen
22d10bf0d5 #2734 Minor grammatical issue. 2024-07-19 14:28:00 +01:00
Nick Todd
82a11b8b85 #2676: Updated doc strings 2024-07-19 12:54:01 +01:00
Archer Bowen
da13eb3dea Merged PR 472: User Guide Updates - Following Feedback
Implements the following changes:

**Moving some of the text from index.html into about.html (reduces repeated text**)

Index.html (home)
	i.	Overview
	ii.	Features (the ones we have listed currently in v3.2.0)
About.html
	i.	Architecture
	ii.	Training & Evaluation Capability
	iii.	What is PrimAITE built with
	iv.	Getting started with PrimAITE

**Adds deepdiff and sb3_contrib to the dependencies list**

![image.png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/472/attachments/image.png)

**NMAP headers were inconsistent with other documentation. **

This may be an issue with the other documentation rather than NMAP however refactoring every header could cause a lot more headache.

![image (2).png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/472/attachments/image%20%282%29.png)

**General Improvements**

Small link fixes

changing up python outdated python information

adding the common.config to .rst documents that didnt have them previously.

Related work items: #2734
2024-07-19 11:52:02 +00:00
Archer.Bowen
bd9f69f062 #2734 Forgot the comma.... 2024-07-19 12:22:22 +01:00
Archer.Bowen
047117cba0 #2734 Slight grammatical improvements following PR 2024-07-19 12:21:16 +01:00
Nick Todd
e4ade6ba54 #2676: Merge nmne.py with io.py 2024-07-19 12:02:43 +01:00
Archer.Bowen
3ff0a37a71 #2734 User guide feedback core changes. 2024-07-19 11:54:10 +01:00
Charlie Crane
5c04f4fa4c Merge branch 'dev' into feature/2712-Terminal_Login_Handling 2024-07-19 11:18:34 +01:00
Charlie Crane
155562cb68 #2712 - Commit before merging in changes on dev 2024-07-19 11:18:17 +01:00
Charlie Crane
2104a7ec7d #2712 - Commit before merging in changes on dev 2024-07-19 11:17:54 +01:00
Nick Todd
9fb3790c1a #2726: Resolve pydantic validators PR comment 2024-07-19 11:10:57 +01:00
Chris McCarthy
8702dc7067 #2735 - tidies up some oif the api, temporarily integrated login checks to ping for testing, added temp test 2024-07-19 10:34:32 +01:00
Nick Todd
ec6d7b46d1 Merge branch 'dev' into bugfix/2676_NMNE_var_access 2024-07-19 08:57:12 +01:00
Archer.Bowen
538c9e1e42 #2734 User Guide Update fixes. 2024-07-18 17:52:31 +01:00
Christopher McCarthy
7ccfea9c57 Merged PR 470: Updated azure-benchmark-pipeline.yaml to use 'Imaginary Yak Pool'
## Summary
Updated azure-benchmark-pipeline.yaml to use 'Imaginary Yak Pool'

## Test process
Manually tested that it runs end-to-end

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2758
2024-07-17 19:17:15 +00:00
Christopher McCarthy
28ee00d990 Merged PR 469: Bumped version number to 3.3.0-dev0
Bumped version number to 3.3.0-dev0

Related work items: #2630
2024-07-17 19:15:14 +00:00
Nick Todd
4361734014 #2676: Code review changes 2024-07-17 17:50:55 +01:00
Christopher McCarthy
b651ee3837 fixed line ending in VERSION 2024-07-17 16:08:30 +00:00
Christopher McCarthy
6b14d6de44 Bumped version number to 3.3.0-dev0 2024-07-17 15:45:25 +00:00
Archer Bowen
05c33b57e0 Merged PR 465: 2734 - Initial User Guide Updates
## Summary
3.2 User Guide Updates for 3.2 release.

Related work items: #2734
2024-07-17 15:18:17 +00:00
Archer.Bowen
819062b627 2734 - updated following pr v2 2024-07-17 16:15:56 +01:00
Christopher McCarthy
b83bab2e2e #2758 - Updated azure-benchmark-pipeline.yaml 2024-07-17 14:34:51 +00:00
Christopher McCarthy
2900ca9b2a #2758 - Updated azure-benchmark-pipeline.yaml so that is created a venv on the vm 2024-07-17 14:33:44 +00:00
Christopher McCarthy
c7431fa0c8 #2758 - Updated azure-benchmark-pipeline.yaml to use python3.10 on the yak pool vm 2024-07-17 14:20:53 +00:00
Christopher McCarthy
f409d0c27c #2758 - Updated azure-benchmark-pipeline.yaml to use 'Imaginary Yak Pool' 2024-07-17 14:11:48 +00:00
Archer.Bowen
8bc84e33be Updated following PR 2024-07-17 15:07:37 +01:00
Charlie Crane
51d29c3ab9 Merged PR 464: Terminal Class Session Manager Methods
## Summary
This PR introduces the ability of the Terminal class to  send/receive messages via the session manager, along with the initial logic for processing the responses that it may receive.
Initial implementation of logging in and disconnecting from a remote session, though this will likely see significant refactor when we start using the `UserManager` from #2735

## Test process
Unit tests written.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2710
2024-07-17 13:33:12 +00:00
Archer.Bowen
e9d9cea739 Updated action masking to include copyright 2024-07-17 14:27:01 +01:00
Archer Bowen
587a5d48c8 Merged PR 466: #2757 fixed dev mode cli double -level alternative issue
#2757 fixed dev mode cli double -level alternative issue

Related work items: #2757
2024-07-17 11:02:53 +00:00
Archer.Bowen
9fd4c8b8dd #2734 - Updating developer_tools.rst to follow #2757 2024-07-17 11:54:53 +01:00
Archer.Bowen
fd57986512 #2757 fixed dev mode cli double -level alternative issue 2024-07-17 11:48:29 +01:00
Nick Todd
061509dffd #2676: Further test fixes. 2024-07-17 10:43:04 +01:00
Nick Todd
07e736977c #2676: Fix some more integration tests 2024-07-16 16:58:11 +01:00
Archer.Bowen
bc660d651d 2734 - Initial User Guide Updates 2024-07-16 09:32:26 +01:00
Nick Todd
34969c588b #2676: Fix mismerge. 2024-07-16 08:59:36 +01:00
Marek Wolan
99af67023a Updated VERSION 2024-07-15 13:41:01 +00:00
Charlie Crane
fee7f202a6 #2711 - Amending some minor changes spotted whilst raising PR 2024-07-15 10:06:28 +01:00
Nick Todd
0e3227c691 Merge branch 'dev' into bugfix/2676_NMNE_var_access 2024-07-15 09:27:11 +01:00
Charlie Crane
32c2ea0b10 #2710 - Pre-commit run ahead of raising PR 2024-07-15 08:22:18 +01:00
Charlie Crane
2eb36149b2 #2710 - Prep for draft PR 2024-07-15 08:20:11 +01:00
Christopher McCarthy
e824391ae3 Merged PR 462: retrospectively added the 3.1.0 benchmark results
retrospectively added the 3.1.0 benchmark results
2024-07-13 19:00:23 +00:00
Chris McCarthy
951fd30e03 retrospectively added the 3.1.0 benchmark results 2024-07-13 19:58:41 +01:00
Chris McCarthy
93350ecd30 Merge branch 'dev' into feature/2735_Implement-UserManager-class-and-integrate-into-Node 2024-07-12 17:14:57 +01:00
Marek Wolan
a1690fe1e3 Merged PR 459: fix test problems and slowness
Related work items: #2747
2024-07-12 11:49:20 +00:00
Marek Wolan
104d033053 Merge remote-tracking branch 'origin/dev' into fix-slow-tests 2024-07-12 11:29:46 +01:00
Marek Wolan
199cd0d9df fix test problems and slowness 2024-07-12 11:23:41 +01:00
Christopher McCarthy
2f649a302c Merged PR 458: Carry over airspace hotfixes from internal
## Summary
Carried over hit fixes from internal that backtracked on the complex channel width stuff for now and focussed on getting a stable data rate baked in for each frequency.  Implemented overriding of frequency max capacities on the airspace. updated documentation to reflect the changes in airspace.py.

## Test process
- Original tests still work
- Tested reading the frequency capacity overrides from config file
- Tested that setting the frequency override to 0.0 blocks the channel

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2745
2024-07-12 10:17:25 +00:00
Marek Wolan
9a0164c254 Merged PR 454: Action masking support
## Summary
* Add action masking to environments
* add notebook demonstrating action masking

## Test process
* E2E test for SB3, Ray SARL, and Ray MARL
* integration test to check if the contents of the action mask change accordingly when statuses of components change

## Checklist
- [x] PR is linked to a **work item**
- [x] **acceptance criteria** of linked ticket are met
- [x] performed **self-review** of the code
- [x] written **tests** for any new functionality added with this PR
- [x] updated the **documentation** if this PR changes or adds functionality
- [x] written/updated **design docs** if this PR implements new functionality
  - https://dev.azure.com/ma-dev-uk/PrimAITE/_wiki/wikis/PrimAITE.wiki/703/Action-Masking
- [ ] updated the **change log**
- [x] ran **pre-commit** checks for code style
- [x] attended to any **TO-DOs** left in the code

Related work items: #2623
2024-07-12 08:14:47 +00:00
Chris McCarthy
cde632066c #2745 implemented overriding of frequency max capacities on the airspace. updated documentation to reflect the changes in airspace.py. 2024-07-11 21:11:27 +01:00
Marek Wolan
e759ae5990 2623 fix issues with tests and revert request show method 2024-07-11 17:44:31 +01:00
Marek Wolan
3af22ac2ed Merge remote-tracking branch 'origin/dev' into feature/2623-action-masking 2024-07-11 15:50:42 +01:00
Marek Wolan
abbfc86942 2623 update defaults 2024-07-11 15:50:35 +01:00
Chris McCarthy
cf563149ec #2745 carried over changes from internal that backtracked on the complex channel width stuff for now and focussed on getting a stable data rate baked in for each frequency 2024-07-11 15:07:58 +01:00
Czar Echavez
a527b8798e Merged PR 455: Add folder and file request permissions validators
## Summary
Implemented the last of the request validators from https://dev.azure.com/ma-dev-uk/PrimAITE/_wiki/wikis/PrimAITE.wiki/703/Action-Masking

files and folders validators

## Test process
integration tests for files and folders
added unit tests for previous validators as well

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2740
2024-07-11 13:59:44 +00:00
Czar Echavez
9636882ed1 #2740: refactor variable 2024-07-11 13:57:23 +01:00
Archer Bowen
643318d090 Merged PR 453: Agent Logging - #2716
## Summary
This PR is intends to introduce a new log for agents. Taking heavy inspiration from sys_log, this implementation grants each agent their own individual logger (inherited by abstractagent).

![image.png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/453/attachments/image.png)

![image (2).png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/453/attachments/image%20%282%29.png)

## Test process
Dev-mode CLI, the show method and the manually checking the logs via file explorer.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2716
2024-07-11 11:47:17 +00:00
Czar Echavez
1d466d6807 #2740: unit tests + a minor fix to nic test 2024-07-11 12:19:27 +01:00
Archer.Bowen
b8c6238610 #2740 Fixed Nmap Test Failure. 2024-07-11 11:55:03 +01:00
Marek Wolan
579469d1c3 2623 add sb3 contrib dependency 2024-07-11 11:25:38 +01:00
Marek Wolan
bdf5ff2167 2623 Add docs for action masking 2024-07-11 10:01:33 +01:00
Charlie Crane
dc3558bc4d #2710 - End of Day commit 2024-07-10 17:39:45 +01:00
Czar Echavez
aa425a5284 #2740: fix tests affected by request permissions 2024-07-10 14:40:25 +01:00
Archer.Bowen
9e7fd017df #2716 Fixed game.py pre-commit issue. 2024-07-10 14:04:52 +01:00
Archer.Bowen
2bedf0c363 Updated changelog 2024-07-10 13:56:33 +01:00
Marek Wolan
0c58c3969a 2623 - finish testing action mask 2024-07-10 13:46:30 +01:00
Archer.Bowen
feb9763f62 Merge https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE into feature/2716-Red-Agent-Logging 2024-07-10 13:40:54 +01:00
Archer.Bowen
239f5b86c0 #2716 Agent logging now sits outside of the simulation output log directory, updated dev-mode CLI to include agent logging and added additional tests. 2024-07-10 13:36:37 +01:00
Czar Echavez
caa6a4809c #2740: tests + implement file request validators 2024-07-10 13:14:22 +01:00
Marek Wolan
7201b7b8e0 2623 Add e2e tests for action masking 2024-07-10 11:01:42 +01:00
Czar Echavez
7cb9bc8dd9 Merge remote-tracking branch 'origin/dev' into feature/2740-add-request-permissions-validator-to-files-and-folder-actions 2024-07-10 10:19:28 +01:00
Christopher McCarthy
2c46fb8b04 Merged PR 452: Automate the benchmark process
## Summary
This pull request integrates full automation of the PrimAITE benchmarking process into our Azure DevOps pipeline, enhancing consistency and minimizing manual effort.

#### Key Changes:

1.  **Pipeline Automation**: Configured to trigger on commits to `dev` and `release` branches, with scheduled runs during off-peak hours.

2.  **Error Handling Improvements**: The pipeline is set to fail on any Python execution errors, ensuring immediate identification of issues.

3.  **Artifact Publishing**: Benchmark results are now automatically compressed and published as artifacts, facilitating easy access and analysis.

## Test process
Tested the pipeline runs from end-to-end and produces a working benchmark report: https://dev.azure.com/ma-dev-uk/PrimAITE/_build/results?buildId=5280&view=results

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2739
2024-07-09 19:39:27 +00:00
Christopher McCarthy
2eb9d970bf Apply suggestions from code review 2024-07-09 19:25:13 +00:00
Archer.Bowen
48645d2e72 #2716 Initial Implementation + Initial Tests and updated changelog and sphinx documentation. 2024-07-09 16:46:31 +01:00
Czar Echavez
20b9b61be5 #2740: added ability to merge validators + validators for folders 2024-07-09 16:44:02 +01:00
Marek Wolan
faf268a9b9 2623 move action mask generation to game and fix MARL masking 2024-07-09 15:59:50 +01:00
Marek Wolan
5367f9ad53 2623 Ray single agent action masking 2024-07-09 15:27:03 +01:00
Marek Wolan
470fa28ee1 2623 Implement basic action masking logic 2024-07-09 13:13:13 +01:00
Charlie Crane
8061102587 #2710 - commit before changing branch 2024-07-09 11:55:16 +01:00
Charlie Crane
42602be953 #2710 - Initial implementation f the receive/send methods. Committing to change branch 2024-07-09 11:54:33 +01:00
Christopher McCarthy
b45f6bbd40 Merged PR 447: Bandwidth load / capacity checks before transmission
## Summary

This pull request introduces significant enhancements to the AirSpace class within our network simulation software, aimed at improving the realism, configurability, and accuracy of wireless network simulations. These changes include the addition of new enums and attributes, enhancements to the configuration schema, and improvements in bandwidth management and transmission logic.

**Additions**

-   **Enums and Attributes:**

-   **AirSpaceEnvironmentType Enum**: Defines various environmental settings that affect wireless signal propagation and interference.
-   **ChannelWidth Enum**: Specifies available channel width options for wireless interfaces.
-   **Channel Width Attribute**: Added to WirelessNetworkInterface for dynamic adjustments based on the operational environment.
-   **airspace_key Attribute**: A tuple identifying the frequency and channel width combination for bandwidth management.
-   **airspace_environment_type Attribute**: Sets the overall environmental context of the airspace, influencing all contained devices.

-   **Functional Enhancements:**

-   **SNR and Capacity Calculation Functions**: New functions estimate_snr and calculate_total_channel_capacity have been implemented to compute signal-to-noise ratios and channel capacities dynamically.
-   **show_bandwidth_load Function**: Provides a visual representation of the current bandwidth load across different channels.
-   **Dynamic Speed Setting**: The speed attribute of WirelessInterface is now adjusted dynamically based on frequency, channel width, and environment.

-   **Configuration and Testing:**

-   **Configuration Schema Update**: The simulation.network config file schema now supports setting the airspace_environment_type.

**Changes**

-   **Interface and Performance Adjustments:**

-   **NetworkInterface Speed Type**: Changed from int to float for more precise speed definitions.
-   **Transmission Feasibility Check**: Updated the _can_transmit function in Link to better handle current load and bandwidth capacities.
-   **WirelessRouter Configurations**: The configure_wireless_access_point function now takes channel_width as an additional parameter.
-   **Grouping Adjustments**: WirelessNetworkInterfaces are now categorized by both AirSpaceFrequency and ChannelWidth.

-   **Transmission Logic Overhaul:**

-   **Interface Adjustments**: Modifying an interface's settings now necessitates its temporary removal from the airspace, followed by a recalculation of its data rate and reintegration under new settings.
-   **Blocking Overloads**: Strengthened the logic in AirSpace to prevent transmissions that would surpass the available capacity.

**Fixes**

-   **Transmission Permission Logic**: Fixed the can_transmit_frame function to accurately enforce transmission limits based on current network load and available bandwidth.

**Conclusion**

These updates significantly enhance the fidelity and flexibility of our network simulation tool, enabling more accurate m...
2024-07-09 10:47:56 +00:00
Czar Echavez
1fdd05a0d1 Merged PR 449: #2688: apply the request validators + fixing the fix duration test + refactor...
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2688: apply the request validators + fixing the fix duration test + refactor test class names

Related work items: #2688
2024-07-09 08:26:31 +00:00
Czar Echavez
a3f74087fa #2688: refactor test classes 2024-07-08 15:26:30 +01:00
Marek Wolan
cbf54d442c #2623 Make it possible to view currently valid simulation requests 2024-07-08 15:17:35 +01:00
Chris McCarthy
47a1daa580 #2735 - Initial work done around User, UserManager, and UserSessionManager 2024-07-08 15:10:06 +01:00
Czar Echavez
829a6371de #2688: tests 2024-07-08 14:39:37 +01:00
Charlie Crane
61c2ee0ee8 Merged PR 450: Terminal Service Class
## Summary
This PR is the base implementation of the Terminal Service Class, containing the skeleton structure for #2711.

## Test process
Future me's problem - see #2714

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [X] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2711
2024-07-08 09:46:53 +00:00
Christopher McCarthy
2d2f2df360 Added set -e to the Run Benchmark Script step in azure-benchmark-pipeline.yaml so that the pipeline fails if the python script fails. 2024-07-08 08:26:52 +00:00
Christopher McCarthy
2a003eece9 Updated v3.0.0_benchmark_metadata.json so that combined_av_reward_per_episode is now named combined_total_reward_per_episode to match the new script 2024-07-08 08:25:05 +00:00
Charlie Crane
252214b468 #2711 Updating Changelog 2024-07-08 08:25:42 +01:00
Charlie Crane
219d448adc #2711 - Rewrite of the majority of the terminal class after not liking how I originally did it. This takes a heavier inspiration for handling connections from the database_client/server 2024-07-08 07:58:10 +01:00
Chris McCarthy
c146992307 #2739 - updated azure-benchmark-pipeline.yaml to run on ubuntu-latest while we wait for authorisation to use the yak pool 2024-07-05 17:02:35 +01:00
Chris McCarthy
5e8343ca91 #2739 - update job name in azure-benchmark-pipeline.yaml 2024-07-05 16:57:40 +01:00
Chris McCarthy
7173c329b0 #2739 - Updated azure-benchmark-pipeline.yaml to allow it to run for unlimited time on the Imaginary Yak Pool 2024-07-05 16:56:07 +01:00
Chris McCarthy
4410e05e3e #2967 - Updated the DB filesize so that it doesn't fill the 100mbit link. moved the can transmit checks to the network interface to enable frame dropped syslog. narrowed the scope of the NODE_NMAP_PORT_SCAN action in nmap_port_scan_red_agent_config.yaml to select ports and protocols as the link was filling up on the full box scan. 2024-07-05 16:27:03 +01:00
Czar Echavez
2a0695d0d1 #2688: apply the request validators + fixing the fix duration test + refactor test class names 2024-07-05 15:06:17 +01:00
Nick Todd
2dcabc9fa7 Merge branch 'dev' into bugfix/2676_NMNE_var_access 2024-07-05 14:20:50 +01:00
Nick Todd
18ae3acf37 #2676: Update nmne tests 2024-07-05 14:09:39 +01:00
Nick Todd
589ea2fed4 #2676: Add local nmne dict 2024-07-05 12:19:52 +01:00
Chris McCarthy
9468adb606 #2967 - Updated the airspace configuration description in simulation.rst 2024-07-04 20:52:20 +01:00
Chris McCarthy
c6b1d35215 #2967 - Enhance AirSpace simulation with dynamic environment and bandwidth/channel management
This commit introduces several key enhancements to the AirSpace class, improving the realism and configurability of the wireless network. Major additions include the AirSpaceEnvironmentType and ChannelWidth enums, dynamic adjustment of interface speeds based on environmental settings, and comprehensive bandwidth management features. Additionally, the software now supports configuration of channel widths via the config file, incorporates accurate SNR and capacity calculations, and enforces bandwidth limits more effectively across wireless interfaces. Updated tests ensure that the new functionalities integrate seamlessly with existing systems.
2024-07-04 20:45:42 +01:00
Nick Todd
3867ec40c9 #2676: Fix nmne_config dict conversion 2024-07-04 17:05:00 +01:00
Nick Todd
47df2aa569 #2676: Store NMNE config data in class variable. 2024-07-04 15:41:13 +01:00
Czar Echavez
20e5e40d0d Merged PR 446: Add fix duration in config
## Summary
Added a ``fix_duration`` config property in applications and services
Defaults to using 2 if none is specified

## Test process
https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/446?_a=files&path=/tests/integration_tests/configuration_file_parsing/test_software_fix_duration.py

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [X] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2725
2024-07-03 10:21:17 +00:00
Czar Echavez
797afc99ab Merge remote-tracking branch 'origin/dev' into feature/2725-add-software-fix-duration-config 2024-07-03 10:37:02 +01:00
Czar Echavez
55c457a87d #2725: apply PR suggestions 2024-07-03 10:34:44 +01:00
Marek Wolan
bd23ee2083 Merged PR 444: Refactor application install
## Summary
* Remove the ip address parameter from application install
* Make it possible to install any application that exists
* Add new configuration actions for applications
* Add an application registry to match names to application classes

## Test process
* several new tests
* notebooks still running

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [X] attended to any **TO-DOs** left in the code

Related work items: #2438, #2705
2024-07-02 15:57:59 +00:00
Czar Echavez
fcd1209156 #2725: documentation 2024-07-02 16:55:28 +01:00
Charlie Crane
ebf6e7a90e #2711 - Added in remote_login and process_login methods. Minor updates to make pydantic happy. Starting to flesh out functionality of Terminal Service in more detail 2024-07-02 16:47:39 +01:00
Czar Echavez
6a72f6af42 #2725: add fix duration to application and service configuration 2024-07-02 15:52:18 +01:00
Marek Wolan
eb1f7555f8 Merged PR 445: #2702 - update data manipulation notebook text
## Summary
*Replace this text with an explanation of what the changes are and how you implemented them. Can this impact any other parts of the codebase that we should keep in mind?*

## Test process
*How have you tested this (if applicable)?*

## Checklist
- [ ] PR is linked to a **work item**
- [ ] **acceptance criteria** of linked ticket are met
- [ ] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [ ] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2702 - update data manipulation notebook text

Related work items: #2702
2024-07-02 14:29:05 +00:00
Marek Wolan
cbc414bddf #2702 - update data manipulation notebook text 2024-07-02 15:25:40 +01:00
Charlie Crane
bd05f4d4e8 #2711 - Initial commit of Terminal Service Skeleton framework. Added in a placeholder SSHPacket class. Currently, this allows the Terminal 'service' to be installed onto a HostNode class, and Port 22 - SSH to be visible when using .show(). Functionality and testing still to be completed 2024-07-02 15:02:59 +01:00
Marek Wolan
59b4a162ef Merged PR 442: Add application configuration actions
## Summary
* Add new actions for configuring applications

## Test process
Integration tests.

## Checklist
- [x] PR is linked to a **work item**
- [x] **acceptance criteria** of linked ticket are met
- [x] performed **self-review** of the code
- [x] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [x] ran **pre-commit** checks for code style
- [x] attended to any **TO-DOs** left in the code

Related work items: #2700
2024-07-02 13:56:34 +00:00
Marek Wolan
feabe5117c #2700 Fix docstrings in application configure methods 2024-07-02 12:48:23 +01:00
Nick Todd
dbc1d73c34 #2676: Update naming of NMNE class 2024-07-02 11:15:31 +01:00
Marek Wolan
b27ac52d9e #2700 add E2E tests for application configure actions 2024-07-02 11:10:19 +01:00
Marek Wolan
33b9c5f6b3 Merge branch 'feature/2701-refactor-install-action' into feature/2700-application-configure-actions 2024-07-02 10:41:17 +01:00
Czar Echavez
eee7a68f28 Merged PR 440: #2620: add nbmake and pytest xdist to run the notebooks as part of pieline
![image.png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/440/attachments/image.png)
![image (2).png](https://dev.azure.com/ma-dev-uk/b50a61ee-86c4-48bc-9a0b-a67645ba12ee/_apis/git/repositories/2825053e-bd3b-45b2-8680-1281809eefa2/pullRequests/440/attachments/image%20%282%29.png)

## Summary
Added nbmake so that the pytest can be used to run the notebooks in primaite as part of the pipeline

## Test process
n/a

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2620: add nbmake and pytest xdist to run the notebooks as part of pieline

Related work items: #2620
2024-07-02 08:21:29 +00:00
Czar Echavez
e2429df220 #2620: remove div zero from notebook 2024-07-02 02:52:08 +01:00
Czar Echavez
a5a93fe850 #2620: commit a div zero to check that the pipeline fails 2024-07-02 02:10:40 +01:00
Czar Echavez
12a6aa5e7f #2620: make the windows script work 2024-07-02 01:31:59 +01:00
Czar Echavez
88ab3c3ca1 #2620: remove shell 2024-07-02 00:45:24 +01:00
Czar Echavez
1faacc8d7c #2620: fix indentation 2024-07-02 00:28:59 +01:00
Czar Echavez
918eba2217 #2620: fix indentation 2024-07-02 00:25:30 +01:00
Czar Echavez
8097884ae2 #2620: modify script 2024-07-02 00:00:20 +01:00
Czar Echavez
ab3e84b8b9 #2620: remove irrelevant change 2024-07-01 17:03:14 +01:00
Czar Echavez
afcb844501 #2620: remove cell that fails on purpose 2024-07-01 16:45:28 +01:00
Marek Wolan
dc2c64b2f6 #2701 - Remove ip address option from node application install 2024-07-01 16:23:10 +01:00
Czar Echavez
9c568b0ff3 Merged PR 439: #2641: Added a check for software health state in db service + tests
## Summary
Added a check in the database service process_sql method that checks if the Database Service is in a GOOD state (mainly so that the database service being in a fixed state returns an error)

## Test process
https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/439?_a=files&path=/tests/integration_tests/system/test_database_on_node.py

https://dev.azure.com/ma-dev-uk/PrimAITE/_git/PrimAITE/pullrequest/439?_a=files&path=/tests/integration_tests/system/test_web_client_server_and_database.py

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

#2641: Added a check for software health state in db service + tests

Related work items: #2641
2024-07-01 15:22:22 +00:00
Czar Echavez
a47a14b86e #2620: Going around azure dev ops to fail the script 2024-07-01 15:57:15 +01:00
Marek Wolan
91727f7fde Merged PR 438: #2705 - Move application registry into application module instead of hardcodi...
## Summary
- Add a registry class variable to Application.
- Add an identifier string for all existing applications
- Utilise application registry in game from_config method.

## Test process
New unit test for new features
existing tests pass
notebooks run as before

## Checklist
- [x] PR is linked to a **work item**
- [x] **acceptance criteria** of linked ticket are met
- [x] performed **self-review** of the code
- [x] written **tests** for any new functionality added with this PR
- [~] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [x] ran **pre-commit** checks for code style
- [x] attended to any **TO-DOs** left in the code

#2705 - Move application registry into application module instead of hardcoding in game module

Related work items: #2705
2024-07-01 14:33:44 +00:00
Marek Wolan
f2db8b0fb5 Merge remote-tracking branch 'origin/feature/2438-application-install-action-refactor' into feature/2700-application-configure-actions 2024-07-01 15:26:19 +01:00
Marek Wolan
bf8ec60833 #2700 Add configure dosbot action 2024-07-01 15:25:20 +01:00
Marek Wolan
ab73ac20e8 #2700 add ransomware configure action 2024-07-01 14:41:41 +01:00
Czar Echavez
4dd50be11a #2620: run notebooks after test so that the results can be published 2024-07-01 14:31:58 +01:00
Charlie Crane
96f62a3229 Merged PR 436: 2656 - Implement Optional Negative Reward
## Summary
This PR implements an "ActionPenalty" Reward class, that can be used for penalising an agent when it carries out an action other than DONOTHING.

The value for this can be configured within the scenario YAML file.

## Test process
I've written unit tests to check that the action penalty is correctly calculated and applied, another to check that the config is read correctly and loads into PrimaiteGymEnv correctly.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [X] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2656
2024-07-01 13:25:05 +00:00
Marek Wolan
2dd7546f3d 2705 Fix application tests by correctly renaming fixture 2024-07-01 13:25:16 +01:00
Marek Wolan
655bc04a42 #2705 Minor comment and name changes to applications 2024-07-01 13:21:08 +01:00
Czar Echavez
cb61756e43 #2620: attempting to fail pipeline if notebook fails 2024-07-01 12:21:05 +01:00
Czar Echavez
ee4e152f13 #2620: publish result of test and checking if pipeline fails 2024-07-01 12:00:17 +01:00
Marek Wolan
c34cb6d7ce #2700 Add DatabaseConfigure action 2024-07-01 11:31:27 +01:00
Czar Echavez
7ac503794d Merge remote-tracking branch 'origin/dev' into feature/2641-prevent-databaseservice-interactions-from-occurring-in-fixing-state 2024-06-28 16:46:52 +01:00
Czar Echavez
ce58f3960c #2620: downgrade pytest-xdist version 2024-06-28 16:43:10 +01:00
Czar Echavez
a4424608dd #2620: add nbmake and pytest xdist to run the notebooks as part of pieline 2024-06-28 16:33:24 +01:00
Czar Echavez
3ac97f8c3f #2641: Added a check for software health state in db service + tests 2024-06-28 13:07:57 +01:00
Marek Wolan
1ebeb27c53 #2705 Update documentation link 2024-06-28 12:03:05 +01:00
Marek Wolan
f796babf93 #2705 - Move application registry into application module instead of hardcoding in game module 2024-06-28 11:57:54 +01:00
Christopher McCarthy
e7fc01781e Merged PR 437: Automate Benchmarking Process with Scheduled and Release Triggers
## Summary

This pull request introduces an Azure DevOps pipeline that automates the benchmarking process for our project. The pipeline is designed to run under specific conditions and ensures that the benchmarking results are committed and published as artifacts. Additionally, the pipeline generates detailed benchmark reports in markdown format.

**Key Features:**

1.  **Triggering Conditions:**

    -   Triggered on creation of branches matching `refs/heads/release/*`.
    -   Runs automatically at 2 AM every weekday for the `dev` branch.
2.  **Version Handling:**

    -   Updates the version number with a `+dev.YYYYMMDD` suffix for the `dev` branch.
3.  **Dependency Installation:**

    -   Sets up Python 3.11 and installs project dependencies, including development and reinforcement learning extras.
4.  **Benchmark Execution:**

    -   Runs the benchmarking script and stores results in a version-based directory structure.
    -   Generates detailed markdown reports for benchmark results.
5.  **Commit and Push Results:**

    -   Commits and pushes benchmark results for release branches.
6.  **Artifact Preparation and Publishing:**

    -   Packages benchmark results into a tarball and publishes it as a pipeline artifact.

## Checklist
- [X] PR is linked to a **work item**
- [X] **acceptance criteria** of linked ticket are met
- [X] performed **self-review** of the code
- [ ] written **tests** for any new functionality added with this PR
- [ ] updated the **documentation** if this PR changes or adds functionality
- [ ] written/updated **design docs** if this PR implements new functionality
- [ ] updated the **change log**
- [X] ran **pre-commit** checks for code style
- [ ] attended to any **TO-DOs** left in the code

Related work items: #2648
2024-06-27 12:58:33 +00:00
Marek Wolan
7a680678aa #2656 - Make action penalty more configurable 2024-06-27 12:01:32 +01:00
Charlie Crane
e204afff6f #2656 - Removing the change to Data_Manipulation.yaml as this isn't necessary 2024-06-26 20:58:52 +01:00
Nick Todd
4796cee2dc #2676: Put global variables in dataclass 2024-06-26 16:51:30 +01:00
Chris McCarthy
7f0a0c562f #2648 - changed av_reward_per_episode to total_reward_per_episode in primaite_benchmark.py and report.py 2024-06-26 13:26:18 +01:00
Chris McCarthy
e7f979b78e #2648 - reverted temp changes to benchmark durations and branch names for testing purposes 2024-06-26 12:52:29 +01:00
Charlie Crane
7a833afe2d #2656 - Unit tests for new ActionPenalty reward component, testing yaml and some minor changes to the implementation. Need to update Documentation to detail how this is added 2024-06-26 12:20:28 +01:00
Chris McCarthy
795b5a80fb #2648 - testing the new benchmark artifact name 2024-06-26 12:00:56 +01:00
Chris McCarthy
20c9719f1e #2648 - added full branch name reference for push 2024-06-26 11:32:17 +01:00
Chris McCarthy
3b118fa0ad #2648 - now testing the release benchmark auto commit and push 2024-06-26 10:52:23 +01:00
Chris McCarthy
08ca4d8889 #2648 - now testing the release benchmark auto commit and push 2024-06-26 10:50:05 +01:00
Chris McCarthy
112f116a89 #2648 - fixed error whereby VERSION variable isn't set before setting the dev build version in the VERSION file 2024-06-26 09:46:05 +01:00
Chris McCarthy
2192516c9a #2648 - reordered steps so that dev version is set first before version variables are set 2024-06-26 09:40:16 +01:00
Chris McCarthy
ad2b132a10 #2648 - added dev and rl extras to the pip install step 2024-06-26 09:13:55 +01:00
Chris McCarthy
0ee243a242 #2648 - trying to fix the artifacts publish stage. currently creating tar.gz and publishing that 2024-06-26 09:09:16 +01:00
Chris McCarthy
4249314672 #2648 - reduced the benchmark sessions and episodes for fail-fast speed while testing 2024-06-25 17:28:05 +01:00
Chris McCarthy
a7731c94e3 Merge remote-tracking branch 'origin/feature/2648_Automate-the-benchmarking-process' into feature/2648_Automate-the-benchmarking-process 2024-06-25 17:25:23 +01:00
Chris McCarthy
55d69d6568 #2648 - updated benchmark run command 2024-06-25 17:23:04 +01:00
Christopher McCarthy
1033e696cd Set up CI with Azure Pipelines
[skip ci]
2024-06-25 16:01:18 +00:00
Chris McCarthy
824729276e #2648 - updated benchmark process to output markdown file instead of LaTeX. Added pipeline that runs benchmarking at 2am on a weekday and automatically upon creation of release branch 2024-06-25 16:58:39 +01:00
Charlie Crane
5ad16fdb7e #2656 - Corrected from_config() for ActionPenalty so that it can pull the negative reward value from YAML and apply, defaulting to 0 still if not found/not configured.
Currerntly prints to terminal when a negative reward is being applied, though this is for implementation and troubleshooting. To be removed before PR is pushed out of draft
2024-06-25 15:36:47 +01:00
Marek Wolan
bf5f443604 Merged PR 433: Bump version to 3.1 2024-06-25 12:05:13 +00:00
Charlie Crane
db27bea4ec #2656 - Committing current state before lunch. New ActionPenalty reward added. Basic implementation returns a -1 reward if last_action_response.action isn't DONOTHING. Minor change in data_manipulation so I can see it working in the data_manipulation notebook. Need to use configured values but so far, promising?. Looks to result in a better average reward than without which is good, I think. 2024-06-25 12:29:01 +01:00
590 changed files with 77444 additions and 11671 deletions

View File

@@ -14,33 +14,38 @@ parameters:
- name: matrix
type: object
default:
# - job_name: 'UbuntuPython38'
# py: '3.8'
# img: 'ubuntu-latest'
# every_time: false
# publish_coverage: false
- job_name: 'UbuntuPython311'
py: '3.11'
- job_name: 'UbuntuPython39'
py: 'v3.9'
img: 'ubuntu-latest'
every_time: false
publish_coverage: false
- job_name: 'UbuntuPython310'
py: 'v3.10'
img: 'ubuntu-latest'
every_time: true
publish_coverage: true
# - job_name: 'WindowsPython38'
# py: '3.8'
# img: 'windows-latest'
# every_time: false
# publish_coverage: false
- job_name: 'WindowsPython311'
py: '3.11'
- job_name: 'UbuntuPython311'
py: 'v3.11'
img: 'ubuntu-latest'
every_time: false
publish_coverage: false
- job_name: 'WindowsPython39'
py: 'v3.9'
img: 'windows-latest'
every_time: false
publish_coverage: false
# - job_name: 'MacOSPython38'
# py: '3.8'
# img: 'macOS-latest'
# every_time: false
# publish_coverage: false
- job_name: 'WindowsPython311'
py: 'v3.11'
img: 'windows-latest'
every_time: false
publish_coverage: false
- job_name: 'MacOSPython39'
py: 'v3.9'
img: 'macOS-latest'
every_time: false
publish_coverage: false
- job_name: 'MacOSPython311'
py: '3.11'
py: 'v3.11'
img: 'macOS-latest'
every_time: false
publish_coverage: false
@@ -63,7 +68,7 @@ stages:
displayName: 'Use Python ${{ item.py }}'
- script: |
python -m pip install pre-commit
python -m pip install pre-commit>=6.1
pre-commit install
pre-commit run --all-files
displayName: 'Run pre-commits'
@@ -71,7 +76,6 @@ stages:
- script: |
python -m pip install --upgrade pip==23.0.1
pip install wheel==0.38.4 --upgrade
pip install setuptools==66 --upgrade
pip install build==0.10.0
pip install pytest-azurepipelines
displayName: 'Install build dependencies'
@@ -102,16 +106,37 @@ stages:
version: '2.1.x'
- script: |
coverage run -m --source=primaite pytest -v -o junit_family=xunit2 --junitxml=junit/test-results.xml --cov-fail-under=80
coverage xml -o coverage.xml -i
coverage html -d htmlcov -i
python run_test_and_coverage.py
displayName: 'Run tests and code coverage'
# Run the notebooks
- script: |
pytest --nbmake -n=auto src/primaite/notebooks --junit-xml=./notebook-tests/notebooks.xml
notebooks_exit_code=$?
# Fail step if exit code not equal to 0
if [ $notebooks_exit_code -ne 0 ]; then
exit 1
fi
displayName: 'Run notebooks on Linux and macOS'
condition: or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin'))
# Run notebooks
- script: |
pytest --nbmake -n=auto src/primaite/notebooks --junit-xml=./notebook-tests/notebooks.xml
set notebooks_exit_code=%ERRORLEVEL%
rem Fail step if exit code not equal to 0
if %notebooks_exit_code% NEQ 0 exit /b 1
displayName: 'Run notebooks on Windows'
condition: eq(variables['Agent.OS'], 'Windows_NT')
- task: PublishTestResults@2
condition: succeededOrFailed()
displayName: 'Publish Test Results'
inputs:
testRunner: JUnit
testResultsFiles: 'junit/**.xml'
testResultsFiles: |
'junit/**.xml'
'notebook-tests/**.xml'
testRunTitle: 'Publish test results'
failTaskOnFailedTests: true

View File

@@ -1,8 +1,8 @@
name: build-sphinx-to-github-pages
env:
GITHUB_ACTOR: {todo:fill in URL}
GITHUB_REPOSITORY: {todo:fill in URL}/PrimAITE
GITHUB_ACTOR: Autonomous-Resilient-Cyber-Defence
GITHUB_REPOSITORY: Autonomous-Resilient-Cyber-Defence/PrimAITE
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
on:

1
.gitignore vendored
View File

@@ -54,6 +54,7 @@ cover/
tests/assets/**/*.png
tests/assets/**/tensorboard_logs/
tests/assets/**/checkpoints/
notebook-tests/*.xml
# Translations
*.mo

View File

@@ -31,7 +31,7 @@ repos:
- id: isort
args: [ "--profile", "black" ]
- repo: http://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:

View File

@@ -2,240 +2,258 @@
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 3.0.0b9
- Removed deprecated `PrimaiteSession` class.
- Added ability to set log levels via configuration.
- Upgraded pydantic to version 2.7.0
- Upgraded Ray to version >= 2.9
- Added ipywidgets to the dependencies
- Added ability to define scenarios that change depending on the episode number.
- Standardised Environment API by renaming the config parameter of `PrimaiteGymEnv` from `game_config` to `env_config`
- Database Connection ID's are now created/issued by DatabaseService and not DatabaseClient
- Updated DatabaseClient so that it can now have a single native DatabaseClientConnection along with a collection of DatabaseClientConnection's.
- Implemented the uninstall functionality for DatabaseClient so that all connections are terminated at the DatabaseService.
- Added the ability for a DatabaseService to terminate a connection.
- Added active_connection to DatabaseClientConnection so that if the connection is terminated active_connection is set to False and the object can no longer be used.
- Added additional show functions to enable connection inspection.
- Updates to agent logging, to include the reward both per step and per episode.
- Introduced Developer CLI tools to assist with developing/debugging PrimAITE
- Can be enabled via `primaite dev-mode enable`
- Activating dev-mode will change the location where the sessions will be output - by default will output where the PrimAITE repository is located
- Refactored all air-space usage to that a new instance of AirSpace is created for each instance of Network. This 1:1 relationship between network and airspace will allow parallelization.
- Added notebook to demonstrate use of SubprocVecEnv from SB3 to vectorise environments to speed up training.
## [Unreleased]
- Made requests fail to reach their target if the node is off
- Added responses to requests
- Made environment reset completely recreate the game object.
- Changed the red agent in the data manipulation scenario to randomly choose client 1 or client 2 to start its attack.
- Changed the data manipulation scenario to include a second green agent on client 1.
- Refactored actions and observations to be configurable via object name, instead of UUID.
- Made database patch correctly take 2 timesteps instead of being immediate
- Made database patch only possible when the software is compromised or good, it's no longer possible when the software is OFF or RESETTING
- Added a notebook which explains Data manipulation scenario, demonstrates the attack, and shows off blue agent's action space, observation space, and reward function.
- Made packet capture and system logging optional (off by default). To turn on, change the io_settings.save_pcap_logs and io_settings.save_sys_logs settings in the config.
- Made observation space flattening optional (on by default). To turn off for an agent, change the `agent_settings.flatten_obs` setting in the config.
- Added support for SQL INSERT command.
- Added ability to log each agent's action choices in each step to a JSON file.
- Removal of Link bandwidth hardcoding. This can now be configured via the network configuraiton yaml. Will default to 100 if not present.
- Added NMAP application to all host and layer-3 network nodes.
### Bug Fixes
- ACL rules were not resetting on episode reset.
- ACLs were not showing up correctly in the observation space.
- Blue agent's ACL actions were being applied against the wrong IP addresses
- Deleted files and folders did not reset correctly on episode reset.
- Service health status was using the actual health state instead of the visible health state
- Database file health status was using the incorrect value for negative rewards
- Preventing file actions from reaching their intended file
- The data manipulation attack was triggered at episode start.
- FTP STOR stored an additional copy on the client machine's filesystem
- The red agent acted to early
- Order of service health state
- Starting a node didn't start the services on it
- Fixed an issue where the services were still able to run even though the node the service is installed on is turned off
- The use of NODE_FILE_CHECKHASH and NODE_FOLDER_CHECKHASH in the current release is marked as 'Not Implemented'.
## [4.0.0] = 2025-03-XX
### Added
- Network Hardware - Added base hardware module with NIC, SwitchPort, Node, and Link. Nodes have
fundamental services like ARP, ICMP, and PCAP running them by default.
- Network Transmission - Modelled OSI Model layers 1 through to 5 with various classes for creating network frames and
transmitting them from a Service/Application, down through the layers, over the wire, and back up through the layers to
a Service/Application another machine.
- Introduced `Router` and `Switch` classes to manage networking routes more effectively.
- Added `ACLRule` and `RouteTableEntry` classes as part of the `Router`.
- New `.show()` methods in all network component classes to inspect the state in either plain text or markdown formats.
- Added `Computer` and `Server` class to better differentiate types of network nodes.
- Integrated a new Use Case 2 network into the system.
- New unit tests to verify routing between different subnets using `.ping()`.
- system - Added the core structure of Application, Services, and Components. Also added a SoftwareManager and
SessionManager.
- Permission System - each action can define criteria that will be used to permit or deny agent actions.
- File System - ability to emulate a node's file system during a simulation
- Example notebooks - There are 5 jupyter notebook which walk through using PrimAITE
1. Training a Stable Baselines 3 agent
2. Training a single agent system using Ray RLLib
3. Training a multi-agent system Ray RLLib
4. Data manipulation end to end demonstration
5. Data manipulation scenario with customised red agents
- Database:
- `DatabaseClient` and `DatabaseService` created to allow emulation of database actions
- Ability for `DatabaseService` to backup its data to another server via FTP and restore data from backup
- Red Agent Services:
- Data Manipulator Bot - A red agent service which sends a payload to a target machine. (By default this payload is a SQL query that breaks a database). The attack runs in stages with a random, configurable probability of succeeding.
- `DataManipulationAgent` runs the Data Manipulator Bot according to a configured start step, frequency and variance.
- DNS Services: `DNSClient` and `DNSServer`
- FTP Services: `FTPClient` and `FTPServer`
- HTTP Services: `WebBrowser` to simulate a web client and `WebServer`
- NTP Services: `NTPClient` and `NTPServer`
- **RouterNIC Class**: Introduced a new class `RouterNIC`, extending the standard `NIC` functionality. This class is specifically designed for router operations, optimizing the processing and routing of network traffic.
- **Custom Layer-3 Processing**: The `RouterNIC` class includes custom handling for network frames, bypassing standard Node NIC's Layer 3 broadcast/unicast checks. This allows for more efficient routing behavior in network scenarios where router-specific frame processing is required.
- **Enhanced Frame Reception**: The `receive_frame` method in `RouterNIC` is tailored to handle frames based on Layer 2 (Ethernet) checks, focusing on MAC address-based routing and broadcast frame acceptance.
- **Subnet-Wide Broadcasting for Services and Applications**: Implemented the ability for services and applications to conduct broadcasts across an entire IPv4 subnet within the network simulation framework.
- Introduced the `NetworkInterface` abstract class to provide a common interface for all network interfaces. Subclasses are divided into two main categories: `WiredNetworkInterface` and `WirelessNetworkInterface`, each serving as an abstract base class (ABC) for more specific interface types. Under `WiredNetworkInterface`, the subclasses `NIC` and `SwitchPort` were added. For wireless interfaces, `WirelessNIC` and `WirelessAccessPoint` are the subclasses under `WirelessNetworkInterface`.
- Added `Layer3Interface` as an abstract base class for networking functionalities at layer 3, including IP addressing and routing capabilities. This class is inherited by `NIC`, `WirelessNIC`, and `WirelessAccessPoint` to provide them with layer 3 capabilities, facilitating their role in both wired and wireless networking contexts with IP-based communication.
- Created the `ARP` and `ICMP` service classes to handle Address Resolution Protocol operations and Internet Control Message Protocol messages, respectively, with `RouterARP` and `RouterICMP` for router-specific implementations.
- Created `HostNode` as a subclass of `Node`, extending its functionality with host-specific services and applications. This class is designed to represent end-user devices like computers or servers that can initiate and respond to network communications.
- Introduced a new `IPV4Address` type in the Pydantic model for enhanced validation and auto-conversion of IPv4 addresses from strings using an `ipv4_validator`.
- Comprehensive documentation for the Node and its network interfaces, detailing the operational workflow from frame reception to application-level processing.
- Detailed descriptions of the Session Manager and Software Manager functionalities, including their roles in managing sessions, software services, and applications within the simulation.
- Documentation for the Packet Capture (PCAP) service and SysLog functionality, highlighting their importance in logging network frames and system events, respectively.
- Expanded documentation on network devices such as Routers, Switches, Computers, and Switch Nodes, explaining their specific processing logic and protocol support.
- **Firewall Node**: Introduced the `Firewall` class extending the functionality of the existing `Router` class. The `Firewall` class incorporates advanced features to scrutinize, direct, and filter traffic between various network zones, guided by predefined security rules and policies. Key functionalities include:
- Access Control Lists (ACLs) for traffic filtering based on IP addresses, protocols, and port numbers.
- Network zone segmentation for managing traffic across external, internal, and DMZ (De-Militarized Zone) networks.
- Interface configuration to establish connectivity and define network parameters for external, internal, and DMZ interfaces.
- Protocol and service management to oversee traffic and enforce security policies.
- Dynamic traffic processing and filtering to ensure network security and integrity.
- `AirSpace` class to simulate wireless communications, managing wireless interfaces and facilitating the transmission of frames within specified frequencies.
- `AirSpaceFrequency` enum for defining standard wireless frequencies, including 2.4 GHz and 5 GHz bands, to support realistic wireless network simulations.
- `WirelessRouter` class, extending the `Router` class, to incorporate wireless networking capabilities alongside traditional wired connections. This class allows the configuration of wireless access points with specific IP settings and operating frequencies.
- Documentation Updates:
- Examples include how to set up PrimAITE session via config
- Examples include how to create nodes and install software via config
- Examples include how to set up PrimAITE session via Python
- Examples include how to create nodes and install software via Python
- Added missing ``DoSBot`` documentation page
- Added diagrams where needed to make understanding some things easier
- Templated parts of the documentation to prevent unnecessary repetition and for easier maintaining of documentation
- Separated documentation pages of some items i.e. client and server software were on the same pages - which may make things confusing
- Configuration section at the bottom of the software pages specifying the configuration options available (and which ones are optional)
- Ability to add ``Firewall`` node via config
- Ability to add ``Router`` routes via config
- Ability to add ``Router``/``Firewall`` ``ACLRule`` via config
- NMNE capturing capabilities to `NetworkInterface` class for detecting and logging Malicious Network Events.
- New `nmne_config` settings in the simulation configuration to enable NMNE capturing and specify keywords such as "DELETE".
- Router-specific SessionManager Implementation: Introduced a specialized version of the SessionManager tailored for router operations. This enhancement enables the SessionManager to determine the routing path by consulting the route table.
- Log observation space data by episode and step.
- Added ability to set the observation threshold for NMNE, file access and application executions.
- Added `show_history` method to Agents, allowing you to view actions taken by an agent per step. By default, `do-nothing` actions are omitted.
- New ``node-send-local-command`` action implemented which grants agents the ability to execute commands locally. (Previously limited to remote only)
- Added ability to set the observation threshold for NMNE, file access and application executions
- UC7 Scenario model changes including Threat Actor Profile, TAP001 and TAP003 agents plus config files and example notebooks.
- New how-to guides describing how to use the new extension system to customise actions, environments and rewards.
- Added version and plugin fields to YAML configs to ensure compatibility with future versions.
- Network Node Adder class provides a framework for adding nodes to a network in a standardised way.
### Changed
- Integrated the RouteTable into the Routers frame processing.
- Frames are now dropped when their TTL reaches 0
- **NIC Functionality Update**: Updated the Network Interface Card (`NIC`) functionality to support Layer 3 (L3) broadcasts.
- **Layer 3 Broadcast Handling**: Enhanced the existing `NIC` classes to correctly process and handle Layer 3 broadcasts. This update allows devices using standard NICs to effectively participate in network activities that involve L3 broadcasting.
- **Improved Frame Reception Logic**: The `receive_frame` method of the `NIC` class has been updated to include additional checks and handling for L3 broadcasts, ensuring proper frame processing in a wider range of network scenarios.
- Standardised the way network interfaces are accessed across all `Node` subclasses (`HostNode`, `Router`, `Switch`) by maintaining a comprehensive `network_interface` attribute. This attribute captures all network interfaces by their port number, streamlining the management and interaction with network interfaces across different types of nodes.
- Refactored all tests to utilise new `Node` subclasses (`Computer`, `Server`, `Router`, `Switch`) instead of creating generic `Node` instances and manually adding network interfaces. This change aligns test setups more closely with the intended use cases and hierarchies within the network simulation framework.
- Updated all tests to employ the `Network()` class for managing nodes and their connections, ensuring a consistent and structured approach to setting up network topologies in testing scenarios.
- **ACLRule Wildcard Masking**: Updated the `ACLRule` class to support IP ranges using wildcard masking. This enhancement allows for more flexible and granular control over traffic filtering, enabling the specification of broader or more specific IP address ranges in ACL rules.
- Updated `NetworkInterface` documentation to reflect the new NMNE capturing features and how to use them.
- Integration of NMNE capturing functionality within the `NICObservation` class.
- Changed blue action set to enable applying node scan, reset, start, and shutdown to every host in data manipulation scenario
### Removed
- Removed legacy simulation modules: `acl`, `common`, `environment`, `links`, `nodes`, `pol`
- Removed legacy training modules
- Removed tests for legacy code
- ACLs are no longer applied to layer-2 traffic.
- Random number seed values are recorded in simulation/seed.log if the seed is set in the config file
or `generate_seed_value` is set to `true`.
- ARP .show() method will now include the port number associated with each entry.
- The behaviour that services, applications, files and folders require scanning before their observations are updated is now optional.
- Updated the `Terminal` class to provide response information when sending remote command execution.
- Agents now follow a common configuration format, simplifying the configuration of agents and their extensibilty.
- Actions within PrimAITE are now extensible, allowing for plugin support.
- Added a config schema to `ObservationManager`, `ActionManager`, and `RewardFunction`.
- Streamlined the way agents are created from config
- Agent config no longer requires a dummy action space if the action space is empty, the same applies for observation space and reward function
- Actions now support a config schema, to allow yaml data validation and default parameter values
- Action parameters are no longer defined through IDs, instead meaningful data is provided directly in the action map
- Test and example YAMLs have been updated to match the new agent and action schemas, such as:
- Removed empty action spaces, observation spaces, or reward spaces for agent which didn't use them
- Relabelled action parameters to match the new action config schemas, and updated the values to no longer rely on indices
- Removed action space options which were previously used for assigning meaning to action space IDs
- Updated tests that don't use YAMLs to still use the new action and agent schemas
- Nodes now use a config schema and are extensible, allowing for plugin support.
- Node tests have been updated to use the new node config schemas when not using YAML files.
- Documentation has been updated to include details of extensibility with PrimAITE.
- Software is created in the GOOD health state instead of UNUSED.
- Standardised naming convention for YAML config files using kebab-case.
This naming convention is used for configuring software, observations, actions and node types.
NB: A migration guide will be available with this release.
### Fixed
- Addressed network transmission issues that previously allowed ARP requests to be incorrectly routed and repeated across different subnets. This fix ensures ARP requests are correctly managed and confined to their appropriate network segments.
- Resolved problems in `Node` and its subclasses where the default gateway configuration was not properly utilized for communications across different subnets. This correction ensures that nodes effectively use their configured default gateways for outbound communications to other network segments, thereby enhancing the network's routing functionality and reliability.
- Network Interface Port name/num being set properly for sys log and PCAP output.
- DNS client no longer fails to check its cache if a DNS server address is missing.
- DNS client now correctly inherits the node's DNS address configuration setting.
- ACL observations now include the ACL at index 0.
- SoftwareManager.show() correctly displays all the software associated with a port whether the software is listening or not.
## [3.3.0] - 2024-09-04
### Added
- Random Number Generator Seeding by specifying a random number seed in the config file.
- Implemented Terminal service class, providing a generic terminal simulation.
- Added `User`, `UserManager` and `UserSessionManager` to enable the creation of user accounts and login on Nodes.
- Added actions to establish SSH connections, send commands remotely and terminate SSH connections.
- Added actions to change users' passwords.
- Added a `listen_on_ports` set in the `IOSoftware` class to enable software listening on ports in addition to the
main port they're assigned.
- Added two new red applications: ``C2Beacon`` and ``C2Server`` which aim to simulate malicious network infrastructure.
Refer to the ``Command and Control Application Suite E2E Demonstration`` notebook for more information.
- Added reward calculation details to AgentHistoryItem.
- Added a new Privilege-Escalation-and Data-Loss-Example.ipynb notebook with a realistic cyber scenario focusing on
internal privilege escalation and data loss through the manipulation of SSH access and Access Control Lists (ACLs).
- Added a new extensible `NetworkNodeAdder` class for convenient addition of sets of nodes based on a simplified config.
### Changed
- File and folder observations can now be configured to always show the true health status, or require scanning like before.
- It's now possible to disable stickiness on reward components, meaning their value returns to 0 during timesteps where agent don't issue the corresponding action. Affects `GreenAdminDatabaseUnreachablePenalty`, `WebpageUnavailablePenalty`, `WebServer404Penalty`
- Node observations can now be configured to show the number of active local and remote logins.
- Ports and IP Protocols no longer use enums. They are defined in dictionary lookups and are handled by custom validation to enable extensibility with plugins.
- Changed AirSpaceFrequency to a data transfer object with a registry to allow extensibility
- Changed the Office LAN creation convenience function to follow the new `NetworkNodeAdder` pattern. Office LANs can now also be defined in YAML config.
### Fixed
- Folder observations showing the true health state without scanning (the old behaviour can be reenabled via config)
- Updated `SoftwareManager` `install` and `uninstall` to handle all functionality that was being done at the `install`
and `uninstall` methods in the `Node` class.
- Updated the `receive_payload_from_session_manager` method in `SoftwareManager` so that it now sends a copy of the
payload to any software listening on the destination port of the `Frame`.
- Made the `show` method of `Network` show all node types, including ones registered at runtime
### Removed
- Removed the `install` and `uninstall` methods in the `Node` class.
## [3.2.0] - 2024-07-18
### Added
- Action penalty is a reward component that applies a negative reward for doing any action other than DONOTHING
- Application configuration actions for RansomwareScript, DatabaseClient, and DoSBot applications
- Ability to configure how long it takes to apply the service fix action
- Terminal service using SSH
- Airspaces now track the amount of data being transmitted, viewable using the `show_bandwidth_load` method
- Tests to verify that airspace bandwidth is applied correctly and can be configured via YAML
- Agent logging for agents' internal decision logic
- Action masking in all PrimAITE environments
### Changed
- Application registry was moved to the `Application` class and now updates automatically when Application is subclassed
- Databases can no longer respond to request while performing a backup
- Application install no longer accepts an `ip_address` parameter
- Application install action can now be used on all applications
- Actions have additional logic for checking validity
- Frame `size` attribute now includes both core size and payload size in bytes
- The `speed` attribute of `NetworkInterface` has been changed from `int` to `float`
- Tidied up CHANGELOG
- Enhanced `AirSpace` logic to block transmissions that would exceed the available capacity.
- Updated `_can_transmit` function in `Link` to account for current load and total bandwidth capacity, ensuring transmissions do not exceed limits.
### Fixed
- Links and airspaces can no longer transmit data if this would exceed their bandwidth
## [3.1.0] - 2024-06-25
### Added
- Observations for traffic amounts on host network interfaces
- NMAP application network discovery, including ping scan and port scan
- NMAP actions
- Automated adding copyright notices to source files
- More file types
- `show` method to files
- `model_dump` methods to network enums to enable better logging
### Changed
- Updated file system actions to stop failures when creating duplicate files
- Improved parsing of ACL add rule actions to make some parameters optional
### Fixed
- Fixed database client uninstall failing due to persistent connections
- Fixed packet storm when pinging broadcast addresses
## [3.0.0] - 2024-06-10
### Added
- New simulation module
- Multi agent reinforcement learning support
- File system class to manage files and folders
- Software for nodes that can have its own behaviour
- Software classes to model FTP, Postgres databases, web traffic, NTP
- Much more detailed network simulation including packets, links, and network interfaces
- More node types: host, computer, server, router, switch, wireless router, and firewalls
- Network Hardware - NIC, SwitchPort, Node, and Link. Nodes have fundamental services like ARP, ICMP, and PCAP running them by default.
- Malicious network event detection
- New `game` module for managing agents
- ACL rule wildcard masking
- Network broadcasting
- Wireless transmission
- More detailed documentation
- Example jupyter notebooks to demonstrate new functionality
- More reward components
- Packet capture logs
- Node system logs
- Per-step full simulation state log
- Attack randomisation with respect to timing and attack source
- Ability to set log level via CLI
- Ability to vary the YAML configuration per-episode
- Developer CLI tools for enhanced debugging (with `primaite dev-mode enable`)
- `show` function to many simulation objects to inspect their current state
### Changed
- Decoupled the environment from the simulation by adding the `game` interface layer
- Made agents share a common base class
- Added more actions
- Made all agents use CAOS actions, including red and green agents
- Reworked YAML configuration file schema
- Reworked the reward system to be component-based
- Changed agent logs to create a JSON output instead of CSV with more detailed action information
- Made observation space flattening optional
- Made all logging optional
- Agent actions now provide responses with a success code
### Removed
- Legacy simulation modules
- Legacy training modules
- Tests for legacy code
- Hardcoded IERs and PoL, traffic generation is now handled by agents and software
- Inbuilt agent training scripts
## [2.0.0] - 2023-07-26
### Added
- Command Line Interface (CLI) for easy access and streamlined usage of PrimAITE.
- Application Directories to enable PrimAITE as a Python package with predefined directories for storage.
- Support for Ray Rllib, allowing training of PPO and A2C agents using Stable Baselines3 and Ray RLlib.
- Random Red Agent to train the blue agent against, with options for randomised Red Agent `POL` and `IER`.
- Repeatability of sessions through seed settings, and deterministic or stochastic evaluation options.
- Session loading to revisit previously run sessions for SB3 Agents.
- Agent Session Classes (`AgentSessionABC` and `HardCodedAgentSessionABC`) to standardise agent training with a common interface.
- Standardised Session Output in a structured format in the user's app sessions directory, providing four types of outputs:
1. Session Metadata
2. Results
3. Diagrams
4. Saved agents (training checkpoints and a final trained agent).
- Configurable Observation Space managed by the `ObservationHandler` class for a more flexible observation space setup.
- Benchmarking of PrimAITE performance, showcasing session and step durations for reference.
- Documentation overhaul, including automatic API and test documentation with recursive Sphinx auto-summary, using the Furo theme for responsive light/dark theme, and enhanced navigation with `sphinx-code-tabs` and `sphinx-copybutton`.
- Command Line Interface (CLI) for easy access and streamlined usage of PrimAITE.
- Application Directories to enable PrimAITE as a Python package with predefined directories for storage.
- Support for Ray Rllib, allowing training of PPO and A2C agents using Stable Baselines3 and Ray RLlib.
- Random Red Agent to train the blue agent against, with options for randomised Red Agent `POL` and `IER`.
- Repeatability of sessions through seed settings, and deterministic or stochastic evaluation options.
- Session loading to revisit previously run sessions for SB3 Agents.
- Agent Session Classes (`AgentSessionABC` and `HardCodedAgentSessionABC`) to standardise agent training with a common interface.
- Standardised Session Output in a structured format in the user's app sessions directory, providing four types of outputs: Session Metadata, Results, Diagrams, Trained agents.
- Configurable Observation Space managed by the `ObservationHandler` class for a more flexible observation space setup.
- Benchmarking of PrimAITE performance, showcasing session and step durations for reference.
- Documentation overhaul, including automatic API and test documentation with recursive Sphinx auto-summary, using the Furo theme for responsive light/dark theme, and enhanced navigation with `sphinx-code-tabs` and `sphinx-copybutton`.
### Changed
- Action Space updated to discrete spaces, introducing a new `ANY` action space option for combined `NODE` and `ACL` actions.
- Improved `Node` attribute naming convention for consistency, now adhering to `Pascal Case`.
- Package Structure has been refactored for better build, distribution, and installation, with all source code now in the `src/` directory, and the `PRIMAITE` Python package renamed to `primaite` to adhere to PEP-8 Package & Module Names.
- Docs and Tests now sit outside the `src/` directory.
- Non-python files (example config files, Jupyter notebooks, etc.) now sit inside a `*/_package_data/` directory in their respective sub-packages.
- All dependencies are now defined in the `pyproject.toml` file.
- Introduced individual configuration for the number of episodes and time steps for training and evaluation sessions, with separate config values for each.
- Decoupled the lay down config file from the training config, allowing more flexibility in configuration management.
- Updated `Transactions` to only report pre-action observation, improving the CSV header and providing more human-readable descriptions for columns relating to observations.
- Changes to `AccessControlList`, where the `acl` dictionary is now a list to accommodate changes to ACL action space and positioning of `ACLRules` inside the list to signal their level of priority.
- Action Space updated to discrete spaces, introducing a new `ANY` action space option for combined `NODE` and `ACL` actions.
- Improved `Node` attribute naming convention for consistency, now adhering to `Pascal Case`.
- Package Structure has been refactored for better build, distribution, and installation, with all source code now in the `src/` directory, and the `PRIMAITE` Python package renamed to `primaite` to adhere to PEP-8 Package & Module Names.
- Docs and Tests now sit outside the `src/` directory.
- Non-python files (example config files, Jupyter notebooks, etc.) now sit inside a `*/_package_data/` directory in their respective sub-packages.
- All dependencies are now defined in the `pyproject.toml` file.
- Introduced individual configuration for the number of episodes and time steps for training and evaluation sessions, with separate config values for each.
- Decoupled the lay down config file from the training config, allowing more flexibility in configuration management.
- Updated `Transactions` to only report pre-action observation, improving the CSV header and providing more human-readable descriptions for columns relating to observations.
- Changes to `AccessControlList`, where the `acl` dictionary is now a list to accommodate changes to ACL action space and positioning of `ACLRules` inside the list to signal their level of priority.
### Fixed
- Various bug fixes, including Green IERs separation, correct clearing of links in the reference environment, and proper reward calculation.
- Logic to check if a node is OFF before executing actions on the node by the blue agent, preventing erroneous state changes.
- Improved functionality of Resetting a Node, adding "SHUTTING DOWN" and "BOOTING" operating states for more reliable reset commands.
- Corrected the order of actions in the `Primaite` env to ensure the blue agent uses the current state for decision-making.
- Various bug fixes, including Green IERs separation, correct clearing of links in the reference environment, and proper reward calculation.
- Logic to check if a node is OFF before executing actions on the node by the blue agent, preventing erroneous state changes.
- Improved functionality of Resetting a Node, adding "SHUTTING DOWN" and "BOOTING" operating states for more reliable reset commands.
- Corrected the order of actions in the `Primaite` env to ensure the blue agent uses the current state for decision-making.
## [1.1.1] - 2023-06-27
### Bug Fixes
* Fixed bug whereby 'reference' environment links reach bandwidth capacity and are never cleared due to green & red IERs being applied to them. This bug had a knock-on effect that meant IERs were being blocked based on the full capacity of links on the reference environment which was not correct; they should only be based on the link capacity of the 'live' environment. This fix has been addressed by:
* Implementing a reference copy of all green IERs (`self.green_iers_reference`).
* Clearing the traffic on reference IERs at the same time as the live IERs.
* Passing the `green_iers_reference` to the `apply_iers` function at the reference stage.
* Passing the `green_iers_reference` as an additional argument to `calculate_reward_function`.
* Updating the green IERs section of the `calculate_reward_function` to now take into account both the green reference IERs and live IERs. The `green_ier_blocked` reward is only applied if the IER is blocked in the live environment but is running in the reference environment.
* Re-ordering the actions taken as part of the step function to ensure the blue action happens first before other changes.
* Removing the unnecessary "Reapply PoL and IERs" action from the step function.
* Moving the deep-copy of nodes and links to below the "Implement blue action" stage of the step function.
### Fixed
- Fixed bug whereby 'reference' environment links reach bandwidth capacity and are never cleared due to green & red IERs being applied to them. This bug had a knock-on effect that meant IERs were being blocked based on the full capacity of links on the reference environment which was not correct; they should only be based on the link capacity of the 'live' environment. This fix has been addressed by:
- Implementing a reference copy of all green IERs (`self.green_iers_reference`).
- Clearing the traffic on reference IERs at the same time as the live IERs.
- Passing the `green_iers_reference` to the `apply_iers` function at the reference stage.
- Passing the `green_iers_reference` as an additional argument to `calculate_reward_function`.
- Updating the green IERs section of the `calculate_reward_function` to now take into account both the green reference IERs and live IERs. The `green_ier_blocked` reward is only applied if the IER is blocked in the live environment but is running in the reference environment.
- Re-ordering the actions taken as part of the step function to ensure the blue action happens first before other changes.
- Removing the unnecessary "Reapply PoL and IERs" action from the step function.
- Moving the deep-copy of nodes and links to below the "Implement blue action" stage of the step function.
## [1.1.0] - 2023-03-13
### Added
* The user can now initiate either a TRAINING session or an EVALUATION (test) session with the Stable Baselines 3 (SB3) agents via the config_main.yaml file. During evaluation/testing, the agent policy will be fixed (no longer learning) and subjected to the SB3 `evaluate_policy()` function.
* The user can choose whether a saved agent is loaded into the session (with reference to a URL) via the `config_main.yaml` file. They specify a Boolean true/false indicating whether a saved agent should be loaded, and specify the URL and file name.
* Active and Service nodes now possess a new "File System State" attribute. This attribute is permitted to have the states GOOD, CORRUPT, DESTROYED, REPAIRING, and RESTORING. This new feature affects the following components:
* Blue agent observation space;
* Blue agent action space;
* Reward function;
* Node pattern-of-life.
* The Red Agent node pattern-of-life has been enhanced so that node PoL is triggered by an 'initiator'. The initiator is either DIRECT (state change is applied to the node without any conditions), IER (state change is applied to the node based on IER entry condition), or SERVICE (state change is applied to the node based on a service state condition on the same node or a different node within the network).
* New default config named "config_5_DATA_MANIPULATION.yaml" and associated Training Use Case Profile.
* NodeStateInstruction has been split into `NodeStateInstructionGreen` and `NodeStateInstructionRed` to reflect the changes within the red agent pattern-of-life capability.
* The reward function has been enhanced so that node attribute states of resetting, patching, repairing, and restarting contribute to the overall reward value.
* The User Guide has been updated to reflect all the above changes.
- The user can now initiate either a TRAINING session or an EVALUATION (test) session with the Stable Baselines 3 (SB3) agents via the config_main.yaml file. During evaluation/testing, the agent policy will be fixed (no longer learning) and subjected to the SB3 `evaluate_policy()` function.
- The user can choose whether a saved agent is loaded into the session (with reference to a URL) via the `config_main.yaml` file. They specify a Boolean true/false indicating whether a saved agent should be loaded, and specify the URL and file name.
- Active and Service nodes now possess a new "File System State" attribute. This attribute is permitted to have the states GOOD, CORRUPT, DESTROYED, REPAIRING, and RESTORING. This new feature affects the following components:
- Blue agent observation space;
- Blue agent action space;
- Reward function;
- Node pattern-of-life.
- The Red Agent node pattern-of-life has been enhanced so that node PoL is triggered by an 'initiator'. The initiator is either DIRECT (state change is applied to the node without any conditions), IER (state change is applied to the node based on IER entry condition), or SERVICE (state change is applied to the node based on a service state condition on the same node or a different node within the network).
- New default config named "config_5_DATA_MANIPULATION.yaml" and associated Training Use Case Profile.
- NodeStateInstruction has been split into `NodeStateInstructionGreen` and `NodeStateInstructionRed` to reflect the changes within the red agent pattern-of-life capability.
- The reward function has been enhanced so that node attribute states of resetting, patching, repairing, and restarting contribute to the overall reward value.
- The User Guide has been updated to reflect all the above changes.
### Changed
* "config_1_DDOS_BASIC.yaml" modified to make it more simplistic to aid evaluation testing.
* "config_2_DDOS_BASIC.yaml" updated to reflect the addition of the File System State and the Red Agent node pattern-of-life enhancement.
* "config_3_DOS_VERY_BASIC.yaml" updated to reflect the addition of the File System State and the Red Agent node pattern-of-life enhancement.
* "config_UNIT_TEST.yaml" is a copy of the new "config_5_DATA_MANIPULATION.yaml" file.
* Updates to Transactions.
- "config_1_DDOS_BASIC.yaml" modified to make it more simplistic to aid evaluation testing.
- "config_2_DDOS_BASIC.yaml" updated to reflect the addition of the File System State and the Red Agent node pattern-of-life enhancement.
- "config_3_DOS_VERY_BASIC.yaml" updated to reflect the addition of the File System State and the Red Agent node pattern-of-life enhancement.
- "config_UNIT_TEST.yaml" is a copy of the new "config_5_DATA_MANIPULATION.yaml" file.
- Updates to Transactions.
### Fixed
* Fixed "config_2_DDOS_BASIC.yaml" by adding another ACL rule to allow traffic to flow from Node 9 to Node 3. Previously, there was no rule, so one of the green IERs could not flow by default.
[unreleased]: https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE/compare/v2.0.0...HEAD
[2.0.0]: https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE/releases/tag/v2.0.0
- Fixed "config_2_DDOS_BASIC.yaml" by adding another ACL rule to allow traffic to flow from Node 9 to Node 3. Previously, there was no rule, so one of the green IERs could not flow by default.

View File

@@ -4,20 +4,17 @@
### **Did you find a bug?**
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/{todo:fill in URL}/PrimAITE/issues).
* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/{todo:fill in URL}/PrimAITE/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=%5BBUG%5D+-+%3Cbug+title+goes+here%3E). Be sure to follow our bug report template with the headers **Describe the bug**, **To Reproduce**, **Expected behaviour**, **Screenshots/Outputs**, **Environment**, and **Additional context**
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE/issues).
* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=%5BBUG%5D+-+%3Cbug+title+goes+here%3E). Be sure to follow our bug report template with the headers **Describe the bug**, **To Reproduce**, **Expected behaviour**, **Screenshots/Outputs**, **Environment**, and **Additional context**
### **Do you have a solution to fix the bug?**
* [Fork the repository](https://github.com/{todo:fill in URL}/PrimAITE/fork).
* [Fork the repository](https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE/fork).
* Install the pre-commit hook with `pre-commit install`.
* Implement the bug fix.
* Update documentation where applicable.
* Update the **UNRELEASED** section of the [CHANGELOG.md](CHANGELOG.md) file
* Write a suitable test/tests.
* Commit the bug fix to the dev branch on your fork. If the bug has an open issue under [Issues](https://github.com/{todo:fill in URL}/PrimAITE/issues), reference the issue in the commit message (e.g. #1 references issue 1).
* Submit a pull request from your dev branch to the {todo:fill in URL}/PrimAITE dev branch. Again, if the bug has an open issue under [Issues](https://github.com/{todo:fill in URL}/PrimAITE/issues), reference the issue in the pull request description.
* Commit the bug fix to the dev branch on your fork. If the bug has an open issue under [Issues](https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE/issues), reference the issue in the commit message (e.g. #1 references issue 1).
* Submit a pull request from your dev branch to the Autonomous-Resilient-Cyber-Defence/PrimAITE dev branch. Again, if the bug has an open issue under [Issues](https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE/issues), reference the issue in the pull request description.
### **Did you fix whitespace, format code, or make a purely cosmetic patch?**
@@ -25,7 +22,7 @@ Changes that are cosmetic in nature and do not add anything substantial to the s
### **Do you intend to add a new feature or change an existing one?**
* Submit a [feature request issue](https://github.com/{todo:fill in URL}/PrimAITE/issues/new?assignees=&labels=feature_request&projects=&template=feature_request.md&title=%5BREQUEST%5D+-+%3Crequest+title+goes+here%3E).
* Submit a [feature request issue](https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE/issues/new?assignees=&labels=feature_request&projects=&template=feature_request.md&title=%5BREQUEST%5D+-+%3Crequest+title+goes+here%3E).
* Know how to implement the new feature or change? Follow the same steps in the bug fix section above to fork, build, document, test, commit, and submit a pull request.
### **Do you have questions about the source code?**

13
LICENSE
View File

@@ -4,24 +4,21 @@ MIT License Conditions
These MIT License conditions confirm the provision of the following artefacts as MIT License by Defence Science and Technology
of this software and associated documentation files (the "Software"), to deal
request to the QQ or FNC mailbox):
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
- Use Case Release Packs
furnished to do so, subject to the following conditions:
Suppliers are required to read and confirm acceptance of the {todo:fill in URL} Foundry SyOPs (https://github.com/{todo:fill in URL}/foundry-syops) before being admitted access to material hosted on the {todo:fill in URL} Foundry GitHub site.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
The material is supplied in confidence to QQ / FNC and their subcontractors under SERAPIS, and is issued to inform only those
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
of DSTL. The material must be stored and protected appropriately. All material must be destroyed at the end of the task.

View File

@@ -1,3 +1,2 @@
include src/primaite/setup/_package_data/primaite_config.yaml
include src/primaite/config/_package_data/*.yaml
include src/primaite/simulator/_package_data/*.ipynb

View File

@@ -24,6 +24,8 @@ PrimAITE presents the following features:
- Support for multiple agents, each having their own customisable observation space, action space, and reward function definition, and either deterministic or RL-directed behaviour
Whilst PrimAITE ships with a number of example modelled scenarios (a.k.a. Use Cases), it has not been developed to mandate the solving of a single cyber challenge, and instead provides a highly flexible environment application that can be extended and reconfigured by the user to suit their specific cyber defence training and evaluation needs. PrimAITE provides default networks, red agent and green agent behaviour, reward functions, and action / observation space configuration, all of which can be utilised out of the box, but which ultimately can (and in some instances should) be built upon and / or reconfigured to meet the needs of different defensive agent developers. The PrimAITE user guide provides comprehensive instruction on all PrimAITE features, functionality and components, and can be consulted in order to help guide users in any reconfiguration or enhancements they wish to undertake; a library of example Jupyter notebooks are also provided to support such work.
## Getting Started with PrimAITE
### 💫 Installation
@@ -77,7 +79,7 @@ To make your own changes to PrimAITE, perform the install from source (developer
#### 1. Clone the PrimAITE repository
``` unix
git clone git@github.com:{todo:fill in URL}/PrimAITE.git
git clone git@github.com:Autonomous-Resilient-Cyber-Defence/PrimAITE.git
```
#### 2. CD into the repo directory

3
_config.yml Normal file
View File

@@ -0,0 +1,3 @@
# Used by nbmake to change build pipeline notebook timeout
execute:
timeout: 600

View File

@@ -1,4 +1,4 @@
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
from typing import Any, Dict, Optional, Tuple
from gymnasium.core import ObsType

View File

@@ -1,11 +1,11 @@
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
import json
import shutil
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, Final, Tuple
from report import build_benchmark_md_report
from report import build_benchmark_md_report, md2pdf
from stable_baselines3 import PPO
import primaite
@@ -159,6 +159,13 @@ def run(
learning_rate: float = 3e-4,
) -> None:
"""Run the PrimAITE benchmark."""
# generate report folder
v_str = f"v{primaite.__version__}"
version_result_dir = _RESULTS_ROOT / v_str
version_result_dir.mkdir(exist_ok=True, parents=True)
output_path = version_result_dir / f"PrimAITE {v_str} Benchmark Report.md"
benchmark_start_time = datetime.now()
session_metadata_dict = {}
@@ -193,6 +200,12 @@ def run(
session_metadata=session_metadata_dict,
config_path=data_manipulation_config_path(),
results_root_path=_RESULTS_ROOT,
output_path=output_path,
)
md2pdf(
md_path=output_path,
pdf_path=str(output_path).replace(".md", ".pdf"),
css_path="static/styles.css",
)

View File

@@ -1,7 +1,8 @@
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
import json
import sys
from datetime import datetime
from os import PathLike
from pathlib import Path
from typing import Dict, Optional
@@ -14,11 +15,9 @@ from utils import _get_system_info
import primaite
PLOT_CONFIG = {
"size": {"auto_size": False, "width": 1500, "height": 900},
"size": {"auto_size": False, "width": 800, "height": 640},
"template": "plotly_white",
"range_slider": False,
"av_s_per_100_steps_10_nodes_benchmark_threshold": 5,
"benchmark_line_color": "grey",
}
@@ -146,6 +145,20 @@ def _plot_benchmark_metadata(
yaxis={"title": "Total Reward"},
title=title,
)
fig.update_layout(
legend=dict(
yanchor="top",
y=0.99,
xanchor="left",
x=0.01,
bgcolor="rgba(255,255,255,0.3)",
)
)
for trace in fig["data"]:
if trace["name"].startswith("Session"):
trace["showlegend"] = False
fig["data"][0]["name"] = "Individual Sessions"
fig["data"][0]["showlegend"] = True
return fig
@@ -196,6 +209,7 @@ def _plot_all_benchmarks_combined_session_av(results_directory: Path) -> Figure:
title=title,
)
fig["data"][0]["showlegend"] = True
fig.update_layout(legend=dict(yanchor="top", y=-0.2, xanchor="left", x=0.01, orientation="h"))
return fig
@@ -229,20 +243,14 @@ def _plot_av_s_per_100_steps_10_nodes(
"""
Creates a bar chart visualising the performance of each version of PrimAITE.
Performance is based on the average training time per 100 steps on 10 nodes. The function also includes a benchmark
line indicating the target maximum time.
Versions that perform under this time are marked in green, and those over are marked in red.
Performance is based on the average training time per 100 steps on 10 nodes.
:param version_times_dict: A dictionary with software versions as keys and average times as values.
:return: A Plotly figure object representing the bar chart of the performance metrics.
"""
major_v = primaite.__version__.split(".")[0]
title = f"Performance of Minor and Bugfix Releases for Major Version {major_v}"
subtitle = (
f"Average Training Time per 100 Steps on 10 Nodes "
f"(target: <= {PLOT_CONFIG['av_s_per_100_steps_10_nodes_benchmark_threshold']} seconds)"
)
subtitle = "Average Training Time per 100 Steps on 10 Nodes "
title = f"{title} <br><sub>{subtitle}</sub>"
layout = go.Layout(
@@ -255,42 +263,12 @@ def _plot_av_s_per_100_steps_10_nodes(
versions = sorted(list(version_times_dict.keys()))
times = [version_times_dict[version] for version in versions]
av_s_per_100_steps_10_nodes_benchmark_threshold = PLOT_CONFIG["av_s_per_100_steps_10_nodes_benchmark_threshold"]
benchmark_line_color = PLOT_CONFIG["benchmark_line_color"]
# Calculate the appropriate maximum y-axis value
max_y_axis_value = max(max(times), av_s_per_100_steps_10_nodes_benchmark_threshold) + 1
fig.add_trace(
go.Bar(
x=versions,
y=times,
marker_color=[
"green" if time < av_s_per_100_steps_10_nodes_benchmark_threshold else "red" for time in times
],
text=times,
textposition="auto",
)
)
# Add a horizontal line for the benchmark
fig.add_shape(
type="line",
x0=-0.5, # start slightly before the first bar
x1=len(versions) - 0.5, # end slightly after the last bar
y0=av_s_per_100_steps_10_nodes_benchmark_threshold,
y1=av_s_per_100_steps_10_nodes_benchmark_threshold,
line=dict(
color=benchmark_line_color,
width=2,
dash="dot",
),
)
fig.add_trace(go.Bar(x=versions, y=times, text=times, textposition="auto", texttemplate="%{y:.3f}"))
fig.update_layout(
xaxis_title="PrimAITE Version",
yaxis_title="Avg Time per 100 Steps on 10 Nodes (seconds)",
yaxis=dict(range=[0, max_y_axis_value]),
title=title,
)
@@ -298,7 +276,11 @@ def _plot_av_s_per_100_steps_10_nodes(
def build_benchmark_md_report(
benchmark_start_time: datetime, session_metadata: Dict, config_path: Path, results_root_path: Path
benchmark_start_time: datetime,
session_metadata: Dict,
config_path: Path,
results_root_path: Path,
output_path: PathLike,
) -> None:
"""
Generates a Markdown report for a benchmarking session, documenting performance metrics and graphs.
@@ -350,7 +332,7 @@ def build_benchmark_md_report(
data = benchmark_metadata_dict
primaite_version = data["primaite_version"]
with open(version_result_dir / f"PrimAITE v{primaite_version} Benchmark Report.md", "w") as file:
with open(output_path, "w") as file:
# Title
file.write(f"# PrimAITE v{primaite_version} Learning Benchmark\n")
file.write("## PrimAITE Dev Team\n")
@@ -424,3 +406,15 @@ def build_benchmark_md_report(
f"![Performance of Minor and Bugfix Releases for Major Version {major_v}]"
f"({performance_benchmark_plot_path.name})\n"
)
def md2pdf(md_path: PathLike, pdf_path: PathLike, css_path: PathLike) -> None:
"""Generate PDF version of Markdown report."""
from md2pdf.core import md2pdf
md2pdf(
pdf_file_path=pdf_path,
md_file_path=md_path,
base_url=Path(md_path).parent,
css_file_path=css_path,
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

After

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@@ -1,10 +1,10 @@
# PrimAITE v3.0.0 Learning Benchmark
# PrimAITE v3.2.0 Learning Benchmark
## PrimAITE Dev Team
### 2024-07-20
### 2024-07-21
---
## 1 Introduction
PrimAITE v3.0.0 was benchmarked automatically upon release. Learning rate metrics were captured to be referenced during system-level testing and user acceptance testing (UAT).
PrimAITE v3.2.0 was benchmarked automatically upon release. Learning rate metrics were captured to be referenced during system-level testing and user acceptance testing (UAT).
The benchmarking process consists of running 5 training session using the same config file. Each session trains an agent for 1000 episodes, with each episode consisting of 128 steps.
The total reward per episode from each session is captured. This is then used to calculate an caverage total reward per episode from the 5 individual sessions for smoothing. Finally, a 25-widow rolling average of the average total reward per session is calculated for further smoothing.
## 2 System Information
@@ -26,12 +26,12 @@ The total reward per episode from each session is captured. This is then used to
- **Total Sessions:** 5
- **Total Episodes:** 5005
- **Total Steps:** 640000
- **Av Session Duration (s):** 1452.5910
- **Av Step Duration (s):** 0.0454
- **Av Duration per 100 Steps per 10 Nodes (s):** 4.5393
- **Av Session Duration (s):** 1691.5034
- **Av Step Duration (s):** 0.0529
- **Av Duration per 100 Steps per 10 Nodes (s):** 5.2859
## 4 Graphs
### 4.1 v3.0.0 Learning Benchmark Plot
![PrimAITE 3.0.0 Learning Benchmark Plot](PrimAITE v3.0.0 Learning Benchmark.png)
### 4.1 v3.2.0 Learning Benchmark Plot
![PrimAITE 3.2.0 Learning Benchmark Plot](PrimAITE v3.2.0 Learning Benchmark.png)
### 4.2 Learning Benchmark of Minor and Bugfix Releases for Major Version 3
![Learning Benchmark of Minor and Bugfix Releases for Major Version 3](PrimAITE Learning Benchmark of Minor and Bugfix Releases for Major Version 3.png)
### 4.3 Performance of Minor and Bugfix Releases for Major Version 3

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -0,0 +1,38 @@
# PrimAITE v3.3.0 Learning Benchmark
## PrimAITE Dev Team
### 2024-09-02
---
## 1 Introduction
PrimAITE v3.3.0 was benchmarked automatically upon release. Learning rate metrics were captured to be referenced during system-level testing and user acceptance testing (UAT).
The benchmarking process consists of running 5 training session using the same config file. Each session trains an agent for 1000 episodes, with each episode consisting of 128 steps.
The total reward per episode from each session is captured. This is then used to calculate an caverage total reward per episode from the 5 individual sessions for smoothing. Finally, a 25-widow rolling average of the average total reward per session is calculated for further smoothing.
## 2 System Information
### 2.1 Python
**Version:** 3.10.14 (main, Apr 6 2024, 18:45:05) [GCC 9.4.0]
### 2.2 System
- **OS:** Linux
- **OS Version:** #76~20.04.1-Ubuntu SMP Thu Jun 13 18:00:23 UTC 2024
- **Machine:** x86_64
- **Processor:** x86_64
### 2.3 CPU
- **Physical Cores:** 2
- **Total Cores:** 4
- **Max Frequency:** 0.00Mhz
### 2.4 Memory
- **Total:** 15.62GB
- **Swap Total:** 0.00B
## 3 Stats
- **Total Sessions:** 5
- **Total Episodes:** 5005
- **Total Steps:** 640000
- **Av Session Duration (s):** 1458.2831
- **Av Step Duration (s):** 0.0456
- **Av Duration per 100 Steps per 10 Nodes (s):** 4.5571
## 4 Graphs
### 4.1 v3.3.0 Learning Benchmark Plot
![PrimAITE 3.3.0 Learning Benchmark Plot](PrimAITE v3.3.0 Learning Benchmark.png)
### 4.2 Learning Benchmark of Minor and Bugfix Releases for Major Version 3
![Learning Benchmark of Minor and Bugfix Releases for Major Version 3](PrimAITE Learning Benchmark of Minor and Bugfix Releases for Major Version 3.png)
### 4.3 Performance of Minor and Bugfix Releases for Major Version 3
![Performance of Minor and Bugfix Releases for Major Version 3](PrimAITE Performance of Minor and Bugfix Releases for Major Version 3.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
body {
font-family: 'Arial', sans-serif;
line-height: 1.6;
/* margin: 1cm; */
}
h1, h2, h3, h4, h5, h6 {
font-weight: bold;
/* margin: 1em 0; */
}
p {
/* margin: 0.5em 0; */
}
ul, ol {
margin: 1em 0;
padding-left: 1.5em;
}
pre {
background: #f4f4f4;
padding: 0.5em;
overflow-x: auto;
}
img {
max-width: 100%;
height: auto;
}
table {
width: 100%;
border-collapse: collapse;
margin: 1em 0;
}
th, td {
padding: 0.5em;
border: 1px solid #ddd;
}

View File

@@ -1,4 +1,4 @@
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
import platform
from typing import Dict

View File

@@ -1,4 +1,4 @@
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
# Minimal makefile for Sphinx documentation
# You can set these variables from the command line, and also
# from the environment for the first two.
@@ -8,16 +8,18 @@ SOURCEDIR = .
BUILDDIR = _build
AUTOSUMMARY="source/_autosummary"
NOTEBOOKS="source/notebooks/notebooks"
# Remove command is different depending on OS
ifdef OS
RM = IF exist $(AUTOSUMMARY) ( RMDIR $(AUTOSUMMARY) /s /q )
RM = IF exist $(AUTOSUMMARY) (RMDIR $(AUTOSUMMARY) /s /q) & IF exist $(NOTEBOOKS) (RMDIR $(NOTEBOOKS) /s /q)
else
ifeq ($(shell uname), Linux)
RM = rm -rf $(AUTOSUMMARY)
RM = rm -rf $(AUTOSUMMARY) $(NOTEBOOKS)
endif
endif
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

BIN
docs/_static/c2_sequence.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
..
Credit to https://github.com/JamesALeedham/Sphinx-Autosummary-Recursion for the custom templates.
@@ -12,7 +12,8 @@
.. autoclass:: {{ objname }}
:members:
:show-inheritance:
:inherited-members:
:inherited-members: BaseModel
:exclude-members: model_computed_fields, model_config, model_fields
:special-members: __init__, __call__, __add__, __mul__
{% block methods %}
@@ -22,7 +23,14 @@
.. autosummary::
:nosignatures:
{% for item in methods %}
{%- if not item.startswith('_') %}
{%- if not item.startswith('_') and item not in [
'construct', 'copy', 'dict', 'from_orm', 'json', 'model_construct',
'model_copy', 'model_dump', 'model_dump_json', 'model_json_schema',
'model_parametrized_name', 'model_post_init', 'model_rebuild', '',
'model_validate', 'model_validate_json', 'model_validate_strings',
'parse_file', 'parse_obj', 'parse_raw', 'schema', 'schema_json',
'update_forward_refs', 'validate',
] %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
@@ -35,7 +43,12 @@
.. autosummary::
{% for item in attributes %}
{%- if not item.startswith('_') and item not in [
'model_computed_fields', 'model_config', 'model_extra', 'model_fields',
'model_fields_set',
] %}
~{{ name }}.{{ item }}
{%- endif -%}
{%- endfor %}
{% endif %}
{% endblock %}

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
..
Credit to https://github.com/JamesALeedham/Sphinx-Autosummary-Recursion for the custom templates.

View File

@@ -2,7 +2,7 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
..
DO NOT DELETE THIS FILE! It contains the all-important `.. autosummary::` directive with `:recursive:` option, without

View File

@@ -1,4 +1,4 @@
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
#!/bin/bash
set -x
@@ -43,7 +43,7 @@ touch .nojekyll
# Add README
cat > README.md <<EOF
# README for the Sphinx Docs GitHub Pages Branch
This branch is simply a cache for the website served from https://{todo:fill in URL}.github.io/PrimAITE/,
This branch is simply a cache for the website served from https://Autonomous-Resilient-Cyber-Defence.github.io/PrimAITE/,
and is not intended to be viewed on github.com.
For more information on how this site is built using Sphinx, Read the Docs, GitHub Actions/Pages, and demo
implementation from https://github.com/annegentle, see:

View File

@@ -1,4 +1,4 @@
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
# © Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
Welcome to PrimAITE's documentation
====================================
@@ -8,101 +8,6 @@ Welcome to PrimAITE's documentation
What is PrimAITE?
-----------------
Overview
^^^^^^^^
The ARCD Primary-level AI Training Environment (**PrimAITE**) provides an effective simulation capability for training and evaluating AI in a cyber-defensive role. It incorporates the functionality required of a primary-level ARCD environment:
- The ability to model a relevant system context;
- Modelling an adversarial agent that the defensive agent can be trained and evaluated against;
- The ability to model key characteristics of a system by representing hosts, servers, network devices, IP addresses, ports, operating systems, folders / files, applications, services and links;
- Modelling background (green) pattern-of-life;
- Operates at machine-speed to enable fast training cycles via Reinforcement Learning (RL).
Features
^^^^^^^^
PrimAITE incorporates the following features:
- Architected with a separate Simulation layer and Game layer. This separation of concerns defines a clear path towards transfer learning with environments of differing fidelity;
- Ability to reconfigure an RL reward function based on (a) the ability to counter the modelled adversarial cyber-attack, and (b) the ability to ensure success for green agents;
- Access Control List (ACL) functions for network devices (routers and firewalls), following standard ACL rule format (e.g., DENY / ALLOW, source / destination IP addresses, protocol and port);
- Application of traffic to the links of the system laydown adheres to the ACL rulesets and routing tables contained within each network device;
- Provides RL environments adherent to the Farama Foundation Gymnasium (Previously OpenAI Gym) API, allowing integration with any compliant RL Agent frameworks;
- Provides RL environments adherent to Ray RLlib environment specifications for single-agent and multi-agent scenarios;
- Assessed for compatibility with Stable-Baselines3 (SB3), Ray RLlib, and bespoke agents;
- Persona-based adversarial (Red) agent behaviour; several out-the-box personas are provided, and more can be developed to suit the needs of the task. Stochastic variations in Red agent behaviour are also included as required;
- A robust system logging tool, automatically enabled at the node level and featuring various log levels and terminal output options, enables PrimAITE users to conduct in-depth network simulations;
- A PCAP service is seamlessly integrated within the simulation, automatically capturing and logging frames for both
inbound and outbound traffic at the network interface level. This automatic functionality, combined with the ability
to separate traffic directions, significantly enhances network analysis and troubleshooting capabilities;
- Agent action logs provide a description of every action taken by each agent during the episode. This includes timestep, action, parameters, request and response, for all Blue agent activity, which is aligned with the Track 2 Common Action / Observation Space (CAOS) format. Action logs also details of all scripted / stochastic red / green agent actions;
- Environment ground truth is provided at every timestep, providing a full description of the environments true state;
- Alignment with CAOS provides the ability to transfer agents between CAOS compliant environments.
Architecture
^^^^^^^^^^^^
PrimAITE is a Python application and will operate on multiple Operating Systems (Windows, Linux and Mac);
a comprehensive installation and user guide is provided with each release to support its usage.
Configuration of PrimAITE is achieved via included YAML files which support full control over the network / system laydown being modelled, background pattern of life, adversarial (red agent) behaviour, and step and episode count.
A Simulation Controller layer manages the overall running of the simulation, keeping track of all low-level objects.
It is agnostic to the number of agents, their action / observation spaces, and the RL library being used.
It presents a public API providing a method for describing the current state of the simulation, a method that accepts action requests and provides responses, and a method that triggers a timestep advancement.
The Game Layer converts the simulation into a playable game for the agent(s).
It translates between simulation state and Gymnasium.Spaces to pass action / observation data between the agent(s) and the simulation. It is responsible for calculating rewards, managing Multi-Agent RL (MARL) action turns, and via a single agent interface can interact with Blue, Red and Green agents.
Agents can either generate their own scripted behaviour or accept input behaviour from an RL agent.
Finally, a Gymnasium / Ray RLlib Environment Layer forwards requests to the Game Layer as the agent sends them. This layer also manages most of the I/O, such as reading in the configuration files and saving agent logs.
.. image:: ../../_static/primAITE_architecture.png
:width: 500
:align: center
Training & Evaluation Capability
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PrimAITE provides a training and evaluation capability to AI agents in the context of cyber-attack, via its Gymnasium / Ray RLlib compliant interface.
Scenarios can be constructed to reflect network / system laydowns consisting of any configuration of nodes (e.g., PCs, servers etc.) and the networking equipment and links between them.
All nodes can be configured to contain applications, services, folders and files (and their status).
Traffic flows between services and applications as directed by an execution definition, with the traffic flow on the network governed by the network equipment (switches, routers and firewalls) and the ACL rules and routing tables they employ.
Highlights of PrimAITEs training and evaluation capability are:
- The scenario is not bound to a representation of any platform, system, or technology;
- Fully configurable (network / system laydown, green pattern-of-life, red personas, reward function, ACL rules for each device, number of episodes / steps, action / observation space) and repeatable to suit the requirements of AI agents;
- Can integrate with any Gymnasium / Ray RLlib compliant AI agent .
PrimAITE provides a number of use cases (network and red/green action configurations) by default which the user is able to extend and modify as required.
What is PrimAITE built with
---------------------------
* `Gymnasium <https://gymnasium.farama.org/>`_ is used as the basis for AI blue agent interaction with the PrimAITE environment
* `Networkx <https://github.com/networkx/networkx>`_ is used as the underlying data structure used for the PrimAITE environment
* `Stable Baselines 3 <https://github.com/DLR-RM/stable-baselines3>`_ is used as a default source of RL algorithms (although PrimAITE is not limited to SB3 agents)
* `Ray RLlib <https://github.com/ray-project/ray>`_ is used as an additional source of RL algorithms
* `Typer <https://github.com/tiangolo/typer>`_ is used for building CLIs (Command Line Interface applications)
* `Jupyterlab <https://github.com/jupyterlab/jupyterlab>`_ is used as an extensible environment for interactive and reproducible computing, based on the Jupyter Notebook Architecture
* `Platformdirs <https://github.com/platformdirs/platformdirs>`_ is used for finding the right location to store user data and configuration but varies per platform
* `Plotly <https://github.com/plotly/plotly.py>`_ is used for building high level charts
Getting Started with PrimAITE
-----------------------------
Head over to the :ref:`getting-started` page to install and setup PrimAITE!
.. toctree::
:maxdepth: 8
:caption: About PrimAITE:
@@ -112,17 +17,36 @@ Head over to the :ref:`getting-started` page to install and setup PrimAITE!
source/dependencies
source/glossary
.. toctree::
:maxdepth: 8
:caption: How To
:hidden:
source/how_to
source/how_to_guides/custom_actions
source/how_to_guides/custom_environments
source/how_to_guides/custom_rewards
source/how_to_guides/custom_software
source/how_to_guides/using_dev_cli
source/how_to_guides/extensible_actions
source/how_to_guides/extensible_agents
source/how_to_guides/extensible_nodes
source/how_to_guides/extensible_rewards
source/how_to_guides/primaite_yaml_migration_guide
.. toctree::
:caption: Usage:
:hidden:
source/getting_started
source/simulation
source/game_layer
source/simulation
source/config
source/environment
source/customising_scenarios
source/rewards
source/varying_config_files
source/environment
source/action_masking
source/node_sets
.. toctree::
:caption: Notebooks:
@@ -140,3 +64,38 @@ Head over to the :ref:`getting-started` page to install and setup PrimAITE!
source/request_system
PrimAITE API <source/_autosummary/primaite>
PrimAITE Tests <source/_autosummary/tests>
Overview
^^^^^^^^
The ARCD Primary-level AI Training Environment (**PrimAITE**) provides an effective simulation capability for training and evaluating AI in a cyber-defensive role. It incorporates the functionality required of a primary-level ARCD environment:
- The ability to model a relevant system context;
- Modelling an adversarial agent that the defensive agent can be trained and evaluated against;
- The ability to model key characteristics of a system by representing hosts, servers, network devices, IP addresses, ports, operating systems, folders / files, applications, services and links;
- Modelling background (green) pattern-of-life;
- Operates at machine-speed to enable fast training cycles via Reinforcement Learning (RL).
PrimAITE has been designed as an extensible environment and toolkit to support the development, test, training and evaluation of AI-based cyber defensive agents. Whilst PrimAITE ships with a number of example modelled scenarios (a.k.a. Use Cases), it has not been developed to mandate the solving of a single cyber challenge, and instead provides a highly flexible environment application that can be extended and reconfigured by the user to suit their specific cyber defence training and evaluation needs. PrimAITE provides default networks, red agent and green agent behaviour, reward functions, and action / observation space configuration, all of which can be utilised out of the box, but which ultimately can (and in some instances should) be built upon and / or reconfigured to meet the needs of different defensive agent developers. The PrimAITE user guide provides comprehensive instruction on all PrimAITE features, functionality and components, and can be consulted in order to help guide users in any reconfiguration or enhancements they wish to undertake; a library of example Jupyter notebooks are also provided to support such work.
Features
^^^^^^^^
PrimAITE incorporates the following features:
- Architected with a separate Simulation layer and Game layer. This separation of concerns defines a clear path towards transfer learning with environments of differing fidelity;
- Ability to reconfigure an RL reward function based on (a) the ability to counter the modelled adversarial cyber-attack, and (b) the ability to ensure success for green agents;
- Access Control List (ACL) functions for network devices (routers and firewalls), following standard ACL rule format (e.g., DENY / PERMIT, source / destination IP addresses, protocol and port);
- Application of traffic to the links of the system laydown adheres to the ACL rulesets and routing tables contained within each network device;
- Provides RL environments adherent to the Farama Foundation Gymnasium (Previously OpenAI Gym) API, allowing integration with any compliant RL Agent frameworks;
- Provides RL environments adherent to Ray RLlib environment specifications for single-agent and multi-agent scenarios;
- Assessed for compatibility with Stable-Baselines3 (SB3), Ray RLlib, and bespoke agents;
- Persona-based adversarial (Red) agent behaviour; several out-the-box personas are provided, and more can be developed to suit the needs of the task. Stochastic variations in Red agent behaviour are also included as required;
- A robust system logging tool, automatically enabled at the node level and featuring various log levels and terminal output options, enables PrimAITE users to conduct in-depth network simulations;
- A PCAP service is seamlessly integrated within the simulation, automatically capturing and logging frames for both
inbound and outbound traffic at the network interface level. This automatic functionality, combined with the ability
to separate traffic directions, significantly enhances network analysis and troubleshooting capabilities;
- Agent action logs provide a description of every action taken by each agent during the episode. This includes timestep, action, parameters, request and response, for all Blue agent activity, which is aligned with the Track 2 Common Action / Observation Space (CAOS) format. Action logs also detail all scripted / stochastic red / green agent actions;
- Environment ground truth is provided at every timestep, providing a full description of the environments true state;
- Alignment with CAOS provides the ability to transfer agents between CAOS compliant environments.

View File

@@ -7,311 +7,66 @@
About PrimAITE
==============
PrimAITE is a simulation environment for training agents to protect a computer network from cyber attacks.
Architecture
^^^^^^^^^^^^
Features
********
PrimAITE is a Python application and will operate on multiple Operating Systems (Windows, Linux and Mac);
a comprehensive installation and user guide is provided with each release to support its usage.
PrimAITE provides the following features:
Configuration of PrimAITE is achieved via included YAML files which support full control over the network / system laydown being modelled, background pattern of life, adversarial (red agent) behaviour, and step and episode count.
A Simulation Controller layer manages the overall running of the simulation, keeping track of all low-level objects.
* A flexible system for defining network layouts and host configurations
* Highly configurable network hosts, including definition of software, file system, and network interfaces,
* Realistic network traffic simulation, including address and sending packets via internet protocols like TCP, UDP, ICMP, etc.
* Routers with traffic routing and firewall capabilities
* Simulation of customisable deterministic agents
* Support for multiple agents, each having their own customisable observation space, action space, and reward function definition.
It is agnostic to the number of agents, their action / observation spaces, and the RL library being used.
It presents a public API providing a method for describing the current state of the simulation, a method that accepts action requests and provides responses, and a method that triggers a timestep advancement.
The Game Layer converts the simulation into a playable game for the agent(s).
It translates between simulation state and Gymnasium.Spaces to pass action / observation data between the agent(s) and the simulation. It is responsible for calculating rewards, managing Multi-Agent RL (MARL) action turns, and via a single agent interface can interact with Blue, Red and Green agents.
Agents can either generate their own scripted behaviour or accept input behaviour from an RL agent.
Finally, a Gymnasium / Ray RLlib Environment Layer forwards requests to the Game Layer as the agent sends them. This layer also manages most of the I/O, such as reading in the configuration files and saving agent logs.
.. image:: ../../_static/primAITE_architecture.png
:width: 500
:align: center
Structure
*********
Training & Evaluation Capability
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PrimAITE consists of a simulator and a 'game' layer that allows agents to interact with the simulator. The simulator is built in a modular way where each component such as network hosts, links, networking devices, softwares, etc. are implemented as instances of a base class, meaning they all support the same interface. This allows for standardised configuration using either the Python API or YAML files.
The game layer is built on top of the simulator and it consumes the simulation action/state interface to allow agents to interact with the simulator. The game layer is also responsible for defining the reward function and observation space for the agents.
PrimAITE provides a training and evaluation capability to AI agents in the context of cyber-attack, via its Gymnasium / Ray RLlib compliant interface.
Scenarios can be constructed to reflect network / system laydowns consisting of any configuration of nodes (e.g., PCs, servers etc.) and the networking equipment and links between them.
All nodes can be configured to contain applications, services, folders, and files (and their status), including a powerful terminal simulation for SSH tunnelling and remote command execution.
Realistic network traffic generated by software or by users. Packets move through the network devices (switches, routers, firewalls, network interfaces) in accordance to control rules such as: internet protocols, Access control lists (ACLs), and routing tables.
Highlights of PrimAITE's training and evaluation capability are:
- Fully configurable (network / system laydown, green pattern-of-life, red personas, reward function, ACL rules for each device, number of episodes / steps, action / observation space) and repeatable to suit the requirements of AI agents;
- Domain randomisation through stochastic agent behaviour and the ability to switch between scenario variants between environment episodes.
- Extensible through plugins to model any network behaviour.
- Can integrate with any Gymnasium / Ray RLlib compliant AI agent.
..
Architecture - Nodes and Links
******************************
**Nodes**
An inheritance model has been adopted in order to model nodes. All nodes have the following base attributes (Class: Node):
* ID
* Name
* Type (e.g. computer, switch, RTU - enumeration)
* Priority (P1, P2, P3, P4 or P5 - enumeration)
* Hardware State (ON, OFF, RESETTING, SHUTTING_DOWN, BOOTING - enumeration)
Active Nodes also have the following attributes (Class: Active Node):
* IP Address
* Software State (GOOD, FIXING, COMPROMISED - enumeration)
* File System State (GOOD, CORRUPT, DESTROYED, REPAIRING, RESTORING - enumeration)
Service Nodes also have the following attributes (Class: Service Node):
* List of Services (where service is composed of service name and port). There is no theoretical limit on the number of services that can be modelled. Services and protocols are currently intrinsically linked (i.e. a service is an application on a node transmitting traffic of this protocol type)
* Service state (GOOD, FIXING, COMPROMISED, OVERWHELMED - enumeration)
Passive Nodes are currently not used (but may be employed for non IP-based components such as machinery actuators in future releases).
**Links**
Links are modelled both as network edges (networkx) and as Python classes, in order to extend their functionality. Links include the following attributes:
* ID
* Name
* Bandwidth (bits/s)
* Source node ID
* Destination node ID
* Protocol list (containing the loading of protocols currently running on the link)
When the simulation runs, IERs are applied to the links in order to model traffic loading, individually assigned to each protocol. This allows green (background) and red agent behaviour to be modelled, and defensive agents to identify suspicious traffic patterns at a protocol / traffic loading level of fidelity.
Information Exchange Requirements (IERs)
****************************************
PrimAITE adopts the concept of Information Exchange Requirements (IERs) to model both green agent (background) and red agent (adversary) behaviour. IERs are used to initiate modelling of traffic loading on the network, and have the following attributes:
* ID
* Start step (i.e. which step in the training episode should the IER start)
* End step (i.e. which step in the training episode should the IER end)
* Source node ID
* Destination node ID
* Load (bits/s)
* Protocol
* Port
* Running status (i.e. on / off)
The application of green agent IERs between a source and destination follows a number of rules. Specifically:
1. Does the current simulation time step fall between IER start and end step
2. Is the source node operational (both physically and at an O/S level), and is the service (protocol / port) associated with the IER (a) present on this node, and (b) in an operational state (i.e. not FIXING)
3. Is the destination node operational (both physically and at an O/S level), and is the service (protocol / port) associated with the IER (a) present on this node, and (b) in an operational state (i.e. not FIXING)
4. Are there any Access Control List rules in place that prevent the application of this IER
5. Are all switches in the (OSPF) path between source and destination operational (both physically and at an O/S level)
For red agent IERs, the application of IERs between a source and destination follows a number of subtly different rules. Specifically:
1. Does the current simulation time step fall between IER start and end step
2. Is the source node operational, and is the service (protocol / port) associated with the IER (a) present on that node and (b) already in a compromised state
3. Is the destination node operational, and is the service (protocol / port) associated with the IER present on that node
4. Are there any Access Control List rules in place that prevent the application of this IER
5. Are all switches in the (OSPF) path between source and destination operational (both physically and at an O/S level)
Assuming the rules pass, the IER is applied to all relevant links (based on use of OSPF) between source and destination.
Node Pattern-of-Life
********************
Every node can be impacted (i.e. have a status change applied to it) by either green agent pattern-of-life or red agent pattern-of-life. This is distinct from IERs, and allows for attacks (and defence) to be modelled purely within the confines of a node.
The status changes that can be made to a node are as follows:
* All Nodes:
* Hardware State:
* ON
* OFF
* RESETTING - when a status of resetting is entered, the node will automatically exit this state after a number of steps (as defined by the nodeResetDuration configuration item) after which it returns to an ON state
* BOOTING
* SHUTTING_DOWN
* Active Nodes and Service Nodes:
* Software State:
* GOOD
* FIXING - when a status of FIXING is entered, the node will automatically exit this state after a number of steps (as defined by the osFIXINGDuration configuration item) after which it returns to a GOOD state
* COMPROMISED
* File System State:
* GOOD
* CORRUPT (can be resolved by repair or restore)
* DESTROYED (can be resolved by restore only)
* REPAIRING - when a status of repairing is entered, the node will automatically exit this state after a number of steps (as defined by the fileSystemRepairingLimit configuration item) after which it returns to a GOOD state
* RESTORING - when a status of repairing is entered, the node will automatically exit this state after a number of steps (as defined by the fileSystemRestoringLimit configuration item) after which it returns to a GOOD state
* Service Nodes only:
* Service State (for any associated service):
* GOOD
* FIXING - when a status of FIXING is entered, the service will automatically exit this state after a number of steps (as defined by the serviceFIXINGDuration configuration item) after which it returns to a GOOD state
* COMPROMISED
* OVERWHELMED
Red agent pattern-of-life has an additional feature not found in the green pattern-of-life. This is the ability to influence the state of the attributes of a node via a number of different conditions:
* DIRECT:
The pattern-of-life described by the configuration file item will be applied regardless of any other conditions in the network. This is particularly useful for direct red agent entry into the network.
* IER:
The pattern-of-life described by the configuration file item will be applied to the service on the node, only if there is an IER of the same protocol / service type incoming at the specified timestep.
* SERVICE:
The pattern-of-life described by the configuration file item will be applied to the node based on the state of a service. The service can either be on the same node, or a different node within the network.
Access Control List modelling
*****************************
An Access Control List (ACL) is modelled to provide the means to manage traffic flows in the system. This will allow defensive agents the means to turn on / off rules, or potentially create new rules, to counter an attack.
The ACL follows a standard network firewall format. For example:
.. list-table:: ACL example
:widths: 25 25 25 25 25
:header-rows: 1
* - Permission
- Source IP
- Dest IP
- Protocol
- Port
* - DENY
- 192.168.1.2
- 192.168.1.3
- HTTPS
- 443
* - ALLOW
- 192.168.1.4
- ANY
- SMTP
- 25
* - DENY
- ANY
- 192.168.1.5
- ANY
- ANY
All ACL rules are considered when applying an IER. Logic follows the order of rules, so a DENY or ALLOW for the same parameters will override an earlier entry.
Observation Spaces
******************
The observation space provides the blue agent with information about the current status of nodes and links.
PrimAITE builds on top of Gymnasium Spaces to create an observation space that is easily configurable for users. It's made up of components which are managed by the :py:class:`primaite.environment.observations.ObservationsHandler`. Each training scenario can define its own observation space, and the user can choose which information to inlude, and how it should be formatted.
NodeLinkTable component
-----------------------
For example, the :py:class:`primaite.environment.observations.NodeLinkTable` component represents the status of nodes and links as a ``gym.spaces.Box`` with an example format shown below:
An example observation space is provided below:
.. list-table:: Observation Space example
:widths: 25 25 25 25 25 25 25
:header-rows: 1
* -
- ID
- Hardware State
- Software State
- File System State
- Service / Protocol A
- Service / Protocol B
* - Node A
- 1
- 1
- 1
- 1
- 1
- 1
* - Node B
- 2
- 1
- 3
- 1
- 1
- 1
* - Node C
- 3
- 2
- 1
- 1
- 3
- 2
* - Link 1
- 5
- 0
- 0
- 0
- 0
- 10000
* - Link 2
- 6
- 0
- 0
- 0
- 0
- 10000
* - Link 3
- 7
- 0
- 0
- 0
- 5000
- 0
For the nodes, the following values are represented:
.. code-block::
[
ID
Hardware State (1=ON, 2=OFF, 3=RESETTING, 4=SHUTTING_DOWN, 5=BOOTING)
Operating System State (0=none, 1=GOOD, 2=PATCHING, 3=COMPROMISED)
File System State (0=none, 1=GOOD, 2=CORRUPT, 3=DESTROYED, 4=REPAIRING, 5=RESTORING)
Service1/Protocol1 state (0=none, 1=GOOD, 2=FIXING, 3=COMPROMISED)
Service2/Protocol2 state (0=none, 1=GOOD, 2=FIXING, 3=COMPROMISED)
]
(Note that each service available in the network is provided as a column, although not all nodes may utilise all services)
For the links, the following statuses are represented:
.. code-block::
[
ID
Hardware State (0=not applicable)
Operating System State (0=not applicable)
File System State (0=not applicable)
Service1/Protocol1 state (Traffic load from this protocol on this link)
Service2/Protocol2 state (Traffic load from this protocol on this link)
]
NodeStatus component
----------------------
This is a MultiDiscrete observation space that can be though of as a one-dimensional vector of discrete states.
The example above would have the following structure:
.. code-block::
[
node1_info
node2_info
node3_info
]
Each ``node_info`` contains the following:
.. code-block::
[
hardware_state (0=none, 1=ON, 2=OFF, 3=RESETTING, 4=SHUTTING_DOWN, 5=BOOTING)
software_state (0=none, 1=GOOD, 2=PATCHING, 3=COMPROMISED)
file_system_state (0=none, 1=GOOD, 2=CORRUPT, 3=DESTROYED, 4=REPAIRING, 5=RESTORING)
service1_state (0=none, 1=GOOD, 2=FIXING, 3=COMPROMISED)
service2_state (0=none, 1=GOOD, 2=FIXING, 3=COMPROMISED)
]
In a network with three nodes and two services, the full observation space would have 15 elements. It can be written with ``gym`` notation to indicate the number of discrete options for each of the elements of the observation space. For example:
.. code-block::
gym.spaces.MultiDiscrete([4,5,6,4,4,4,5,6,4,4,4,5,6,4,4])
.. note::
NodeStatus observation component provides information only about nodes. Links are not considered.
LinkTrafficLevels
-----------------
This component is a MultiDiscrete space showing the traffic flow levels on the links in the network, after applying a threshold to convert it from a continuous to a discrete value.
There are two configurable parameters:
* ``quantisation_levels`` determines how many discrete bins to use for converting the continuous traffic value to discrete (default is 5).
* ``combine_service_traffic`` determines whether to separately output traffic use for each network protocol or whether to combine them into an overall value for the link. (default is ``True``)
For example, with default parameters and a network with three links, the structure of this component would be:
.. code-block::
[
link1_status
link2_status
link3_status
]
Each ``link_status`` is a number from 0-4 representing the network load in relation to bandwidth.
.. code-block::
0 = No traffic (0%)
1 = low traffic (1%-33%)
2 = medium traffic (33%-66%)
3 = high traffic (66%-99%)
4 = max traffic/ overwhelmed (100%)
Using ``gym`` notation, the shape of the obs space is: ``gym.spaces.MultiDiscrete([5,5,5])``.
Action Spaces
**************
The action space available to the blue agent comes in two types:
1. Node-based
2. Access Control List
3. Any (Agent can take both node-based and ACL-based actions)
The choice of action space used during a training session is determined in the config_[name].yaml file.
**Node-Based**
The agent is able to influence the status of nodes by switching them off, resetting, or FIXING operating systems and services. In this instance, the action space is a Gymnasium spaces.Discrete type, as follows:
* Dictionary item {... ,1: [x1, x2, x3,x4] ...}
The placeholders inside the list under the key '1' mean the following:
* [0, num nodes] - Node ID (0 = nothing, node ID)
* [0, 4] - What property it's acting on (0 = nothing, 1 = state, 2 = SoftwareState, 3 = service state, 4 = file system state)
* [0, 3] - Action on property (0 = nothing, 1 = on / scan, 2 = off / repair, 3 = reset / patch / restore)
* [0, num services] - Resolves to service ID (0 = nothing, resolves to service)
**Access Control List**
The blue agent is able to influence the configuration of the Access Control List rule set (which implements a system-wide firewall). In this instance, the action space is an Gymnasium spaces.Discrete type, as follows:
* Dictionary item {... ,1: [x1, x2, x3, x4, x5, x6] ...}
The placeholders inside the list under the key '1' mean the following:
* [0, 2] - Action (0 = do nothing, 1 = create rule, 2 = delete rule)
* [0, 1] - Permission (0 = DENY, 1 = ALLOW)
* [0, num nodes] - Source IP (0 = any, then 1 -> x resolving to IP addresses)
* [0, num nodes] - Dest IP (0 = any, then 1 -> x resolving to IP addresses)
* [0, num services] - Protocol (0 = any, then 1 -> x resolving to protocol)
* [0, num ports] - Port (0 = any, then 1 -> x resolving to port)
**ANY**
The agent is able to carry out both **Node-Based** and **Access Control List** operations.
This means the dictionary will contain key-value pairs in the format of BOTH Node-Based and Access Control List as seen above.
Rewards
*******
A reward value is presented back to the blue agent on the conclusion of every step. The reward value is calculated via two methods which combine to give the total value:
1. Node and service status
2. IER status
**Node and service status**
On every step, the status of each node is compared against both a reference environment (simulating the situation if the red and blue agents had not impacted the environment)
and the before and after state of the environment. If the comparison against the reference environment shows no difference, then the score provided is "AllOK". If there is a
difference with respect to the reference environment, the before and after states are compared, and a score determined. See :ref:`config` for details of reward values.
**IER status**
On every step, the full IER set is examined to determine whether green and red agent IERs are being permitted to run. Any red agent IERs running incur a penalty; any green agent
IERs not permitted to run also incur a penalty. See :ref:`config` for details of reward values.
Future Enhancements
*******************
The PrimAITE project has an ambition to include the following enhancements in future releases:
* Integration with a suitable standardised framework to allow multi-agent integration
* Integration with external threat emulation tools, either using off-line data, or integrating at runtime
PrimAITE provides a number of use cases (network and red/green action configurations) by default which the user is able to extend and modify as required.
What is PrimAITE built with
---------------------------
* `Gymnasium <https://gymnasium.farama.org/>`_ is used as the basis for AI blue agent interaction with the PrimAITE environment
* `Pydantic <https://docs.pydantic.dev/latest/>`_ is used for data validation
* `Platformdirs <https://github.com/platformdirs/platformdirs>`_ is used for storing user data and configuration correctly between platforms
* `Typer <https://github.com/tiangolo/typer>`_ is used for the Command Line Interface
* `Jupyterlab <https://github.com/jupyterlab/jupyterlab>`_ is used as an extensible environment for interactive and reproducible computing, based on the Jupyter Notebook Architecture
* `Plotly <https://github.com/plotly/plotly.py>`_ is used for building high level charts
* `Stable Baselines 3 <https://github.com/DLR-RM/stable-baselines3>`_ is used for ensuring compatibility with RL libraries
* `Ray RLlib <https://github.com/ray-project/ray>`_ is also used for ensuring compatibility with RL libraries
Getting Started with PrimAITE
-----------------------------
Head over to the :ref:`getting-started` page to install and setup PrimAITE!

View File

@@ -0,0 +1,148 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _action_masking:
Action Masking
**************
The PrimAITE simulation is able to provide action masks in the environment output. These action masks let the agents know
about which actions are invalid based on the current environment state. For instance, it's not possible to install
software on a node that is turned off. Therefore, if an agent has a ``node-software-install`` in it's action map for that node,
the action mask will show `0` in the corresponding entry.
*Note: just because an action is available in the action mask does not mean it will be successful when executed. It just means it's possible to try to execute the action at this time.*
Configuration
=============
Action masking is supported for agents that use the `ProxyAgent` class (the class used for connecting to RL algorithms).
In order to use action masking, set the agent_settings.action_masking parameter to True in the config file.
Masking Logic
=============
The following logic is applied:
+------------------------------------------+------------------------------------------------+
| Action | Action Mask Logic |
+==========================================+================================================+
| **do-nothing** | Always Possible. |
+------------------------------------------+------------------------------------------------+
| **node-service-scan** | Node is on. Service is running. |
+------------------------------------------+------------------------------------------------+
| **node-service-stop** | Node is on. Service is running. |
+------------------------------------------+------------------------------------------------+
| **node-service-start** | Node is on. Service is stopped. |
+------------------------------------------+------------------------------------------------+
| **node-service-pause** | Node is on. Service is running. |
+------------------------------------------+------------------------------------------------+
| **node-service-resume** | Node is on. Service is paused. |
+------------------------------------------+------------------------------------------------+
| **node-service-restart** | Node is on. Service is running. |
+------------------------------------------+------------------------------------------------+
| **node-service-disable** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-service-enable** | Node is on. Service is disabled. |
+------------------------------------------+------------------------------------------------+
| **node-service-fix** | Node is on. Service is running. |
+------------------------------------------+------------------------------------------------+
| **node-application-execute** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-application-scan** | Node is on. Application is running. |
+------------------------------------------+------------------------------------------------+
| **node-application-close** | Node is on. Application is running. |
+------------------------------------------+------------------------------------------------+
| **node-application-fix** | Node is on. Application is running. |
+------------------------------------------+------------------------------------------------+
| **node-application-install** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-application-remove** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-file-scan** | Node is on. File exists. File not deleted. |
+------------------------------------------+------------------------------------------------+
| **node-file-create** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-file-checkhash** | Node is on. File exists. File not deleted. |
+------------------------------------------+------------------------------------------------+
| **node-file-delete** | Node is on. File exists. |
+------------------------------------------+------------------------------------------------+
| **node-file-repair** | Node is on. File exists. File not deleted. |
+------------------------------------------+------------------------------------------------+
| **node-file-restore** | Node is on. File exists. File is deleted. |
+------------------------------------------+------------------------------------------------+
| **node-file-corrupt** | Node is on. File exists. File not deleted. |
+------------------------------------------+------------------------------------------------+
| **node-file-access** | Node is on. File exists. File not deleted. |
+------------------------------------------+------------------------------------------------+
| **node-folder-create** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-folder-scan** | Node is on. Folder exists. Folder not deleted. |
+------------------------------------------+------------------------------------------------+
| **node-folder-checkhash** | Node is on. Folder exists. Folder not deleted. |
+------------------------------------------+------------------------------------------------+
| **node-folder-repair** | Node is on. Folder exists. Folder not deleted. |
+------------------------------------------+------------------------------------------------+
| **node-folder-restore** | Node is on. Folder exists. Folder is deleted. |
+------------------------------------------+------------------------------------------------+
| **node-os-scan** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **host-nic-enable** | NIC is disabled. Node is on. |
+------------------------------------------+------------------------------------------------+
| **host-nic-disable** | NIC is enabled. Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-shutdown** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-startup** | Node is off. |
+------------------------------------------+------------------------------------------------+
| **node-reset** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-nmap-ping-scan** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-nmap-port-scan** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-network-service-recon** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **network-port-enable** | Node is on. Router is on. |
+------------------------------------------+------------------------------------------------+
| **network-port-disable** | Router is on. |
+------------------------------------------+------------------------------------------------+
| **router-acl-add-rule** | Router is on. |
+------------------------------------------+------------------------------------------------+
| **router-acl-remove-rule** | Router is on. |
+------------------------------------------+------------------------------------------------+
| **firewall-acl-add-rule** | Firewall is on. |
+------------------------------------------+------------------------------------------------+
| **firewall-acl-remove-rule** | Firewall is on. |
+------------------------------------------+------------------------------------------------+
| **configure-database-client** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **configure-ransomware-script** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **c2-server-ransomware-configure** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **configure-dos-bot** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **configure-c2-beacon** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **c2-server-ransomware-launch** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **c2-server-terminal-command** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **c2-server-data-exfiltrate** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-account-change-password** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-session-remote-login** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-session-remote-logoff** | Node is on. |
+------------------------------------------+------------------------------------------------+
| **node-send-remote-command** | Node is on. |
+------------------------------------------+------------------------------------------------+
Mechanism
=========
The environment iterates over the RL agent's ``action_map`` and generates the corresponding simulator :ref:`request <request_system>` string. It uses the :py:meth:`RequestManager.check_valid()<primaite.simulator.core.RequestManager.check_valid>` method to invoke the relevant :py:class:`RequestPermissionValidator <primaite.simulator.core.RequestPermissionValidator>` without actually running the request on the simulation.
Current Limitations
===================
Currently, action masking only considers whether the action as a whole is possible, it doesn't verify that the exact parameter combination passed to the action make sense in the current context. or instance, if ACL rule 3 on router_1 is already populated, the action for adding another rule at position 3 will be available regardless, as long as that router is turned on. This will never block valid actions. It will just occasionally allow invalid actions.

View File

@@ -1,6 +1,8 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _Configurable_Items:
PrimAITE |VERSION| Configuration
********************************

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
``agents``
@@ -13,39 +13,19 @@ Agents can be scripted (deterministic and stochastic), or controlled by a reinfo
.. code-block:: yaml
agents:
- ref: red_agent_example
...
- ref: blue_agent_example
...
- ref: green_agent_example
team: GREEN
type: ProbabilisticAgent
observation_space:
type: UC2GreenObservation
action_space:
action_list:
- type: DONOTHING
- type: NODE_APPLICATION_EXECUTE
options:
nodes:
- node_name: client_2
applications:
- application_name: WebBrowser
max_folders_per_node: 1
max_files_per_folder: 1
max_services_per_node: 1
max_applications_per_node: 1
- ref: red_agent_example
...
- ref: blue_agent_example
...
- ref: green_agent_example
team: GREEN
type: probabilistic-agent
reward_function:
reward_components:
- type: DUMMY
agent_settings:
start_settings:
start_step: 5
frequency: 4
variance: 3
flatten_obs: False
agent_settings:
start_step: 5
frequency: 4
variance: 3
flatten_obs: False
``ref``
-------
@@ -57,13 +37,13 @@ Specifies if the agent is malicious (``RED``), benign (``GREEN``), or defensive
``type``
--------
Specifies which class should be used for the agent. ``ProxyAgent`` is used for agents that receive instructions from an RL algorithm. Scripted agents like ``RedDatabaseCorruptingAgent`` and ``ProbabilisticAgent`` generate their own behaviour.
Specifies which class should be used for the agent. ``proxy-agent`` is used for agents that receive instructions from an RL algorithm. Scripted agents like ``red-database-corrupting-agent`` and ``probabilistic-agent`` generate their own behaviour.
Available agent types:
- ``ProbabilisticAgent``
- ``ProxyAgent``
- ``RedDatabaseCorruptingAgent``
- ``probabilistic-agent``
- ``proxy-agent``
- ``red-database-corrupting-agent``
``observation_space``
---------------------
@@ -79,10 +59,10 @@ selects which python class from the :py:mod:`primaite.game.agent.observation` mo
Allows configuration of the chosen observation type. These are optional.
* ``num_services_per_node``, ``num_folders_per_node``, ``num_files_per_folder``, ``num_nics_per_node`` all define the shape of the observation space. The size and shape of the obs space must remain constant, but the number of files, folders, ACL rules, and other components can change within an episode. Therefore padding is performed and these options set the size of the obs space.
* ``num_services_per_node``, ``num_folders_per_node``, ``num_files_per_folder``, ``num_nics_per_node`` all define the shape of the observation space. The size and shape of the obs space must remain constant, but the number of files, folders, acl rules, and other components can change within an episode. Therefore padding is performed and these options set the size of the obs space.
* ``nodes``: list of nodes that will be present in this agent's observation space. The ``node_ref`` relates to the human-readable unique reference defined later in the ``simulation`` part of the config. Each node can also be configured with services, and files that should be monitored.
* ``links``: list of links that will be present in this agent's observation space. The ``link_ref`` relates to the human-readable unique reference defined later in the ``simulation`` part of the config.
* ``acl``: configure how the agent reads the access control list on the router in the simulation. ``router_node_ref`` is for selecting which router's ACL table should be used. ``ip_list`` sets the encoding of ip addresses as integers within the observation space.
* ``acl``: configure how the agent reads the access control list on the router in the simulation. ``router_node_ref`` is for selecting which router's acl table should be used. ``ip_list`` sets the encoding of ip addresses as integers within the observation space.
For more information see :py:mod:`primaite.game.agent.observations`
@@ -91,10 +71,6 @@ For more information see :py:mod:`primaite.game.agent.observations`
The action space is configured to be made up of individual action types. Once configured, the agent can select an action type and some optional action parameters at every step. For example: The ``NODE_SERVICE_SCAN`` action takes the parameters ``node_id`` and ``service_id``.
``action_list``
^^^^^^^^^^^^^^^
A list of action modules. The options are listed in the :py:mod:`primaite.game.agent.actions.ActionManager.act_class_identifiers` module.
``action_map``
^^^^^^^^^^^^^^
@@ -120,16 +96,21 @@ Similar to action space, this is defined as a list of components from the :py:mo
``reward_components``
^^^^^^^^^^^^^^^^^^^^^
A list of reward types from :py:mod:`primaite.game.agent.rewards.RewardFunction.rew_class_identifiers`
A list of available reward types from :py:mod:`primaite.game.agent.rewards.RewardFunction.rew_class_identifiers`
e.g.
.. code-block:: yaml
reward_components:
- type: DUMMY
- type: DATABASE_FILE_INTEGRITY
- type: dummy
weight: 1.0
- type: database-file-integrity
weight: 0.40
options:
node_hostname: database_server
folder_name: database
file_name: database.db
``agent_settings``
@@ -142,10 +123,9 @@ e.g.
.. code-block:: yaml
agent_settings:
start_settings:
start_step: 25
frequency: 20
variance: 5
start_step: 25
frequency: 20
variance: 5
``start_step``
^^^^^^^^^^^^^^
@@ -172,3 +152,9 @@ The amount of timesteps that the frequency can randomly change.
---------------
If ``True``, gymnasium flattening will be performed on the observation space before sending to the agent. Set this to ``True`` if your agent does not support nested observation spaces.
``Agent History``
-----------------
Agents will record their action log for each step. This is a summary of what the agent did, along with response information from requests within the simulation.
A summary of the actions taken by the agent can be viewed using the `show_history()` function. By default, this will display all actions taken apart from ``do-nothing``.

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
``game``
@@ -28,6 +28,7 @@ This section defines high-level settings that apply across the game, currently i
high: 10
medium: 5
low: 0
seed: 1
``max_episode_length``
----------------------
@@ -41,16 +42,21 @@ The maximum number of episodes a Reinforcement Learning agent(s) can be trained
A list of ports that the Reinforcement Learning agent(s) are able to see in the observation space.
See :ref:`List of Ports <List of Ports>` for a list of ports.
See :py:const:`primaite.utils.validation.port.PORT_LOOKUP` for a list of ports.
``protocols``
-------------
A list of protocols that the Reinforcement Learning agent(s) are able to see in the observation space.
See :ref:`List of IPProtocols <List of IPProtocols>` for a list of protocols.
See :py:const:`primaite.utils.validation.ip_protocol.PROTOCOL_LOOKUP` for a list of protocols.
``thresholds``
--------------
These are used to determine the thresholds of high, medium and low categories for counted observation occurrences.
``seed``
--------
Used to configure the random seeds used within PrimAITE, ensuring determinism within episode/session runs. If empty or set to -1, no seed is set. The given seed value is logged (by default) in ``primaite/<VERSION>/sessions/<DATE>/<TIME>/simulation_output``.

View File

@@ -1,7 +1,8 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _io_settings:
``io_settings``
===============
@@ -13,20 +14,17 @@ This section configures how PrimAITE saves data during simulation and training.
.. code-block:: yaml
io_settings:
# save_logs: True
save_agent_actions: True
save_step_metadata: False
save_pcap_logs: False
save_sys_logs: False
save_agent_logs: False
write_sys_log_to_terminal: False
write_agent_log_to_terminal: False
sys_log_level: WARNING
agent_log_level: INFO
``save_logs``
-------------
*currently unused*.
``save_agent_actions``
----------------------
@@ -57,6 +55,12 @@ Optional. Default value is ``False``.
If ``True``, then the log files which contain all node actions during the simulation will be saved.
``save_agent_logs``
-----------------
Optional. Default value is ``False``.
If ``True``, then the log files which contain all human readable agent behaviour during the simulation will be saved.
``write_sys_log_to_terminal``
-----------------------------
@@ -65,16 +69,25 @@ Optional. Default value is ``False``.
If ``True``, PrimAITE will print sys log to the terminal.
``write_agent_log_to_terminal``
-----------------------------
``sys_log_level``
-------------
Optional. Default value is ``False``.
If ``True``, PrimAITE will print all human readable agent behaviour logs to the terminal.
``sys_log_level & agent_log_level``
---------------------------------
Optional. Default value is ``WARNING``.
The level of logging that should be visible in the sys logs or the logs output to the terminal.
The level of logging that should be visible in the syslog, agent logs or the logs output to the terminal.
``save_sys_logs`` or ``write_sys_log_to_terminal`` has to be set to ``True`` for this setting to be used.
This is also true for agent behaviour logging.
Available options are:
- ``DEBUG``: Debug level items and the items below

View File

@@ -1,13 +1,12 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
``simulation``
==============
In this section the network layout is defined. This part of the config follows a hierarchical structure. Almost every component defines a ``ref`` field which acts as a human-readable unique identifier, used by other parts of the config, such as agents.
At the top level of the network are ``nodes`` and ``links``.
In this section the network layout is defined. This part of the config follows a hierarchical structure.
At the top level of the network are ``nodes``, ``links`` and ``airspace``.
e.g.
@@ -19,11 +18,14 @@ e.g.
...
links:
...
airspace:
...
``nodes``
---------
This is where the list of nodes are defined. Some items will differ according to the node type, however, there will be common items such as a node's reference (which is used by the agent), the node's ``type`` and ``hostname``
This is where the list of nodes are defined. Some items will differ according to the node type, however, there will be common items such as a node's hostname (which is used by the agent) and the node's ``type``.
To see the configuration for these nodes, refer to the following:
@@ -71,10 +73,6 @@ this results in:
endpoint_b_port: 2 # port 2 on switch
bandwidth: 100
``ref``
^^^^^^^
The human readable name for the link. Not used in code, however is useful for a human to understand what the link is for.
``endpoint_a_hostname``
^^^^^^^^^^^^^^^^^^^^^^^
@@ -101,3 +99,27 @@ This accepts an integer value e.g. if port 1 is to be connected, the configurati
``bandwidth``
This is an integer value specifying the allowed bandwidth across the connection. Units are in Mbps.
``airspace``
------------
This section configures settings specific to the wireless network's virtual airspace.
``frequency_max_capacity_mbps``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This setting allows the user to override the default maximum bandwidth capacity set for each frequency. The key should
be the AirSpaceFrequency name and the value be the desired maximum bandwidth capacity in mbps (megabits per second) for
a single timestep.
The below example would permit 123.45 megabits to be transmit across the WiFi 2.4 GHz frequency in a single timestep.
Setting a frequencies max capacity to 0.0 blocks that frequency on the airspace.
.. code-block:: yaml
simulation:
network:
airspace:
frequency_max_capacity_mbps:
WIFI_2_4: 123.45
WIFI_5: 0.0

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _Node Attributes:

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _common_host_node_attributes:

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _common_network_node_attributes:

View File

@@ -1,14 +1,9 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _common_node_attributes:
``ref``
-------
Human readable name used as reference for the |NODE|. Not used in code.
``hostname``
------------
@@ -53,3 +48,60 @@ The number of time steps required to occur in order for the node to cycle from `
Optional. Default value is ``3``.
The number of time steps required to occur in order for the node to cycle from ``ON`` to ``SHUTTING_DOWN`` and then finally ``OFF``.
``file_system``
---------------
Optional.
The file system of the node. This configuration allows nodes to be initialised with files and/or folders.
The file system takes a list of folders and files.
Example:
.. code-block:: yaml
simulation:
network:
nodes:
- hostname: client_1
type: computer
ip_address: 192.168.10.11
subnet_mask: 255.255.255.0
default_gateway: 192.168.10.1
file_system:
- empty_folder # example of an empty folder
- downloads:
- "test_1.txt" # files in the downloads folder
- "test_2.txt"
- root:
- passwords: # example of file with size and type
size: 69 # size in bytes
type: TXT # See FileType for list of available file types
List of file types: :py:mod:`primaite.simulator.file_system.file_type.FileType`
``users``
---------
The list of pre-existing users that are additional to the default admin user (``username=admin``, ``password=admin``).
Additional users are configured as an array and must contain a ``username``, ``password``, and can contain an optional
boolean ``is_admin``.
Example of adding two additional users to a node:
.. code-block:: yaml
simulation:
network:
nodes:
- hostname: [hostname]
type: [Node Type]
users:
- username: jane.doe
password: '1234'
is_admin: true
- username: john.doe
password: password_1
is_admin: false

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
``type``
--------
@@ -12,6 +12,7 @@ Available options are:
- ``computer``
- ``firewall``
- ``router``
- ``wireless_router``
- ``server``
- ``switch``

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _computer_configuration:
@@ -17,19 +17,18 @@ example computer
.. code-block:: yaml
simulation:
network:
nodes:
- ref: client_1
hostname: client_1
type: computer
ip_address: 192.168.0.10
subnet_mask: 255.255.255.0
default_gateway: 192.168.0.1
dns_server: 192.168.1.10
applications:
...
services:
...
network:
nodes:
- hostname: client_1
type: computer
ip_address: 192.168.0.10c
subnet_mask: 255.255.255.0
default_gateway: 192.168.0.1
dns_server: 192.168.1.10
applications:
...
services:
...
.. include:: common/common_node_attributes.rst

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _firewall_configuration:
@@ -19,38 +19,35 @@ example firewall
.. code-block:: yaml
simulation:
network:
nodes:
- ref: firewall
hostname: firewall
type: firewall
start_up_duration: 0
shut_down_duration: 0
ports:
external_port: # port 1
ip_address: 192.168.20.1
subnet_mask: 255.255.255.0
internal_port: # port 2
ip_address: 192.168.1.2
subnet_mask: 255.255.255.0
dmz_port: # port 3
ip_address: 192.168.10.1
subnet_mask: 255.255.255.0
acl:
internal_inbound_acl:
...
internal_outbound_acl:
...
dmz_inbound_acl:
...
dmz_outbound_acl:
...
external_inbound_acl:
...
external_outbound_acl:
...
routes:
...
network:
nodes:
- hostname: firewall
type: firewall
ports:
external_port: # port 1
ip_address: 192.168.20.1
subnet_mask: 255.255.255.0
internal_port: # port 2
ip_address: 192.168.1.2
subnet_mask: 255.255.255.0
dmz_port: # port 3
ip_address: 192.168.10.1
subnet_mask: 255.255.255.0
acl:
internal_inbound_acl:
...
internal_outbound_acl:
...
dmz_inbound_acl:
...
dmz_outbound_acl:
...
external_inbound_acl:
...
external_outbound_acl:
...
routes:
...
.. include:: common/common_node_attributes.rst
@@ -70,18 +67,18 @@ The ports should be defined with an ip address and subnet mask e.g.
.. code-block:: yaml
nodes:
- ref: firewall
...
- hostname: firewall
...
ports:
external_port: # port 1
ip_address: 192.168.20.1
subnet_mask: 255.255.255.0
internal_port: # port 2
ip_address: 192.168.1.2
subnet_mask: 255.255.255.0
dmz_port: # port 3
ip_address: 192.168.10.1
subnet_mask: 255.255.255.0
external_port: # port 1
ip_address: 192.168.20.1
subnet_mask: 255.255.255.0
internal_port: # port 2
ip_address: 192.168.1.2
subnet_mask: 255.255.255.0
dmz_port: # port 3
ip_address: 192.168.10.1
subnet_mask: 255.255.255.0
``ip_address``
""""""""""""""
@@ -129,21 +126,21 @@ example:
.. code-block:: yaml
nodes:
- ref: firewall
- hostname: firewall
...
acl:
internal_inbound_acl:
21: # position 21 on ACL list
action: PERMIT # allow packets that
src_port: POSTGRES_SERVER # are emitted from the POSTGRES_SERVER port
dst_port: POSTGRES_SERVER # are going towards an POSTGRES_SERVER port
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
internal_inbound_acl:
21: # position 21 on ACL list
action: PERMIT # allow packets that
src_port: POSTGRES_SERVER # are emitted from the POSTGRES_SERVER port
dst_port: POSTGRES_SERVER # are going towards an POSTGRES_SERVER port
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
``internal_outbound_acl``
"""""""""""""""""""""""""
@@ -155,21 +152,21 @@ example:
.. code-block:: yaml
nodes:
- ref: firewall
...
- hostname: firewall
...
acl:
internal_outbound_acl:
21: # position 21 on ACL list
action: PERMIT # allow packets that
src_port: POSTGRES_SERVER # are emitted from the POSTGRES_SERVER port
dst_port: POSTGRES_SERVER # are going towards an POSTGRES_SERVER port
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
internal_outbound_acl:
21: # position 21 on ACL list
action: PERMIT # allow packets that
src_port: POSTGRES_SERVER # are emitted from the POSTGRES_SERVER port
dst_port: POSTGRES_SERVER # are going towards an POSTGRES_SERVER port
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
``dmz_inbound_acl``
@@ -216,29 +213,29 @@ example:
.. code-block:: yaml
nodes:
- ref: firewall
...
acl:
dmz_outbound_acl:
19: # position 19 on ACL list
action: PERMIT # allow packets that
src_port: POSTGRES_SERVER # are emitted from the POSTGRES_SERVER port
dst_port: POSTGRES_SERVER # are going towards an POSTGRES_SERVER port
20: # position 20 on ACL list
action: PERMIT # allow packets that
src_port: HTTP # are emitted from the HTTP port
dst_port: HTTP # are going towards an HTTP port
21: # position 21 on ACL list
action: PERMIT # allow packets that
src_port: HTTPS # are emitted from the HTTPS port
dst_port: HTTPS # are going towards an HTTPS port
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
- hostname: firewall
...
acl:
dmz_outbound_acl:
19: # position 19 on ACL list
action: PERMIT # allow packets that
src_port: POSTGRES_SERVER # are emitted from the POSTGRES_SERVER port
dst_port: POSTGRES_SERVER # are going towards an POSTGRES_SERVER port
20: # position 20 on ACL list
action: PERMIT # allow packets that
src_port: HTTP # are emitted from the HTTP port
dst_port: HTTP # are going towards an HTTP port
21: # position 21 on ACL list
action: PERMIT # allow packets that
src_port: HTTPS # are emitted from the HTTPS port
dst_port: HTTPS # are going towards an HTTPS port
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
@@ -254,21 +251,21 @@ example:
.. code-block:: yaml
nodes:
- ref: firewall
...
acl:
external_inbound_acl:
21: # position 19 on ACL list
action: DENY # deny packets that
src_port: POSTGRES_SERVER # are emitted from the POSTGRES_SERVER port
dst_port: POSTGRES_SERVER # are going towards an POSTGRES_SERVER port
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
- hostname: firewall
...
acl:
external_inbound_acl:
21: # position 19 on ACL list
action: DENY # deny packets that
src_port: POSTGRES_SERVER # are emitted from the POSTGRES_SERVER port
dst_port: POSTGRES_SERVER # are going towards an POSTGRES_SERVER port
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
``external_outbound_acl``
"""""""""""""""""""""""""
@@ -282,17 +279,17 @@ example:
.. code-block:: yaml
nodes:
- ref: firewall
...
- hotsname: firewall
...
acl:
external_outbound_acl:
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
external_outbound_acl:
22: # position 22 on ACL list
action: PERMIT # allow packets that
src_port: ARP # are emitted from the ARP port
dst_port: ARP # are going towards an ARP port
23: # position 23 on ACL list
action: PERMIT # allow packets that
protocol: ICMP # are ICMP
.. include:: common/common_network_node_attributes.rst

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _network_examples:
@@ -389,7 +389,7 @@ connections, but the ACL that allows the nodes in the LAN to communicate with th
pc_1 = network.get_node_by_hostname("pc_1")
pc_1.ping(pc_1.default_gateway)
pc_1.sys_log.show()
pc_1.sys_log.show()
If SysLog capture is toggled on and the simulation log level is set to INFO, the `pc_1` the result of the ping should be
captured in the `pc_1` SysLog:
@@ -443,7 +443,8 @@ SomeTech. This extended network includes detailed sub-networks with specialised
complex routing capabilities, and robust security protocols implemented through Access Control Lists (ACLs). Designed
to mimic the intricacies of actual network environments, this network provides a detailed look at how various network
components interact and function together to support both internal corporate activities and external communications.
NB: the network described here is not the same as the UC7 network used by notebooks such as ``UC7-Training,ipynb`` or
the network in ``Privilege-Escalation-and-Data-Loss-Example.ipynb``.
.. image:: images/primaite_example_multi_lan_with_internet_network_dark.png
:align: center
@@ -617,10 +618,10 @@ Each node is configured to ensure it meets the specific security and operational
default_gateway: 192.168.1.1
dns_server: 8.8.8.2
applications:
- type: DatabaseClient
- type: database-client
options:
db_server_ip: 10.10.1.11
- type: WebBrowser
- type: web-browser
options:
target_url: http://sometech.ai
@@ -631,10 +632,10 @@ Each node is configured to ensure it meets the specific security and operational
default_gateway: 192.168.1.1
dns_server: 8.8.8.2
applications:
- type: DatabaseClient
- type: database-client
options:
db_server_ip: 10.10.1.11
- type: WebBrowser
- type: web-browser
options:
target_url: http://sometech.ai
@@ -700,7 +701,7 @@ Each node is configured to ensure it meets the specific security and operational
default_gateway: 8.8.8.1
services:
- ref: dns_server
type: DNSServer
type: dns-server
options:
domain_mapping:
sometech.ai: 94.10.180.6
@@ -794,9 +795,9 @@ Each node is configured to ensure it meets the specific security and operational
dns_server: 8.8.8.2
services:
- ref: web_server
type: WebServer
type: web-server
applications:
- type: DatabaseClient
- type: database-client
options:
db_server_ip: 10.10.1.11
@@ -903,10 +904,10 @@ Each node is configured to ensure it meets the specific security and operational
default_gateway: 10.10.1.1
dns_server: 8.8.8.2
services:
- type: DatabaseService
- type: database-service
options:
backup_server_ip: 10.10.1.12 # The some_tech_storage_srv server
- type: FTPClient
- type: ftp-client
- hostname: some_tech_storage_srv
type: server
@@ -915,7 +916,7 @@ Each node is configured to ensure it meets the specific security and operational
default_gateway: 10.10.1.1
dns_server: 8.8.8.2
services:
- type: FTPServer
- type: ftp-server
- hostname: some_tech_hr_1
type: computer
@@ -924,10 +925,10 @@ Each node is configured to ensure it meets the specific security and operational
default_gateway: 10.10.3.1
dns_server: 8.8.8.2
applications:
- type: DatabaseClient
- type: database-client
options:
db_server_ip: 10.10.1.11
- type: WebBrowser
- type: web-browser
options:
target_url: http://sometech.ai
@@ -938,10 +939,10 @@ Each node is configured to ensure it meets the specific security and operational
default_gateway: 10.10.2.1
dns_server: 8.8.8.2
applications:
- type: DatabaseClient
- type: database-client
options:
db_server_ip: 10.10.1.11
- type: WebBrowser
- type: web-browser
options:
target_url: http://sometech.ai
@@ -952,10 +953,10 @@ Each node is configured to ensure it meets the specific security and operational
default_gateway: 10.10.2.1
dns_server: 8.8.8.2
applications:
- type: DatabaseClient
- type: database-client
options:
db_server_ip: 10.10.1.11
- type: WebBrowser
- type: web-browser
options:
target_url: http://sometech.ai
@@ -1177,8 +1178,8 @@ ACLs permitting or denying traffic as per our configured ACL rules.
some_tech_storage_srv = network.get_node_by_hostname("some_tech_storage_srv")
some_tech_storage_srv.file_system.create_file(file_name="test.png")
pc_1_ftp_client: FTPClient = network.get_node_by_hostname("pc_1").software_manager.software["FTPClient"]
pc_2_ftp_client: FTPClient = network.get_node_by_hostname("pc_2").software_manager.software["FTPClient"]
pc_1_ftp_client: FTPClient = network.get_node_by_hostname("pc_1").software_manager.software["ftp-client"]
pc_2_ftp_client: FTPClient = network.get_node_by_hostname("pc_2").software_manager.software["ftp-client"]
assert not pc_1_ftp_client.request_file(
dest_ip_address=some_tech_storage_srv.network_interface[1].ip_address,
@@ -1224,7 +1225,7 @@ ACLs permitting or denying traffic as per our configured ACL rules.
web_server: Server = network.get_node_by_hostname("some_tech_web_srv")
web_ftp_client: FTPClient = web_server.software_manager.software["FTPClient"]
web_ftp_client: FTPClient = web_server.software_manager.software["ftp-client"]
assert not web_ftp_client.request_file(
dest_ip_address=some_tech_storage_srv.network_interface[1].ip_address,
@@ -1269,7 +1270,7 @@ ACLs permitting or denying traffic as per our configured ACL rules.
some_tech_storage_srv.file_system.create_file(file_name="test.png")
some_tech_snr_dev_pc: Computer = network.get_node_by_hostname("some_tech_snr_dev_pc")
snr_dev_ftp_client: FTPClient = some_tech_snr_dev_pc.software_manager.software["FTPClient"]
snr_dev_ftp_client: FTPClient = some_tech_snr_dev_pc.software_manager.software["ftp-client"]
assert snr_dev_ftp_client.request_file(
dest_ip_address=some_tech_storage_srv.network_interface[1].ip_address,
@@ -1294,7 +1295,7 @@ ACLs permitting or denying traffic as per our configured ACL rules.
some_tech_storage_srv.file_system.create_file(file_name="test.png")
some_tech_jnr_dev_pc: Computer = network.get_node_by_hostname("some_tech_jnr_dev_pc")
jnr_dev_ftp_client: FTPClient = some_tech_jnr_dev_pc.software_manager.software["FTPClient"]
jnr_dev_ftp_client: FTPClient = some_tech_jnr_dev_pc.software_manager.software["ftp-client"]
assert not jnr_dev_ftp_client.request_file(
dest_ip_address=some_tech_storage_srv.network_interface[1].ip_address,
@@ -1337,7 +1338,7 @@ ACLs permitting or denying traffic as per our configured ACL rules.
some_tech_storage_srv.file_system.create_file(file_name="test.png")
some_tech_hr_pc: Computer = network.get_node_by_hostname("some_tech_hr_1")
hr_ftp_client: FTPClient = some_tech_hr_pc.software_manager.software["FTPClient"]
hr_ftp_client: FTPClient = some_tech_hr_pc.software_manager.software["ftp-client"]
assert not hr_ftp_client.request_file(
dest_ip_address=some_tech_storage_srv.network_interface[1].ip_address,

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _router_configuration:
@@ -17,16 +17,15 @@ example router
.. code-block:: yaml
simulation:
network:
nodes:
- ref: router_1
hostname: router_1
type: router
num_ports: 5
ports:
...
acl:
...
network:
nodes:
- hostname: router_1
type: router
num_ports: 5
ports:
...
acl:
...
.. include:: common/common_node_attributes.rst
@@ -49,15 +48,15 @@ Example of setting ports for a router with 2 ports:
.. code-block:: yaml
nodes:
- ref: router_1
- hostname: router_1
...
ports:
1:
ip_address: 192.168.1.1
subnet_mask: 255.255.255.0
2:
ip_address: 192.168.10.1
subnet_mask: 255.255.255.0
1:
ip_address: 192.168.1.1
subnet_mask: 255.255.255.0
2:
ip_address: 192.168.10.1
subnet_mask: 255.255.255.0
``ip_address``
""""""""""""""
@@ -74,23 +73,19 @@ The subnet mask setting for the port.
``acl``
-------
Sets up the ACL rules for the router.
Sets up the ACL rules for the router to apply to layer-3 traffic. These are not applied to layer-2 traffic such as ARP.
e.g.
.. code-block:: yaml
nodes:
- ref: router_1
- hostname: router_1
...
acl:
1:
action: PERMIT
src_port: ARP
dst_port: ARP
2:
action: PERMIT
protocol: ICMP
1:
action: PERMIT
protocol: ICMP
See :py:mod:`primaite.simulator.network.hardware.nodes.network.router.AccessControlList`

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _server_configuration:
@@ -19,16 +19,15 @@ example server
simulation:
network:
nodes:
- ref: server_1
hostname: server_1
type: server
ip_address: 192.168.10.10
subnet_mask: 255.255.255.0
default_gateway: 192.168.10.1
dns_server: 192.168.1.10
applications:
- hostname: server_1
type: server
ip_address: 192.168.10.10
subnet_mask: 255.255.255.0
default_gateway: 192.168.10.1
dns_server: 192.168.1.10
applications:
...
services:
services:
...
.. include:: common/common_node_attributes.rst

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _switch_configuration:
@@ -17,12 +17,11 @@ example switch
.. code-block:: yaml
simulation:
network:
nodes:
- ref: switch_1
hostname: switch_1
type: switch
num_ports: 8
network:
nodes:
hostname: switch_1
type: switch
num_ports: 8
.. include:: common/common_node_attributes.rst

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
``applications``
----------------
@@ -14,12 +14,10 @@ Applications takes a list of applications as shown in the example below.
.. code-block:: yaml
- ref: client_1
hostname: client_1
type: computer
- hostname: client_1
type: computer
...
applications:
- ref: example_application
type: example_application_type
options:
# this section is different for each application

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
``services``
------------
@@ -14,12 +14,10 @@ Services takes a list of services as shown in the example below.
.. code-block:: yaml
- ref: client_1
hostname: client_1
type: computer
...
applications:
- ref: example_service
type: example_service_type
options:
# this section is different for each service

View File

@@ -1,8 +0,0 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
Customising Agents
******************
For an example of how to customise red agent behaviour in the Data Manipulation scenario, please refer to the notebook ``Data-Manipulation-Customising-Red-Agent.ipynb``.

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. role:: raw-html(raw)
:format: html

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _Developer Tools:
@@ -49,36 +49,68 @@ dev-mode configuration
The following configures some specific items that the dev-mode overrides, if enabled.
`--sys-log-level` or `-level`
----------------------------
`--sys-log-level` or `-slevel`
-----------------------------
The level of system logs can be overridden by dev-mode.
By default, this is set to DEBUG
The available options are [DEBUG|INFO|WARNING|ERROR|CRITICAL]
The available options for both system and agent logs are:
.. code-block::
primaite dev-mode config -level INFO
or
+-------------------+
| Log Level |
+===================+
| DEBUG |
+-------------------+
| INFO |
+-------------------+
| WARNING |
+-------------------+
| ERROR |
+-------------------+
| CRITICAL |
+-------------------+
.. code-block::
primaite dev-mode config --sys-log-level INFO
or
.. code-block::
primaite dev-mode config -slevel INFO
`--agent-log-level` or `-alevel`
--------------------------------
The level of agent logs can be overridden by dev-mode.
By default, this is set to DEBUG.
.. code-block::
primaite dev-mode config --agent-log-level INFO
or
.. code-block::
primaite dev-mode config -alevel INFO
`--output-sys-logs` or `-sys`
-----------------------------
The outputting of system logs can be overridden by dev-mode.
The output of system logs can be overridden by dev-mode.
By default, this is set to False
Enabling system logs
""""""""""""""""""""
To enable outputting of system logs
To enable output of system logs
.. code-block::
@@ -93,7 +125,7 @@ or
Disabling system logs
"""""""""""""""""""""
To disable outputting of system logs
To disable output of system logs
.. code-block::
@@ -105,17 +137,47 @@ or
primaite dev-mode config -nsys
Enabling agent logs
""""""""""""""""""""
To enable output of system logs
.. code-block::
primaite dev-mode config --output-agent-logs
or
.. code-block::
primaite dev-mode config -agent
Disabling system logs
"""""""""""""""""""""
To disable output of system logs
.. code-block::
primaite dev-mode config --no-agent-logs
or
.. code-block::
primaite dev-mode config -nagent
`--output-pcap-logs` or `-pcap`
-------------------------------
The outputting of packet capture logs can be overridden by dev-mode.
The output of packet capture logs can be overridden by dev-mode.
By default, this is set to False
Enabling PCAP logs
""""""""""""""""""
To enable outputting of packet capture logs
To enable output of packet capture logs
.. code-block::
@@ -130,7 +192,7 @@ or
Disabling PCAP logs
"""""""""""""""""""
To disable outputting of packet capture logs
To disable output of packet capture logs
.. code-block::
@@ -145,14 +207,14 @@ or
`--output-to-terminal` or `-t`
------------------------------
The outputting of system logs to the terminal can be overridden by dev-mode.
The output of system logs to the terminal can be overridden by dev-mode.
By default, this is set to False
Enabling system log output to terminal
""""""""""""""""""""""""""""""""""""""
To enable outputting of system logs to terminal
To enable output of system logs to terminal
.. code-block::
@@ -167,7 +229,7 @@ or
Disabling system log output to terminal
"""""""""""""""""""""""""""""""""""""""
To disable outputting of system logs to terminal
To disable output of system logs to terminal
.. code-block::

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
RL Environments
***************

View File

@@ -1,6 +1,8 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _example jupyter notebooks:
Example Jupyter Notebooks
=========================
@@ -18,6 +20,7 @@ Running Jupyter Notebooks
-------------------------
1. Navigate to the PrimAITE directory
"""""""""""""""""""""""""""""""""""""
.. code-block:: bash
:caption: Unix
@@ -29,7 +32,10 @@ Running Jupyter Notebooks
cd ~\primaite\{VERSION}
2. Run jupyter notebook (the python environment to which you installed PrimAITE must be active)
2. Run jupyter notebook
"""""""""""""""""""""""
**Please note that the python environment to which you installed PrimAITE must be active.**
.. code-block:: bash
:caption: Unix
@@ -42,11 +48,13 @@ Running Jupyter Notebooks
jupyter notebook
3. Opening the jupyter webpage (optional)
"""""""""""""""""""""""""""""""""""""""""
The default web browser may automatically open the webpage. However, if that is not the case, click the link shown in your command prompt output. It should look like this: ``http://localhost:8888/?token=0123456798abc0123456789abc``
4. Navigate to the list of notebooks
"""""""""""""""""""""""""""""""""""""""""
The example notebooks are located in ``notebooks/example_notebooks/``. The file system shown in the jupyter webpage is relative to the location in which the ``jupyter notebook`` command was used.
@@ -77,6 +85,6 @@ The following extensions should now be installed
:width: 300
:align: center
VSCode will then ask for a Python environment version to use. PrimAITE is compatible with Python versions 3.9 - 3.11
VSCode will then ask for a Python environment version to use. PrimAITE is compatible with Python versions 3.8 - 3.11
You should now be able to interact with the notebook.

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
PrimAITE Game layer
*******************
@@ -42,49 +42,50 @@ An agent's reward function is managed by the ``RewardManager``. It calculates re
Reward Components
-----------------
Currently implemented are reward components tailored to the data manipulation scenario. View the full API and description of how they work here: :py:module:`primaite.game.agent.reward`.
Currently implemented are reward components tailored to the data manipulation scenario. View the full API and description of how they work here: :py:mod:`primaite.game.agent.rewards`.
Reward Sharing
--------------
An agent's reward can be based on rewards of other agents. This is particularly useful for modelling a situation where the blue agent's job is to protect the ability of green agents to perform their pattern-of-life. This can be configured in the YAML file this way:
```yaml
green_agent_1: # this agent sometimes tries to access the webpage, and sometimes the database
# actions, observations, and agent settings go here
reward_function:
reward_components:
.. code-block:: yaml
# When the webpage loads, the reward goes up by 0.25 when it fails to load, it goes down to -0.25
- type: WEBPAGE_UNAVAILABLE_PENALTY
weight: 0.25
options:
node_hostname: client_2
green_agent_1: # this agent sometimes tries to access the webpage, and sometimes the database
# actions, observations, and agent settings go here
reward_function:
reward_components:
# When the database is reachable, the reward goes up by 0.05, when it is unreachable it goes down to -0.05
- type: GREEN_ADMIN_DATABASE_UNREACHABLE_PENALTY
weight: 0.05
options:
node_hostname: client_2
# When the webpage loads, the reward goes up by 0.25 when it fails to load, it goes down to -0.25
- type: webpage-unavailable-penalty
weight: 0.25
options:
node_hostname: client_2
blue_agent:
# actions, observations, and agent settings go here
reward_function:
reward_components:
# When the database is reachable, the reward goes up by 0.05, when it is unreachable it goes down to -0.05
- type: green-admin-database-unreachable-penalty
weight: 0.05
options:
node_hostname: client_2
# When the database file is in a good state, blue's reward is 0.4, when it's in a corrupted state the reward is -0.4
- type: DATABASE_FILE_INTEGRITY
weight: 0.40
options:
node_hostname: database_server
folder_name: database
file_name: database.db
blue_agent:
# actions, observations, and agent settings go here
reward_function:
reward_components:
# When the database file is in a good state, blue's reward is 0.4, when it's in a corrupted state the reward is -0.4
- type: database-file-integrity
weight: 0.40
options:
node_hostname: database_server
folder_name: database
file_name: database.db
# The green's reward is added onto the blue's reward.
- type: shared-reward
weight: 1.0
options:
agent_name: client_2_green_user
# The green's reward is added onto the blue's reward.
- type: SHARED_REWARD
weight: 1.0
options:
agent_name: client_2_green_user
```
When defining agent reward sharing, users must be careful to avoid circular references, as that would lead to an infinite calculation loop. PrimAITE will prevent circular dependencies and provide a helpful error message if they are detected in the yaml.

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _getting-started:
@@ -113,7 +113,7 @@ For example:
.. code-block:: bash
git clone https://github.com/{todo:fill in URL}/PrimAITE
git clone https://github.com/Autonomous-Resilient-Cyber-Defence/PrimAITE
cd primaite
2. Create and activate your Python virtual environment (venv)

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
Glossary
=============
@@ -9,10 +9,10 @@ Glossary
:sorted:
Network
The network in primaite is a logical representation of a computer network containing :term:`Nodes<Node>` and :term:`Links<Link>`.
The network in primaite is a logical representation of a computer network containing :term:`Nodes<Node>` and :term:`Links<Link>`. See :ref:`network`.
Node
A Node represents a network endpoint. For example a computer, server, switch, or an actuator.
A Node represents a network endpoint. For example a computer, server, switch, or an actuator. See :ref:`node_description`
Link
A Link represents the connection between two Nodes. For example, a physical wire between a computer and a switch or a wireless connection.
@@ -21,7 +21,7 @@ Glossary
Protocols are used by links to separate different types of network traffic. Common examples would be HTTP, TCP, and UDP.
Service
A service represents a piece of software that is installed on a node, such as a web server or a database.
A service represents a piece of software that is installed on a node, such as a web server or a database. See :ref:`software`
Access Control List
PrimAITE blocks or allows certain traffic on the network by simulating firewall rules, which are defined in the Access Control List.
@@ -42,7 +42,7 @@ Glossary
PoLs allow agents to change the current hardware, OS, file system, or service statuses of nodes during the course of an episode. For example, a green agent may restart a server node to represent scheduled maintainance. A red agent's Pattern-of-Life can be used to attack nodes by changing their states to CORRUPTED or COMPROMISED.
Reward
The reward is a single number used by the blue agent to understand whether it's performing well or poorly. RL agents change their behaviour in an attempt to increase the expected reward each episode. The reward is generated based on the current states of the environment and is impacted positively by things like green PoL running successfully and negatively by things like nodes being compromised.
The reward is a single number used by the blue agent to understand whether it's performing well or poorly. RL agents change their behaviour in an attempt to increase the expected reward each episode. The reward is generated based on the current states of the environment and is impacted positively by things like green PoL running successfully and negatively by things like nodes being compromised. See :ref:`Rewards`
Observation
An observation is a representation of the current state of the environment that is given to the learning agent so it can decide on which action to perform. If the environment is 'fully observable', the observation contains information about every possible aspect of the environment. More commonly, the environment is 'partially observable' which means the learning agent has to make decisions without knowing every detail of the current environment state.
@@ -50,6 +50,9 @@ Glossary
Action
The learning agent decides on an action to take on every step in the simulation. The action has the chance to positively or negatively impact the environment state. Over time, the agent aims to learn which actions to take when to maximise the expected reward.
Action mask
An input to RL algorithms that contains information about which of the actions in the action space are currently valid. See :ref:`action_masking`
Training
During training, an RL agent is placed in the simulated network and it learns which actions to take in which scenarios to obtain maximum reward.
@@ -69,4 +72,13 @@ Glossary
PrimAITE uses the Gymnasium reinforcement learning framework API to create a training environment and interface with RL agents. Gymnasium defines a common way of creating observations, actions, and rewards.
User app home
PrimAITE supports upgrading software version while retaining user data. The user data directory is where configs, notebooks, and results are stored, this location is `~/primaite<version>/` on linux/darwin and `C:\\Users\\<username>\\primaite<version>` on Windows.
PrimAITE supports upgrading software version while retaining user data. The user data directory is where configs, notebooks, and results are stored, this location is ``~/primaite/<version>/`` on linux/darwin and ``C:\\Users\\<username>\\primaite\\<version>`` on Windows.
Episode schedule
The strategy for selecting different variants around the same scenario when advancing from one episode to another in the environment.
Discriminator
A unique string given to extensible components in PrimAITE that allow them to be mapped from a YAML config definition to a simulation class.
Plugin
A python package that extends base PrimAITE classes.

10
docs/source/how_to.rst Normal file
View File

@@ -0,0 +1,10 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
How-To Guides
=============
These how-to guides aim to provide a starting point for development within PrimAITE, creating your own custom components and environments for use when training agents. More detailed information for each section can be found within the documentation.
There are also some additional notebooks which provide a walkthrough of established content. It's encouraged to reference these when developing for PrimAITE.

View File

@@ -0,0 +1,58 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _custom_actions:
Creating Custom Actions in PrimAITE
***********************************
PrimAITE contains a selection of possible actions that can be exercised within a training environment. Actions provided as a part of PrimAITE can be seen within `src/primaite/game/agent/actions`. `Note`: Agents are only able to perform the actions listed within it's action_map, defined within it's configuration YAML. See :ref:`custom_environment` for more information.
Developing Custom Actions
=========================
Actions within PrimAITE follow a default format, as seen below and in ``actions.py``. It's important that they have an identifier when declared, as this is used when creating the training environment.
An example of a custom action is seen below, with key information about what is required for new actions in :ref:`extensible_actions`.
.. code:: Python
class ExampleActionClass(AbstractAction, discriminator="ExampleActions"):
"""Example Action Class"""
config: ExampleAction.ConfigSchema(AbstractAction.ConfigSchema)
class ConfigSchema(AbstractAction.ConfigSchema)
node_name: str
@classmethod
def form_request(cls, config: ConfigSchema) -> RequestFormat:
return [config.node_name, "example_action"]
Integration with PrimAITE ActionManager
=======================================
Any custom actions should then be added to the `ActionManager` class, and the `act_class_identifiers` dictionary. This will map the action class to the corresponding action type string that would be passed through the PrimAITE `request_system`.
Interaction with the PrimAITE Request Manager
=============================================
Where an action would cause a request to be sent through the PrimAITE RequestManager, a `form_request` method is expected to be defined within the Action Class. This should format the action into a format that can be ingested by the `RequestManager`. Examples of this include the `NodeFolderCreateAction`, which sends a formed request to create a folder on a given node (seen below):
.. code:: Python
def form_request(self, node_id: int, folder_name: str) -> RequestFormat:
"""Return the action formatted as a request which can be ingested by the PrimAITE simulation."""
node_name = self.manager.get_node_name_by_idx(node_id)
if node_name is None or folder_name is None:
return ["do_nothing"]
return ["network", "node", node_name, "file_system", "create", "folder", folder_name]
Action Masking
==============
Agents which use the `ProxyAgent` class within PrimAITE are able to use Action Masking. This allows the agent to know if the actions are valid/invalid based on the current environment.
Information on how to ensure this can be applied to your custom action can be found in :ref:`action_masking`

View File

@@ -0,0 +1,45 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _custom_environments:
Creating Custom Environments for PrimAITE
*****************************************
PrimAITE generates it's training configuration/Environments through ingestion of YAML files. A detailed walkthrough of how to create your own environment can be found within the ``Creating-Custom-Environments`` jupyter notebook.
You configuration file should follow the hierarchy seen below:
.. code:: yaml
metadata:
version: 4.0
required_plugins:
- name: Example_Plugin
version: 1.0
io_settings:
...
game:
...
agents:
...
simulation:
...
MetaData
========
It's important to include the metadata tag within your YAML file, as this is used to ensure PrimAITE can interpret the configuration correctly. This should also include any plugins that are required for the defined environment, along with their respective version.
Required Plugins
================
Should your custom environment need any additional PrimAITE plugins, each must be specified under the `required_plugins` tab, as seen in the above example.
Configuration Items
===================
For detailed information about the remaining configuration items found within the configuration file, see :ref:`Configurable_Items`.

View File

@@ -0,0 +1,48 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _custom_rewards:
Creating Custom Rewards in PrimAITE
***********************************
Rewards within PrimAITE are contained within ``rewards.py``, which details the rewards available for all agents within training sessions, how they are calculated and any other specific information where necessary.
Rewards within PrimAITE have been updated to facilitate extensibility and the creation of plugins with the release of PrimAITE version 4.0. Additional information about this is covered within :ref:`extensible_rewards`.
Custom Rewards within PrimAITE should inherit from the ``AbstractReward`` class, found in ``rewards.py``. It's important to include an identifier for any class created within PrimAITE.
.. code:: Python
class ExampleAward(AbstractReward, identifier="ExampleAward"):
"""Example Reward Class """
def calculate(self, state: Dict, last_action_response: "AgentHistoryItem") -> float:
"""Calculate the reward for the current state."""
return 1.0
@classmethod
def from_config(cls, config: dict) -> "AbstractReward":
"""Create a reward function component from a config dictionary."""
return cls()
Custom rewards that have been created should be added to the ``rew_class_identifiers`` dictionary within the ``RewardFunction`` class in ``rewards.py``.
Including Custom Rewards within PrimAITE configuration
======================================================
Custom rewards can then be included within an agents configuration by it's inclusion within the training session configuration YAML.
.. code:: yaml
agents:
- ref: agent_name
reward_function:
reward_components:
- type: DUMMY
weight: 1.0
More detailed information about rewards within PrimAITE can be found within :ref:`Rewards`

View File

@@ -0,0 +1,80 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _custom_software:
Creating Custom Software for PrimAITE
*************************************
This page aims to provide a how-to guide on how to create your own custom software for use within PrimAITE.
PrimAITE has a base software class which should be inherited from when building custom software. Examples of this can be seen in the ``IOSoftware`` and ``Process`` classes.
It's important that any new software created within PrimAITE has the ``identifier`` attribute defined, for use when generating the environment.
Some default attributes may need to be adjusted to align with the intended application of the custom software.
.. code:: Python
from src.primaite.simulator.system.software import Software
class CustomSoftware(Software, identifier="CustomSoftware"):
"""
An example of Custom Software within PrimAITE.
"""
operating_state: OperatingState
"The current operating state of the Custom software"
def describe_state(self) -> Dict:
"""
Produce a dictionary describing the current state of this object.
:return: Current state of this object and child objects.
:rtype: Dict
"""
state = super().describe_state()
state.update({"operating_state": self.operating_state.value})
Default Install
###############
Software can be set to auto-install onto a Node by adding it to the ``SYSTEM_SOFTWARE`` dictionary for the node. An example can be seen in the ``HostNode`` class, which pre-installs some key software that is expected on Nodes, such as the ``NTPClient`` and ``UserManager``.
Requirements
############
Any custom software will need to provide an implementation of the ``describe_state`` method, and conform to the general Pydantic requirements.
It's a good idea, if possible, to also create a ``.show()`` method, as this can be used for visualising the software's status when developing within PrimAITE.
Interaction with the PrimAITE Request System
############################################
If the software is intended to be used by an agent via a :ref:`custom_action`, then it will likely need an implementation of the ``RequestManager``.
Detailed information about the PrimAITE request system can be seen in :ref:`request_system`. An example implementation, derived from the `Application` class is seen below:
.. code:: Python
def _init_request_manager(self) -> RequestManager:
"""
Initialise the request manager.
More information in user guide and docstring for SimComponent._init_request_manager.
"""
_is_application_running = Application._StateValidator(application=self, state=ApplicationOperatingState.RUNNING)
rm = super()._init_request_manager()
rm.add_request(
"scan",
RequestType(
func=lambda request, context: RequestResponse.from_bool(self.scan()), validator=_is_application_running
),
)
return rm
Further information
###################
For more detailed information about the implementation of software within PrimAITE, see :ref:`software`.

View File

@@ -0,0 +1,68 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _extensible_actions:
Extensible Actions
******************
Changes to Actions class Structure.
===================================
Actions within PrimAITE have been updated to inherit from a base class, AbstractAction, standardising their format and allowing for easier creation of custom actions. Actions now use a ``ConfigSchema`` to define the possible configuration variables, and use pydantic to enforce correct parameters are passed through.
Developing Custom Actions.
==========================
Custom actions within PrimAITE must be a sub-class of `AbstractAction`, and contain 3 key items:
#. ConfigSchema class
#. Unique discriminator
#. `form_request` method.
ConfigSchema
############
The ConfigSchema sub-class of the action must contain all `configurable` variables within the action, that would be specified within the environments configuration YAML file.
Unique discriminator
####################
When declaring a custom class, it must have a unique discriminator string, that allows PrimAITE to generate the correct action when needed.
.. code:: Python
class CreateDirectoryAction(AbstractAction, discriminator="node-folder-create")
config: CreateDirectoryAction.ConfigSchema
class ConfigSchema(AbstractAction.ConfigSchema):
verb: ClassVar[str] = "create"
node_name: str
directory_name: str
@classmethod
def form_request(cls, config: ConfigSchema) -> RequestFormat:
return ["network",
"node",
config.node_name,
"file_system",
config.verb,
"folder",
config.directory_name,
]
The above action would fail pydantic validation as the discriminator "node-folder-create" is already used by the `NodeFolderCreateAction`, and would create a duplicate listing within `AbstractAction._registry`.
form_request method
###################
PrimAITE actions need to have a `form_request` method, which can be passed to the `RequestManager` for processing. This allows the custom action to be actioned within the simulation environment. Further information and an example of this can be seen in :ref:`custom_actions`.

View File

@@ -0,0 +1,75 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _extensible_agents:
Extensible Agents
*****************
Agents defined within PrimAITE have been updated to allow for easier creation of new bespoke agents for use in custom environments.
Developing Agents for PrimAITE
==============================
All agent types within PrimAITE must be subclassed from ``AbstractAgent`` in order to be used from configuration YAML files. This then allows you to implement any custom agent logic for the new agent in your training scenario. Examples of implementing custom agent logic can be seen in pre-existing agents, such as the ``DataManipulationBot`` and ``RandomAgent``.
The core features that should be implemented in any new agent are detailed below:
**ConfigSchema**:
Configurable items within a new agent within PrimAITE should contain a ``ConfigSchema`` which holds all configurable variables of the agent. This should not include parameters related to its *state*, these would be listed seperately.
Agent generation will fail pydantic checks if incorrect or invalid parameters are passed to the ConfigSchema of the chosen Agent.
.. code-block:: python
class ExampleAgent(AbstractAgent, discriminator = "ExampleAgent"):
"""An example agent for demonstration purposes."""
config: "ExampleAgent.ConfigSchema" = Field(default_factory= lambda: ExampleAgent.ConfigSchema())
"""Agent configuration"""
num_executions: int = 0
"""Number of action executions by agent"""
class ConfigSchema(AbstractAgent.ConfigSchema):
"""ExampleAgent configuration schema"""
type: str = "ExampleAgent
"""Name of agent"""
starting_host: int
"""Host node that this agent should start from in the given environment."""
.. code-block:: yaml
- ref: example_green_agent
team: GREEN
type: example-agent
agent_settings:
start_step: 25
frequency: 20
variance: 5
starting_host: "Server_1"
action_space:
action_map:
0:
action: do-nothing
options: {}
**discriminators**:
All agent classes should have an ``discriminator`` attribute, a unique kebab-case string, for when they are added to the base ``AbstractAgent`` registry. This is then specified in your configuration YAML, and used by PrimAITE to generate the correct Agent.
Changes to YAML file
====================
PrimAITE v4.0.0 introduces some breaking changes to how environment configuration yaml files are created. YAML files created for Primaite versions 3.3.0 should be compatible through a translation function, though it is encouraged that these are updated to reflect the updated format of 4.0.0+.
Agents now follow a more standardised settings definition, so should be more consistent across YAML files and the available agent types with PrimAITE.
All configurable items for agents sit under the ``agent_settings`` heading within your YAML files. There is no need for the inclusion of a ``start_settings``. Please see the above YAML example for full changes to agents.

View File

@@ -0,0 +1,55 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _extensible_nodes:
Extensible Nodes
****************
Node classes within PrimAITE have been updated to allow for easier generation of custom nodes within simulations.
Changes to Node Class structure.
================================
Node classes all inherit from the base Node Class, though new classes should inherit from either HostNode or NetworkNode, subject to the intended application of the Node.
The use of an `__init__` method is not necessary, as configurable variables for the class should be specified within the `config` of the class, and passed at run time via your YAML configuration using the `from_config` method.
An example of how additional Node classes is below, taken from `router.py` within PrimAITE.
.. code-block:: Python
class Router(NetworkNode, identifier="router"):
""" Represents a network router within the simulation, managing routing and forwarding of IP packets across network interfaces."""
SYSTEM_SOFTWARE: ClassVar[Dict] = {
"user-session-manager": UserSessionManager,
"user-manager": UserManager,
"terminal": Terminal,
}
network_interfaces: Dict[str, RouterInterface] = {}
"The Router Interfaces on the node."
network_interface: Dict[int, RouterInterface] = {}
"The Router Interfaces on the node by port id."
sys_log: SysLog
config: "Router.ConfigSchema" = Field(default_factory=lambda: Router.ConfigSchema())
class ConfigSchema(NetworkNode.ConfigSchema):
"""Configuration Schema for Router Objects."""
num_ports: int = 5
hostname: str = "Router"
Changes to YAML file.
=====================
While effort has been made to ensure that nodes defined within configuration YAML files for use with PrimAITE 3.X remain compatible with PrimAITE v4+, it is encouraged to review for minor changes needed.

View File

@@ -0,0 +1,55 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _extensible_rewards:
Extensible Rewards
******************
Extensible Rewards differ from the previous reward mechanism used in PrimAITE v3.x as new reward
types can be added without requiring a change to the RewardFunction class in rewards.py (PrimAITE
core repository).
Changes to reward class structure.
==================================
Reward classes are inherited from AbstractReward (a sub-class of Pydantic's BaseModel).
Within the reward class there is a ConfigSchema class responsible for ensuring the config file data
is in the correct format. This also means there is little (if no) requirement for and `__init__`
method. The `.from_config` method is no longer required as it's inherited from `AbstractReward`.
Each class requires an discriminator string which is used by the ConfigSchema class to verify that it
hasn't previously been added to the registry.
Inheriting from `BaseModel` removes the need for an `__init__` method but means that object
attributes need to be passed by keyword.
To add a new reward class follow the example below. Note that the type attribute in the
`ConfigSchema` class should match the type used in the config file to define the reward.
.. code-block:: Python
class DatabaseFileIntegrity(AbstractReward, discriminator="database-file-integrity"):
"""Reward function component which rewards the agent for maintaining the integrity of a database file."""
config: "DatabaseFileIntegrity.ConfigSchema"
location_in_state: List[str] = [""]
reward: float = 0.0
class ConfigSchema(AbstractReward.ConfigSchema):
"""ConfigSchema for DatabaseFileIntegrity."""
type: str = "database-file-integrity"
node_hostname: str
folder_name: str
file_name: str
def calculate(self, state: Dict, last_action_response: "AgentHistoryItem") -> float:
"""Calculate the reward for the current state.
pass
Changes to YAML file.
=====================
There's no longer a need to provide a `dns_server` as an option in the simulation section
of the config file.

View File

@@ -0,0 +1,411 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _migration_guide:
PrimAITE 4.0.0 YAML Configuration Migration Guide
*************************************************
Users upgrading from previous PrimAITE versions will be required to update their pre-existing YAML configs.
This migration guide details how to update any 3.0.0 yaml configs section by section to match the new 4.0.0 schema.
Any users accustomed to PrimAITE 2.0.0 are encouraged to make a fresh start to fully adapt to the changes since 2.0.0 release.
``io_settings``
===============
No major schema alterations are required for ``io_settings``.
However, a few more options have been introduced:
.. code-block:: yaml
io_settings:
save_agent_actions: false
save_step_metadata: false
save_pcap_logs: false
save_sys_logs: false
save_agent_logs: false
write_sys_log_to_terminal: false
sys_log_level: WARNING
agent_log_level: INFO
More information can be found in the detailed in the configuration page: :ref:`io_settings`.
``game``
========
No reformatting required for ``game`` section.
If users have installed plugins that introduce new ports or protocols then the game can be configured with use them.
This can be done by adding to the ``ports`` and ``protocols`` list as shown in the yaml snippet below:
.. code-block:: yaml
game:
max_episode_length: 128
ports:
- HTTP
- POSTGRES_SERVER
- <EXAMPLE_PLUGIN_PORT>
protocols:
- ICMP
- TCP
- UDP
- <EXAMPLE_PLUGIN_PROTOCOL>
thresholds:
nmne:
high: 10
medium: 5
low: 0
``agents``
==========
PrimAITE 4.0.0 changes action parameters to use meaningful names instead of indexes.
To match the new schema, agent configs written for PrimAITE 3.X should make the following changes:
``action_space``
----------------
- remove the ``options``, and ``action_list`` sections.
- update the ``action_map`` to use the new naming schema for actions, they use kebab case instead of camel case. A conversion table is provided below.
- update the ``action_map`` to follow the new parameter schemas. ID-based parameters were replaced with name-based parameters. Use your old config's ``action_space.options`` field to find the appropriate mapping for action parameters in your particular scenario.
- ``node_id`` is now ``node_name``
- ``application_id`` is now ``application_name``
- ``service_id`` is now ``service_name``
- ``folder_id`` is now ``folder_name``
- ``nic_id`` is now ``nic_num`` (and is now 1-indexed instead of 0-indexed for consistency with the simulation)
- ``port_id`` is now ``port_num`` (and is now 1-indexed instead of 0-indexed for consistency with the simulation)
- ``source_ip_id`` is now ``src_ip``
- ``source_wildcard_id`` is now ``src_wildcard``
- ``source_port_id`` is now ``src_port``
- ``dest_port_id`` is now ``dst_port``
- ``dest_wildcard_id`` is now ``dst_wildcard``
- ``dest_port_id`` is now ``dst_port``
- ``protocol_id`` is now ``protocol``
**Example on how to map old paramater IDs to new paramter names**
.. code-block:: yaml
game:
max_episode_length: 128
ports:
- FTP
- HTTP
protocols:
- TCP
- UDP
# ...
options:
nodes:
- node_name: PC-1
applications:
- application_name: DatabaseClient
folders:
- folder_name: downloads
files:
- file_name: chrome.exe
- folder_name: other_folder
files:
- file_name: firefox.exe
- node_name: PC-2
applications:
- application_name: WebBrowser
folders:
- folder_name: folder_1
files:
- file_name: file2.jpg
- folder_name: folder_2
files:
- file_name: file3.jpg
- node_name: PC-3
services:
- service_name: FTPClient
- node_name: PC-4
- node_name: PC-5
max_folders_per_node: 1
max_files_per_folder: 1
max_services_per_node: 2
max_nics_per_node: 8
max_acl_rules: 10
ip_list:
# 0 reserved for padding to align with observations
# 1 reserved for ALL ips
- 192.168.1.11 # 2
- 200.10.1.10 # 3
wildcard_list:
- 0.0.0.1 # 0
- 0.0.0.255 # 1
- 0.0.255.255 # 2
From the above old-style YAML ``action_space.options`` example, the following changes should be made to action map:
- Actions with ``node_id: 0`` should use ``node_name: PC-1``
- Actions with ``node_id: 1`` should use ``node_name: PC-2``
- Actions with ``node_id: 2`` should use ``node_name: PC-3``
- Actions with ``node_id: 3`` should use ``node_name: PC-4``
- Actions with ``node_id: 4`` should use ``node_name: PC-5``
- Actions with ``node_id: 0`` and ``application_id: 0`` should use ``application_name: DatabaseClient`` (The application list is specific to each node)
- Actions with ``node_id: 1`` and ``application_id: 0`` should use ``application_name: WebBrowser`` (The application list is specific to each node)
- Actions with ``node_id: 0`` and ``folder_id: 0`` should use ``folder_name: downloads`` (The folder list is specific to each node)
- Actions with ``node_id: 0`` and ``folder_id: 1`` should use ``folder_name: other_folder`` (The folder list is specific to each node)
- Actions with ``node_id: 1`` and ``folder_id: 0`` should use ``folder_name: folder_1`` (The folder list is specific to each node)
- Actions with ``node_id: 1`` and ``folder_id: 1`` should use ``folder_name: folder_2`` (The folder list is specific to each node)
- Actions with ``node_id: 0`` and ``folder_id: 0`` and ``file_id: 0`` should use ``file_name: chrome.exe`` (The file list is specific to each node and folder)
- Actions with ``node_id: 0`` and ``folder_id: 1`` and ``file_id: 0`` should use ``file_name: firefox.exe`` (The file list is specific to each node and folder)
- Actions with ``node_id: 1`` and ``folder_id: 0`` and ``file_id: 0`` should use ``file_name: file2.jpg`` (The file list is specific to each node and folder)
- Actions with ``node_id: 1`` and ``folder_id: 1`` and ``file_id: 0`` should use ``file_name: file3.jpg`` (The file list is specific to each node and folder)
- Actions with ``nic_id: <N>`` should use ``nic_num: <N+1>``
- Actions with ``port_id: <N>`` should use ``port_num: <N+1>``
- Actions with ``source_ip_id: 0`` should not be present in your original config as this has no effect
- Actions with ``source_ip_id: 1`` should use ``src_ip: ALL``
- Actions with ``source_ip_id: 2`` should use ``src_ip: 192.168.1.11``
- Actions with ``source_ip_id: 3`` should use ``src_ip: 200.10.1.10``
- Actions with ``dest_ip_id: 0`` should not be present in your original config as this has no effect
- Actions with ``dest_ip_id: 1`` should use ``dst_ip: ALL``
- Actions with ``dest_ip_id: 2`` should use ``dst_ip: 192.168.1.11``
- Actions with ``dest_ip_id: 3`` should use ``dst_ip: 200.10.1.10``
- Actions with ``source_wildcard_id: 0`` should use ``src_wildcard: 0.0.0.1``
- Actions with ``source_wildcard_id: 0`` should use ``src_wildcard: 0.0.0.255``
- Actions with ``source_wildcard_id: 0`` should use ``src_wildcard: 0.0.255.255``
- Actions with ``dest_wildcard_id: 0`` should use ``dst_wildcard: 0.0.0.1``
- Actions with ``dest_wildcard_id: 0`` should use ``dst_wildcard: 0.0.0.255``
- Actions with ``dest_wildcard_id: 0`` should use ``dst_wildcard: 0.0.255.255``
- Actions with ``source_port_id: 0`` should not be present in your original config as this has no effect
- Actions with ``source_port_id: 1`` should use ``src_port: ALL``
- Actions with ``source_port_id: 2`` should use ``src_port: FTP``
- Actions with ``source_port_id: 3`` should use ``src_port: HTTP``
- Actions with ``dest_port_id: 0`` should not be present in your original config as this has no effect
- Actions with ``dest_port_id: 1`` should use ``dst_port: ALL``
- Actions with ``dest_port_id: 2`` should use ``dst_port: FTP``
- Actions with ``dest_port_id: 3`` should use ``dst_port: HTTP``
- Actions with ``protocol_id: 0`` should not be present in your original config as this has no effect
- Actions with ``protocol_id: 1`` should use ``protocol: ALL``
- Actions with ``protocol_id: 2`` should use ``protocol: TCP``
- Actions with ``protocol_id: 3`` should use ``protocol: UDP``
``observation_space``
---------------------
- the ``type`` parameter values now use lower kebab case. A conversion table is provided below.
``reward_function``
-------------------
- the ``type`` parameter values now use lower kebab case. A conversion table is provided below.
+-------------------------------------+-------------------------------------+
| *3.0.0 action name* | *4.0.0 action name* |
+=====================================+=====================================+
| ``DONOTHING`` | ``do-nothing`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_SCAN`` | ``node-service-scan`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_STOP`` | ``node-service-stop`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_START`` | ``node-service-start`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_PAUSE`` | ``node-service-pause`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_RESUME`` | ``node-service-resume`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_RESTART`` | ``node-service-restart`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_DISABLE`` | ``node-service-disable`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_ENABLE`` | ``node-service-enable`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SERVICE_FIX`` | ``node-service-fix`` |
+-------------------------------------+-------------------------------------+
| ``NODE_APPLICATION_REMOVE`` | ``node-application-remove`` |
+-------------------------------------+-------------------------------------+
| ``NODE_APPLICATION_CLOSE`` | ``node-application-close`` |
+-------------------------------------+-------------------------------------+
| ``NODE_APPLICATION_SCAN`` | ``node-application-scan`` |
+-------------------------------------+-------------------------------------+
| ``NODE_APPLICATION_FIX`` | ``node-application-fix`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FILE_SCAN`` | ``node-file-scan`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FILE_CHECKHASH`` | ``node-file-checkhash`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FILE_DELETE`` | ``node-file-delete`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FILE_REPAIR`` | ``node-file-repair`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FILE_RESTORE`` | ``node-file-restore`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FOLDER_SCAN`` | ``node-folder-scan`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FOLDER_CHECKHASH`` | ``node-folder-checkhash`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FOLDER_REPAIR`` | ``node-folder-repair`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FOLDER_RESTORE`` | ``node-folder-restore`` |
+-------------------------------------+-------------------------------------+
| ``NODE_OS_SCAN`` | ``node-os-scan`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SHUTDOWN`` | ``node-shutdown`` |
+-------------------------------------+-------------------------------------+
| ``NODE_STARTUP`` | ``node-startup`` |
+-------------------------------------+-------------------------------------+
| ``NODE_RESET`` | ``node-reset`` |
+-------------------------------------+-------------------------------------+
| ``HOST_NIC_ENABLE`` | ``host-nic-enable`` |
+-------------------------------------+-------------------------------------+
| ``HOST_NIC_DISABLE`` | ``host-nic-disable`` |
+-------------------------------------+-------------------------------------+
| ``NETWORK_PORT_ENABLE`` | ``network-port-enable`` |
+-------------------------------------+-------------------------------------+
| ``NETWORK_PORT_DISABLE`` | ``network-port-disable`` |
+-------------------------------------+-------------------------------------+
| ``ROUTER_ACL_ADDRULE`` | ``router-acl-addrule`` |
+-------------------------------------+-------------------------------------+
| ``ROUTER_ACL_REMOVERULE`` | ``router-acl-removerule`` |
+-------------------------------------+-------------------------------------+
| ``FIREWALL_ACL_ADDRULE`` | ``firewall-acl-addrule`` |
+-------------------------------------+-------------------------------------+
| ``FIREWALL_ACL_REMOVERULE`` | ``firewall-acl-removerule`` |
+-------------------------------------+-------------------------------------+
| ``NODE_APPLICATION_EXECUTE`` | ``node-application-execute`` |
+-------------------------------------+-------------------------------------+
| ``NODE_APPLICATION_INSTALL`` | ``node-application-install`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FOLDER_CREATE`` | ``node-folder-create`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FILE_CREATE`` | ``node-file-create`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FILE_ACCESS`` | ``node-file-access`` |
+-------------------------------------+-------------------------------------+
| ``NODE_NMAP_PING_SCAN`` | ``node-nmap-ping-scan`` |
+-------------------------------------+-------------------------------------+
| ``NODE_NMAP_PORT_SCAN`` | ``node-nmap-port-scan`` |
+-------------------------------------+-------------------------------------+
| ``NODE_NMAP_NETWORK_SERVICE_RECON`` | ``node-nmap-network-service-recon`` |
+-------------------------------------+-------------------------------------+
| ``CONFIGURE_RANSOMWARE_SCRIPT`` | ``configure-ransomware-script`` |
+-------------------------------------+-------------------------------------+
| ``CONFIGURE_C2_BEACON`` | ``configure-c2-beacon`` |
+-------------------------------------+-------------------------------------+
| ``CONFIGURE_DATABASE_CLIENT`` | ``configure-database-client`` |
+-------------------------------------+-------------------------------------+
| ``CONFIGURE_DOS_BOT`` | ``configure-dos-bot`` |
+-------------------------------------+-------------------------------------+
| ``C2_SERVER_RANSOMWARE_LAUNCH`` | ``c2-server-ransomware-launch`` |
+-------------------------------------+-------------------------------------+
| ``C2_SERVER_RANSOMWARE_CONFIGURE`` | ``c2-server-ransomware-configure`` |
+-------------------------------------+-------------------------------------+
| ``C2_SERVER_TERMINAL_COMMAND`` | ``c2-server-terminal-command`` |
+-------------------------------------+-------------------------------------+
| ``C2_SERVER_DATA_EXFILTRATE`` | ``c2-server-data-exfiltrate`` |
+-------------------------------------+-------------------------------------+
| ``HOST_NIC_ENABLE`` | ``host-nic-enable`` |
+-------------------------------------+-------------------------------------+
| ``HOST_NIC_DISABLE`` | ``host-nic-disable`` |
+-------------------------------------+-------------------------------------+
| ``NODE_FILE_CORRUPT`` | ``node-file-corrupt`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SESSION_REMOTE_LOGIN`` | ``node-session-remote-login`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SESSION_REMOTE_LOGOFF`` | ``node-session-remote-logoff`` |
+-------------------------------------+-------------------------------------+
| ``NODE_ACCOUNT_CHANGE_PASSWORD`` | ``node-account-change-password`` |
+-------------------------------------+-------------------------------------+
| ``NODE_SEND_REMOTE_COMMAND`` | ``node-send-remote-command`` |
+-------------------------------------+-------------------------------------+
- All reward component types must be converted to kebab-case. (``SHARED_REWARD`` - ``shared-reward``)
+----------------------------------------------+----------------------------------------------+
| *3.0.0 reward type* | *4.0.0 reward name* |
+==============================================+==============================================+
| ``SHARED_REWARD`` | ``shared-reward`` |
+----------------------------------------------+----------------------------------------------+
| ``WEB_SERVER_404_PENALTY`` | ``web-server-404-penalty`` |
+----------------------------------------------+----------------------------------------------+
| ``WEBPAGE_UNAVAILABLE_PENALTY`` | ``webpage-unavailable-penalty`` |
+----------------------------------------------+----------------------------------------------+
| ``GREEN_ADMIN_DATABASE_UNREACHABLE_PENALTY`` | ``green-admin-database-unreachable-penalty`` |
+----------------------------------------------+----------------------------------------------+
| ``ACTION_PENALTY`` | ``action-penalty`` |
+----------------------------------------------+----------------------------------------------+
| ``DATABASE_FILE_INTEGRITY`` | ``database-file-integrity`` |
+----------------------------------------------+----------------------------------------------+
- All agent types must be converted to kebab-case. (``ProxyAgent`` - ``proxy-agent``)
+--------------------------------+-----------------------------------+
| *3.0.0 action type* | *4.0.0 agent type* |
+================================+===================================+
| ``ProxyAgent`` | ``proxy-agent`` |
+--------------------------------+-----------------------------------+
| ``RedDatabaseCorruptingAgent`` | ``red-database-corrupting-agent`` |
+--------------------------------+-----------------------------------+
| ``ProbabilisticAgent`` | ``probabilistic-agent`` |
+--------------------------------+-----------------------------------+
| ``RandomAgent`` | ``random-agent`` |
+--------------------------------+-----------------------------------+
| ``PeriodicAgent`` | ``periodic-agent`` |
+--------------------------------+-----------------------------------+
``simulation``
==============
The only simulation yaml changes are that all software has been renamed to use kebab-case:
+-----------------------+------------------------+
|*3.0.0 software name* |*4.0.0 software name* |
+=======================+========================+
| ``WebBrowser`` | ``web-browser`` |
+-----------------------+------------------------+
| ``DatabaseClient`` | ``database-client`` |
+-----------------------+------------------------+
| ``DNSClient`` | ``dns-client`` |
+-----------------------+------------------------+
| ``FTPServer`` | ``ftp-server`` |
+-----------------------+------------------------+
| ``C2Beacon`` | ``c2-beacon`` |
+-----------------------+------------------------+
| ``C2Server`` | ``c2-server`` |
+-----------------------+------------------------+
| ``RansomwareScript`` | ``ransomware-script`` |
+-----------------------+------------------------+
| ``WebServer`` | ``web-server`` |
+-----------------------+------------------------+
| ``DOSBot`` | ``dos-bot`` |
+-----------------------+------------------------+
| ``FTPClient`` | ``ftp-client`` |
+-----------------------+------------------------+
| ``DNSServer`` | ``dns-server`` |
+-----------------------+------------------------+
| ``Terminal`` | ``terminal`` |
+-----------------------+------------------------+
| ``NTPClient`` | ``ntp-client`` |
+-----------------------+------------------------+
| ``NTPServer`` | ``ntp-server`` |
+-----------------------+------------------------+
| ``NMAP`` | ``nmap`` |
+-----------------------+------------------------+
| ``HostARP`` | ``host-arp`` |
+-----------------------+------------------------+
| ``ICMP`` | ``icmp`` |
+-----------------------+------------------------+
A simple search and replace can be used with the lists above to update any configs.

View File

@@ -0,0 +1,8 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
Utilising the PrimAITE dev-mode cli
***********************************
A guide for utilising `primaite dev-mode` can be found within the ``How-To-Use-Primaite-Dev-Mode`` jupyter notebook, and also :ref:`Developer Tools`.

116
docs/source/node_sets.rst Normal file
View File

@@ -0,0 +1,116 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _network_node_adder:
Network Node Adder Module
#########################
This module provides a framework for adding nodes to a network in a standardised way. It defines a base class ``NetworkNodeAdder``, which can be extended to create specific node adders, and utility functions to calculate network infrastructure requirements.
The module allows you to use the pre-defined node adders, ``OfficeLANAdder``, or create custom ones by extending the base class.
How It Works
============
The main class in the module is ``NetworkNodeAdder``, which defines the interface for adding nodes to a network. Child classes are expected to:
1. Define a ``ConfigSchema`` nested class to define configuration options.
2. Implement the ``add_nodes_to_net(config, network)`` method, which adds the nodes to the network according to the configuration object.
The ``NetworkNodeAdder`` base class handles node adders defined in the primAITE config YAML file as well. It does this by keeping a registry of node adder classes, and uses the ``type`` field of the config to select the appropriate class to which to pass the configuration.
Example Usage
=============
Via Python API
--------------
Adding nodes to a network can be done using the python API by constructing the relevant ``ConfigSchema`` object like this:
.. code-block:: python
net = Network()
office_lan_config = OfficeLANAdder.ConfigSchema(
lan_name="CORP-LAN",
subnet_base=2,
pcs_ip_block_start=10,
num_pcs=8,
include_router=False,
bandwidth=150,
)
OfficeLANAdder.add_nodes_to_net(config=office_lan_config, network=net)
In this example, a network with 8 computers connected by a switch will be added to the network object.
Via YAML Config
---------------
.. code-block:: yaml
simulation:
network:
nodes:
# ... nodes go here
node_sets:
- type: office-lan
lan_name: CORP_LAN
subnet_base: 2
pcs_ip_block_start: 10
num_pcs: 8
include_router: False
bandwidth: 150
# ... additional node sets can be added below
``NetworkNodeAdder`` reads the ``type`` property of the config, then constructs and passes the configuration to ``OfficeLANAdder.add_nodes_to_net()``.
In this example, a network with 8 computers connected by a switch will be added to the network object. Equivalent to the above.
Creating Custom Node Adders
===========================
To create a custom node adder, subclass NetworkNodeAdder and define:
* A ConfigSchema class that defines the configuration schema for the node adder.
* The add_nodes_to_net method that implements how nodes should be added to the network.
Example: DataCenterAdder
------------------------
Here is an example of creating a custom node adder, DataCenterAdder:
.. code-block:: python
class DataCenterAdder(NetworkNodeAdder, discriminator="data-center"):
class ConfigSchema(NetworkNodeAdder.ConfigSchema):
type: Literal["data-center"] = "data-center"
num_servers: int
data_center_name: str
@classmethod
def add_nodes_to_net(cls, config: ConfigSchema, network: Network) -> None:
for i in range(config.num_servers):
server = Computer(
hostname=f"server_{i}_{config.data_center_name}",
ip_address=f"192.168.100.{i + 8}",
subnet_mask="255.255.255.0",
default_gateway="192.168.100.1",
start_up_duration=0
)
server.power_on()
network.add_node(server)
**Using the Custom Node Adder:**
.. code-block:: python
config = {
"type": "data-center",
"num_servers": 5,
"data_center_name": "dc1"
}
network = Network()
DataCenterAdder.from_config(config, network)

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _Executed Notebooks:

View File

@@ -1,41 +1,47 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| Name | Version | License | Description | URL |
+===================+=========+====================================+=======================================================================================================+==============================================+
| gymnasium | 0.28.1 | MIT License | A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym). | https://farama.org |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| ipywidgets | 8.1.3 | BSD License | Jupyter interactive widgets | http://jupyter.org |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| jupyterlab | 3.6.1 | BSD License | JupyterLab computational environment | https://jupyter.org |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| kaleido | 0.2.1 | MIT | Static image export for web-based visualization libraries with zero dependencies | https://github.com/plotly/Kaleido |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| matplotlib | 3.7.1 | Python Software Foundation License | Python plotting package | https://matplotlib.org |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| networkx | 3.1 | BSD License | Python package for creating and manipulating graphs and networks | https://networkx.org/ |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| numpy | 1.23.5 | BSD License | NumPy is the fundamental package for array computing with Python. | https://www.numpy.org |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| platformdirs | 3.5.1 | MIT License | A small Python package for determining appropriate platform-specific dirs, e.g. a "user data dir". | https://github.com/platformdirs/platformdirs |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| plotly | 5.15.0 | MIT License | An open-source, interactive data visualization library for Python | https://plotly.com/python/ |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| polars | 0.18.4 | MIT License | Blazingly fast DataFrame library | https://www.pola.rs/ |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| prettytable | 3.8.0 | BSD License (BSD (3 clause)) | A simple Python library for easily displaying tabular data in a visually appealing ASCII table format | https://github.com/jazzband/prettytable |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| pydantic | 2.7.0 | MIT License | Data validation using Python type hints | https://github.com/pydantic/pydantic |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| PyYAML | 6.0 | MIT License | YAML parser and emitter for Python | https://pyyaml.org/ |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| ray | 2.23.0 | Apache 2.0 | Ray provides a simple, universal API for building distributed applications. | https://github.com/ray-project/ray |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| stable-baselines3 | 2.1.0 | MIT | Pytorch version of Stable Baselines, implementations of reinforcement learning algorithms. | https://github.com/DLR-RM/stable-baselines3 |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| tensorflow | 2.12.0 | Apache Software License | TensorFlow is an open source machine learning framework for everyone. | https://www.tensorflow.org/ |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
| typer | 0.9.0 | MIT License | Typer, build great CLIs. Easy to code. Based on Python type hints. | https://github.com/tiangolo/typer |
+-------------------+---------+------------------------------------+-------------------------------------------------------------------------------------------------------+----------------------------------------------+
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| Name | Supported Version | Built Version | License | Description | URL |
+===================+=====================+===============+======================================+========================================================================================================+=====================================================================+
| gymnasium | 0.28.1 | 0.28.1 | MIT License | A standard API for reinforcement learning and a diverse set of reference environments (formerly Gym). | https://farama.org |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| ipywidgets | ~=8.0 | 8.1.5 | BSD License | Jupyter interactive widgets | http://jupyter.org |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| jupyterlab | 3.6.1 | 3.6.1 | BSD License | JupyterLab computational environment | https://jupyter.org |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| kaleido | ==0.2.1 | 0.2.1 | MIT | Static image export for web-based visualization libraries with zero dependencies | https://github.com/plotly/Kaleido |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| matplotlib | >=3.7.1 | 3.10.1 | Python Software Foundation License | Python plotting package | https://matplotlib.org |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| matplotlib-inline | >=0.1.7 | 0.1.7 | BSD License | Matplotlib Inline Back-end for IPython and Jupyter | https://github.com/ipython/matplotlib-inline |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| networkx | 3.1 | 3.1 | BSD License | Python package for creating and manipulating graphs and networks | https://networkx.org/ |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| numpy | ~1.23 | 1.23.5 | BSD License | NumPy is the fundamental package for array computing with Python. | https://www.numpy.org |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| platformdirs | 3.5.1 | 3.5.1 | MIT License | A small Python package for determining appropriate platform-specific dirs, e.g. a "user data dir". | https://github.com/platformdirs/platformdirs |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| plotly | 5.15 | 5.15.0 | MIT License | An open-source, interactive data visualization library for Python | https://plotly.com/python/ |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| polars | 0.20.30 | 0.20.30 | MIT License | Blazingly fast DataFrame library | https://www.pola.rs/ |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| prettytable | 3.8.0 | 3.8.0 | BSD License (BSD (3 clause)) | A simple Python library for easily displaying tabular data in a visually appealing ASCII table format | https://github.com/jazzband/prettytable |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| pydantic | 2.7.0 | 2.7.0 | MIT License | Data validation using Python type hints | https://github.com/pydantic/pydantic |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| PyYAML | >=6.0 | 6.0.2 | MIT License | YAML parser and emitter for Python | https://pyyaml.org/ |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| ray | >=2.20, <2.33 | 2.32.0 | Apache 2.0 | Ray provides a simple, universal API for building distributed applications. | https://github.com/ray-project/ray |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| stable-baselines3 | 2.1.0 | 2.1.0 | MIT | Pytorch version of Stable Baselines, implementations of reinforcement learning algorithms. | https://github.com/DLR-RM/stable-baselines3 |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| tensorflow | ~=2.12 | 2.12.0 | Apache Software License | TensorFlow is an open source machine learning framework for everyone. | https://www.tensorflow.org/ |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| typer | >=0.9 | 0.15.2 | MIT License | Typer, build great CLIs. Easy to code. Based on Python type hints. | https://github.com/tiangolo/typer |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| Deepdiff | >=8.0.1 | 8.3.0 | MIT License | Deep difference of dictionaries, iterables, strings, and any other object objects. | https://github.com/seperman/deepdiff |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
| sb3_contrib | 2.1.0 | 2.1.0 | MIT License | Contrib package for Stable-Baselines3 - Experimental reinforcement learning (RL) code (Action Masking) | https://github.com/Stable-Baselines-Team/stable-baselines3-contrib |
+-------------------+---------------------+---------------+--------------------------------------+--------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+

View File

@@ -1,6 +1,8 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _request_system:
Request System
**************
@@ -9,49 +11,55 @@ Request System
Just like other aspects of SimComponent, the request types are not managed centrally for the whole simulation, but instead they are dynamically created and updated based on the nodes, links, and other components that currently exist in the simulation. This is achieved in the following way:
- API
When requesting an action within the simulation, these two arguments must be provided:
When requesting an action within the simulation, these two arguments must be provided:
1. ``request`` - selects which action you want to take on this ``SimComponent``. This is formatted as a list of strings such as ``['network', 'node', '<node-name>', 'service', '<service-name>', 'restart']``.
2. ``context`` - optional extra information that can be used to decide how to process the request. This is formatted as a dictionary. For example, if the request requires authentication, the context can include information about the user that initiated the request to decide if their permissions are sufficient.
1. ``request`` - selects which action you want to take on this ``SimComponent``. This is formatted as a list of strings such as ``['network', 'node', '<node-name>', 'service', '<service-name>', 'restart']``.
2. ``context`` - optional extra information that can be used to decide how to process the request. This is formatted as a dictionary. For example, if the request requires authentication, the context can include information about the user that initiated the request to decide if their permissions are sufficient.
When a request is resolved, it returns a success status, and optional additional data about the request.
When a request is resolved, it returns a success status, and optional additional data about the request.
``status`` can be one of:
``status`` can be one of:
* ``success``: the request was executed
* ``failure``: the request could not be executed
* ``unreachable``: the target for the request was not found
* ``pending``: the request was initiated, but has not finished during this step
* ``success``: the request was executed
* ``failure``: the request could not be executed
* ``unreachable``: the target for the request was not found
* ``pending``: the request was initiated, but has not finished during this step
``data`` can be a dictionary with any arbitrary JSON-like data to describe the outcome of the request.
``data`` can be a dictionary with any arbitrary JSON-like data to describe the outcome of the request.
- ``request`` detail
The request is a list of strings which help specify who should handle the request. The strings in the request list help RequestManagers traverse the 'ownership tree' of SimComponent. The example given above would be handled in the following way:
Requests:
"""""""""
1. ``Simulation`` receives ``['network', 'node', 'computer_1', 'service', 'DNSService', 'restart']``.
The first element of the request is ``network``, therefore it passes the request down to its network.
2. ``Network`` receives ``['node', 'computer_1', 'service', 'DNSService', 'restart']``.
The first element of the request is ``node``, therefore the network looks at the node name and passes the request down to the node with that name.
3. ``computer_1`` receives ``['service', 'DNSService', 'restart']``.
The first element of the request is ``service``, therefore the node looks at the service name and passes the rest of the request to the service with that name.
4. ``DNSService`` receives ``['restart']``.
Since ``restart`` is a defined request type in the service's own RequestManager, the service performs a restart.
Request Syntax
---------------
- ``context`` detail
The request is a list of strings which help specify who should handle the request. The strings in the request list help RequestManagers traverse the 'ownership tree' of SimComponent. The example given above would be handled in the following way:
1. ``Simulation`` receives ``['network', 'node', 'computer_1', 'service', 'DNSService', 'restart']``.
The first element of the request is ``network``, therefore it passes the request down to its network.
2. ``Network`` receives ``['node', 'computer_1', 'service', 'DNSService', 'restart']``.
The first element of the request is ``node``, therefore the network looks at the node name and passes the request down to the node with that name.
3. ``computer_1`` receives ``['service', 'DNSService', 'restart']``.
The first element of the request is ``service``, therefore the node looks at the service name and passes the rest of the request to the service with that name.
4. ``DNSService`` receives ``['restart']``.
Since ``restart`` is a defined request type in the service's own RequestManager, the service performs a restart.
- ``context``
The context is not used by any of the currently implemented components or requests.
- Request response
When the simulator receives a request, it returns a response with a success status. The possible statuses are:
Request responses
-----------------
* **success**: The request was received and successfully executed.
* For example, the agent tries to add an ACL rule and specifies correct parameters, and the ACL rule is added successfully.
When the simulator receives a request, it returns a response with a success status. The possible statuses are:
* **failure**: The request was received, but it could not be executed, or it failed while executing.
* For example, the agent tries to execute the ``WebBrowser`` application, but the webpage wasn't retrieved because the DNS server is not setup on the node.
* **success**: The request was received and successfully executed.
* For example, the agent tries to add an acl rule and specifies correct parameters, and the acl rule is added successfully.
* **unreachable**: The request was sent to a simulation component that does not exist.
* For example, the agent tries to scan a file that has not been created yet.
* **failure**: The request was received, but it could not be executed, or it failed while executing.
* For example, the agent tries to execute the ``web-browser`` application, but the webpage wasn't retrieved because the DNS server is not setup on the node.
* **unreachable**: The request was sent to a simulation component that does not exist.
* For example, the agent tries to scan a file that has not been created yet.
For more information, please refer to the ``Requests-and-Responses.ipynb`` jupyter notebook
@@ -70,17 +78,26 @@ The ``RequestType`` object stores a reference to a method that executes the requ
The ``RequestManager`` object stores a mapping between strings and request types. It is responsible for processing the request and passing it down the ownership tree. Technically, the ``RequestManager`` is itself a callable that accepts `request, context` tuple, and so it can be chained with other request managers.
A simple example without chaining can be seen in the :py:class:`primaite.simulator.file_system.file_system.File` class.
A simple example without chaining can be seen in the :py:class:`primaite.simulator.file_system.file_systemfile_system_item_abc.FileSystemItemABC` class.
.. code-block:: python
class File(FileSystemItemABC):
class FileSystemItemABC(SimComponent):
...
def _init_request_manager(self):
...
request_manager.add_request("scan", RequestType(func=lambda request, context: RequestResponse.from_bool(self.scan())))
request_manager.add_request("repair", RequestType(func=lambda request, context: RequestResponse.from_bool(self.repair())))
request_manager.add_request("restore", RequestType(func=lambda request, context: RequestResponse.from_bool(self.restore())))
rm.add_request(
name="scan", request_type=RequestType(func=lambda request, context: RequestResponse.from_bool(self.scan()))
)
rm.add_request(
name="checkhash",
request_type=RequestType(func=lambda request, context: RequestResponse.from_bool(self.check_hash())),
)
rm.add_request(
name="repair",
request_type=RequestType(func=lambda request, context: RequestResponse.from_bool(self.repair())),
)
...
*ellipses (``...``) used to omit code impertinent to this explanation*
@@ -95,27 +112,18 @@ An example of how this works is in the :py:class:`primaite.simulator.network.har
.. code-block:: python
class Node(SimComponent):
class Node(SimComponent, ABC):
...
def _init_request_manager(self):
def _init_request_manager(self) -> RequestManager:
...
# a regular action which is processed by the Node itself
request_manager.add_request("turn_on", RequestType(func=lambda request, context: self.turn_on()))
# if the Node receives a request where the first word is 'service', it will use a dummy manager
# called self._service_request_manager to pass on the request to the relevant service. This dummy
# manager is simply here to map the service name that that service's own action manager. This is
# done because the next string after "service" is always the name of that service, so we need an
# RequestManager to pop that string before sending it onto the relevant service's RequestManager.
# since there are potentially many services, create an request manager that can map service name
self._service_request_manager = RequestManager()
request_manager.add_request("service", RequestType(func=self._service_request_manager))
...
rm.add_request("service", RequestType(func=self._service_request_manager, validator=_node_is_on))
self._nic_request_manager = RequestManager()
rm.add_request("network_interface", RequestType(func=self._nic_request_manager, validator=_node_is_on))
rm.add_request("file_system", RequestType(func=self.file_system._request_manager, validator=_node_is_on))
def install_service(self, service):
self.services[service.name] = service
...
# Here, the service name is registered to allow passing actions between the node and the service.
self._service_request_manager.add_request(service.name, RequestType(func=service._request_manager))
This process is repeated until the request word corresponds to a callable function rather than another ``RequestManager`` .
@@ -134,3 +142,8 @@ The :py:class:`primaite.interface.request.RequestResponse<RequestResponse>` carr
For instance, the ``execute`` action on a :py:class:`primaite.simulator.system.applications.web_browser.WebBrowser<WebBrowser>` calls the ``get_webpage()`` method. ``get_webpage()`` returns a True if the webpage was successfully retrieved, and False if unsuccessful for any reason, such as being blocked by an ACL, or if the database server is unresponsive. The boolean returned from ``get_webpage()`` is used to create the request response with ``from_bool()``.
Just as the requests themselves were passed from owner to component, the request response is bubbled back up from component to owner until it arrives at the game layer.
Example notebooks
-----------------
Further examples of the request system and be found in ``Requests-and-Responses.ipynb``
and ``Terminal-Processing.ipynb`` notebooks.

128
docs/source/rewards.rst Normal file
View File

@@ -0,0 +1,128 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _Rewards:
Rewards
#######
Rewards in PrimAITE are based on a system of individual components that react to events in the simulation. An agent's reward function is calculated as the weighted sum of several reward components.
Some rewards, such as the ``green-admin-database-unreachable-penalty``, can be marked as 'sticky' in their configuration. Setting this to ``True`` will mean that they continue to output the same value after an event until another event of that type.
In the instance of the ``green-admin-database-unreachable-penalty``, the database admin reward will stay negative until the next successful database request is made, even if the database admin agents do nothing and the database returns a good state.
Components
**********
The following API pages describe the use of each reward component and the possible configuration options. An example of configuring each via yaml is also provided.
:py:class:`primaite.game.agent.rewards.DummyReward`
.. code-block:: yaml
agents:
- ref: agent_name
# ...
reward_function:
reward_components:
- type: dummy
weight: 1.0
:py:class:`primaite.game.agent.rewards.DatabaseFileIntegrity`
.. code-block:: yaml
agents:
- ref: agent_name
# ...
reward_function:
reward_components:
- type: database-file-integrity
weight: 1.0
options:
node_hostname: server_1
folder_name: database
file_name: database.db
:py:class:`primaite.game.agent.rewards.WebServer404Penalty`
.. code-block:: yaml
agents:
- ref: agent_name
# ...
reward_function:
reward_components:
- type: web-server-404-penalty
node_hostname: web_server
weight: 1.0
options:
service_name: WebService
sticky: false
:py:class:`primaite.game.agent.rewards.WebpageUnavailablePenalty`
.. code-block:: yaml
agents:
- ref: agent_name
# ...
reward_function:
reward_components:
- type: webpage-unavailable-penalty
node_hostname: computer_1
weight: 1.0
options:
sticky: false
:py:class:`primaite.game.agent.rewards.GreenAdminDatabaseUnreachablePenalty`
.. code-block:: yaml
agents:
- ref: agent_name
# ...
reward_function:
reward_components:
- type: green-admin-database-unreachable-penalty
weight: 1.0
options:
node_hostname: admin_pc_1
sticky: false
:py:class:`primaite.game.agent.rewards.SharedReward`
.. code-block:: yaml
agents:
- ref: scripted_agent
# ...
- ref: agent_name
# ...
reward_function:
reward_components:
- type: shared-reward
weight: 1.0
options:
agent_name: scripted_agent
:py:class:`primaite.game.agent.rewards.ActionPenalty`
.. code-block:: yaml
agents:
- ref: agent_name
# ...
reward_function:
reward_components:
- type: action-penalty
weight: 1.0
options:
action_penalty: -0.3
do_nothing_penalty: 0.0

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
Simulation
@@ -27,6 +27,7 @@ Contents
simulation_components/network/nodes/firewall
simulation_components/network/switch
simulation_components/network/network
simulation_components/network/airspace
simulation_components/system/internal_frame_processing
simulation_components/system/sys_log
simulation_components/system/pcap

View File

@@ -0,0 +1,42 @@
.. only:: comment
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _airspace:
AirSpace
========
1. Introduction
---------------
The AirSpace class is the central component for wireless networks in PrimAITE and is designed to model and manage the behavior and interactions of wireless network interfaces within a simulated wireless network environment. This documentation provides a detailed overview of the AirSpace class, its components, and how they interact to create a realistic simulation of wireless network dynamics.
2. Overview of the AirSpace System
----------------------------------
The AirSpace is a virtual representation of a physical wireless environment, managing multiple wireless network interfaces that simulate devices connected to the wireless network. These interfaces communicate over radio frequencies, with their interactions influenced by various factors modeled within the AirSpace.
2.1 Key Components
^^^^^^^^^^^^^^^^^^
- **Wireless Network Interfaces**: Representations of network interfaces connected physical devices like routers, computers, or IoT devices that can send and receive data wirelessly.
- **Bandwidth Management**: Tracks data transmission over frequencies to prevent overloading and simulate real-world network congestion.
3. Managing Wireless Network Interfaces
---------------------------------------
- Interfaces can be dynamically added or removed.
- Configurations can be changed in real-time.
- The AirSpace handles data transmissions, ensuring data sent by an interface is received by all other interfaces on the same frequency.
4. AirSpace Inspection
----------------------
The AirSpace class provides methods for visualizing network behavior:
- ``show_wireless_interfaces()``: Displays current state of all interfaces
- ``show_bandwidth_load()``: Shows bandwidth utilisation

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
#############
Base Hardware
@@ -21,6 +21,9 @@ The key elements defined in ``base.py`` are:
``Node``
========
.. _node_description:
The Node class stands as a central component in ``base.py``, acting as the superclass for all network nodes within a
PrimAITE simulation.
@@ -42,7 +45,7 @@ Example code where a node is turned on:
from primaite.simulator.network.hardware.base import Node
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
node = Node(hostname="pc_a")
node = Node(config={"hostname":"pc_a"})
assert node.operating_state is NodeOperatingState.OFF # By default, node is instantiated in an OFF state
@@ -65,7 +68,7 @@ If the node needs to be instantiated in an on state:
from primaite.simulator.network.hardware.base import Node
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
node = Node(hostname="pc_a", operating_state=NodeOperatingState.ON)
node = Node(config={"hostname":"pc_a", "operating_state":NodeOperatingState.ON})
assert node.operating_state is NodeOperatingState.ON # node is in ON state
@@ -76,7 +79,7 @@ Setting ``start_up_duration`` and/or ``shut_down_duration`` to ``0`` will allow
from primaite.simulator.network.hardware.base import Node
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
node = Node(hostname="pc_a", start_up_duration=0, shut_down_duration=0)
node = Node(config={"hostname":"pc_a", "start_up_duration":0, "shut_down_duration":0})
assert node.operating_state is NodeOperatingState.OFF # node is in OFF state
@@ -97,8 +100,8 @@ Node Behaviours/Functions
- **receive_frame()**: Handles the processing of incoming network frames.
- **apply_timestep()**: Advances the state of the node according to the simulation timestep.
- **power_on()**: Initiates the node, enabling all connected Network Interfaces and starting all Services and
Applications, taking into account the `start_up_duration`.
- **power_off()**: Stops the node's operations, adhering to the `shut_down_duration`.
Applications, taking into account the ``start_up_duration``.
- **power_off()**: Stops the node's operations, adhering to the ``shut_down_duration``.
- **ping()**: Sends ICMP echo requests to a specified IP address to test connectivity.
- **has_enabled_network_interface()**: Checks if the node has any network interfaces enabled, facilitating network
communication.
@@ -109,3 +112,207 @@ Node Behaviours/Functions
The Node class handles installation of system software, network connectivity, frame processing, system logging, and
power states. It establishes baseline functionality while allowing subclassing to model specific node types like hosts,
routers, firewalls etc. The flexible architecture enables composing complex network topologies.
User, UserManager, and UserSessionManager
=========================================
The ``base.py`` module also includes essential classes for managing users and their sessions within the PrimAITE
simulation. These are the ``User``, ``UserManager``, and ``UserSessionManager`` classes. The base ``Node`` class comes
with ``UserManager``, and ``UserSessionManager`` classes pre-installed.
User Class
----------
The ``User`` class represents a user in the system. It includes attributes such as ``username``, ``password``,
``disabled``, and ``is_admin`` to define the user's credentials and status.
Example Usage
^^^^^^^^^^^^^
Creating a user:
.. code-block:: python
user = User(username="john_doe", password="12345")
UserManager Class
-----------------
The ``UserManager`` class handles user management tasks such as creating users, authenticating them, changing passwords,
and enabling or disabling user accounts. It maintains a dictionary of users and provides methods to manage them
effectively.
Example Usage
^^^^^^^^^^^^^
Creating a ``UserManager`` instance and adding a user:
.. code-block:: python
user_manager = UserManager()
user_manager.add_user(username="john_doe", password="12345")
Authenticating a user:
.. code-block:: python
user = user_manager.authenticate_user(username="john_doe", password="12345")
UserSessionManager Class
------------------------
The ``UserSessionManager`` class manages user sessions, including local and remote sessions. It handles session creation,
timeouts, and provides methods for logging users in and out.
Example Usage
^^^^^^^^^^^^^
Creating a ``UserSessionManager`` instance and logging a user in locally:
.. code-block:: python
session_manager = UserSessionManager()
session_id = session_manager.local_login(username="john_doe", password="12345")
Logging a user out:
.. code-block:: python
session_manager.local_logout()
Practical Examples
------------------
Below are unit tests which act as practical examples illustrating how to use the ``User``, ``UserManager``, and
``UserSessionManager`` classes within the context of a client-server network simulation.
Setting up a Client-Server Network
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
from typing import Tuple
from uuid import uuid4
import pytest
from primaite.simulator.network.container import Network
from primaite.simulator.network.hardware.nodes.host.computer import Computer
from primaite.simulator.network.hardware.nodes.host.server import Server
@pytest.fixture(scope="function")
def client_server_network() -> Tuple[Computer, Server, Network]:
network = Network()
client = Computer(config={
"hostname":"client",
"ip_address":"192.168.1.2",
"subnet_mask":"255.255.255.0",
"default_gateway":"192.168.1.1",
"start_up_duration":0,
}
)
client.power_on()
server = Server(config = {
"hostname":"server",
"ip_address":"192.168.1.3",
"subnet_mask":"255.255.255.0",
"default_gateway":"192.168.1.1",
"start_up_duration":0,
}
)
server.power_on()
network.connect(client.network_interface[1], server.network_interface[1])
return client, server, network
Local Login Success
^^^^^^^^^^^^^^^^^^^
.. code-block:: python
def test_local_login_success(client_server_network):
client, server, network = client_server_network
assert not client.user_session_manager.local_user_logged_in
client.user_session_manager.local_login(username="admin", password="admin")
assert client.user_session_manager.local_user_logged_in
Local Login Failure
^^^^^^^^^^^^^^^^^^^
.. code-block:: python
def test_local_login_failure(client_server_network):
client, server, network = client_server_network
assert not client.user_session_manager.local_user_logged_in
client.user_session_manager.local_login(username="jane.doe", password="12345")
assert not client.user_session_manager.local_user_logged_in
Adding a New User and Successful Local Login
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
def test_new_user_local_login_success(client_server_network):
client, server, network = client_server_network
assert not client.user_session_manager.local_user_logged_in
client.user_manager.add_user(username="jane.doe", password="12345")
client.user_session_manager.local_login(username="jane.doe", password="12345")
assert client.user_session_manager.local_user_logged_in
Clearing Previous Login on New Local Login
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
def test_new_local_login_clears_previous_login(client_server_network):
client, server, network = client_server_network
assert not client.user_session_manager.local_user_logged_in
current_session_id = client.user_session_manager.local_login(username="admin", password="admin")
assert client.user_session_manager.local_user_logged_in
assert client.user_session_manager.local_session.user.username == "admin"
client.user_manager.add_user(username="jane.doe", password="12345")
new_session_id = client.user_session_manager.local_login(username="jane.doe", password="12345")
assert client.user_session_manager.local_user_logged_in
assert client.user_session_manager.local_session.user.username == "jane.doe"
assert new_session_id != current_session_id
Persistent Login for the Same User
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
def test_new_local_login_attempt_same_uses_persists(client_server_network):
client, server, network = client_server_network
assert not client.user_session_manager.local_user_logged_in
current_session_id = client.user_session_manager.local_login(username="admin", password="admin")
assert client.user_session_manager.local_user_logged_in
assert client.user_session_manager.local_session.user.username == "admin"
new_session_id = client.user_session_manager.local_login(username="admin", password="admin")
assert client.user_session_manager.local_user_logged_in
assert client.user_session_manager.local_session.user.username == "admin"
assert new_session_id == current_session_id

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
.. _network:
@@ -48,7 +48,7 @@ we'll use the following Network that has a client, server, two switches, and a r
.. code-block:: python
router_1 = Router(hostname="router_1", num_ports=3)
router_1 = Router(config={"hostname":"router_1", "num_ports":3})
router_1.power_on()
router_1.configure_port(port=1, ip_address="192.168.1.1", subnet_mask="255.255.255.0")
router_1.configure_port(port=2, ip_address="192.168.2.1", subnet_mask="255.255.255.0")
@@ -57,9 +57,9 @@ we'll use the following Network that has a client, server, two switches, and a r
.. code-block:: python
switch_1 = Switch(hostname="switch_1", num_ports=6)
switch_1 = Switch(config={"hostname":"switch_1", "num_ports":6})
switch_1.power_on()
switch_2 = Switch(hostname="switch_2", num_ports=6)
switch_2 = Switch(config={"hostname":"switch_2", "num_ports":6})
switch_2.power_on()
5. Connect the Switches to the Router
@@ -75,18 +75,20 @@ we'll use the following Network that has a client, server, two switches, and a r
.. code-block:: python
client_1 = Computer(
hostname="client_1",
ip_address="192.168.2.2",
subnet_mask="255.255.255.0",
default_gateway="192.168.2.1"
client_1 = Computer(config = {
"hostname":"client_1",
"ip_address":"192.168.2.2",
"subnet_mask":"255.255.255.0",
"default_gateway":"192.168.2.1",
}
)
client_1.power_on()
server_1 = Server(
hostname="server_1",
ip_address="192.168.1.2",
subnet_mask="255.255.255.0",
default_gateway="192.168.1.1"
server_1 = Server(config= {
"hostname":"server_1",
"ip_address":"192.168.1.2",
"subnet_mask":"255.255.255.0",
"default_gateway":"192.168.1.1",
}
)
server_1.power_on()
@@ -97,19 +99,19 @@ we'll use the following Network that has a client, server, two switches, and a r
network.connect(endpoint_a=switch_2.network_interface[1], endpoint_b=client_1.network_interface[1])
network.connect(endpoint_a=switch_1.network_interface[1], endpoint_b=server_1.network_interface[1])
8. Add ACL rules on the Router to allow ARP and ICMP traffic.
8. Add an ACL rule on the Router to allow ICMP traffic.
.. code-block:: python
router_1.acl.add_rule(
action=ACLAction.PERMIT,
src_port=Port.ARP,
dst_port=Port.ARP,
src_port=PORT_LOOKUP["ARP"],
dst_port=PORT_LOOKUP["ARP"],
position=22
)
router_1.acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.ICMP,
protocol=PROTOCOL_LOOKUP["ICMP"],
position=23
)

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
#################################
Network Interface Hierarchy Model

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
########
Firewall
@@ -156,8 +156,8 @@ To prevent all external traffic from accessing the internal network, with except
# Exception rule to allow HTTP traffic from external to internal network
firewall.internal_inbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
dst_port=Port.HTTP,
protocol=PROTOCOL_LOOKUP["TCP"],
dst_port=PORT_LOOKUP["HTTP"],
dst_ip_address="192.168.1.0",
dst_wildcard_mask="0.0.0.255",
position=2
@@ -172,16 +172,16 @@ To enable external traffic to access specific services hosted within the DMZ:
# Allow HTTP and HTTPS traffic to the DMZ
firewall.dmz_inbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
dst_port=Port.HTTP,
protocol=PROTOCOL_LOOKUP["TCP"],
dst_port=PORT_LOOKUP["HTTP"],
dst_ip_address="172.16.0.0",
dst_wildcard_mask="0.0.0.255",
position=3
)
firewall.dmz_inbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
dst_port=Port.HTTPS,
protocol=PROTOCOL_LOOKUP["TCP"],
dst_port=PORT_LOOKUP["HTTPS"],
dst_ip_address="172.16.0.0",
dst_wildcard_mask="0.0.0.255",
position=4
@@ -196,9 +196,9 @@ To permit SSH access from a designated external IP to a specific server within t
# Allow SSH from a specific external IP to an internal server
firewall.internal_inbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
protocol=PROTOCOL_LOOKUP["TCP"],
src_ip_address="10.0.0.2",
dst_port=Port.SSH,
dst_port=PORT_LOOKUP["SSH"],
dst_ip_address="192.168.1.10",
position=5
)
@@ -212,9 +212,9 @@ To limit database server access to selected external IP addresses:
# Allow PostgreSQL traffic from an authorized external IP to the internal DB server
firewall.internal_inbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
protocol=PROTOCOL_LOOKUP["TCP"],
src_ip_address="10.0.0.3",
dst_port=Port.POSTGRES_SERVER,
dst_port=PORT_LOOKUP["POSTGRES_SERVER"],
dst_ip_address="192.168.1.20",
position=6
)
@@ -222,8 +222,8 @@ To limit database server access to selected external IP addresses:
# Deny all other PostgreSQL traffic from external sources
firewall.internal_inbound_acl.add_rule(
action=ACLAction.DENY,
protocol=IPProtocol.TCP,
dst_port=Port.POSTGRES_SERVER,
protocol=PROTOCOL_LOOKUP["TCP"],
dst_port=PORT_LOOKUP["POSTGRES_SERVER"],
dst_ip_address="192.168.1.0",
dst_wildcard_mask="0.0.0.255",
position=7
@@ -247,15 +247,15 @@ To authorize HTTP/HTTPS access to a DMZ-hosted web server, excluding known malic
# Allow HTTP/HTTPS traffic to the DMZ web server
firewall.dmz_inbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
dst_port=Port.HTTP,
protocol=PROTOCOL_LOOKUP["TCP"],
dst_port=PORT_LOOKUP["HTTP"],
dst_ip_address="172.16.0.2",
position=9
)
firewall.dmz_inbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
dst_port=Port.HTTPS,
protocol=PROTOCOL_LOOKUP["TCP"],
dst_port=PORT_LOOKUP["HTTPS"],
dst_ip_address="172.16.0.2",
position=10
)
@@ -269,9 +269,9 @@ To facilitate restricted access from the internal network to DMZ-hosted services
# Permit specific internal application server HTTPS access to a DMZ-hosted API
firewall.internal_outbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
protocol=PROTOCOL_LOOKUP["TCP"],
src_ip_address="192.168.1.30", # Internal application server IP
dst_port=Port.HTTPS,
dst_port=PORT_LOOKUP["HTTPS"],
dst_ip_address="172.16.0.3", # DMZ API server IP
position=11
)
@@ -289,9 +289,9 @@ To facilitate restricted access from the internal network to DMZ-hosted services
# Corresponding rule in DMZ inbound ACL to allow the traffic from the specific internal server
firewall.dmz_inbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
protocol=PROTOCOL_LOOKUP["TCP"],
src_ip_address="192.168.1.30", # Ensuring this specific source is allowed
dst_port=Port.HTTPS,
dst_port=PORT_LOOKUP["HTTPS"],
dst_ip_address="172.16.0.3", # DMZ API server IP
position=13
)
@@ -301,7 +301,7 @@ To facilitate restricted access from the internal network to DMZ-hosted services
action=ACLAction.DENY,
src_ip_address="192.168.1.0",
src_wildcard_mask="0.0.0.255",
dst_port=Port.HTTPS,
dst_port=PORT_LOOKUP["HTTPS"],
dst_ip_address="172.16.0.3", # DMZ API server IP
position=14
)
@@ -315,8 +315,8 @@ To block all SSH access attempts from the external network:
# Deny all SSH traffic from any external source
firewall.external_inbound_acl.add_rule(
action=ACLAction.DENY,
protocol=IPProtocol.TCP,
dst_port=Port.SSH,
protocol=PROTOCOL_LOOKUP["TCP"],
dst_port=PORT_LOOKUP["SSH"],
position=1
)
@@ -329,8 +329,8 @@ To allow the internal network to initiate HTTP connections to the external netwo
# Permit outgoing HTTP traffic from the internal network to any external destination
firewall.external_outbound_acl.add_rule(
action=ACLAction.PERMIT,
protocol=IPProtocol.TCP,
dst_port=Port.HTTP,
protocol=PROTOCOL_LOOKUP["TCP"],
dst_port=PORT_LOOKUP["HTTP"],
position=2
)

View File

@@ -1,6 +1,6 @@
.. only:: comment
© Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
© Crown-owned copyright 2025, Defence Science and Technology Laboratory UK
#########
@@ -49,3 +49,5 @@ fundamental network operations:
5. **NTP (Network Time Protocol) Client:** Synchronises the host's clock with network time servers.
6. **Web Browser:** A simulated application that allows the host to request and display web content.
7. **Terminal:** A simulated service that allows the host to connect to remote hosts and execute commands.

Some files were not shown because too many files have changed in this diff Show More