add more debug
This commit is contained in:
parent
c502773ab9
commit
7c1fb5c9c8
1 changed files with 40 additions and 12 deletions
|
@ -16,7 +16,6 @@ import sys
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
from logging.handlers import SysLogHandler
|
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
import binascii
|
import binascii
|
||||||
import click
|
import click
|
||||||
|
@ -659,7 +658,23 @@ class NextcloudHandler:
|
||||||
if all_passwords:
|
if all_passwords:
|
||||||
for password in all_passwords:
|
for password in all_passwords:
|
||||||
if self.is_same_password(obj, password):
|
if self.is_same_password(obj, password):
|
||||||
|
safer_password = dict(password, **{ 'password': '***' })
|
||||||
|
self._log.debug(
|
||||||
|
{
|
||||||
|
"action": "test_exists_password",
|
||||||
|
"message": "Same password already exists",
|
||||||
|
"object": safer_obj,
|
||||||
|
"existing_password": safer_password
|
||||||
|
}
|
||||||
|
)
|
||||||
return True
|
return True
|
||||||
|
self._log.debug(
|
||||||
|
{
|
||||||
|
"action": "test_exists_password",
|
||||||
|
"message": "No password match found",
|
||||||
|
"object": safer_obj
|
||||||
|
}
|
||||||
|
)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def create_password(self, post_obj):
|
def create_password(self, post_obj):
|
||||||
|
@ -804,16 +819,16 @@ class NextcloudHandler:
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
if obj1['label'] == obj2['label']:
|
# if obj1['label'] == obj2['label']:
|
||||||
self.debug(
|
# self.debug(
|
||||||
{
|
# {
|
||||||
"action": "notify_name_match",
|
# "action": "notify_name_match",
|
||||||
"object": {
|
# "object": {
|
||||||
"obj1": safer_obj1,
|
# "obj1": safer_obj1,
|
||||||
"obj2": safer_obj2
|
# "obj2": safer_obj2
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
)
|
# )
|
||||||
if (
|
if (
|
||||||
self.is_same_key('username', obj1, obj2) and
|
self.is_same_key('username', obj1, obj2) and
|
||||||
self.is_same_key('password', obj1, obj2) and
|
self.is_same_key('password', obj1, obj2) and
|
||||||
|
@ -960,6 +975,7 @@ class NcPasswordClient:
|
||||||
obj['password'] = raw_values[0]
|
obj['password'] = raw_values[0]
|
||||||
raw_values.pop(0)
|
raw_values.pop(0)
|
||||||
for line in raw_values:
|
for line in raw_values:
|
||||||
|
custom_fields = {}
|
||||||
if ': ' in line:
|
if ': ' in line:
|
||||||
split_line = line.split(': ')
|
split_line = line.split(': ')
|
||||||
field = split_line[0]
|
field = split_line[0]
|
||||||
|
@ -967,10 +983,22 @@ class NcPasswordClient:
|
||||||
else:
|
else:
|
||||||
field = line
|
field = line
|
||||||
value = ''
|
value = ''
|
||||||
if field != '' and value != '':
|
if value != '':
|
||||||
|
if field == '':
|
||||||
|
field = 'notes'
|
||||||
if field == 'login':
|
if field == 'login':
|
||||||
field = 'username'
|
field = 'username'
|
||||||
|
if field == 'uri':
|
||||||
|
field = 'url'
|
||||||
|
if field not in custom_fields:
|
||||||
|
custom_fields[field] = value
|
||||||
|
else:
|
||||||
|
if isinstance(custom_fields[field], str):
|
||||||
|
custom_fields[field] = [ custom_fields[field], value]
|
||||||
|
else:
|
||||||
|
custom_fields[field].append(value)
|
||||||
obj[field] = value
|
obj[field] = value
|
||||||
|
obj['customFields'] = json.dumps(custom_fields)
|
||||||
new_password = self.nc.create_password(obj)
|
new_password = self.nc.create_password(obj)
|
||||||
if new_password:
|
if new_password:
|
||||||
self.debug(
|
self.debug(
|
||||||
|
|
Loading…
Reference in a new issue