-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: configuration based rest proxy support #1073
Feature: configuration based rest proxy support #1073
Conversation
validates the `proxies` value if provided is a `dict` and passed on to the requests call
Note that this PR also suggest additional possible sensitive configuration details that may deserve warnings similar to #1049, the format for proxy endpoints can accept a basic auth proxy in a format like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few minor points in comments, lgtm
_config.plugins.generators["rest"]["RestGenerator"]["proxies"] = test_proxies | ||
with pytest.raises(GarakException) as exc_info: | ||
_plugins.load_plugin("generators.rest.RestGenerator", config_root=_config) | ||
assert "not in the required format" in str(exc_info.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good thinking
) | ||
generator._call_model("Who is Enabran Tain's son?") | ||
mock_http_function.assert_called_once() | ||
assert mock_http_function.call_args_list[0].kwargs["proxies"] == test_proxies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess maybe this isn't the strongest possible test we can do (we could check mock proxy logs), but validation shows that the code works (by tailing proxy logs)
Adds configuration based support for
proxies
to therest.RestGenerator
.This extracts the proxy capability from @au70ma70n's PR #878
Verification
example rest_config.json, add any required configuration for your rest endpoint found here:
garak -m rest -G rest_config.json -p lmrc
http
proxy.In theory this capability is possible to drive via environment variables as noted in the
requests
library docs, this PR enables a configuration based method for when environment variables are not available for the user to set, or instance ifgarak
were to be wrapped in an executor service.