obfuscate api key when logging to ST console
This commit is contained in:
parent
b671856341
commit
aa30110343
1 changed files with 12 additions and 1 deletions
13
WakaTime.py
13
WakaTime.py
|
@ -124,6 +124,17 @@ def python_binary():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def obfuscate_apikey(cmd):
|
||||||
|
apikey_index = None
|
||||||
|
for num in range(len(cmd)):
|
||||||
|
if cmd[num] == '--key':
|
||||||
|
apikey_index = num + 1
|
||||||
|
break
|
||||||
|
if apikey_index is not None and apikey_index < len(cmd):
|
||||||
|
cmd[apikey_index] = '********-****-****-****-********' + cmd[apikey_index][-4:]
|
||||||
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
def enough_time_passed(now, last_time):
|
def enough_time_passed(now, last_time):
|
||||||
if now - last_time > ACTION_FREQUENCY * 60:
|
if now - last_time > ACTION_FREQUENCY * 60:
|
||||||
return True
|
return True
|
||||||
|
@ -203,7 +214,7 @@ class SendActionThread(threading.Thread):
|
||||||
if python_binary():
|
if python_binary():
|
||||||
cmd.insert(0, python_binary())
|
cmd.insert(0, python_binary())
|
||||||
if self.debug:
|
if self.debug:
|
||||||
print('[WakaTime] %s' % ' '.join(cmd))
|
print('[WakaTime] %s' % ' '.join(obfuscate_apikey(cmd)))
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
Popen(cmd, shell=False)
|
Popen(cmd, shell=False)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue