mirror of
https://github.com/dtomlinson91/csops.git
synced 2025-12-22 13:55:45 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b752a10165 | |||
| ebff9e901f | |||
| f654d199ee | |||
| 573ab8ca2d | |||
| c10a40273b |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -3,6 +3,21 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
<!-- marker -->
|
||||
## [v0.2.0](https://github.com/dtomlinson91/csops/commits/v0.2.0) - 2022-01-17
|
||||
<small>[Compare with v0.1.0](https://github.com/dtomlinson91/csops/compare/v0.1.0..v0.2.0)</small>
|
||||
|
||||
### ✨ Features
|
||||
|
||||
- Add user configuration of `gcp_kms_key` #1 ([f654d19](https://github.com/dtomlinson91/csops/commit/f654d199ee54f487842e7fd89a6e8a4c5f3d55ce))
|
||||
|
||||
### 📘 Documentation
|
||||
|
||||
- Update README with usage example ([c10a402](https://github.com/dtomlinson91/csops/commit/c10a40273bb6ace06a4b1640488045d21dcd9ee1))
|
||||
- Update README with config example #1 ([ebff9e9](https://github.com/dtomlinson91/csops/commit/ebff9e901fb44d94674a8845cd341e5d5f5fed2c))
|
||||
|
||||
### 🧱 Build
|
||||
|
||||
- Add panaetius 2.3.4 ([573ab8c](https://github.com/dtomlinson91/csops/commit/573ab8ca2d414d90ea101507c5313b932eb29413))
|
||||
## [v0.1.0](https://github.com/dtomlinson91/csops/commits/v0.1.0) - 2022-01-17
|
||||
|
||||
### ✨ Features
|
||||
|
||||
30
README.md
30
README.md
@@ -0,0 +1,30 @@
|
||||
# CSOPS
|
||||
|
||||
Wrapper around [mozilla/sops](https://github.com/mozilla/sops).
|
||||
|
||||
## Installation
|
||||
|
||||
`pipx install git+https://github.com/dtomlinson91/csops`
|
||||
|
||||
## Configuration
|
||||
|
||||
Either use a `config.yml` or use environment variables.
|
||||
|
||||
If using a `config.yml` create this file in either `~/.config/csops/` or a custom directory. If using a custom directory set the environment variable `CSOPS_CONFIG` equal to this directory.
|
||||
|
||||
### GCP KMS Key
|
||||
|
||||
If using a `config.yml` set the `gcp_mks_key` under the `csops` header:
|
||||
|
||||
```yml
|
||||
csops:
|
||||
gcp_kms_key: projects/plex-mozilla-sops/locations/global/keyRings/sops/cryptoKeys/sops-key
|
||||
```
|
||||
|
||||
Or set the environment variable `CSOPS_GCP_KMS_KEY="projects/plex-mozilla-sops/locations/global/keyRings/sops/cryptoKeys/sops-keys"`
|
||||
|
||||
## Usage
|
||||
|
||||
Encrypt: `csops e test.log`
|
||||
|
||||
Decrypt: `csops d test.enc.log`
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import os
|
||||
from typing import Any
|
||||
|
||||
import panaetius
|
||||
|
||||
|
||||
_config_path = os.environ.get("CSOPS_CONFIG")
|
||||
if _config_path is not None:
|
||||
CONFIG: Any = panaetius.Config("csops", _config_path, skiper_header_init=True)
|
||||
else:
|
||||
CONFIG = panaetius.Config("csops", "~/.config")
|
||||
|
||||
|
||||
panaetius.set_config(CONFIG, "gcp_kms_key")
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
"""Module containing the version of csops."""
|
||||
|
||||
__version__ = "0.1.0"
|
||||
__version__ = "0.2.0"
|
||||
|
||||
@@ -2,12 +2,14 @@ import argparse
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
from csops import CONFIG
|
||||
|
||||
|
||||
def encrypt(args):
|
||||
encrypted_filename = f"{args.file.stem}.enc{args.file.suffix}"
|
||||
subprocess.run(
|
||||
"sops --encrypt --gcp-kms"
|
||||
f" projects/plex-mozilla-sops/locations/global/keyRings/sops/cryptoKeys/sops-key {args.file} > {encrypted_filename}",
|
||||
"sops --encrypt --gcp-kms "
|
||||
f"{CONFIG.gcp_kms_key} {args.file} > {encrypted_filename}",
|
||||
check=True,
|
||||
text=True,
|
||||
shell=True,
|
||||
|
||||
73
poetry.lock
generated
73
poetry.lock
generated
@@ -76,6 +76,18 @@ category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[[package]]
|
||||
name = "panaetius"
|
||||
version = "2.3.4"
|
||||
description = "Python module to gracefully handle a .config file/environment variables for scripts, with built in masking for sensitive options. Provides a Splunk friendly formatted logger instance."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.7,<4.0"
|
||||
|
||||
[package.dependencies]
|
||||
PyYAML = ">=6.0,<7.0"
|
||||
toml = ">=0.10.0,<0.11.0"
|
||||
|
||||
[[package]]
|
||||
name = "ptyprocess"
|
||||
version = "0.7.0"
|
||||
@@ -84,10 +96,26 @@ category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "pyyaml"
|
||||
version = "6.0"
|
||||
description = "YAML parser and emitter for Python"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.10.2"
|
||||
description = "Python Library for Tom's Obvious, Minimal Language"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.7"
|
||||
content-hash = "25c39083344a50ca67bfcb0dc9f537b2514800593d520f88c6251d0d6e1d6555"
|
||||
content-hash = "e73025defcee2a371099bcc0f600114c7c819317a5816da738f3d0e535c39b6d"
|
||||
|
||||
[metadata.files]
|
||||
ansimarkup = [
|
||||
@@ -185,7 +213,50 @@ markupsafe = [
|
||||
{file = "MarkupSafe-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:693ce3f9e70a6cf7d2fb9e6c9d8b204b6b39897a2c4a1aa65728d5ac97dcc1d8"},
|
||||
{file = "MarkupSafe-2.0.1.tar.gz", hash = "sha256:594c67807fb16238b30c44bdf74f36c02cdf22d1c8cda91ef8a0ed8dabf5620a"},
|
||||
]
|
||||
panaetius = [
|
||||
{file = "panaetius-2.3.4-py3-none-any.whl", hash = "sha256:26b3f5bc213ea6e2076eecd46ff3adb8dba08a287756c948cc09a2bf504bc4d8"},
|
||||
{file = "panaetius-2.3.4.tar.gz", hash = "sha256:da6884c12b1b79be4b338946cb4552cfcabf96e631f28068f95f1cf0842262f2"},
|
||||
]
|
||||
ptyprocess = [
|
||||
{file = "ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35"},
|
||||
{file = "ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"},
|
||||
]
|
||||
pyyaml = [
|
||||
{file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"},
|
||||
{file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"},
|
||||
{file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"},
|
||||
{file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"},
|
||||
{file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"},
|
||||
{file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"},
|
||||
{file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"},
|
||||
]
|
||||
toml = [
|
||||
{file = "toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b"},
|
||||
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
|
||||
]
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
[tool.poetry]
|
||||
name = "csops"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
description = ""
|
||||
authors = ["Daniel Tomlinson <dtomlinson@panaetius.co.uk>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.7"
|
||||
panaetius = "^2.3.4"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
duty = "^0.7.0"
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
|
||||
panaetius==2.3.4; python_version >= "3.7" and python_version < "4.0"
|
||||
pyyaml==6.0; python_version >= "3.7" and python_version < "4.0"
|
||||
toml==0.10.2; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.3.0"
|
||||
|
||||
@@ -5,4 +5,7 @@ duty==0.7.0; python_version >= "3.6"
|
||||
failprint==0.8.0; python_version >= "3.6"
|
||||
jinja2==3.0.3; python_version >= "3.6"
|
||||
markupsafe==2.0.1; python_version >= "3.6"
|
||||
panaetius==2.3.4; python_version >= "3.7" and python_version < "4.0"
|
||||
ptyprocess==0.7.0; sys_platform != "win32" and python_version >= "3.6"
|
||||
pyyaml==6.0; python_version >= "3.7" and python_version < "4.0"
|
||||
toml==0.10.2; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4.0" or python_version >= "3.7" and python_version < "4.0" and python_full_version >= "3.3.0"
|
||||
|
||||
6
setup.py
6
setup.py
@@ -7,12 +7,15 @@ packages = \
|
||||
package_data = \
|
||||
{'': ['*']}
|
||||
|
||||
install_requires = \
|
||||
['panaetius>=2.3.4,<3.0.0']
|
||||
|
||||
entry_points = \
|
||||
{'console_scripts': ['csops = csops.run:run']}
|
||||
|
||||
setup_kwargs = {
|
||||
'name': 'csops',
|
||||
'version': '0.1.0',
|
||||
'version': '0.2.0',
|
||||
'description': '',
|
||||
'long_description': None,
|
||||
'author': 'Daniel Tomlinson',
|
||||
@@ -22,6 +25,7 @@ setup_kwargs = {
|
||||
'url': None,
|
||||
'packages': packages,
|
||||
'package_data': package_data,
|
||||
'install_requires': install_requires,
|
||||
'entry_points': entry_points,
|
||||
'python_requires': '>=3.7,<4.0',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user