Skip to content

Commit 9870b99

Browse files
authored
Merge branch 'main' into fix-1142
2 parents 5184d1a + bf5e7ae commit 9870b99

19 files changed

Lines changed: 1297 additions & 252 deletions

File tree

.github/workflows/cli.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ jobs:
3535
id: go
3636

3737
- name: Check out code into the Go module directory
38-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
38+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3939
with:
4040
persist-credentials: false
4141

42-
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
42+
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
4343
with:
4444
path: ~/go/pkg/mod
4545
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
@@ -68,14 +68,14 @@ jobs:
6868

6969
- name: Upload artifact for ${{ matrix.os }}
7070
if: matrix.os != 'windows'
71-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
71+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
7272
with:
7373
name: sops-${{ matrix.go-version }}-${{ matrix.os }}-${{ matrix.arch }}-${{ github.sha }}
7474
path: sops-${{ matrix.go-version }}-${{ matrix.os }}-${{ matrix.arch }}-${{ github.sha }}
7575

7676
- name: Upload artifact for ${{ matrix.os }}
7777
if: matrix.os == 'windows'
78-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
78+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
7979
with:
8080
name: sops-${{ matrix.go-version }}-${{ matrix.os }}-${{ github.sha }}
8181
path: sops-${{ matrix.go-version }}-${{ matrix.os }}-${{ github.sha }}
@@ -92,7 +92,7 @@ jobs:
9292
VAULT_ADDR: "http://127.0.0.1:8200"
9393
steps:
9494
- name: Check out code
95-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
95+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
9696
with:
9797
persist-credentials: false
9898

@@ -105,7 +105,7 @@ jobs:
105105
- name: Show Rust version
106106
run: cargo --version
107107

108-
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
108+
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
109109
with:
110110
name: sops-${{ matrix.go-version }}-linux-amd64-${{ github.sha }}
111111

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ jobs:
2929

3030
steps:
3131
- name: Checkout code
32-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
32+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3333
with:
3434
persist-credentials: false
3535

3636
# Initializes the CodeQL tools for scanning.
3737
- name: Initialize CodeQL
38-
uses: github/codeql-action/init@fe4161a26a8629af62121b670040955b330f9af2 # v4.31.6
38+
uses: github/codeql-action/init@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4.31.8
3939
with:
4040
languages: go
4141
# xref: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
@@ -52,6 +52,6 @@ jobs:
5252
make install
5353
5454
- name: Perform CodeQL Analysis
55-
uses: github/codeql-action/analyze@fe4161a26a8629af62121b670040955b330f9af2 # v4.31.6
55+
uses: github/codeql-action/analyze@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4.31.8
5656
with:
5757
category: "/language:go"

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
steps:
2525
- name: Checkout code
26-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
26+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2727
with:
2828
persist-credentials: false
2929

.github/workflows/linters.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Check out code
24-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
24+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2525
with:
2626
persist-credentials: false
2727

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
steps:
2727
- name: Checkout
28-
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
28+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2929
with:
3030
fetch-depth: 0
3131
persist-credentials: false
@@ -37,7 +37,7 @@ jobs:
3737
cache: false
3838

3939
- name: Setup Syft
40-
uses: anchore/sbom-action/download-syft@fbfd9c6c189226748411491745178e0c2017392d # v0.20.10
40+
uses: anchore/sbom-action/download-syft@43a17d6e7add2b5535efe4dcae9952337c479a93 # v0.20.11
4141

4242
- name: Setup Cosign
4343
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0

.release/alpine.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:3.22
1+
FROM alpine:3.23
22

33
RUN apk --no-cache add \
44
ca-certificates \

README.rst

Lines changed: 98 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SOPS: Secrets OPerationS
22
========================
33

44
**SOPS** is an editor of encrypted files that supports YAML, JSON, ENV, INI and BINARY
5-
formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, age, and PGP.
5+
formats and encrypts with AWS KMS, GCP KMS, Azure Key Vault, HuaweiCloud KMS, age, and PGP.
66
(`demo <https://www.youtube.com/watch?v=YTEVyLXFiq0>`_)
77

