-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat(anta): Add support for command blacklist to secure tests #416
Conversation
This implementation won't prevent a malicious device implementation (injecting reload / conf t / ... in its own _collect. Wondering if we should not rather implement this in the AntaDevice(ABC) collect ? |
we keep it in test |
Co-authored-by: Guillaume Mulocher <gmulocher@arista.com>
707fdb7
to
6039900
Compare
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.
Tested a few blocked commands locally with collect
of AntaTest
and it works.
Should we add this guard to anta debug
as well?
(.anta) ➜ anta git:(test_blacklist) anta debug run-cmd -c "configure terminal" -d DC1-LEAF1A --ofmt text
Run command configure terminal on DC1-LEAF1A
(.anta) ➜ anta git:(test_blacklist) anta debug run-cmd -c "write" -d DC1-LEAF1A
Run command write on DC1-LEAF1A
{'messages': ['Copy completed successfully.']}
Ideas was to protect tests to send dangerous command while in debug mode, you do that on purpose. A complete protection of the device should be done via a correct RBAC configuration. Adding this protection to |
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
Description
Add support of a list of blacklisted regex to secure test execution and avoid
any critical change on devices.
It currently blocked CLI with following regex
^reload\s*\w*
^conf\w*\s*(terminal|session)*
^wr\w*\s*\w+
Fixes #413
Checklist:
pre-commit run
)tox -e testenv
)