Commit Graph

151 Commits

Author SHA1 Message Date
Stefan Prodan ed816fbc9e receiver: Update default API versions to GA
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
(cherry picked from commit c5e11470bd)
2025-10-02 19:18:34 +00:00
Adrian Fernandez De La Torre a332f9c326 Setup OTEL provider type
Signed-off-by: Adrian Fernandez De La Torre <adri1197@gmail.com>
2025-09-05 11:02:14 +02:00
Stefan Prodan e2151f5632
Migrate tests to Gomega
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2025-08-31 13:50:53 +03:00
abhijith-darshan 4eae0d34da
Add support for mTLS to GitHub App transport
This commit ensures that if GitHub app secret data contains ca.crt then a TLS config with user provided custom ca is used in the underlying HTTP transports. The ca.crt in GitHub App secretRef is ignored if certSecretRef is also provided.

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): keep Makefile in sync with other controllers

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): use proper func naming format

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): revert Makefile changes

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): add get secret helper

This commit creates a getSecret helper func which can be used to resolve secret. createNotifier re-uses this helper func to extract and pass secrets down to other methods

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): adds tls test cases

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): remove debug logs

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): adds documentation

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>

(chore): update docs with mTLS info

Signed-off-by: abhijith-darshan <abhijith.darshan@hotmail.com>
2025-08-18 11:03:43 +02:00
cappyzawa 10a6172536
[RFC-0010] Add default-service-account for lockdown
Add --default-service-account flag for multi-tenant workload identity
lockdown support. This flag sets the default service account name to
be used when .spec.serviceAccountName is not specified in resources.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-08-18 01:44:25 +09:00
cappyzawa 5be0d2b66c
Remove TLS ServerName pinning in TLS config creation
Updates pkg/runtime dependency to v0.80.0 which removes the need for
the insecure parameter in TLSConfigFromSecretRef. This change removes
the forced ServerName pinning behavior that was causing TLS verification
issues, allowing for more flexible certificate validation.

The TLS config creation now relies on the standard Go TLS verification
process without forcing specific ServerName values, improving
compatibility with various certificate configurations.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-08-15 02:44:18 +09:00
cappyzawa f333296240
Fix missing TLS ServerName in Provider notifications
Updates pkg/runtime/secrets to v0.75.0 which adds targetURL and insecure
parameters to TLS functions. This resolves ServerName regression that
caused TLS handshake failures in virtual hosting environments.

The Provider API has no insecure field, so certificates are always
verified (insecure=false). This maintains secure-by-default behavior
and is consistent with the original pre-pkg/runtime/secrets implementation.

All 17+ notification providers automatically benefit from proper ServerName
setting through the centralized TLS configuration in createNotifier().

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-22 12:41:05 +09:00
cappyzawa 0c1801906a
Add mTLS support for git-based notifiers
Replace x509.CertPool with tls.Config across all Git-based notifiers
(GitHub, GitLab, Gitea, Bitbucket, Azure DevOps, GitHub Dispatch) to
enable mutual TLS authentication for enterprise environments.

Adopt runtime/secrets AuthMethodsFromSecret for standardized handling
of Bearer tokens, basic auth, and token auth while maintaining full
backward compatibility with existing Secret formats.

This unifies authentication processing across Git-based providers and
adds mTLS capability without changing API surface or breaking existing
deployments.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-19 08:31:47 +09:00
cappyzawa 955d24142c
Make address field optional for providers that generate URLs internally
This change removes the generic address validation from event_handlers.go
that was preventing address-optional providers from functioning without
specifying a dummy address value. Some providers generate URLs internally
and don't require external address configuration.

This allows providers that generate URLs internally to work without
requiring dummy address values in the provider configuration.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-16 00:13:29 +09:00
Matheus Pimenta febff88be7
Upgrade Kubernetes to 1.33.2
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-07-14 16:45:44 +01:00
cappyzawa a8c2fc0759
Fix double secret fetching in BasicAuth processing
This commit addresses the performance issue where spec.secretRef
was being fetched twice - once in extractAuthFromSecret and again
in secrets.BasicAuthFromSecret. The fix moves BasicAuth processing
directly into extractAuthFromSecret using the already-fetched
secret data, eliminating the redundant API call.

This aligns with the special nature of spec.secretRef that contains
multiple authentication methods and follows the advice to not use
runtime/secrets for special requirements as discussed in flux2#5433.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-10 19:38:33 +09:00
cappyzawa d1c85df902
Unify BasicAuth processing using pkg/runtime/secrets
This commit refactors the createNotifier function to use
pkg/runtime/secrets.BasicAuthFromSecret for standardized BasicAuth
handling while maintaining token-first authentication precedence.

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-10 16:56:33 +09:00
cappyzawa 98ecf2de79
Add mTLS support for postMessage-based notifiers
- Implement mTLS support for 10 postMessage notifiers
- Unify constructor signatures with tlsConfig parameter
- Make TLSConfig field public for consistency
- Update factory functions and fuzz tests
- Add mTLS test cases
- Replace CertPool with TLSConfig using runtime/secrets

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-07-03 21:39:16 +09:00
cappyzawa 8858332c27
Add ProxySecretRef field to Provider API
Introduce spec.proxySecretRef to enable secure proxy configuration
through dedicated Secrets. This provides a more secure alternative
to the deprecated spec.proxy field and secret proxy key.

