Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit usages of secret.StringData #3125

Closed
georgethebeatle opened this issue Feb 16, 2024 · 0 comments · Fixed by #3141
Closed

Revisit usages of secret.StringData #3125

georgethebeatle opened this issue Feb 16, 2024 · 0 comments · Fixed by #3141
Labels

Comments

@georgethebeatle
Copy link
Member

Background

We have noticed that using secret.StringData can be dangerous in controllers context, especially in CreateOrPatch.

Usually , when we CreateOrPatch a secret, we are modifying an already existing secret that has its Data populated. According to the k8s docs values from secret.StringData are merged into the existing secret.Data. This is dangerous when we want to replace the whole secret data (e.g. we want to remove a key by applying all other keys).

Action to take

It is worth going through all usages of StringData in Korifi and re-evaluating if we are really doing the right thing, filling any test gaps.

@github-project-automation github-project-automation bot moved this to 🧊 Icebox in Korifi - Backlog Feb 16, 2024
@georgethebeatle georgethebeatle moved this from 🧊 Icebox to 🇪🇺 To do in Korifi - Backlog Feb 16, 2024
@github-project-automation github-project-automation bot moved this to 🧊 Icebox in Korifi - Backlog Feb 16, 2024
@georgethebeatle georgethebeatle moved this from 🇪🇺 To do to 🔄 In progress in Korifi - Backlog Feb 23, 2024
danail-branekov added a commit that referenced this issue Feb 23, 2024
According to the [docs](https://github.com/kubernetes/api/blob/48ed98046a81320c5ec6681f614e31892035edef/core/v1/types.go#L6841):

```
stringData allows specifying non-binary secret data in string form.
It is provided as a write-only input field for convenience.
All keys and values are merged into the data field on write, overwriting any existing values.
```

This means that it is not always safe to use StringData, since existing
keys will never be removed

fixes #3125

Co-authored-by: Danail Branekov <danailster@gmail.com>
@georgethebeatle georgethebeatle linked a pull request Feb 23, 2024 that will close this issue
danail-branekov added a commit that referenced this issue Feb 26, 2024
According to the [docs](https://github.com/kubernetes/api/blob/48ed98046a81320c5ec6681f614e31892035edef/core/v1/types.go#L6841):

```
stringData allows specifying non-binary secret data in string form.
It is provided as a write-only input field for convenience.
All keys and values are merged into the data field on write, overwriting any existing values.
```

This means that it is not always safe to use StringData, since existing
keys will never be removed

fixes #3125

Co-authored-by: Danail Branekov <danailster@gmail.com>
Co-authored-by: Georgi Sabev <georgethebeatle@gmail.com>
danail-branekov added a commit that referenced this issue Feb 26, 2024
According to the [docs](https://github.com/kubernetes/api/blob/48ed98046a81320c5ec6681f614e31892035edef/core/v1/types.go#L6841):

```
stringData allows specifying non-binary secret data in string form.
It is provided as a write-only input field for convenience.
All keys and values are merged into the data field on write, overwriting any existing values.
```

This means that it is not always safe to use StringData, since existing
keys will never be removed

fixes #3125

Co-authored-by: Danail Branekov <danailster@gmail.com>
Co-authored-by: Georgi Sabev <georgethebeatle@gmail.com>
@github-project-automation github-project-automation bot moved this from 🔄 In progress to ✅ Done in Korifi - Backlog Feb 26, 2024
marsteg pushed a commit to marsteg/korifi that referenced this issue Mar 19, 2024
According to the [docs](https://github.com/kubernetes/api/blob/48ed98046a81320c5ec6681f614e31892035edef/core/v1/types.go#L6841):

```
stringData allows specifying non-binary secret data in string form.
It is provided as a write-only input field for convenience.
All keys and values are merged into the data field on write, overwriting any existing values.
```

This means that it is not always safe to use StringData, since existing
keys will never be removed

fixes cloudfoundry#3125

Co-authored-by: Danail Branekov <danailster@gmail.com>
Co-authored-by: Georgi Sabev <georgethebeatle@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant