diff --git a/garak/command.py b/garak/command.py index 441154796..0e2b26db3 100644 --- a/garak/command.py +++ b/garak/command.py @@ -131,12 +131,12 @@ def print_buffs(): def plugin_info(plugin_name): import inspect - from garak._plugins import enumerate_plugins, load_plugin + from garak._plugins import load_plugin # load plugin try: plugin = load_plugin(plugin_name) - print(f"Info on {plugin_name}:") + print(f"Configured info on {plugin_name}:") priority_fields = ["description"] skip_fields = ["prompts", "triggers"] # print the attribs it has @@ -195,14 +195,6 @@ def list_config(): print("_config:") _enumerate_obj_values(_config) - print("system:") - _enumerate_obj_values(_config.system) - - print("transient:") - _enumerate_obj_values(_config.transient) - - print("run:") - _enumerate_obj_values(_config.run) - - print("plugins:") - _enumerate_obj_values(_config.plugins) + for section in "system transient run plugins".split(): + print(f"{section}:") + _enumerate_obj_values(getattr(_config, section)) diff --git a/garak/generators/rest.py b/garak/generators/rest.py index 47ce341fa..64a6caa23 100644 --- a/garak/generators/rest.py +++ b/garak/generators/rest.py @@ -29,7 +29,7 @@ class RESTRateLimitError(Exception): class RestGenerator(Generator): """Generic API interface for REST models - Uses the following options from _config.run.generator_options: + Uses the following options from _config.run.generators["rest"]: * uri - (optional) the URI of the REST endpoint; this can also be passed in --model_name * name - a short name for this service; defaults to the uri @@ -63,18 +63,20 @@ class RestGenerator(Generator): and response value are both under the "text" key, we'd define the service using something like: - { - "name": "example service", - "uri": "https://example.ai/llm", - "method": "post", - "headers":{ - "X-Authorization": "$KEY", - }, - "req_template_json_object":{ - "text":"$INPUT" - }, - "response_json": true, - "response_json_field": "text" + {"rest.RestGenerator": + { + "name": "example service", + "uri": "https://example.ai/llm", + "method": "post", + "headers":{ + "X-Authorization": "$KEY", + }, + "req_template_json_object":{ + "text":"$INPUT" + }, + "response_json": true, + "response_json_field": "text" + } } To use this specification with garak, you can either pass the JSON as a @@ -110,7 +112,7 @@ def __init__(self, uri=None, generations=10): self.retry_5xx = True self.key_env_var = "REST_API_KEY" - if "generator_options" in dir(_config.plugins): + if "rest" in dir(_config.plugins.generators): for field in ( "name", "uri", @@ -122,19 +124,19 @@ def __init__(self, uri=None, generations=10): "response_timeout", "ratelimit_codes", ): - if field in _config.plugins.generator_options: - setattr(self, field, _config.plugins.generator_options[field]) + if field in _config.plugins.generators["rest"]: + setattr(self, field, _config.plugins.generator["rest"][field]) - if "req_template_json_object" in _config.plugins.generator_options: + if "req_template_json_object" in _config.plugins.generators["rest"]: self.req_template = json.dumps( - _config.plugins.generator_options["req_template_json_object"] + _config.plugins.generators["rest"]["req_template_json_object"] ) if ( self.response_json - and "response_json_field" in _config.plugins.generator_options + and "response_json_field" in _config.plugins.generators["rest"] ): - self.response_json_field = _config.plugins.generator_options[ + self.response_json_field = _config.plugins.generators["rest"][ "response_json_field" ] diff --git a/garak/probes/encoding.py b/garak/probes/encoding.py index da33a8297..cc317c899 100644 --- a/garak/probes/encoding.py +++ b/garak/probes/encoding.py @@ -67,12 +67,12 @@ def load_payloads(): payloads = [] if _config.plugins.probe_options: - if "encoding.payloads" in _config.plugins.probe_options: - if isinstance(_config.plugins.probe_options["encoding.payloads"], str): - _config.plugins.probe_options["encoding.payloads"] = [ - _config.plugins.probe_options["encoding.payloads"] + if "encoding" in _config.plugins.probes: + if isinstance(_config.plugins.probes["encoding"]["payloads"], str): + _config.plugins.probes["encoding"]["payloads"] = [ + _config.plugins.probes["encoding"]["payloads"] ] - for payload_class in _config.plugins.probe_options["encoding.payloads"]: + for payload_class in _config.plugins.probes["encoding"]["payloads"]: if payload_class in payload_library: payloads += payload_library[payload_class]