[PR #9580/25a262bd backport][stable-10] Create onepassword_ssh_key plugin (#9632)

Create `onepassword_ssh_key` plugin (#9580)

* add 1password_ssh_key lookup

* refactor

* Delete onepassword_ssh_key.py

* Revert "Delete onepassword_ssh_key.py"

This reverts commit e17ff7e232.

* Delete onepassword_ssh_key.py

* add tests

* add test license

* cleanup

* refactor

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* fix indentation

* fix RETURN indentation

* use get_option to get ssh_format

* linting

* update project year in copyright

* add plugin to BOTMETA.yml

* use OnePassCLIv2's get_raw and use OnePass's token

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 25a262bdcf)

Co-authored-by: Mohammed Babelly <mohammed@nevercode.io>
This commit is contained in:
patchback[bot] 2025-01-26 15:43:32 +01:00 committed by GitHub
commit 04b68c296b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 252 additions and 0 deletions

View file

@ -293,3 +293,39 @@ MOCK_ENTRIES = {
},
],
}
SSH_KEY_MOCK_ENTRIES = [
# loads private key in PKCS#8 format by default
{
"vault_name": "Personal",
"queries": ["ssh key"],
"expected": [
"-----BEGIN PRIVATE KEY-----\n..........=\n-----END PRIVATE KEY-----\n"
],
"output": load_file("ssh_key_output.json"),
},
# loads private key in PKCS#8 format becasue ssh_format=false
{
"vault_name": "Personal",
"queries": ["ssh key"],
"kwargs": {
"ssh_format": False,
},
"expected": [
"-----BEGIN PRIVATE KEY-----\n..........=\n-----END PRIVATE KEY-----\n"
],
"output": load_file("ssh_key_output.json"),
},
# loads private key in ssh format
{
"vault_name": "Personal",
"queries": ["ssh key"],
"kwargs": {
"ssh_format": True,
},
"expected": [
"-----BEGIN OPENSSH PRIVATE KEY-----\r\n.....\r\n-----END OPENSSH PRIVATE KEY-----\r\n"
],
"output": load_file("ssh_key_output.json"),
},
]