forked from gardener/gardener
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from LucaBernstein/LucaBernstein-patch-1
Create gitguardian.yaml
- Loading branch information
Showing
9 changed files
with
104 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
|
||
secret: | ||
ignored_matches: | ||
- match: vpn-seed-server-tlsauth-a1d0aa00-2a3206b8 | ||
name: it's a secret name only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: GitGuardian scan | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
scanning: | ||
name: GitGuardian scan | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # fetch all history so multiple commits can be scanned | ||
- name: GitGuardian scan | ||
uses: GitGuardian/ggshield/actions/[email protected] | ||
env: | ||
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }} | ||
GITHUB_PUSH_BASE_SHA: ${{ github.event.base }} | ||
GITHUB_PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }} | ||
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }} | ||
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package vpntlsauth | ||
|
||
import ( | ||
"context" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
|
||
secretsutils "github.com/gardener/gardener/pkg/utils/secrets" | ||
secretsmanager "github.com/gardener/gardener/pkg/utils/secrets/manager" | ||
) | ||
|
||
const ( | ||
// SecretNameTLSAuth is the name of seed server tlsauth Secret. | ||
SecretNameTLSAuth = "vpn-seed-server-tlsauth" // #nosec G101 -- No credential. | ||
) | ||
|
||
// VPNTLSAuthConfigFromSecret is a configuration for a VPN TLS auth secret with the tlsauth key itself as part | ||
// of the configuration. | ||
type VPNTLSAuthConfigFromSecret struct { | ||
Name string | ||
Data map[string][]byte | ||
} | ||
|
||
var _ secretsutils.ConfigInterface = &VPNTLSAuthConfigFromSecret{} | ||
var _ secretsutils.DataInterface = &VPNTLSAuthConfigFromSecret{} | ||
|
||
// GetName returns the name of the secret. | ||
func (s *VPNTLSAuthConfigFromSecret) GetName() string { | ||
return s.Name | ||
} | ||
|
||
// Generate implements ConfigInterface. | ||
func (s *VPNTLSAuthConfigFromSecret) Generate() (secretsutils.DataInterface, error) { | ||
return s, nil | ||
} | ||
|
||
// SecretData computes the data map which can be used in a Kubernetes secret. | ||
func (s *VPNTLSAuthConfigFromSecret) SecretData() map[string][]byte { | ||
return s.Data | ||
} | ||
|
||
// GenerateSecret generates a VPN TLS auth secret using the provided secrets manager. | ||
// It is used for two-staged generation of tlsauth secret to include the tlsauth key in the secret name hash. | ||
func GenerateSecret(ctx context.Context, secretsManager secretsmanager.Interface) (*corev1.Secret, error) { | ||
// generate a secret with the tlsauth key | ||
secretTLSAuthIntermediate, err := secretsManager.Generate(ctx, &secretsutils.VPNTLSAuthConfig{ | ||
Name: SecretNameTLSAuth, | ||
}, secretsmanager.Rotate(secretsmanager.InPlace)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// use the secret to get a secret with same data but including the tlsauth key itself in name hash | ||
secretTLSAuth, err := secretsManager.Generate(ctx, &VPNTLSAuthConfigFromSecret{ | ||
Name: secretTLSAuthIntermediate.Name, | ||
Data: secretTLSAuthIntermediate.Data, | ||
}, secretsmanager.Rotate(secretsmanager.InPlace)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return secretTLSAuth, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters