Граф коммитов

5 Коммитов

Автор SHA1 Сообщение Дата
Vasily Marnopolsky cdfc7d6a20 fix(azkv): handle whitespace in Azure Key Vault URLs
### Problem:

The Azure Key Vault key parser would fail when URLs contained leading or trailing whitespace, which commonly occurs when using YAML Block Scalar syntax.

```yaml
creation_rules:
  - azure_keyvault: >-
      https://test.vault.azure.net/keys/test-key/a2a690a4fcc04166b739da342a912c90,
      https://test2.vault.azure.net/keys/another-test-key/cf0021e8b743453bae758e7fbf71b60e
```

This resulted in the error:

```bash
"could not parse " https://test2.vault.azure.net/keys/another-test-key/cf0021e8b743453bae758e7fbf71b60e" into a valid Azure Key Vault MasterKey"
```

### Fix:

- Added `strings.TrimSpace()` to clean the URL before parsing in `NewMasterKeyFromURL()`
- Added test case to verify handling of URLs with leading/trailing spaces

Signed-off-by: Vasily Marnopolsky <sept0r.com@gmail.com>
2024-10-22 18:40:53 +02:00
Hidde Beydals b80c0d1eba azkv: update SDK to latest, add tests, tidy
This updates the Azure SDK to latest[1], while dropping the custom
authentication flow in favor of the SDK default[2]. It includes
integration tests, which require the `integration` Go build tag and
a set of environmental variables to be configured to be run:

```
PASS
coverage: 81.2% of statements
ok  	go.mozilla.org/sops/v3/azkv	5.376s	coverage: 81.2% of statements
```

The improvements are based on a fork of the key source in the Flux
project's kustomize-controller, built due to SOPS' limitation around
credential managment without relying on runtime environment variables.

- Azure SDK has been updated to latest, including integration test
  coverage.
- Custom authentication flow has been dropped in favor of the SDK
  default[2]. This should work well on almost any system and is
  generally the go-to way of setting this up, including on cloud
  environments, etc.
- It introduces a `TokenCredential` type which holds an
  `azcore.TokenCredential`, and can be applied to a `MasterKey`.
  When applied, the token is used instead of the SDK default. This is
  most useful when working with SOPS as an SDK, in combination with
  e.g. a local key service server implementation.
- Extensive test coverage.

The forked version of this has compatibility tests to ensure it works
with current SOPS:

- 327a3560b3/internal/sops/azkv/keysource_integration_test.go (L89)
- 327a3560b3/internal/sops/azkv/keysource_integration_test.go (L117)

[1]: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/keyvault/azkeys
[2]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity#DefaultAzureCredential

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-06-02 22:26:07 +02:00
Adriano 4b99fa18b3
go lint 2019-07-11 10:30:32 -07:00
Calle Pettersson 19e964ebdd Make Azure key parsing failable 2018-06-18 16:03:24 +02:00
Calle Pettersson 9fa4f0e90e Add support for Azure Key Vault 2018-06-17 22:50:30 +02:00