88
.. image:: https://i.imgur.com/X0TM5NI.gif
@@ -532,13 +532,77 @@ To easily deploy Vault locally: (DO NOT DO THIS FOR PRODUCTION!!!)
532532
533533
$ sops encrypt --verbose prod/raw.yaml > prod/encrypted.yaml
534534
535+
Encrypting using HuaweiCloud KMS
536+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
537+
538+
The HuaweiCloud KMS integration uses the
539+
`default credential provider chain <https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/core/auth/provider/provider.go>`_
540+
which tries several authentication methods, in this order:
541+
542+
1. Environment variables: ``HUAWEICLOUD_SDK_AK``, ``HUAWEICLOUD_SDK_SK``, ``HUAWEICLOUD_SDK_PROJECT_ID``
543+
2. Credentials file at ``~/.huaweicloud/credentials``
544+
3. Instance metadata (when running on HuaweiCloud instances)
545+
546+
For example, you can use environment variables:
547+
548+
.. code:: bash
549+
550+
export HUAWEICLOUD_SDK_AK="your-access-key"
551+
export HUAWEICLOUD_SDK_SK="your-secret-key"
552+
export HUAWEICLOUD_SDK_PROJECT_ID="your-project-id"
553+
554+
Alternatively, you can create a credentials file at ``~/.huaweicloud/credentials``:
555+
556+
.. code:: sh
557+
558+
$ cat ~/.huaweicloud/credentials
559+
[default]
560+
ak = your-access-key
561+
sk = your-secret-key
562+
project_id = your-project-id
563+
564+
Encrypting/decrypting with HuaweiCloud KMS requires a KMS key ID in the format
565+
``region:key-uuid``. You can get the key ID from the HuaweiCloud console or using
566+
the HuaweiCloud API. The key ID format is ``region:key-uuid`` where:
567+
568+
- ``region`` is the HuaweiCloud region (e.g., ``tr-west-1``, ``cn-north-1``)
569+
- ``key-uuid`` is the UUID of the KMS key (e.g., ``abc12345-6789-0123-4567-890123456789``)
570+
571+
Now you can encrypt a file using:
572+
573+
.. code:: sh
574+
575+
$ sops encrypt --hckms tr-west-1:abc12345-6789-0123-4567-890123456789 test.yaml > test.enc.yaml
576+
577+
Or using the environment variable:
578+
579+
.. code:: sh
580+
581+
$ export SOPS_HUAWEICLOUD_KMS_IDS="tr-west-1:abc12345-6789-0123-4567-890123456789"
582+
$ sops encrypt test.yaml > test.enc.yaml
583+
584+
And decrypt it using:
585+
586+
.. code:: sh
587+
588+
$ sops decrypt test.enc.yaml
589+
590+
You can also configure HuaweiCloud KMS keys in the ``.sops.yaml`` config file:
591+
592+
.. code:: yaml
593+
594+
creation_rules:
595+
- path_regex: \.hckms\.yaml$
596+
hckms:
597+
- tr-west-1:abc12345-6789-0123-4567-890123456789,tr-west-2:def67890-1234-5678-9012-345678901234
598+
535599
Adding and removing keys
536600
~~~~~~~~~~~~~~~~~~~~~~~~
537601
538602
When creating new files, ``sops`` uses the PGP, KMS and GCP KMS defined in the
539-
command line arguments ``--kms``, ``--pgp``, ``--gcp-kms`` or ``--azure-kv``, or from
603+
command line arguments ``--kms``, ``--pgp``, ``--gcp-kms``, ``--hckms`` or ``--azure-kv``, or from
540604
the environment variables ``SOPS_KMS_ARN``, ``SOPS_PGP_FP``, ``SOPS_GCP_KMS_IDS``,
541-
``SOPS_AZURE_KEYVAULT_URLS``. That information is stored in the file under the
605+
``SOPS_HUAWEICLOUD_KMS_IDS``, ``SOPS_AZURE_KEYVAULT_URLS``. That information is stored in the file under the
542606
``sops`` section, such that decrypting files does not require providing those
543607
parameters again.
544608
@@ -582,9 +646,9 @@ disabled by supplying the ``-y`` flag.
582646
583647
The ``rotate`` command generates a new data encryption key and reencrypt all values
584648
with the new key. At the same time, the command line flag ``--add-kms``, ``--add-pgp``,
585-
``--add-gcp-kms``, ``--add-azure-kv``, ``--rm-kms``, ``--rm-pgp``, ``--rm-gcp-kms``
586-
and ``--rm-azure-kv`` can be used to add and remove keys from a file. These flags use
587-
the comma separated syntax as the ``--kms``, ``--pgp``, ``--gcp-kms`` and ``--azure-kv``
649+
``--add-gcp-kms``, ``--add-hckms``, ``--add-azure-kv``, ``--rm-kms``, ``--rm-pgp``, ``--rm-gcp-kms``,
650+
``--rm-hckms`` and ``--rm-azure-kv`` can be used to add and remove keys from a file. These flags use
651+
the comma separated syntax as the ``--kms``, ``--pgp``, ``--gcp-kms``, ``--hckms`` and ``--azure-kv``
588652
arguments when creating new files.
589653
590654
Use ``updatekeys`` if you want to add a key without rotating the data key.
@@ -760,7 +824,7 @@ stdout.
760824
Using .sops.yaml conf to select KMS, PGP and age for new files
761825
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
762826
763-
It is often tedious to specify the ``--kms`` ``--gcp-kms`` ``--pgp`` and ``--age`` parameters for creation
827+
It is often tedious to specify the ``--kms`` ``--gcp-kms`` ``--hckms`` ``--pgp`` and ``--age`` parameters for creation
764828
of all new files. If your secrets are stored under a specific directory, like a
765829
``git`` repository, you can create a ``.sops.yaml`` configuration file at the root
766830
directory to define which keys are used for which filename.
@@ -802,6 +866,10 @@ can manage the three sets of configurations for the three types of files:
802866
- path_regex: \.gcp\.yaml$
803867
gcp_kms: projects/mygcproject/locations/global/keyRings/mykeyring/cryptoKeys/thekey
804868
869+
# hckms files using HuaweiCloud KMS
870+
- path_regex: \.hckms\.yaml$
871+
hckms: tr-west-1:abc12345-6789-0123-4567-890123456789,tr-west-2:def67890-1234-5678-9012-345678901234
872+
805873
# Finally, if the rules above have not matched, this one is a
806874
# catchall that will encrypt the file using KMS set C as well as PGP
807875
# The absence of a path_regex means it will match everything
@@ -1797,6 +1865,16 @@ To directly specify a single key group, you can use the following keys:
17971865
- hc_vault_transit_uri:
17981866
- http://my.vault/v1/sops/keys/secondkey
17991867
1868+
* ``hckms`` (list of strings): list of HuaweiCloud KMS key IDs (format: ``<region>:<key-uuid>``).
1869+
Example:
1870+
1871+
.. code:: yaml
1872+
1873+
creation_rules:
1874+
- hckms:
1875+
- tr-west-1:abc12345-6789-0123-4567-890123456789
1876+
- tr-west-1:def67890-1234-5678-9012-345678901234
1877+
18001878
To specify a list of key groups, you can use the following key:
18011879
18021880
* ``key_groups`` (list of key group objects): a list of key group objects.
@@ -1824,6 +1902,8 @@ To specify a list of key groups, you can use the following key:
18241902
- https://vault.url/keys/key-name/ # key without version, the latest will be used
18251903
hc_vault_transit_uri:
18261904
- http://my.vault/v1/sops/keys/secondkey
1905+
hckms:
1906+
- tr-west-1:abc12345-6789-0123-4567-890123456789
18271907
18281908
merge:
18291909
- pgp:
@@ -1901,6 +1981,17 @@ A key group supports the following keys:
19011981
19021982
* ``hc_vault`` (list of strings): list of HashiCorp Vault transit URIs.
19031983
1984+
* ``hckms`` (list of objects): list of HuaweiCloud KMS key IDs.
1985+
Every object must have the following key:
1986+
1987+
* ``key_id`` (string): the key ID in format ``<region>:<key-uuid>``.
1988+
1989+
Example:
1990+
1991+
.. code:: yaml
1992+
1993+
- key_id: tr-west-1:abc12345-6789-0123-4567-890123456789
1994+
19041995
* ``age`` (list of strings): list of Age public keys.
19051996
19061997
* ``pgp`` (list of strings): list of PGP/GPG key fingerprints.

0 commit comments

Comments
 (0)