Skip to content

Commit 5669072

Browse files
committed
Better help messages and docs, secure prompt option
1 parent 40172ee commit 5669072

File tree

3 files changed

+31
-11
lines changed

3 files changed

+31
-11
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ $ secretscli remove TestSecret postgreshost
4343
$ secretscli get TestSecret postgreshost
4444
```
4545

46+
To avoid passing the value directly into the console (potentially logging it in places like bash history) the `-s` flag can be passed and the value can be passed in interactively without displaying it.
47+
48+
49+
```bash
50+
$ secretscli set TestSecret postgrespassword -s
51+
Value:
52+
Repeat for confirmation:
53+
$ secretscli get TestSecret postgrespassword
54+
super_secret_string
55+
```
56+
4657
### Working with entire Files
4758

4859
The entire Secret can be downloaded as a file. This command works regardless of the format of the file- Secrets that are not managed by `secretcli` can be downloaded using this tool.
@@ -59,4 +70,6 @@ $ secretscli upload TestSecret ./secret_configuration.json
5970

6071
## Datastore Format
6172

62-
`secretcli` stores data as a json object. It uses the `SecretString` field in the AWS Secrets Manager- saving it as a string allows the database to be viewed in the AWS Console.
73+
`secretcli` stores data as a JSON Object in an attempt to be as interoperable as possible. Each `key` passed to `secretcli` is represented by a `key` in the JSON Object.
74+
75+
When storing in AWS Secret Manager `secretcli` uses the `SecretString` field in the AWS Secrets Manager. This allows the database to be viewed in the AWS Console both as a raw string and using the Key/Value table.

secretcli/secretcli.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def region():
8080

8181
@cli.command(short_help="Initialize a new secret in the AWS Secrets Manager")
8282
@click.argument('secret')
83-
@click.option('-r', '--region', default=None)
83+
@click.option('-r', '--region', default=None, help='Specify which AWS Region the secret is stored in')
8484
@click.option('-d', '--description', default='')
8585
def init(secret, region, description):
8686
client = get_aws_client(region)
@@ -95,7 +95,7 @@ def init(secret, region, description):
9595
@click.argument('secret')
9696
@click.argument('key')
9797
@click.option('-c', '--category', default=None)
98-
@click.option('-r', '--region', default=None)
98+
@click.option('-r', '--region', default=None, help='Specify which AWS Region the secret is stored in')
9999
def get(secret, key, category, region):
100100
secret_data = get_secret(secret, region)
101101
if category:
@@ -112,10 +112,17 @@ def get(secret, key, category, region):
112112
@cli.command(short_help="Set a specific value in the secret datastore")
113113
@click.argument('secret')
114114
@click.argument('key')
115-
@click.argument('value')
115+
@click.argument('value', required=False)
116+
@click.option('-s', '--secure', is_flag=True, default=False, help='Pass value to prompt without displaying it on screen')
116117
@click.option('-c', '--category', default=None)
117-
@click.option('-r', '--region', default=None)
118-
def set(secret, key, value, category, region):
118+
@click.option('-r', '--region', default=None, help='Specify which AWS Region the secret is stored in')
119+
def set(secret, key, value, category, secure, region):
120+
if not value:
121+
if secure:
122+
value = click.prompt('Value', hide_input=True, confirmation_prompt=True)
123+
else:
124+
raise click.UsageError("Value must be provided for set command")
125+
119126
secret_data = get_secret(secret, region)
120127
if category:
121128
if category not in secret_data:
@@ -130,7 +137,7 @@ def set(secret, key, value, category, region):
130137
@click.argument('secret')
131138
@click.argument('key')
132139
@click.option('-c', '--category', default=None)
133-
@click.option('-r', '--region', default=None)
140+
@click.option('-r', '--region', default=None, help='Specify which AWS Region the secret is stored in')
134141
def remove(secret, key, category, region):
135142
secret_data = get_secret(secret, region)
136143
if category:
@@ -147,7 +154,7 @@ def remove(secret, key, category, region):
147154
@cli.command(short_help="Set a specific value in the secret datastore")
148155
@click.argument('secret')
149156
@click.option('-c', '--category', default=None)
150-
@click.option('-r', '--region', default=None)
157+
@click.option('-r', '--region', default=None, help='Specify which AWS Region the secret is stored in')
151158
def list(secret, category, region):
152159
secret_data = get_secret(secret, region)
153160
if category:
@@ -162,7 +169,7 @@ def list(secret, category, region):
162169
@cli.command(short_help="Upload a replacement secrets file")
163170
@click.argument('secret')
164171
@click.argument('input', type=click.File('rb'))
165-
@click.option('-r', '--region', default=None)
172+
@click.option('-r', '--region', default=None, help='Specify which AWS Region the secret is stored in')
166173
def upload(secret, input, region):
167174
content = input.read().decode("utf-8")
168175
put_secret(secret, content, region, raw=True)
@@ -171,7 +178,7 @@ def upload(secret, input, region):
171178
@cli.command(short_help="Download the entire secrets file")
172179
@click.argument('secret')
173180
@click.argument('output', type=click.File('wb'), required=False)
174-
@click.option('-r', '--region', default=None)
181+
@click.option('-r', '--region', default=None, help='Specify which AWS Region the secret is stored in')
175182
def download(secret, output, region):
176183
contents = get_secret(secret, region, raw=True)
177184
if not output:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
long_description = open('README.md').read()
1111

1212

13-
version = '0.1.1'
13+
version = '0.1.2'
1414
setup(
1515

1616
name = 'secretcli',

0 commit comments

Comments
 (0)