The new field integrates with runtime/secrets for unified proxy
handling and maintains backward compatibility. Deprecation warnings
are implemented for existing proxy configuration methods.

Proxy priority: ProxySecretRef > secret proxy key > spec.proxy

Signed-off-by: cappyzawa <cappyzawa@gmail.com>
2025-06-27 23:31:02 +09:00
Matheus Pimenta e95f8d5b38
[RFC-0010] Introduce feature gate
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-05-19 14:15:57 +01:00
Dipti Pai 0beb3d02f7 Managed Identity support for Azure Event Hubs. Changes include -
- If authentication token is not specified in provider, attempt to get the token using workload identity.
= Add new field .spec.serviceAccountName to support multi-tenant workload identity as defined in RFC-0010 to use an identity with a service account other than the notification-controller.
- Use proxy to get the token if specified in provider spec.
- Cache the tokens if enabled in the notification controller options.
- If address has SAS connection string, use that for authentication, this takes priority over token-authentication
- If static JWT token is specified in the secret reference, use it for authentication, this takes priority over workload identity-acquired token.
- Update RBAC for notification-controller to be able to create service token requests.
- Add unit tests for the 3 authentication mechanisms (SAS, JWT, managed identity).
- Add documentation for using single-tenant and multi-tenant approaches of workload identity with azureeventhub provider.
- Add operation post to github helpers and provider controller for cache event metrics
- Enable token cache by default.

Signed-off-by: Dipti Pai <diptipai89@outlook.com>

review comments

Signed-off-by: Dipti Pai <diptipai89@outlook.com>

enable cache by default

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2025-05-05 12:03:52 -07:00
Matheus Pimenta fdeab17bff
Sanitize proxy error logging
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-04-08 10:37:45 +01:00
Dipti Pai bc7166d419 [RFC-007] GitHub App authentication support for github and github-dispatch providers.
- Add providerOpts in notifier to configure authentication options for various providers.
- If token/password are not set to PAT, check if github app details are configured in secret and if found; authenticate using github-app by retrieving app installation token.
- If proxy is specified in the provider spec OR in the secret, configure github app authentication to fetch the installation token over the proxy.
- Add unit tests for providers.
- Update documentation describing the usage of github app authentication with the providers.
- Add token cache to notification controller to cache and re-use the tokens.

Signed-off-by: Dipti Pai <diptipai89@outlook.com>
2025-03-20 14:18:10 -07:00
kathleen french 1967bc0c74 feat: support CEL expressions to construct commit statuses for v1beta3 provider types
Signed-off-by: kathleen french <kfrench@groq.com>
2025-03-14 08:53:55 -04:00
Matheus Pimenta 3dc0b66390
Improvements after CEL resource filtering
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-02-12 16:46:59 +00:00
Matheus Pimenta c4eed6b243
Fix add missing return statement and a few style issues
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-02-12 11:17:50 +00:00
Kevin McDermott 28deef923f
Implement Receiver resource filtering with CEL
Signed-off-by: Kevin McDermott <bigkevmcd@gmail.com>
Co-authored-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-02-10 16:21:50 +00:00
Matheus Pimenta b362a258fe
Enforce namespace check on receiver
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-01-30 10:27:01 +00:00
Matheus Pimenta e0b98ca519
Add support for MetaOriginRevisionKey from the Event API
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-01-21 08:28:31 +00:00
Matheus Pimenta 939a16620f
[RFC-0008] Custom Event Metadata from Annotations
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2025-01-10 13:19:15 +00:00
Stefan Prodan b2ab2c2b07
Update go-github to v63
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-09-26 15:05:47 +03:00
Sunny 3585b77c40 Fix CDEvents API usage and tests
Signed-off-by: Sunny <github@darkowlzz.space>
2024-09-25 23:31:05 +00:00
Alexey Kuzbekov c85b1eb391
Change default behavior and naming
Signed-off-by: Alexey Kuzbekov <alexey@kuzbekov.me>
2024-08-24 15:29:29 +01:00
Alexey Kuzbekov ab58c812bd
New flag to disable detailed metrics for path
Flag detailed-metrics added to provide a way to disable exposing all accessed paths to the metrics and  prevent potential metrics cardinality explosion

