Skip to content

Commit

Permalink
unify property Id suffix
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
  • Loading branch information
fjogeleit committed Sep 19, 2024
1 parent a2fd24a commit ab7c0b6
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
* Policy Reporter
* New `certificate` config for `loki`, `elasticsearch`, `teams`, `webhook` and `ui`, to set the path to your custom certificate for the related client.
* New `skipTLS` config for `loki`, `elasticsearch`, `teams`, `webhook` and `ui`, to skip tls if needed for the given target.
* New `secretRef` for targets to reference a secret with the related `username`, `password`, `webhook`, `host`, `accessKeyID`, `secretAccessKey` information of the given target, instead of configure your credentials directly.
* New `secretRef` for targets to reference a secret with the related `username`, `password`, `webhook`, `host`, `accessKeyId`, `secretAccessKey` information of the given target, instead of configure your credentials directly.
* Policy Reporter UI
* New value `refreshInterval` to configure the default refresh interval for API polling. Set `0` to disable polling.
* Policy Reporter Kyverno Plugin
Expand Down
8 changes: 4 additions & 4 deletions charts/policy-reporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Check the [Documentation](https://kyverno.github.io/policy-reporter/guide/02-get
| target.webhook.filter | object | `{}` | |
| target.webhook.channels | list | `[]` | |
| target.telegram.token | string | `""` | |
| target.telegram.chatID | string | `""` | |
| target.telegram.chatId | string | `""` | |
| target.telegram.host | string | `""` | |
| target.telegram.certificate | string | `""` | |
| target.telegram.skipTLS | bool | `false` | |
Expand All @@ -252,7 +252,7 @@ Check the [Documentation](https://kyverno.github.io/policy-reporter/guide/02-get
| target.googleChat.customFields | object | `{}` | |
| target.googleChat.filter | object | `{}` | |
| target.googleChat.channels | list | `[]` | |
| target.s3.accessKeyID | string | `""` | |
| target.s3.accessKeyId | string | `""` | |
| target.s3.secretAccessKey | string | `""` | |
| target.s3.secretRef | string | `""` | |
| target.s3.mountedSecret | string | `""` | |
Expand All @@ -270,7 +270,7 @@ Check the [Documentation](https://kyverno.github.io/policy-reporter/guide/02-get
| target.s3.customFields | object | `{}` | |
| target.s3.filter | object | `{}` | |
| target.s3.channels | list | `[]` | |
| target.kinesis.accessKeyID | string | `""` | |
| target.kinesis.accessKeyId | string | `""` | |
| target.kinesis.secretAccessKey | string | `""` | |
| target.kinesis.secretRef | string | `""` | |
| target.kinesis.mountedSecret | string | `""` | |
Expand All @@ -283,7 +283,7 @@ Check the [Documentation](https://kyverno.github.io/policy-reporter/guide/02-get
| target.kinesis.customFields | object | `{}` | |
| target.kinesis.filter | object | `{}` | |
| target.kinesis.channels | list | `[]` | |
| target.securityHub.accessKeyID | string | `""` | |
| target.securityHub.accessKeyId | string | `""` | |
| target.securityHub.secretAccessKey | string | `""` | |
| target.securityHub.secretRef | string | `""` | |
| target.securityHub.mountedSecret | string | `""` | |
Expand Down
10 changes: 5 additions & 5 deletions charts/policy-reporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ config:

{{- define "target.telegram" -}}
config:
chatID: {{ .chatID | quote }}
chatId: {{ .chatId | quote }}
token: {{ .token | quote }}
webhook: {{ .webhook | quote }}
certificate: {{ .certificate | quote }}
Expand All @@ -205,7 +205,7 @@ config:

{{- define "target.s3" -}}
config:
accessKeyID: {{ .accessKeyID }}
accessKeyId: {{ .accessKeyId }}
secretAccessKey: {{ .secretAccessKey }}
region: {{ .region }}
endpoint: {{ .endpoint }}
Expand All @@ -220,7 +220,7 @@ config:

{{- define "target.kinesis" -}}
config:
accessKeyID: {{ .accessKeyID }}
accessKeyId: {{ .accessKeyId }}
secretAccessKey: {{ .secretAccessKey }}
region: {{ .region }}
endpoint: {{ .endpoint }}
Expand All @@ -230,11 +230,11 @@ config:

{{- define "target.securityhub" -}}
config:
accessKeyID: {{ .accessKeyID }}
accessKeyId: {{ .accessKeyId }}
secretAccessKey: {{ .secretAccessKey }}
region: {{ .region }}
endpoint: {{ .endpoint }}
accountID: {{ .accountID }}
accountId: {{ .accountId }}
productName: {{ .productName }}
companyName: {{ .companyName }}
delayInSeconds: {{ .delayInSeconds }}
Expand Down
20 changes: 10 additions & 10 deletions charts/policy-reporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ reportFilter:
sourceConfig: []
# - selector:
# source: kyverno
# customID:
# customId:
# enabled: true
# fields: ["resource", "policy", "rule", "category", "result", "message"]

Expand Down Expand Up @@ -475,7 +475,7 @@ target:
# telegram bot token
token: ""
# telegram chat id
chatID: ""
chatId: ""
# optional telegram proxy host
host: ""
# path to your custom certificate
Expand Down Expand Up @@ -531,10 +531,10 @@ target:

s3:
# S3 access key
accessKeyID: ""
accessKeyId: ""
# S3 secret access key
secretAccessKey: ""
# receive the accessKeyID and/or secretAccessKey from an existing secret instead
# receive the accessKeyId and/or secretAccessKey from an existing secret instead
secretRef: ""
# Mounted secret path by Secrets Controller, secret should be in json format
mountedSecret: ""
Expand Down Expand Up @@ -569,10 +569,10 @@ target:

kinesis:
# AWS access key
accessKeyID: ""
accessKeyId: ""
# AWS secret access key
secretAccessKey: ""
# receive the accessKeyID and/or secretAccessKey from an existing secret instead
# receive the accessKeyId and/or secretAccessKey from an existing secret instead
secretRef: ""
# Mounted secret path by Secrets Controller, secret should be in json format
mountedSecret: ""
Expand All @@ -597,19 +597,19 @@ target:

securityHub:
# AWS access key
accessKeyID: ""
accessKeyId: ""
# AWS secret access key
secretAccessKey: ""
# receive the accessKeyID and/or secretAccessKey from an existing secret instead
# receive the accessKeyId and/or secretAccessKey from an existing secret instead
secretRef: ""
# Mounted secret path by Secrets Controller, secret should be in json format
mountedSecret: ""
# AWS region
region: ""
# AWS SecurityHub endpoint (optional)
endpoint: ""
# AWS accountID
accountID: ""
# AWS accountId
accountId: ""
# Used product name, defaults to "Polilcy Reporter"
productName: ""
# minimum severity "" < info < low < medium < high < critical
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v2/views.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ func MapTelegramToTarget(ta *target.Config[target.TelegramOptions]) *Target {
t.Host = ta.Config.Webhook
t.SkipTLS = ta.Config.SkipTLS
t.UseTLS = ta.Config.Certificate != ""
t.Properties["chatID"] = ta.Config.ChatID
t.Properties["chatId"] = ta.Config.ChatID

return t
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v2/views_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func TestV2Views(t *testing.T) {

assert.Equal(t, "Telegram", target.Type)
assert.Equal(t, "http://telegram.com", target.Host)
assert.Equal(t, "1234567", target.Properties["chatID"])
assert.Equal(t, "1234567", target.Properties["chatId"])
assert.True(t, target.SkipTLS)
assert.True(t, target.UseTLS)
assert.False(t, target.Auth)
Expand Down Expand Up @@ -302,7 +302,7 @@ func TestV2Views(t *testing.T) {
assert.Equal(t, "SecurityHub", target.Type)
assert.Equal(t, "https://securityhub.aws.com", target.Host)
assert.Equal(t, "eu-central-1", target.Properties["region"])
assert.Equal(t, true, target.Properties["cleanup"])
assert.Equal(t, true, target.Properties["synchronize"])
assert.True(t, target.Auth)
})

Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ type CustomID struct {

type SourceConfig struct {
Selector SourceSelector `mapstructure:"selector"`
CustomID `mapstructure:"customID"`
CustomID `mapstructure:"customId"`
}

// Config of the PolicyReporter
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ var targets = target.Targets{
Endpoint: "https://storage.yandexcloud.net",
Region: "ru-central1",
},
AccountID: "AccountID",
AccountID: "AccountId",
},
SkipExisting: true,
MinimumSeverity: "debug",
Expand Down
8 changes: 4 additions & 4 deletions pkg/kubernetes/secrets/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type Values struct {
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
APIKey string `json:"apiKey,omitempty"`
AccessKeyID string `json:"accessKeyID,omitempty"`
AccessKeyID string `json:"accessKeyId,omitempty"`
SecretAccessKey string `json:"secretAccessKey,omitempty"`
AccountID string `json:"accountID,omitempty"`
AccountID string `json:"accountId,omitempty"`
KmsKeyID string `json:"kmsKeyId,omitempty"`
Token string `json:"token,omitempty"`
Credentials string `json:"credentials,omitempty"`
Expand Down Expand Up @@ -79,7 +79,7 @@ func (c *k8sClient) Get(ctx context.Context, name string) (Values, error) {
values.DSN = string(dsn)
}

if accessKeyID, ok := secret.Data["accessKeyID"]; ok {
if accessKeyID, ok := secret.Data["accessKeyId"]; ok {
values.AccessKeyID = string(accessKeyID)
}

Expand All @@ -91,7 +91,7 @@ func (c *k8sClient) Get(ctx context.Context, name string) (Values, error) {
values.KmsKeyID = string(kmsKeyID)
}

if accountID, ok := secret.Data["accountID"]; ok {
if accountID, ok := secret.Data["accountId"]; ok {
values.AccountID = string(accountID)
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/kubernetes/secrets/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func newFakeClient() v1.SecretInterface {
"password": []byte("password"),
"apiKey": []byte("apiKey"),
"webhook": []byte("http://localhost:9200/webhook"),
"accessKeyID": []byte("accessKeyID"),
"accessKeyId": []byte("accessKeyId"),
"secretAccessKey": []byte("secretAccessKey"),
"kmsKeyId": []byte("kmsKeyId"),
"token": []byte("token"),
"accountID": []byte("accountID"),
"accountId": []byte("accountId"),
"database": []byte("database"),
"dsn": []byte("dsn"),
"typelessApi": []byte("false"),
Expand Down Expand Up @@ -68,7 +68,7 @@ func Test_Client(t *testing.T) {
t.Errorf("Unexpected ApiKey: %s", values.APIKey)
}

if values.AccessKeyID != "accessKeyID" {
if values.AccessKeyID != "accessKeyId" {
t.Errorf("Unexpected AccessKeyID: %s", values.AccessKeyID)
}

Expand All @@ -84,8 +84,8 @@ func Test_Client(t *testing.T) {
t.Errorf("Unexpected KmsKeyId: %s", values.KmsKeyID)
}

if values.AccountID != "accountID" {
t.Errorf("Unexpected AccountID: %s", values.AccountID)
if values.AccountID != "accountId" {
t.Errorf("Unexpected accountId: %s", values.AccountID)
}

if values.Database != "database" {
Expand Down
6 changes: 3 additions & 3 deletions pkg/target/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (config *Config[T]) Secret() string {
}

type AWSConfig struct {
AccessKeyID string `mapstructure:"accessKeyID"`
AccessKeyID string `mapstructure:"accessKeyId"`
SecretAccessKey string `mapstructure:"secretAccessKey"`
Region string `mapstructure:"region"`
Endpoint string `mapstructure:"endpoint"`
Expand Down Expand Up @@ -85,7 +85,7 @@ type HostOptions struct {
type TelegramOptions struct {
WebhookOptions `mapstructure:",squash"`
Token string `mapstructure:"token"`
ChatID string `mapstructure:"chatID"`
ChatID string `mapstructure:"chatId"`
}

type SlackOptions struct {
Expand Down Expand Up @@ -127,7 +127,7 @@ type KinesisOptions struct {

type SecurityHubOptions struct {
AWSConfig `mapstructure:",squash"`
AccountID string `mapstructure:"accountID"`
AccountID string `mapstructure:"accountId"`
ProductName string `mapstructure:"productName"`
CompanyName string `mapstructure:"companyName"`
DelayInSeconds int `mapstructure:"delayInSeconds"`
Expand Down
18 changes: 9 additions & 9 deletions pkg/target/factory/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func newFakeClient() v1.SecretInterface {
"channel": []byte("general"),
"apiKey": []byte("apiKey"),
"webhook": []byte("http://localhost:9200/webhook"),
"accountId": []byte("accountID"),
"accountId": []byte("accountId"),
"typelessApi": []byte("true"),
"accessKeyID": []byte("accessKeyID"),
"accessKeyId": []byte("accessKeyId"),
"secretAccessKey": []byte("secretAccessKey"),
"kmsKeyId": []byte("kmsKeyId"),
"token": []byte("token"),
Expand All @@ -57,7 +57,7 @@ func mountSecret() {
Username: "username",
Password: "password",
APIKey: "apiKey",
AccountID: "accountID",
AccountID: "accountId",
AccessKeyID: "accessKeyId",
SecretAccessKey: "secretAccessKey",
KmsKeyID: "kmsKeyId",
Expand Down Expand Up @@ -426,13 +426,13 @@ func Test_SecurityHubValidation(t *testing.T) {
},
}

t.Run("SecurityHub.AccountID", func(t *testing.T) {
t.Run("SecurityHub.AccountId", func(t *testing.T) {
if len(factory.CreateClients(&targets).Clients()) != 0 {
t.Error("Expected Client to be nil if no accountID is configured")
t.Error("Expected Client to be nil if no accountId is configured")
}
})

targets.SecurityHub.Config.AccountID = "accountID"
targets.SecurityHub.Config.AccountID = "accountId"
t.Run("SecurityHub.AccessKey", func(t *testing.T) {
if len(factory.CreateClients(&targets).Clients()) != 0 {
t.Error("Expected Client to be nil if no accessKey is configured")
Expand Down Expand Up @@ -514,7 +514,7 @@ func Test_GetValuesFromSecret(t *testing.T) {
SecretRef: secretName,
Config: &target.SecurityHubOptions{
AWSConfig: target.AWSConfig{Endpoint: "endoint", Region: "region"},
AccountID: "accountID",
AccountID: "accountId",
},
},
GCS: &target.Config[target.GCSOptions]{
Expand Down Expand Up @@ -730,7 +730,7 @@ func Test_CustomFields(t *testing.T) {
Endpoint: "https://storage.yandexcloud.net",
Region: "ru-central1",
},
AccountID: "AccountID",
AccountID: "AccountId",
},
CustomFields: map[string]string{"field": "value"},
},
Expand Down Expand Up @@ -883,7 +883,7 @@ func Test_GetValuesFromMountedSecret(t *testing.T) {
MountedSecret: mountedSecret,
Config: &target.SecurityHubOptions{
AWSConfig: target.AWSConfig{Endpoint: "endoint", Region: "region"},
AccountID: "accountID",
AccountID: "accountId",
},
},
GCS: &target.Config[target.GCSOptions]{
Expand Down
Loading

0 comments on commit ab7c0b6

Please sign in to comment.