Fix example secrets for credential fields without a length - #670
Merged
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
ExampleSecretFromCompositionsizes the random part of an example secret asLength - len(prefix) - len(suffix), which assumesLengthis always set. It's optional inValueComposition, and correctly left unset for values that vary in length. With noLength, a field without a prefix produced an empty value, and a field with a prefix produced a negative length that panicked inmake([]byte, n). On currentmain,<plugin>/example-secretsprints blank values for 14 plugins (e.g. Snowflake) and crashes for 11 (e.g. PyPI).When
Lengthis unset, the value is now built additively: prefix, 24 random characters, then theEXAMPLEsuffix when the charset has letters. The random part no longer depends on the prefix, so a long prefix can't consume it. WhenLengthis set, output is unchanged except at the edges:EXAMPLEis only added if at least one random character still fits, and the random part is clamped at zero so aLengthshorter than the prefix can't panic. All 61 existing fields that declare aLengthstill produce exactly that length.Type of change
Related Issue(s)
How To Test
Unit tests, including regression tests for the reported bug:
go test ./sdk/plugintest/ -vEnd to end with the contributor tooling. These printed blank values or panicked before this change, and should now print a full value for every field:
These declare a fixed
Lengthand should print values of exactly that length, as before:Changelog
<plugin>/example-secretsnow generates example values for credential fields without aLength, instead of printing blanks or crashing.