add some basic key validation

This commit is contained in:
Girish Ramakrishnan 2020-01-17 11:09:14 -08:00
parent 38f24649fe
commit 891169e87b
1 changed files with 4 additions and 0 deletions

View File

@ -24,6 +24,10 @@ if (process.argv[2] === 'get') {
} else if (process.argv[2] === 'set') {
if (process.argv.length !== 5) return usage();
// https://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateAccessKey.html
if (process.argv[4].length < 5) return console.log('secret key must be atleast 5 characters');
if (!/^[\w+=,.@-]+$/.test(process.argv[3])) return console.log('access key has invalid characters');
accessKey.value = process.argv[3];
if (process.argv[4].length < 8) return console.log('secret key must be atleast 8 characters');