The GitOps Toolkit source management component
Go to file
Florian Forster 8be37ef1d2
Fix incorrect use of format strings with the `conditions` package.
Many of the functions in the `conditions` package accept a format string and
(optional) arguments, just like `fmt.Printf` and friends.

In many places, the code passed an error message as the format string, causing
it to be interpreted by the `fmt` package. This leads to issues when the
message contains percent signs, e.g. URL-encoded values.

Consider the following code:

```go
// internal/controller/ocirepository_controller.go
revision, err := r.getRevision(ref, opts)
if err != nil {
	e := serror.NewGeneric(
		fmt.Errorf("failed to determine artifact digest: %w", err),
		ociv1.OCIPullFailedReason,
	)
	conditions.MarkTrue(obj, sourcev1.FetchFailedCondition, e.Reason, e.Err.Error())
	return sreconcile.ResultEmpty, e
}
```

Since `getRevision()` includes the URL in the error message and the error
message is used as a format string, the resulting condition reads:

```
failed to determine artifact digest: GET https://gitlab.com/jwt/auth?scope=repository%!A(MISSING)fforster%!F(MISSING)<REDACTED>%!F(MISSING)k8s-resource-manifests%!A(MISSING)pull&service=container_registry: DENIED: access forbidden
```

This adds an explicit format string and shortens `e.Error()` and
`e.Err.Error()` to `e`, which yields the same output.

To the best of my knowledge, Go is safe from format string attacks. I **don't**
think this is a security vulnerability, but I'm also not a security expert.

Signed-off-by: Florian Forster <fforster@gitlab.com>
2024-07-05 15:55:31 +02:00
.github Run ARM64 tests on GitHub runners 2024-06-14 11:41:44 +03:00
api Add support for .spec.proxySecretRef for generic provider of Bucket API 2024-07-03 15:10:47 +01:00
config Add support for .spec.proxySecretRef for generic provider of Bucket API 2024-07-03 15:10:47 +01:00
docs Add support for .spec.proxySecretRef for generic provider of Bucket API 2024-07-03 15:10:47 +01:00
hack Promote Helm APIs to v1 (GA) 2024-05-02 16:04:27 +03:00
internal Fix incorrect use of format strings with the `conditions` package. 2024-07-05 15:55:31 +02:00
pkg Add support for .spec.proxySecretRef for generic provider of Bucket API 2024-07-03 15:10:47 +01:00
tests/fuzz Update dependencies to Go 1.22 and Kubernetes 1.29.3 2024-04-02 16:52:10 +03:00
.dockerignore libgit2: Remove references to libgit2 from code 2022-12-12 15:34:28 +00:00
.gitignore Update libgit2 to 1.1.1-6 2022-02-07 13:00:57 +00:00
.goreleaser.yaml Adapt config to GoRelease v2 2024-06-11 09:35:42 +03:00
CHANGELOG.md Add changelog entry for v1.3.0 2024-05-03 12:34:15 +03:00
CODE_OF_CONDUCT.md Add governance files like DCO, MAINTAINERS, CoC 2020-04-12 23:54:35 +02:00
DCO Add governance files like DCO, MAINTAINERS, CoC 2020-04-12 23:54:35 +02:00
DEVELOPMENT.md Add verification support for notation signed artifacts 2024-03-26 21:32:23 +11:00
Dockerfile Update dependencies to Go 1.22 and Kubernetes 1.29.3 2024-04-02 16:52:10 +03:00
LICENSE Initial commit 2020-04-05 11:55:46 +03:00
MAINTAINERS Add matheuscscp as maintainer 2024-07-03 15:33:53 +01:00
Makefile Rename make target `build` to `manager` 2024-05-03 09:30:54 +03:00
PROJECT Promote Helm APIs to v1 (GA) 2024-05-02 16:04:27 +03:00
README.md docs: Add API spec for Helm v1 2024-05-02 16:19:48 +03:00
go.mod Add support for .spec.proxySecretRef for generic provider of Bucket API 2024-07-03 15:10:47 +01:00
go.sum Add support for .spec.proxySecretRef for generic provider of Bucket API 2024-07-03 15:10:47 +01:00
main.go Promote Helm APIs to v1 (GA) 2024-05-02 16:04:27 +03:00

README.md

Source controller

CII Best Practices e2e report license release

The source-controller is a Kubernetes operator, specialised in artifacts acquisition from external sources such as Git, OCI, Helm repositories and S3-compatible buckets. The source-controller implements the source.toolkit.fluxcd.io API and is a core component of the GitOps toolkit.

overview

APIs

Kind API Version
GitRepository source.toolkit.fluxcd.io/v1
OCIRepository source.toolkit.fluxcd.io/v1beta2
HelmRepository source.toolkit.fluxcd.io/v1
HelmChart source.toolkit.fluxcd.io/v1
Bucket source.toolkit.fluxcd.io/v1beta2

Features

  • authenticates to sources (SSH, user/password, API token, Workload Identity)
  • validates source authenticity (PGP, Cosign, Notation)
  • detects source changes based on update policies (semver)
  • fetches resources on-demand and on-a-schedule
  • packages the fetched resources into a well-known format (tar.gz, yaml)
  • makes the artifacts addressable by their source identifier (sha, version, ts)
  • makes the artifacts available in-cluster to interested 3rd parties
  • notifies interested 3rd parties of source changes and availability (status conditions, events, hooks)
  • reacts to Git, Helm and OCI artifacts push events (via notification-controller)

Guides

Roadmap

The roadmap for the Flux family of projects can be found at https://fluxcd.io/roadmap/.

Contributing

This project is Apache 2.0 licensed and accepts contributions via GitHub pull requests. To start contributing please see the development guide.