Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
91e93a1
Add safer and more intuitive key generation for Iris
d-strat Feb 28, 2025
d21cc6a
Merge branch 'stratosphereips:develop' into develop
d-strat Mar 5, 2025
14338b9
Merge remote-tracking branch 'upstream/develop' into develop
d-strat Mar 10, 2025
53b8dc4
Merge remote-tracking branch 'origin/develop' into develop
d-strat Mar 10, 2025
89ca6fe
More automation of Iris configuration
d-strat Mar 11, 2025
7f4bb2c
Merge remote-tracking branch 'upstream/develop' into develop
d-strat Mar 20, 2025
00aa370
Testing improvements
d-strat Mar 20, 2025
5065a91
Add bootstrapping mode
d-strat Mar 25, 2025
13f0054
Fix mocking for test of Slips
d-strat Mar 25, 2025
3ae02ed
Fix mocking for test of Slips by splitting the bootstrap config into …
d-strat Mar 25, 2025
422a71f
Fix typo in ProcessManager reading config
d-strat Mar 25, 2025
cec16d4
Rerun tests
d-strat Mar 25, 2025
64a1a96
Add documentation for bootstrapping mode
d-strat Mar 25, 2025
04b7062
Fix a typo
d-strat Mar 31, 2025
7e6c0de
Add global P2P bootstrapping through melchior.slips.stratosphere.fel.…
d-strat Apr 7, 2025
a7edf6b
Fix bootstrapping node address
d-strat Apr 8, 2025
438587e
add test_fides_queues.py and test_fides_bridge.py to unit tests that …
AlyaGomaa Apr 8, 2025
803bb52
move bootrapping node docs to iris_module docs instead of contributin…
AlyaGomaa Apr 8, 2025
1a701bf
Fix list of disabled modules in bootstrapping mode
d-strat Apr 9, 2025
5104070
Merge remote-tracking branch 'origin/develop' into develop
d-strat Apr 9, 2025
a359f70
Solve placement of Bootstrapping module selector
d-strat Apr 9, 2025
b40d34a
add bootstrapping_modules param to slips.yaml
AlyaGomaa Apr 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
- test_idea_format.py
- test_fides_sqlite_db.py
- test_fides_module.py
- test_fides_queues.py
- test_fides_bridge.py

steps:
- uses: actions/checkout@v4
Expand Down
12 changes: 7 additions & 5 deletions config/iris_config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Identity:
GenerateNewKey: true
Server:
port: 9010
Host: 127.0.0.1
DhtServerMode: true
Port: 9010
Host: 192.168.1.220
DhtServerMode: 'true'
Redis:
Host: 127.0.0.1
Port: 6644
Port: 6379
Tl2NlChannel: iris_internal
PeerDiscovery:
DisableBootstrappingNodes: true
DisableBootstrappingNodes: false
ListOfMultiAddresses:
- /dns/melchior.slips.stratosphere.fel.cvut.cz/udp/6437/quic 12D3KooWJJa9PpMFVP7s3TQs2sedypJXxtMVkphRhgkjGH9EYMfM
3 changes: 2 additions & 1 deletion config/slips.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,9 @@ global_p2p:
# this is the global p2p's trust model + global P2P
# network handler combination. can only be enabled when
# running slips on an interface
use_global_p2p: False
use_global_p2p: True
Comment thread
d-strat marked this conversation as resolved.
Outdated
iris_conf: config/iris_config.yaml
bootstrapping_node: False

#############################
local_p2p:
Expand Down
6 changes: 6 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,9 @@ For more details, the code [here](https://github.com/stratosphereips/fides/tree/


Implementations of Fides_Module-network-communication can be found in ```modules/fidesModule/messaging/network_bridge.py```.

### Bootstrapping node
The Slips configuration file now has an option of bootstrapping-node mode.
The bootstrapping functionality for the global P2P network under Iris is facilitated.
This mode triggers only if Slips is run on an interface or growing zeek log directory mode AND the bootstrapping is set to True in the Slips configurations file AND GlobalP2P mode is allowed.
When the bootstrapping mode is used, Slips runs with a subset of nodes that are selected by names (currently Fides and Iris).
32 changes: 30 additions & 2 deletions managers/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
)
import multiprocessing

from scipy.stats import bootstrap

import modules
from modules.update_manager.update_manager import UpdateManager
from slips_files.common.slips_utils import utils
Expand Down Expand Up @@ -77,6 +79,9 @@ def read_config(self):
self.modules_to_ignore: list = self.main.conf.get_disabled_modules(
self.main.input_type
)
self.bootstrap_p2p = self.main.conf.is_bootstrapping_node()
self.bootstrapping_modules = self.main.conf.get_bootstrapping_modules()
#self.bootstrap_p2p, self.boootstrapping_modules = self.main.conf.get_bootstrapping_setting()

