Skip to content

Fix validation logic for SecretOrConfigMap - #3413

Merged
s-urbaniak merged 2 commits into
prometheus-operator:masterfrom
matthiasr:mr/fix-validate-secret-or-config-map
Aug 17, 2020
Merged

s-urbaniak merged 2 commits into
prometheus-operator:masterfrom
matthiasr:mr/fix-validate-secret-or-config-map

Conversation

@matthiasr

Copy link
Copy Markdown
Contributor

This was flagged by
golangci-lint. The check
was for the address of the pointer, not the value. Add a test (failing
on master) to verify this, and fix the validation logic.

Follow-up to #2716.

Signed-off-by: Matthias Rampke [email protected]

This was flagged by
[golangci-lint](https://staticcheck.io/docs/checks#SA4022). The check
was for the address of the pointer, not the value. Add a test (failing
on master) to verify this, and fix the validation logic.

Follow-up to prometheus-operator#2716.

Signed-off-by: Matthias Rampke <[email protected]>
@matthiasr
matthiasr requested a review from a team as a code owner August 17, 2020 11:51
@matthiasr
matthiasr requested review from paulfantom and removed request for a team August 17, 2020 11:51
@matthiasr

Copy link
Copy Markdown
Contributor Author

The main question I have is: how has this not become a problem so far? I feel like I am missing something about how all this works together; if I understood the bug correctly this should fail any and all TLS configs?

@simonpasquier

Copy link
Copy Markdown
Contributor

Thanks a lot!

how has this not become a problem so far?

If I read the code correctly, it would only manifest if you've set arbitraryFSAccessThroughSMs to true in your Prometheus spec and define a non-nil TLSConfig. I'll do some additional testing.

@matthiasr

Copy link
Copy Markdown
Contributor Author

aha, that partially explains why exactly those two e2e tests are failing now …

@s-urbaniak

Copy link
Copy Markdown
Contributor

@matthiasr great catch thank you 👍

@matthiasr

Copy link
Copy Markdown
Contributor Author

I believe the denied-tls-secret and denied-tls-configmap e2e tests are wrong – they are testing that local filesystem access is denied, but the configuration that they give does not perform local filesystem access. They passed because validation always failed, but they should not pass.

When local filesystem access is denied, values from secrets and config
maps can still be used. This is the desired behavior, as this is the way
to get secrets into Prometheus without access to its filesystem.

The tests gave the wrong result because validation of the TLS
configuration would always fail, not because it actually attempted to
access local files.

Signed-off-by: Matthias Rampke <[email protected]>
@s-urbaniak

Copy link
Copy Markdown
Contributor

LGTM on green.

@s-urbaniak
s-urbaniak merged commit 156a5ec into prometheus-operator:master Aug 17, 2020
@matthiasr
matthiasr deleted the mr/fix-validate-secret-or-config-map branch August 17, 2020 21:56
simonpasquier added a commit to simonpasquier/prometheus-operator that referenced this pull request Aug 18, 2020
After prometheus-operator#3413, it appears that some of the sub-tests in
`testPromArbitraryFSAcc` aren't useful because the outcome doesn't
depend on the value of ArbitraryFSAccessThroughSMsConfig.Deny. In all
cases, the test should succeed.

Signed-off-by: Simon Pasquier <[email protected]>
simonpasquier added a commit that referenced this pull request Aug 19, 2020
After #3413, it appears that some of the sub-tests in
`testPromArbitraryFSAcc` aren't useful because the outcome doesn't
depend on the value of ArbitraryFSAccessThroughSMsConfig.Deny. In all
cases, the test should succeed.

Signed-off-by: Simon Pasquier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants