Commit Graph

168 Commits

Author SHA1 Message Date
Stefan Prodan 31a62adfa9
Move `controllers` to `internal/controllers`
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-03-29 12:27:05 +03:00
Hidde Beydals f9878cfd1b
Drop string cast from SSA action comparisons
As this is no longer required given the action is now typed.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-07 17:55:10 +01:00
Hidde Beydals cb4622be40
kstatus: allow disabling of caching cluster reader
This commit allows the disabling of the caching cluster reader used by
the status poller while waiting and/or checking the health of resources.
Potentially reducing the memory usage of the controller on large scale
clusters, at the cost of an increase in direct API calls.

The feature can be enabled using
`--feature-gates=DisableStatusPollerCache=true`.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-03-07 12:56:17 +01:00
Hidde Beydals c877c07db9 Disable caching of Secrets and ConfigMaps
You can re-enable caching by starting the controller with the argument
`--feature-gates=CacheSecretsAndConfigMaps=true`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2023-01-30 15:37:49 +00:00
Hidde Beydals 648825603c build: update dockertest to Go Mod compatible v3
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-12-14 14:38:37 +00:00
Soule BA ab04480ef3
Replace internal/generator by flux/pkg/kustomize
Signed-off-by: Soule BA <bah.soule@gmail.com>
2022-11-14 23:02:38 +01:00
Hidde Beydals d10a45bf7f Update `keyvault/azkeys` Azure SDK to v0.9.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-11-09 09:19:08 +00:00
Stefan Prodan 7799bb0920
Refactor: Adopt Flux runtime conditions and status standards
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-14 14:22:53 +03:00
Stefan Prodan 484cbcc14c
Refactor: Move inventory helpers to internal package
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-11 13:45:54 +03:00
Stefan Prodan 731188e45b
Refactor: Extract generator to internal package
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-07 12:49:36 +03:00
Stefan Prodan 06ce60f7bf
Refactor: Extract decrytor to internal package
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-10-06 19:45:12 +03:00
Stefan Prodan 69509c92e2
Build with Go 1.19
- Update Go to 1.19 in CI
- Use Go 1.19 in base image
- Update controller-gen v0.8.0 (v0.7 fails with Go 1.19) and regenerate manifests

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2022-09-28 18:17:34 +03:00
Stefan Prodan 8feccf0aeb
Merge pull request #726 from bkreitch/try-offline-methods-first
Sort SOPS masterkeys so offline decrypt methods are tried first
2022-09-12 12:06:11 +03:00
Boris Kreitchman 5fe7910ab8 Sort masterkeys so offline decrypt methods are tried first
Signed-off-by: Boris Kreitchman <bkreitch@gmail.com>
2022-09-10 15:38:57 +03:00
Paulo Gomes 73f005e541
fuzz: Refactor Fuzzers based on Go native fuzzing
The existing fuzzers are converted into the Go native format. This
works well with most fuzzers, apart from the one that fuzzes the
controller.

That specific test depends on funcs and vars that are defined on
suite_test.go, which is not supported when building fuzzers leveraging
Go native fuzz for oss-fuzz. That test is therefore ignored when
executed with make fuzz-native. But, all tests are covered with
make fuzz-smoketest, in order to support oss-fuzz.

Once the controller is rewritten we can revist this and ensure that
fuzzers does not require envtest nor embedded CRDs.

Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-09-07 12:26:43 +01:00
Sanskar Jaiswal 72f0e605be sops/awskms: fix compatibility tests with upstream sops
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-05-30 18:03:04 +05:30
Sanskar Jaiswal 10bc7eadff sops/awskms: fix awskms config creation and expand tests
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-05-28 00:36:54 +05:30
Hidde Beydals 0539f6f3dc Drop deprecated github.com/golang/protobuf
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-25 10:40:33 +02:00
Hidde Beydals cbb0fc9df5 sops/gcpkms: disable integration tests
This temporarily disables the integration tests as we are waiting for
the CNCF to provide us with GCP credits.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-24 21:52:01 +02:00
Somtochi Onyekwere 2ac475ebef sops/gcpkms: add key source implementation
This adds a SOPS GCP KMS key source which makes use of the latest GCP
client, and supports both injection of master key credentials and a
default client making use of environmental runtime values.

