Skip to content

Commit

Permalink
Add --force to Bloodhound sync
Browse files Browse the repository at this point in the history
  • Loading branch information
helviojunior committed Aug 1, 2024
1 parent 341b27c commit 4252b57
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions knowsmore/cmd/bloodhound.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ImportMode(Enum):
mode = ImportMode.Undefined
synced = []
tasks = 6
force = False

class BloodhoundFile:
file_name = None
Expand Down Expand Up @@ -351,6 +352,12 @@ def add_flags(self, flags: _ArgumentGroup):
dest=f'neo4j_database',
help=Color.s('Neo4j Database to mark host/users as owned. (default: neo4j)'))

flags.add_argument('--force',
action='store_true',
default=False,
dest=f'force',
help=Color.s('Enable group chain calculation.'))

def add_commands(self, cmds: _ArgumentGroup):
cmds.add_argument('--import-data',
action='store',
Expand Down Expand Up @@ -379,6 +386,7 @@ def load_from_arguments(self, args: Namespace) -> bool:

host = args.neo4j_host
self.mode = Bloodhound.ImportMode.MarkOwned
self.force = args.force

if args.neo4j_host2 is not None and args.neo4j_host2 != '':
self.mode = Bloodhound.ImportMode.Sync
Expand Down Expand Up @@ -602,6 +610,20 @@ def run(self):

Color.pl('{?} {W}{D}Syncing objects...{W}')

if self.force:
self.db.update(
'bloodhound_objects',
filter_data={},
sync_date=datetime.datetime.now() - datetime.timedelta(seconds=60),
updated_date=datetime.datetime.now()
)
self.db.update(
'bloodhound_edge',
filter_data={},
sync_date=datetime.datetime.now() - datetime.timedelta(seconds=60),
updated_date=datetime.datetime.now()
)

db_sync_count = self.db.select_raw(
sql='select count(*) as qty from bloodhound_objects '
'where sync_date <= updated_date',
Expand Down

0 comments on commit 4252b57

Please sign in to comment.