fix(cli config):

This commit is contained in:
Alexander Myasoedov committed 2025-01-04 19:40:56 +02:00
1 parent 64f7f4b2d5
commit 7a7ee4f0de
2 files changed
+28 -7

No files matched your search

+4 -2
View File
@@ -33,12 +33,14 @@ class CLI:
sys.path.append(os.path.dirname(".")) sys.path.append(os.path.dirname("."))
AgenticSecurity().entrypoint() AgenticSecurity().entrypoint()
def init(self): def init(self, host: str = "0.0.0.0", port: int = 8718):
""" """
Generate the default CI configuration file. Generate the default CI configuration file.
""" """
sys.path.append(os.path.dirname(".")) sys.path.append(os.path.dirname("."))
AgenticSecurity().generate_default_cfg() AgenticSecurity().generate_default_cfg(host, port)
i = init
def main(): def main():
+24 -5
View File
@@ -254,16 +254,31 @@ class AgenticSecurity(CfgMixin):
exit(1) exit(1)
self.load_config(self.default_path) self.load_config(self.default_path)
print(f"Configuration: {self.config}") logger.info("Configuration loaded successfully.")
print(self.config)
datasets = list(self.get_config_value("modules").values())
for d in datasets:
d["selected"] = True
self.scan(
llmSpec=self.get_config_value("general.llmSpec"),
maxBudget=self.get_config_value("general.maxBudget"),
datasets=datasets,
max_th=self.get_config_value("general.max_th"),
optimize=self.get_config_value("general.optimize"),
enableMultiStepAttack=self.get_config_value(
"general.enableMultiStepAttack"
),
)
def generate_default_cfg(self): def generate_default_cfg(self, host: str = "0.0.0.0", port: int = 8718):
# Accept host / port as parameters
with open(self.default_path, "w") as f: with open(self.default_path, "w") as f:
f.write( f.write(
""" """
[general] [general]
# General configuration for the security scan # General configuration for the security scan
llmSpec = \""" llmSpec = \"""
POST http://0.0.0.0:9094/v1/self-probe POST http://$HOST:$PORT/v1/self-probe
Authorization: Bearer XXXXX Authorization: Bearer XXXXX
Content-Type: application/json Content-Type: application/json
@@ -279,7 +294,7 @@ enableMultiStepAttack = false # Enable multi-step attack simulations
[modules.AgenticBackend] [modules.AgenticBackend]
dataset_name = "AgenticBackend" dataset_name = "AgenticBackend"
[modules.AgenticBackend.opts] [modules.AgenticBackend.opts]
port = 9094 port = $PORT
modules = ["encoding"] modules = ["encoding"]
[thresholds] [thresholds]
@@ -289,7 +304,11 @@ medium = 0.3
high = 0.5 high = 0.5
""" """.replace(
"$HOST", host
).replace(
"$PORT", str(port)
)
) )
logger.info( logger.info(