Skip to content

Commit 254b181

Browse files
committed
Fix default parser logic in ParsingPipelineFactory;
Add progress callback to data source processing in ParsingPipeline
1 parent e39760c commit 254b181

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

bofhound/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@ def main(
118118
pipeline = ParsingPipelineFactory.create_pipeline(parser_type=parser_type)
119119

120120
with console.status("", spinner="aesthetic") as status:
121-
results = pipeline.process_data_source(data_source)
121+
results = pipeline.process_data_source(
122+
data_source,
123+
progress_callback=lambda id: status.update(f"Processing {id}")
124+
)
122125

123126
ldap_objects = results.get_ldap_objects()
124127
local_objects = results.get_local_group_memberships() + results.get_sessions() + \

bofhound/parsers/parsing_pipeline.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def register_parser(self, parser: ToolParser):
5757
"""Register a tool parser with the pipeline"""
5858
self.tool_parsers.append(parser)
5959

60-
def process_data_source(self, data_source: DataSource) -> ParsingResult:
60+
def process_data_source(self, data_source: DataSource, progress_callback=None) -> ParsingResult:
6161
"""
6262
Process a data source through all registered parsers.
6363
@@ -66,6 +66,8 @@ def process_data_source(self, data_source: DataSource) -> ParsingResult:
6666
result = ParsingResult()
6767

6868
for data_stream in data_source.get_data_streams():
69+
if progress_callback:
70+
progress_callback(data_stream.identifier)
6971
for line in data_stream.lines():
7072
# Apply platform-specific filtering
7173
filtered_line = line.rstrip('\n\r')
@@ -116,9 +118,9 @@ def create_pipeline(parser_type: ParserType = ParserType.LdapsearchBof) -> Parsi
116118
pipeline.register_parser(NetSessionBofParser())
117119
pipeline.register_parser(NetLocalGroupBofParser())
118120
pipeline.register_parser(RegSessionBofParser())
119-
if parser_type == ParserType.LdapsearchBof:
120-
pipeline.register_parser(LdapSearchBofParser())
121-
elif parser_type == ParserType.BRC4:
121+
if parser_type == ParserType.BRC4:
122122
pipeline.register_parser(Brc4LdapSentinelParser())
123+
else:
124+
pipeline.register_parser(LdapSearchBofParser())
123125

124126
return pipeline

0 commit comments

Comments
 (0)