The implementation fully replaces SOPS', and is covered with
compatability tests.

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2022-05-24 21:51:46 +02:00
Max Jonas Werner 62fb2d96a2
Merge pull request #656 from fluxcd/relicense-sops
Relicense SOPS module to MPL 2.0
2022-05-22 09:03:24 +02:00
Sanskar Jaiswal c8a00fb495 update sops awskms files to use MPL 2.0
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-05-20 17:39:42 +05:30
Hidde Beydals 327a3560b3 Relicense SOPS module to MPL 2.0
This relicenses all of our SOPS implementation code to MPL 2.0, where
Apache 2.0 was previously used due to code being written from scratch.

By making this license change, we are better capable of contributing
the changes upstream.

In case there is doubt about validity of DCO sign-off to make such
changes: all code where Apache 2.0 license applies were authored by
myself. In addition, Apache 2.0 is compatible with MPL 2.0[1][2].

[1]: https://opensource.com/law/11/9/mpl-20-copyleft-and-license-compatibility
[2]: https://blog.gerv.net/2013/02/relicensing-when-do-you-have-to-ask/

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-20 13:10:06 +02:00
Sanskar Jaiswal 326e20c41b update code comments and kms decryption docs
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-05-19 14:34:16 +05:30
Sanskar Jaiswal 1ee85e5988 add and update tests for awskms and hcvault
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-05-19 14:34:16 +05:30
Sanskar Jaiswal e5a37b7013 migrate aws kms implementation to aws-go-sdk-v2
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-05-19 14:34:15 +05:30
Sanskar Jaiswal c801f75458 add docs
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-05-19 14:33:31 +05:30
Sanskar Jaiswal 53aded2596 add support for AWS KMS credentials using .spec.decryption
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-05-19 14:33:22 +05:30
Hidde Beydals e5653b2ff3 Drop SOPS LocalClient implementation
As patch has been merged upstream, and `keyservice.LocalClient` does
now accept the `KeyServiceServer` interface.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-05-09 22:02:05 +02:00
Hidde Beydals 9db141d9db sops/keyservice: tidy and add tests
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-05 12:44:35 +02:00
Hidde Beydals ffdda3f3da sops/azkv: add Token utility type
This adds a new Token type which can be used to configure an
azcore.TokenCredential on a master key. Due to this introduction, the
server only has to go through the AADConfig once.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-05 12:44:35 +02:00
Hidde Beydals dfbeae9487 sops/age: add ParsedIdentities utility type
This adds a new ParsedIdentities type which can be used to parse a set
of age identities just once, instead of parsing them for every Decrypt
request.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-05 12:44:35 +02:00
Hidde Beydals ed49f8427f sops/pgp: add GnuPGHome utility type
This adds a new GnuPGHome type which can be used to create a new
contained GnuPG home directory. The type is self-validating, ensuring
it adheres to e.g. permission rules set out by GnuPG, and allows for
importing keys from armored bytes and files.

Because of this introduction, the decryptor service no longer has to
write data from a Secret to a temporary file, but is instead able to
directly import them into the keyring from the Secret entry's bytes.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals eaec2b9164 sops/hcvault: tidy and test keysource impl
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals 6554be2208 sops/pgp: tidy and test keysource implementation
This revises the PGP keysource implementation, removing bits of code
that were not actually in use, or not viable in combination with how we
work with keys. In short:

- crypto/openpgp implementation has been removed. As it is unable to read
  the keystore created by newer versions of GnuPG. Given we import user
  provided keys _with_ GnuPG, this was basically dead code.
- All capabilities around fetching public keys from a server have been
  removed.
