garak

garak._config

This module holds config values.

These are broken into the following major categories:

  • system: options that don’t affect the security assessment

  • run: options that describe how a garak run will be conducted

  • plugins: config for plugins (generators, probes, detectors, buffs)

  • transient: internal values local to a single garak execution

Config values are loaded in the following priority (lowest-first):

  • Plugin defaults in the code

  • Core config: from garak/resources/garak.core.yaml; not to be overridden

  • Site config: from garak/garak.site.yaml

  • Runtime config: from an optional config file specified manually, via e.g. CLI parameter

  • Command-line options

Code

garak global config

class garak._config.BuffManager

Bases: object

class to store instantiated buffs

buffs = []
class garak._config.GarakSubConfig

Bases: object

class garak._config.TransientConfig

Bases: GarakSubConfig

Object to hold transient global config items not set externally

args = None
basedir = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/garak/checkouts/latest/docs/source/../../garak')
hitlogfile = None
report_filename = None
reportfile = None
run_id = None
starttime = None
starttime_iso = None
garak._config.load_base_config() None
garak._config.load_config(site_config_filename='garak.site.yaml', run_config_filename=None) None
garak._config.parse_plugin_spec(spec: str, category: str, probe_tag_filter: str = '') tuple[List[str], List[str]]

garak._plugins

This module manages plugin enumeration and loading. There is one class per plugin in garak. Enumerating the classes, with e.g. --list_probes on the command line, means importing each module. Therefore, modules should do as little as possible on load, and delay intensive activities (like loading classifiers) until a plugin’s class is instantiated.

Code

Functions for working with garak plugins (enumeration, loading, etc)

garak._plugins.configure_plugin(plugin_path: str, plugin: object) object
garak._plugins.enumerate_plugins(category: str = 'probes', skip_base_classes=True) List[tuple[str, bool]]

A function for listing all modules & plugins of the specified kind.

garak’s plugins are organised into four packages - probes, detectors, generators and harnesses. Each package contains a base module defining the core plugin classes. The other modules in the package define classes that inherit from the base module’s classes.

enumerate_plugins() works by first looking at the base module in a package and finding the root classes here; it will then go through the other modules in the package and see which classes can be enumerated from these.

Parameters:

category (str) – the name of the plugin package to be scanned; should be one of probes, detectors, generators, or harnesses.

garak._plugins.load_plugin(path, break_on_fail=True) object

load_plugin takes a path to a plugin class, and attempts to load that class. If successful, it returns an instance of that class.

Parameters:
  • path (str) – The path to the class to be loaded, e.g. “probes.test.Blank”

  • break_on_fail (bool) – Should we raise exceptions if there are problems with the load? (default is True)