Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
Adds support for Wazuh Manager and Agent
Browse files Browse the repository at this point in the history
The commit adds support for two new solutions, Wazuh Manager and
Agent.

Besides this, it modifies the configuration printing in the CLI
module and solves some typos.

Resolves: #14

Signed-off-by: George-Andrei Iosif <[email protected]>
  • Loading branch information
iosifache committed Jun 13, 2022
1 parent 8266a87 commit 9b29508
Show file tree
Hide file tree
Showing 9 changed files with 752 additions and 9 deletions.
5 changes: 5 additions & 0 deletions mutablesecurity/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ def _print_module_help(ctx, solution):
possible_values = ", ".join([value.name for value in details["type"]])
required_type = "str"

if read_only := details.get("read_only", False):
required_type += ", read-only"
elif not details["default"]:
required_type += ", mandatory"

table.add_row(key, required_type, possible_values, details["help"])

# Create the text
Expand Down
4 changes: 4 additions & 0 deletions mutablesecurity/modules/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ class MandatoryAspectLeftUnsetException(MutableSecurityException):

class SameSetConfigurationValue(MutableSecurityException):
"""The value set in the configuration is the same with the old one."""


class OperationNotSupported(MutableSecurityException):
"""The operation is not supported at the moment."""
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _check_installation_config(state, host, solution_class):
configuration_meta = solution_class.meta["configuration"]
for key, _ in configuration_meta.items():
# Check the default aspects to be set
if not solution_class._configuration[key]:
if solution_class._configuration[key] is None:
raise MandatoryAspectLeftUnsetException()

return True
Expand Down Expand Up @@ -63,11 +63,12 @@ def process(self, output):
continue

# Convert to the real type
real_type = value["type"]
try:
config[key] = real_type(config[key])
except:
config[key] = real_type[config[key]]
if config[key] is not None:
real_type = value["type"]
try:
config[key] = real_type(config[key])
except:
config[key] = real_type[config[key]]

return config

Expand Down
9 changes: 9 additions & 0 deletions mutablesecurity/modules/solutions_manager/facts/services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pyinfra.api import FactBase


class ServiceRunning(FactBase):
def command(self, service_name):
return "systemctl show -p SubState --value " + service_name

def process(self, output):
return output[0] == "running"
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ class AvailableSolution(Enum):
SURICATA = ("suricata", "Suricata")
TELER = ("teler", "Teler")
LETS_ENCRYPT = ("lets_encrypt", "LetsEncrypt")
WAZUH_MANAGER = ("wazuh_manager", "WazuhManager")
WAZUH_AGENT = ("wazuh_agent", "WazuhAgent")
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def install(state, host):
state=state,
host=host,
sudo=True,
name="Updates the apt reporisoties",
name="Updates the apt repositories",
env={"LC_TIME": "en_US.UTF-8"},
cache_time=3600,
success_exit_codes=[0, 100],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def install(state, host):
state=state,
host=host,
sudo=True,
name="Updates the apt reporisoties",
name="Updates the apt repositories",
env={"LC_TIME": "en_US.UTF-8"},
cache_time=3600,
success_exit_codes=[0, 100],
Expand All @@ -239,7 +239,7 @@ def install(state, host):
state=state,
host=host,
sudo=True,
name="Updates the apt reporisoties",
name="Updates the apt repositories",
cache_time=3600,
success_exit_codes=[0, 100],
)
Expand Down
Loading

0 comments on commit 9b29508

Please sign in to comment.