-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Added more automatic generator functions (#694) #866
Conversation
suggestion from Kapitan Workgroup: introduce one new function
where class is one of:
i.e. |
Do you think in |
Fixes issue #694
Proposed Changes
New generic
random
function:Generates a random string based on given parameters.
Usage
The first parameter
type
has to be one of:str
: generator function for alphanumeric characters, will be url-token-safeint
: generator function for digits (0-9)loweralpha
: generator function for lowercase letters (a-z)upperalpha
: generator function for uppercase letters (A-Z)loweralphanum
: generator function for lowercase letters and numbers (a-z and 0-9)upperalphanum
: generator function for uppercase letters and numbers (A-Z and 0-9)special
: generator function for alphanumeric characters and given special charactersI'm always open for name suggestions.
All these types have in common, that the second parameter
nchars
indicates how many characters the generated secret contains.The default value for this is
random:str
: 43 charactersrandom:int
: 16 charactersThe
special
type has a third argument that indicates which special characters are allowed for the generation.The default for that is
string.punctuation
(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
).NOTE: in manual usage the characters
|
and:
are used for function and argument parsing, so they can't be specified.This might be a
Breaking change
To pass special characters into the generator pool, we have to change the REF_TOKEN_TAG_PATTERN-regex.
The new regex
(\?{(\w+:[\w\-\.\@\=\/\:]+)(\|(?:(?:\|\w+)(?::\S*)*)+)?\=*})
matches all existing use cases, but is more restricted.So be beware of unexpected errors.
Furthermore the existing generator functions
randomstr
andlowernumalpha
are still working and still behave the same.But they will be removed soon.
Examples
Here are some example cases with expected output:
?{ref:path/to/secret||random:int}
generates a secret containing 16 (default) digits, i.e.1254872907909324
?{ref:path/to/secret||random:upperalphanum:12}
generates a secret containing 12 chars from uppercase letters and numbers, i.e.VUPA0GIO47C2
?{ref:path/to/secret||random:special:16:!$%&}
generates a secret containing 16 chars from alphanumeric letters and given special characters!$%&
, i.e.!kQT&m%csSDsdaBy
You could leave the argument empty, so
?{ref:path/to/secret||random:special:12:}
generates a alphanumeric string without any special characters.Documentation and testing
Minor Issue
tl;dr: Some errors don't get caught and could produce some unexpected behavior.
See detailed: #694 (comment)