[DDO-3911] improve chart name validation #701
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sherlock checks that the chart name isn't empty, but it doesn't impose validation on it not having special characters. This is a problem when security scanners target Sherlock's API, because "garbage in garbage out" means Sherlock ingests and stores the garbage.
This PR changes the validation to not just check emptiness but also that it matches the same kind of regex we use to validate environment names.
It is possible for deployment of this change to fail if there's already garbage in the database. I've checked and prod doesn't suffer from this. Dev does so I'll clean up manually.
Testing
We have a ton of testing for all sorts of valid chart names; everything in TestData gets automatically created. I added a test that checks invalid characters and it now properly passes with this fix in place.
Risk
Low. No impact to prod. Any issues would halt rollout.