-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
Add support for blacklisting hosts to the HTTP runner #4757
Conversation
"hosts_blacklist" runner attribute.
If others think it makes sense, I could also add new |
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.
This is a little bit confusing. At first, I thought host blacklist is indicating which action runner hosts cannot run the HTTP operation. Looking further into the code, it's actually restricting which web address in the URL is blacklisted. Maybe name this url_hosts_blacklist?
@m4dcoder Correct. I'm fine with calling the parameter |
@Kami Does it make sense to make this a configurable option in st2.conf? I'm wondering if st2 admins want to add to the list, how would they configure it? |
It could be solved both ways. Nice thing about the runner parameter approach is that it's not global. For example, with RBAC you could allow some (super) users to run / execute |
@Kami Do you have an example how the RBAC policy would configure this? I'm ok with either or with both approach. I'm just wondering how admins can add to this black list. |
Sorry, maybe I wasn't clear in my previous comment. I just described one possible approach which would utilize existing RBAC primitives for limiting which actions a particular user can run in combination with immutable default action parameter value. To define a blacklist, operator would need to define a custom action which sets a default value for the That's a similar approach which is already used for various use cases (e.g. chatops, etc.). |
And to clarify it further - I also didn't put it in Having said that, our only approach for configuring / changing runner behavior right now is via runner parameters and that's why I went with this approach. It might not be 100% ideal, but it's already there and this pattern has already been used before. |
"url_hosts_blacklist" and also add support for whitelist approach using "url_hosts_whitelist" runner parameter.
I pushed a change which renames the existing runner attribute and adds a new one for the whitelist approach - c074677. |
client = HTTPClient(url=url, method='GET', url_hosts_whitelist=url_hosts_whitelist) | ||
client.run() | ||
|
||
self.assertEqual(mock_requests.request.call_count, 1) |
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.
Can you add a unit test where both whitelist and blacklist are provided?
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.
Added in c07f6d6.
While at it, I might also look at adding some integration tests (if it doesn't become too big of a rabbit hole), since we don't have any at the moment.
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.
For the time being, I just decided to add some additional unit tests for the runner class itself - 25b43cb.
Previously we don't had test cases for HTTPClient class, but not the actual runner.
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.
LGTM. But just a note on the use case you are trying to address. The real solution you need to address is to sandbox actions from executing system commands and also network policies to restrict access to internal endpoints. This solution here is complementary to that and does not offer sufficient protection alone.
This pull request adds support for blacklisting hosts to the HTTP runner by adding a new
hosts_blacklist
attribute.With this attribute, pack author can specify a list of hosts which will be blacklisted (aka won't work) with the HTTP runner.
For example, if an operator wants to allow StackStorm users to use HTTP runner, without being able to hit some hosts, they could define new
mypack.http
action which metadata could look something like this:NOTE: As with any feature which could be used in a security sensitive context, it's important to know that this feature doesn't cover all scenarios and security is all about layers.
This means that runner level filtering should be just one of those layers. Where security is very important, it should be combined with additional filtering on the network layer (e.g. firewall) and potentially also in combination with a custom StackStorm action / workflow which performs more complex logic (e.g. also resolves the hostname and checks the IP, etc.).