- "Jailing" of GnuPG shell-out is now handled in `gpgExec`, in addition,
  arguments for encrypt and decrypt execs have been revised to ensure
  they e.g. do not instruct to use the agent.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals 182ddbf837 sops/age: tidy and test keysource implementation
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals 2487b51e51 sops/keyservice: error on unfulfilled requirements
This ensures we signal early that we will be unable to fulfill the
request, instead of letting the underlying keysource implementation
run into mayhem. Which can be problematic for e.g. PGP, which has
assumptions about things being located relative to the given home
directory, resulting in possible unexpected behavior if an empty path
is given.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals 512e749219 sops/keyservice: handle nil key requests
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals e5c2730342 sops/keyservice: allow config of server via opts
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals 2e30a18b50 sops/keyservice: keep server fields private
This ensures data used for decryption is not exposed widely after
constructing the Server, and prevents a bypass to the default server
fallback.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals 7450a1a9a3 sops/keyservice: simplify switch logic
These bits of code have a history of accidents around the fallback
behavior. By simplifying it, the fallback should generally always work,
unless you put in instructions to take another route.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Hidde Beydals 31bfd5a057 sops/keyservice: remove prompt capabilities
The original keyservice implementation was forked from SOPS, keeping
the prompt capabilities intact. However, since the implementations have
started to grow, it is better to remove this capability and resort to
a hardcoded `false` default for the fallback server. As the controller
is never expected to have an interactive TTY/shell.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-04-04 23:57:46 +02:00
Sanskar Jaiswal ed5fb9fd6c add custom statusreader for jobs
Signed-off-by: Sanskar Jaiswal <sanskar.jaiswal@weave.works>
2022-04-01 15:11:13 +05:30
Paulo Gomes 1ba95077df
Fix build tag syntax
Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
2022-04-01 10:11:25 +01:00
Hidde Beydals 692e4a726b sops/azkv: ensure compatibility with upstream
To please the older Azure SDK, the upstream SOPS implementation base64
URL encodes data before encryption, and decodes it afterwards. With the
new SDK, this has changed, requiring us to do the opposite to ensure
compatibility.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-29 13:22:53 +02:00
Hidde Beydals da09e21043 sops/azkv: test compatibility with upstream
Add integration tests to ensure compatibility between our own Azure
keyservice implementation and upstream.
Tests are enabled to only run for `main`.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-29 13:22:53 +02:00
Hidde Beydals 069a1065fc sops/keyservice: properly fallback to default
This solves a regression bug introduced in `v0.22.0`, which caused the
keyservice to not properly fall back to the default for Azure Key Vault
decryption requests.

A couple of nitpicks that I ran into while inspecting the code have
been adressed as well.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-25 18:03:17 +01:00
Hidde Beydals 400b685249 Update dependencies
- github.com/Azure/azure-sdk-for-go/sdk/azcore to v0.22.0
- github.com/Azure/azure-sdk-for-go/sdk/azidentity to v0.13.2
- github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys to v0.4.0
- github.com/ProtonMail/go-crypto to v0.0.0-20220113124808-70ae35bab23f
- github.com/cyphar/filepath-securejoin to v0.2.3
- github.com/drone/envsubst to v1.0.3
- github.com/fluxcd/pkg/apis/kustomize to v0.3.2
- github.com/fluxcd/pkg/ssa to v0.15.1
- github.com/hashicorp/vault/api to v1.4.1
- go.mozilla.org/sops/v3 to v3.7.2
- golang.org/x/net to v0.0.0-20220225172249-27dd8689420f
- google.golang.org/grpc to v1.45.0
- k8s.io/api to v0.23.4
- k8s.io/apiextensions-apiserver to v0.23.4
- k8s.io/apimachinery to v0.23.4
- k8s.io/client-go to v0.23.4
- sigs.k8s.io/cli-utils to v0.29.3

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-18 14:09:52 +01:00
Hidde Beydals 6876a1e95a sops/azkv: support YAML Azure authentication files
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-14 10:28:56 +01:00
Hidde Beydals 02343b047b sops/azkv: support fields from `az` generated SP
This supports the fields as documented in the AKS documentation:
https://docs.microsoft.com/en-us/azure/aks/kubernetes-service-principal?tabs=azure-cli#manually-create-a-service-principal

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-14 10:28:53 +01:00
Hidde Beydals 369193ee59 sops/azkv: update to SDK including azidentity
This updates to the `github.com/Azure/azure-sdk-for-go` SDK, which is
the (apparent) successor of the previous SDK, and allows for easier
configuration of credentials through the `azidentity` package.

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-14 10:28:46 +01:00
Hidde Beydals f67efe0dc6 sops/azkv: configure retry and throttle on client
Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-14 10:28:46 +01:00
Hidde Beydals a72e687607 sops/azkv: refactor initial Azure Keyvault impl
- Ensure key source follows upstream SOPS contracts as closely as
  possible (e.g. `MasterKey` interface).