def start_output_process(self, stderr, slips_logfile, stdout=""):
output_process = Output(
Expand Down Expand Up @@ -210,6 +215,25 @@ def is_ignored_module(self, module_name: str) -> bool:
return True
return False

def is_bootstrapping_module(self, module_name: str) -> bool:
m1 = (
module_name.replace(" ", "")
.replace("_", "")
.replace("-", "")
.lower()
)
for bootstrap_module in self.bootstrapping_modules:
m2 = (
bootstrap_module.replace(" ", "")
.replace("_", "")
.replace("-", "")
.lower()
)

if m1.__contains__(m2):
return True
return False

def is_abstract_module(self, obj) -> bool:
return obj.name in ("IModule", "AsyncModule")

Expand Down Expand Up @@ -241,8 +265,12 @@ def get_modules(self):
if dir_name != file_name:
continue

if self.is_ignored_module(module_name):
continue
if self.bootstrap_p2p: # if bootstrapping the p2p network
if not self.is_bootstrapping_module(module_name): # keep only the bootstrapping-necessary modules
continue
else: # if not bootstrappig mode
if self.is_ignored_module(module_name): # ignore blacklisted modules
continue

# Try to import the module, otherwise skip.
try:
Expand Down
Binary file modified modules/irisModule/iris
Binary file not shown.
12 changes: 11 additions & 1 deletion modules/irisModule/irisModule.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ def _iris_configurator(self, config_path: str, redis_port: int):
"Port": redis_port,
"Tl2NlChannel": "iris_internal",
}
if "Server" in config:
#config["Server"]["Port"] = 9010
config["Server"]["Host"] = self.db.get_host_ip()
config["Server"]["DhtServerMode"] = "true"
else:
config["Redis"] = {
"Port": 6644,
"Host": self.db.get_host_ip(),
"DhtServerMode": "true",
}

# Write the updated configuration back to the file
with open(config_path, "w") as file:
Expand All @@ -79,7 +89,7 @@ def _iris_configurator(self, config_path: str, redis_port: int):
# Catch any other unexpected errors
self.print(f"An unexpected error occurred: {e}")
return None
return config["Server"]["port"]
return config["Server"]["Port"]

def pre_main(self):
"""
Expand Down
13 changes: 13 additions & 0 deletions slips_files/common/parsers/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,3 +722,16 @@ def get_iris_config_location(self) -> str:
return self.read_configuration(
"global_p2p", "iris_conf", "config/iris_config.yaml"
)

def get_bootstrapping_setting(self) -> (bool, list):
return (self.read_configuration("global_p2p", "bootstrapping_node", False) \
and self.read_configuration("global_p2p", "use_global_p2p", False) \
and ("-i" in sys.argv or "-g" in sys.argv), ["fidesModule", "irisModule"])

def is_bootstrapping_node(self) -> bool:
return self.read_configuration("global_p2p", "bootstrapping_node", False) \
and self.read_configuration("global_p2p", "use_global_p2p", False) \
and ("-i" in sys.argv or "-g" in sys.argv)

def get_bootstrapping_modules(self) -> list:
Comment thread
d-strat marked this conversation as resolved.
return ["fidesModule", "irisModule"]
13 changes: 13 additions & 0 deletions tests/integration_tests/test_iris.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def test_messaging(
"PeerDiscovery": {
"ListOfMultiAddresses": [original_conn_string]
},
"Identity": {"KeyFile": "second.priv"}
},
)
# generate a second command for the second peer
Expand Down Expand Up @@ -294,3 +295,15 @@ def test_messaging(
print("Deleting the output directories")
shutil.rmtree(output_dir)
shutil.rmtree(output_dir_peer)
os.remove("modules/irisModule/second.priv")
modify_yaml_config(
input_path="config/iris_config.yaml",
output_dir=os.path.dirname(iris_peer_config_file),
output_filename=os.path.basename(iris_peer_config_file),
changes={
"Redis": {"Port": 6644},
"Server": {"Port": 9010},
"PeerDiscovery": {},
"Identity": {"KeyFile": "private.key"}
},
)
3 changes: 3 additions & 0 deletions tests/module_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ def create_profile_handler_obj(self):
def create_process_manager_obj(self):
main_mock = Mock()
main_mock.conf.get_disabled_modules.return_value = []
#main_mock.conf.get_bootstrapping_setting.return_value = (False, [])
main_mock.conf.is_bootstrapping_node.return_value = False
main_mock.conf.get_bootstrapping_modules.return_value = ["fidesModule", "irisModule"]
main_mock.input_type = "pcap"
main_mock.mode = "normal"
main_mock.stdout = ""
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions tests/test_process_manager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2021 Sebastian Garcia <sebastian.garcia@agents.fel.cvut.cz>
# SPDX-License-Identifier: GPL-2.0-only
import pytest
from unittest.mock import Mock, patch
from unittest.mock import Mock, patch, MagicMock
from managers.process_manager import ProcessManager
from tests.module_factory import ModuleFactory
from slips_files.common.slips_utils import utils
Expand Down Expand Up @@ -286,7 +286,9 @@ def test_is_stop_msg_received(
],
)
def test_is_debugger_active(mock_return_value, expected_result):
process_manager = ProcessManager(Mock())
mock_conf = Mock()
mock_conf.get_bootstrapping_setting.return_value = (False, [])
process_manager = ProcessManager(mock_conf) # This line should now work
with patch("sys.gettrace", return_value=mock_return_value):
assert process_manager.is_debugger_active() == expected_result

Expand Down
Loading