Skip to content

Commit fe97da0

Browse files
committed
Initialize file that stores API key with 0600 permissions
1 parent 6552a7a commit fe97da0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

bin/shodan

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def get_api_key():
5050

5151
# Make sure it is a read-only file
5252
os.chmod(keyfile, 0600)
53-
53+
5454
with open(keyfile, 'r') as fin:
5555
return fin.read().strip()
5656

@@ -85,10 +85,13 @@ def init(key):
8585
raise click.ClickException('Unable to create directory to store the Shodan API key (%s)' % shodan_dir)
8686

8787
# Store the API key in the user's directory
88-
with open(shodan_dir + '/api_key', 'w') as fout:
88+
keyfile = shodan_dir + '/api_key'
89+
with open(keyfile, 'w') as fout:
8990
fout.write(key.strip())
9091
click.echo(click.style('Successfully initialized', fg='green'))
9192

93+
os.chmod(keyfile, 0600)
94+
9295

9396
@main.command()
9497
@click.argument('query', metavar='<search query>', nargs=-1)

0 commit comments

Comments
 (0)