From 36dcc4dc195955b10c16cdf4036ca7370da22347 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 29 Jan 2024 04:01:50 +0000 Subject: [PATCH 1/3] 1.0.0 Automatically generated by python-semantic-release --- CHANGELOG.md | 8 ++++++++ pyproject.toml | 2 +- salt_gnupg_rotate/__init__.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0cf709b..abe97e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,9 @@ # CHANGELOG + + + +## v1.0.0 (2024-01-29) + +### Breaking + +* feat!: initial release ([`7eefa6a`](https://github.com/raddessi/salt-gnupg-rotate/commit/7eefa6a9c262bcd5e36f68af2a7bafb752cbce4e)) diff --git a/pyproject.toml b/pyproject.toml index 937e6c22..41dd2150 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ # Poetry package config [tool.poetry] name = "salt-gnupg-rotate" -version = "0.2.2" +version = "1.0.0" description = "Easily rotate gnupg encryption keys of fully or partially encrypted files." authors = ["Ryan Addessi "] license = "BSD 2-Clause 'Simplified' License" diff --git a/salt_gnupg_rotate/__init__.py b/salt_gnupg_rotate/__init__.py index 6006abeb..d814bced 100644 --- a/salt_gnupg_rotate/__init__.py +++ b/salt_gnupg_rotate/__init__.py @@ -3,4 +3,4 @@ Easily rotate gnupg encryption keys of fully or partially encrypted files. """ -__version__ = "0.2.2" +__version__ = "1.0.0" From 21b85430313d4e9923773d03a5f9dab0c033281a Mon Sep 17 00:00:00 2001 From: Ryan Addessi Date: Sun, 28 Jan 2024 21:58:43 -0700 Subject: [PATCH 2/3] fix: duplicate blocks in the same file causes errors (#28) When an encrypted block is present more than one time in a file it causes errors since the first replacement replaces both instances and the second then fails. --- .github/workflows/ci.yaml | 2 ++ salt_gnupg_rotate/rotate.py | 2 +- tests/conftest.py | 1 + .../salt_pillar/duplicate_blocks_in_yaml.sls | 30 +++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/data/salt_pillar/duplicate_blocks_in_yaml.sls diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4321fa2a..74111022 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,6 +35,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - uses: actions/setup-python@v2 with: python-version: "3.10" diff --git a/salt_gnupg_rotate/rotate.py b/salt_gnupg_rotate/rotate.py index 019ccafa..824b3c86 100644 --- a/salt_gnupg_rotate/rotate.py +++ b/salt_gnupg_rotate/rotate.py @@ -178,7 +178,7 @@ def encrypt(self) -> None: ) proposed_change = new_contents.replace( - encrypted_block, reencrypted_padded_block + encrypted_block, reencrypted_padded_block, 1 ) # check if nothing was changed incorrectly if proposed_change == new_contents: diff --git a/tests/conftest.py b/tests/conftest.py index 5497df55..a3eb5b85 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -76,6 +76,7 @@ def gnupg_keyring_dirpath() -> str: "multiple_keys_in_yaml.sls", "one_key_in_yaml.sls", "nonconforming_file_type.txt", + "duplicate_blocks_in_yaml.sls", ], ) def salt_pillar_fpath_fixture( diff --git a/tests/data/salt_pillar/duplicate_blocks_in_yaml.sls b/tests/data/salt_pillar/duplicate_blocks_in_yaml.sls new file mode 100644 index 00000000..37acfab2 --- /dev/null +++ b/tests/data/salt_pillar/duplicate_blocks_in_yaml.sls @@ -0,0 +1,30 @@ +this-value: | + -----BEGIN PGP MESSAGE----- + + hF4Dv6kh6n/3RV4SAQdAfdDaT1ktkS3ktXnEG50DlmouWC5DGCZzBKzY/bR42hUw + R8Nvh06CDXJKwst4WxvLM72aOIjOnTL3KZtDqiWi4e8wuPCbvh1c2K+D5YwIVC4Y + 1FcBCQIQqw/ziVZigFuWV/CWlGz7kqYWRiKP0ZnGcENhcQTYseYeEjThHyYA0Mki + fB6t85QuRuIANeR2SrMeKVhI1AU1hoH0UAzrrDeFzdMz0mVxFEWbQhc= + =QPmN + -----END PGP MESSAGE----- + +gets repeated in the same file: | + -----BEGIN PGP MESSAGE----- + + hF4Dv6kh6n/3RV4SAQdAfdDaT1ktkS3ktXnEG50DlmouWC5DGCZzBKzY/bR42hUw + R8Nvh06CDXJKwst4WxvLM72aOIjOnTL3KZtDqiWi4e8wuPCbvh1c2K+D5YwIVC4Y + 1FcBCQIQqw/ziVZigFuWV/CWlGz7kqYWRiKP0ZnGcENhcQTYseYeEjThHyYA0Mki + fB6t85QuRuIANeR2SrMeKVhI1AU1hoH0UAzrrDeFzdMz0mVxFEWbQhc= + =QPmN + -----END PGP MESSAGE----- + +and sometimes: + at different indentation: | + -----BEGIN PGP MESSAGE----- + + hF4Dv6kh6n/3RV4SAQdAfdDaT1ktkS3ktXnEG50DlmouWC5DGCZzBKzY/bR42hUw + R8Nvh06CDXJKwst4WxvLM72aOIjOnTL3KZtDqiWi4e8wuPCbvh1c2K+D5YwIVC4Y + 1FcBCQIQqw/ziVZigFuWV/CWlGz7kqYWRiKP0ZnGcENhcQTYseYeEjThHyYA0Mki + fB6t85QuRuIANeR2SrMeKVhI1AU1hoH0UAzrrDeFzdMz0mVxFEWbQhc= + =QPmN + -----END PGP MESSAGE----- From 0e3531ed03d45d97ab182e33072932d210bad6b9 Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 29 Jan 2024 05:00:52 +0000 Subject: [PATCH 3/3] 1.0.1 Automatically generated by python-semantic-release --- CHANGELOG.md | 9 +++++++++ pyproject.toml | 2 +- salt_gnupg_rotate/__init__.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abe97e75..8268643e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ +## v1.0.1 (2024-01-29) + +### Fix + +* fix: duplicate blocks in the same file causes errors (#28) + +When an encrypted block is present more than one time in a file it causes errors since the first replacement replaces both instances and the second then fails. ([`21b8543`](https://github.com/raddessi/salt-gnupg-rotate/commit/21b85430313d4e9923773d03a5f9dab0c033281a)) + + ## v1.0.0 (2024-01-29) ### Breaking diff --git a/pyproject.toml b/pyproject.toml index 41dd2150..48ae5d73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ # Poetry package config [tool.poetry] name = "salt-gnupg-rotate" -version = "1.0.0" +version = "1.0.1" description = "Easily rotate gnupg encryption keys of fully or partially encrypted files." authors = ["Ryan Addessi "] license = "BSD 2-Clause 'Simplified' License" diff --git a/salt_gnupg_rotate/__init__.py b/salt_gnupg_rotate/__init__.py index d814bced..868e6146 100644 --- a/salt_gnupg_rotate/__init__.py +++ b/salt_gnupg_rotate/__init__.py @@ -3,4 +3,4 @@ Easily rotate gnupg encryption keys of fully or partially encrypted files. """ -__version__ = "1.0.0" +__version__ = "1.0.1"