Skip to content

Commit

Permalink
fix: gcs bug with empty paths
Browse files Browse the repository at this point in the history
  • Loading branch information
ocervell committed Nov 13, 2024
1 parent 4db7b46 commit 2d57e1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion secator/hooks/gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def process_item(self, item):
return item
to_send = ITEMS_TO_SEND[item._type]
for k, v in item.toDict().items():
if k in to_send and Path(v).exists():
if k in to_send and v and Path(v).exists():
blob_name = f'{item._uuid}_{k}'
t = Thread(target=upload_blob, args=(GCS_BUCKET_NAME, v, blob_name))
t.start()
Expand Down
12 changes: 6 additions & 6 deletions secator/hooks/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def find_duplicates(self):
if not ws_id:
return
if self.sync:
tag_duplicates(ws_id)
debug(f'running duplicate check on workspace {ws_id}', sub='hooks.mongodb')
tag_duplicates(ws_id)
else:
celery_id = tag_duplicates.delay(ws_id)
debug(f'running duplicate check on workspace {ws_id}', id=celery_id, sub='hooks.mongodb')
Expand Down Expand Up @@ -172,19 +172,19 @@ def tag_duplicates(ws_id: str = None):
'seen dupes': len(seen_dupes)
},
id=ws_id,
sub='hooks.mongodb',
sub='hooks.mongodb.duplicates',
verbose=True)
tmp_duplicates_ids = list(dict.fromkeys([i._uuid for i in tmp_duplicates]))
debug(f'duplicate ids: {tmp_duplicates_ids}', id=ws_id, sub='hooks.mongodb', verbose=True)
debug(f'duplicate ids: {tmp_duplicates_ids}', id=ws_id, sub='hooks.mongodb.duplicates', verbose=True)

# Update latest object as non-duplicate
if tmp_duplicates:
duplicates.extend([f for f in tmp_duplicates])
db.findings.update_one({'_id': ObjectId(item._uuid)}, {'$set': {'_related': tmp_duplicates_ids}})
debug(f'adding {item._uuid} as non-duplicate', id=ws_id, sub='hooks.mongodb', verbose=True)
debug(f'adding {item._uuid} as non-duplicate', id=ws_id, sub='hooks.mongodb.duplicates', verbose=True)
non_duplicates.append(item)
else:
debug(f'adding {item._uuid} as non-duplicate', id=ws_id, sub='hooks.mongodb', verbose=True)
debug(f'adding {item._uuid} as non-duplicate', id=ws_id, sub='hooks.mongodb.duplicates', verbose=True)
non_duplicates.append(item)

# debug(f'found {len(duplicates)} total duplicates')
Expand All @@ -208,7 +208,7 @@ def tag_duplicates(ws_id: str = None):
'duplicates': len(duplicates_ids),
'non-duplicates': len(non_duplicates_ids)
},
sub='hooks.mongodb')
sub='hooks.mongodb.duplicates')


HOOKS = {
Expand Down

0 comments on commit 2d57e1a

Please sign in to comment.