- Prevent unnecesary FS operations by allowing token creation and
  and authorizer configuration to be factored from file bytes.
- Ensure a limited number of configuration option is taken into
  account, excluding e.g. file path references.
- Ensure server maintains backwards compatibility with previously
  supported "global" Azure configuration, _without_ relying on file
  assumptions and/or inspections (but rather, server configurations).

Signed-off-by: Hidde Beydals <hello@hidde.co>
2022-03-14 10:28:46 +01:00
David Quagebeur 343f937e59 sops/azkv: support for credentials via SecretRef
Signed-off-by: David Quagebeur <david.quagebeur@worldline.com>
2022-03-14 10:27:55 +01:00
Soule BA c579e71430
add native support for sops decryption/encryption with Vault
If implemented, the kustomize controller will be able to retrieve a
secret containing a VAULT TOKEN and use it to decrypt the sops encrypted
master key. It will then use it to decrypt the data key and finally use the data
key to decrypt the final data.

Signed-off-by: Soule BA <bah.soule@gmail.com>
2022-01-19 21:59:10 +01:00
Soule BA 3191f497e6
fix encryption using the defaultServer
Signed-off-by: Soule BA <bah.soule@gmail.com>
2021-12-09 15:04:01 +01:00
Stefan Prodan 1badc828b4
Replace deprecated dependencies
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2021-11-23 14:21:21 +02:00
Aurel Canciu 4410e8df6d
Lowercase first letters for fmt.Errorf messages
Some of these error messages were likely imported from somewhere else.

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2021-11-04 19:32:52 +01:00
Aurel Canciu f03d2c9b05
Remove PGP passphrase prompt
We do not support encrypted PGP private keys hence the prompt function
logic can be reduced to signaling an error.

Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
2021-11-04 13:14:25 +01:00
Rishabh Bohra b8cebd3838
chore: remove deprecated io/ioutil
Signed-off-by: Rishabh Bohra <rishabhbohra01@gmail.com>
2021-10-29 20:28:25 +05:30
Hidde Beydals b8bdc0c999 Support decrypting using age keys
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-03-31 11:55:44 +02:00
Hidde Beydals 9aee369f31 Update SOPS to v3.7.0
Signed-off-by: Hidde Beydals <hello@hidde.co>
2021-03-25 22:36:31 +01:00
Hidde Beydals 07f13e56eb GPG decryption in contained environment 2020-09-02 15:42:02 +02:00
stefanprodan 2ebd5b6450 Implement event recording
- emit Kubernetes events for reconciliation actions
- forward events to notification controller
- remove the Profile API/CRD
2020-07-01 20:39:48 +03:00
stefanprodan ab15f3c185 Migrate to fluxcd/pkg 2020-06-30 17:25:03 +03:00
stefanprodan 912d5fa744 Add Go license to forked package 2020-06-10 13:06:51 +03:00
stefanprodan 81ff97bc8d Implement Slack and Discord alerting 2020-04-21 14:09:26 +03:00
stefanprodan 9f7d995577 Add locking to kustomization apply 2020-04-17 10:30:40 +03:00