Skip to content

Commit

Permalink
expand docs and suppress warnings
Browse files Browse the repository at this point in the history
* expand the docs to note acceptance of file path to CA bundle
* suppress warnings when validation is fully disabled
  • Loading branch information
jmartin-tech committed Jan 16, 2025
1 parent ac2621b commit 5ab903e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/source/garak.generators.rest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Uses the following options from ``_config.plugins.generators["rest.RestGenerator
* ``request_timeout`` - How many seconds should we wait before timing out? Default 20
* ``ratelimit_codes`` - Which endpoint HTTP response codes should be caught as indicative of rate limiting and retried? ``List[int]``, default ``[429]``
* ``skip_codes`` - Which endpoint HTTP response code should lead to the generation being treated as not possible and skipped for this query. Takes precedence over ``ratelimit_codes``.
* ``verify_ssl`` - (optional) Enforce ssl certificate validation? Default is True (bool)
* ``verify_ssl`` - (optional) Enforce ssl certificate validation? Default is ``True``, a file path to a CA bundle can be provided. (bool|str)

Templates can be either a string or a JSON-serialisable Python object.
Instance of ``$INPUT`` here are replaced with the prompt; instances of ``$KEY``
Expand Down
4 changes: 4 additions & 0 deletions garak/generators/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def __init__(self, uri=None, config_root=_config):
"`proxies` value provided is not in the required format. See documentation from the `requests` package for details on expected format. https://requests.readthedocs.io/en/latest/user/advanced/#proxies"
)

# suppress warnings about intentional SSL validation suppression
if isinstance(self.verify_ssl, bool) and not self.verify_ssl:
requests.packages.urllib3.disable_warnings()

# validate jsonpath
if self.response_json and self.response_json_field:
try:
Expand Down

0 comments on commit 5ab903e

Please sign in to comment.