Signed-off-by: Alexey Kuzbekov <alexey@kuzbekov.me>
2024-08-24 15:29:24 +01:00
Matheus Pimenta bd12728d0f Upgrade dependencies
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2024-08-15 09:03:03 -03:00
Stefan Prodan 3aba5bbd39
Update Helm APIs to v1
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-05-02 21:00:30 +03:00
Stefan Prodan 6ba1a713fe
Sanitize provider data loaded from secret
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2024-04-09 18:35:01 +03:00
adam b4949b6e05 Implement CDEvents Receiver
Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Added CDEvents Receiver

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Added CDEvent Validation + Tests

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Small changes to CDEvent Receiver

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

More CDEvents Tests and Docs added

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Adding imports to go.mod

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

small changes + manifests and formatting

Signed-off-by: adamkenihan <adam.kenihan@est.tech>

Changing string compare to EqualFold

Signed-off-by: adamkenihan <adam.kenihan@est.tech>
2024-03-27 10:36:51 +00:00
Sunny 68c38244cc Exclude eventv1.MetaTokenKey from event metadata
eventv1.MetaTokenKey is required to be considered in rate limiting but
it is only for internal use by flux components and should not be sent to
the alert provider. Remove eventv1.MetaTokenKey from the metadata of
event before processing the event for various matching alerts.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-12-13 23:13:38 +05:30
Matheus Pimenta 143a0b3ee0 Remove URL syntax validation for provider address entirely
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-12-12 19:01:31 +00:00
Max Jonas Werner 52d8945284
Cap provider address at 2048 bytes
The provider address is already capped at 2048 bytes in the CRD and
this commit adds the same upper limit when reading the address from a
Secret.

Signed-off-by: Max Jonas Werner <mail@makk.es>
2023-11-28 12:31:20 +01:00
Sunny 6df2c74b2a event_handler: Use proper ctx for post fail log
Use the context containing proper information about the event for
logging. Previously, the logged error didn't contain any information
about the event, alert or the involved object.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 19a60e98ea event handler: Add k8s events for Alerts
Emit events in the event handler along with logs on the respective alert
to make the message visible on the alert it belongs to.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Sunny 80f7237673 Refactor event handler
- Break down the EventServer.handleEvent() implementation into multiple
  smaller functions which are extensively tested on their own.
  - New implementation of filter Alerts for Event
  - New implementation of Event matches Alert
- Remove any readiness check on Alert or Provider.
- Add kubebuilder marker for generating RBAC permissions to create and
  patch events, and query Alert and Provider objects.
- Convert the event handler test from controllers/ dir to work with
  just EventServer without any reconciler, keeping all the test cases
  and slightly modified test set up code.

Signed-off-by: Sunny <darkowlzz@protonmail.com>
2023-11-28 16:17:03 +05:30
Hidde Beydals 3dce75a07e
misc: fix hypothetical implicit memory aliasing
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-11 15:02:56 +02:00
Hidde Beydals edb6a54e23
misc: take errs into account
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-11 15:01:35 +02:00
Hidde Beydals 23d57eb9d3
misc: use `strings.EqualFold`
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-10 12:07:31 +02:00
Hidde Beydals 30db06d0df
misc: do not capitalize err strings
Except for where names are being used (e.g. `Authorization` header,
Nexus, etc.)

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-10-10 12:07:30 +02:00
Somtochi Onyekwere 23e733b9c7 use kubernetes tls style secret in provider
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2023-08-23 14:06:15 +01:00
Somtochi Onyekwere 4f5d2dfdb8 use TrimPrefix instead of TrimLeft
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
2023-08-01 16:31:15 +01:00
Stefan Prodan 749a6c4cb7
Update dependencies
- k8s.io/* v0.27.3
- cloud.google.com/go/pubsub v1.31.0
- github.com/Azure/azure-event-hubs-go/v3 v3.6.0
- github.com/getsentry/sentry-go v0.22.0
- github.com/google/go-github/v53 v53.2.0
- github.com/ktrysmt/go-bitbucket v0.9.60
- github.com/xanzy/go-gitlab v0.86.0
- github.com/fluxcd/pkg/runtime v0.39.0

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
2023-06-27 11:16:42 +03:00
Matheus Pimenta ae6cc4b4f6 Reduce logging repeated code in event server
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-06-12 14:26:59 +01:00
Hidde Beydals b7cccbee81 Prefix event key attributes with identifier
This to prevent collisions between different event attributes.

For example when first an event with revision `foo` is received
without a token, after which a token `foo` is received without a
revision.

Signed-off-by: Hidde Beydals <hidde@hhh.computer>
2023-05-24 15:52:46 +02:00
Matheus Pimenta 8c11d8a19b Fix Alert .spec.eventMetadata behavior
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-24 11:27:27 +01:00
Matheus Pimenta 4e05bc8ee2 Include eventv1.MetaTokenKey on event rate limiting key calculation
Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
2023-05-24 11:30:14 +02:00