Skip to content
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 option to disable clients in netapi #59622

Conversation

barneysowood
Copy link
Contributor

@barneysowood barneysowood commented Feb 26, 2021

What does this PR do?

Adds a new config option "netapi_disable_clients" that takes a list of clients to disable in the netapi.

Checks the list early in handling the the request before authentication occurs. Should be useful where certain clients (eg ssh or wheel) aren't required and should be disabled to reduce attack surface in the salt-api.

replaces #58872

What issues does this PR fix or reference?

New Behavior

Adds "netapi_disable_clients" list option to the config which is checked when a request is passed to NetApiClient.run() and an exception raised if the requested client is in the list.

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

No

@barneysowood barneysowood requested a review from a team as a code owner February 26, 2021 08:45
@barneysowood barneysowood requested review from Akm0d and removed request for a team February 26, 2021 08:45
@barneysowood barneysowood changed the title Add option to disable clients in netapi WIP: Add option to disable clients in netapi Feb 26, 2021
@barneysowood barneysowood force-pushed the config-disable-salt-api-clients branch from 717853b to 7e1d683 Compare February 26, 2021 09:34
@barneysowood barneysowood changed the title WIP: Add option to disable clients in netapi Add option to disable clients in netapi Feb 26, 2021
@barneysowood barneysowood force-pushed the config-disable-salt-api-clients branch 2 times, most recently from 130e491 to 0996333 Compare March 4, 2021 10:09
@sagetherage sagetherage requested review from garethgreenaway and removed request for Akm0d March 5, 2021 23:41
@barneysowood
Copy link
Contributor Author

re-run ci/py3/macosxmojave/pytest

@barneysowood
Copy link
Contributor Author

re-run pr-macosxmojave-py3-pytest

@sagetherage
Copy link
Contributor

@barneysowood I updated the branch with master as I think we have fixed these tests that are failing, here. That reruns the full test suite so I will check back, as well. I hope that that helps!

@barneysowood
Copy link
Contributor Author

@barneysowood I updated the branch with master as I think we have fixed these tests that are failing, here. That reruns the full test suite so I will check back, as well. I hope that that helps!

Thanks @sagetherage. Looks like the failing tests are fixed now - thanks! Unfortunately seems to have times out on ci/py3/centos7/pycryptodome/pytest - I'll try that again now.

@barneysowood
Copy link
Contributor Author

re-run pr-centos7-py3-pycryptodome-pytest

@barneysowood
Copy link
Contributor Author

OK, tests now all green.

@garethgreenaway - if you get a chance to review that would be great, thanks!

Ch3LL
Ch3LL previously approved these changes Apr 21, 2021
@Ch3LL
Copy link
Contributor

Ch3LL commented Apr 21, 2021

I approved but look like there is a merge conflict. Would also like to get @dwoz review here as well.

@barneysowood
Copy link
Contributor Author

Hmm, have totally messed up the rebase trying to sort the conflict. Will fix that and re-push

@barneysowood barneysowood force-pushed the config-disable-salt-api-clients branch 2 times, most recently from 3b15891 to 6e21408 Compare April 28, 2021 18:47
@barneysowood
Copy link
Contributor Author

re-run pr-freebsd-122-amd64-py3-pytest

@barneysowood
Copy link
Contributor Author

re-run pr-ubuntu-2004-arm64-py3-pytest

@barneysowood
Copy link
Contributor Author

re-run pr-macosx-mojave-x86_64-py3-pytest

@barneysowood barneysowood force-pushed the config-disable-salt-api-clients branch from 6e21408 to e03b3b1 Compare May 2, 2021 10:22
@barneysowood
Copy link
Contributor Author

@Ch3LL and @dwoz - merge conflict resolved and all tests now passing. If you could review that would be great, thanks.

Ch3LL
Ch3LL previously approved these changes May 18, 2021
@barneysowood
Copy link
Contributor Author

re-run pr-fedora-34-x86_64-py3-pytest

1 similar comment
@barneysowood
Copy link
Contributor Author

re-run pr-fedora-34-x86_64-py3-pytest

@barneysowood
Copy link
Contributor Author

re-run pr-macosx-catalina-x86_64-py3-pytest

@barneysowood
Copy link
Contributor Author

re-run pr-macosx-mojave-x86_64-py3-pytest

Copy link
Contributor

@dwoz dwoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, due to the amount of problems we've had with the netapi I think this should be an opt in scenario rather than opt out. Meaning it'd be netapi_enable_clients and they are all disabled by default.

@barneysowood
Copy link
Contributor Author

Honestly, due to the amount of problems we've had with the netapi I think this should be an opt in scenario rather than opt out. Meaning it'd be netapi_enable_clients and they are all disabled by default.

@dwoz - I would tend to agree, but I was trying to avoid a breaking change. If everyone is OK with that I'm happy rework this to be netapi_enable_clients and also add some documentation for that.

The other option would be to set the default (either using the netapi_enable_clients or netapi_disable_clients form) to disable the ssh client by default as that has tended to be the most problematic.

@barneysowood barneysowood dismissed stale reviews from garethgreenaway and Ch3LL via dcdeed4 February 14, 2022 23:35
@barneysowood barneysowood force-pushed the config-disable-salt-api-clients branch from 9a19bf2 to dcdeed4 Compare February 14, 2022 23:35
@barneysowood
Copy link
Contributor Author

re-run pr-amazon-2-x86_64-py3-pytest

@Ch3LL
Copy link
Contributor

Ch3LL commented Feb 15, 2022

@dwoz I really like the idea of the opt in as well, but that seems like a big change for users of salt-api. Shouldn't we add a deprecation notice somehow or give users notice before we make this change?

@barneysowood barneysowood force-pushed the config-disable-salt-api-clients branch 3 times, most recently from 080df77 to 5df0cd4 Compare November 9, 2022 14:13
barneysowood and others added 4 commits November 9, 2022 14:14
Adds an option to allow you to disable clients (eg ssh, wheel) in the
netapi. Does the check before any attempts to authenticate.
Adds pytest based integration tests as the old non-pytest
netapi/test_client.py tests have been removed.
@barneysowood barneysowood force-pushed the config-disable-salt-api-clients branch from 5df0cd4 to eb6b085 Compare November 9, 2022 14:14
@barneysowood
Copy link
Contributor Author

Closing in favour of #63050

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants