Skip to content

Commit

Permalink
fix(screenshot): get only some columns from csv file
Browse files Browse the repository at this point in the history
  • Loading branch information
psyray committed Jun 20, 2024
1 parent 0509a91 commit 6854031
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 14 additions & 1 deletion web/reNgine/common_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,4 +1027,17 @@ def generate_gospider_params(custom_header):
params.append(f' --cookie "{value}"')
else:
params.append(f' -H "{key}:{value}"')
return ' '.join(params)
return ' '.join(params)

def extract_columns(row, columns):
"""
Extract specific columns from a row based on column indices.
Args:
row (list): The CSV row as a list of values.
columns (list): List of column indices to extract.
Returns:
list: Extracted values from the specified columns.
"""
return [row[i] for i in columns]
5 changes: 3 additions & 2 deletions web/reNgine/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,9 +1195,10 @@ def screenshot(self, ctx={}, description=None):
screenshot_paths = []
with open(output_path, 'r') as file:
reader = csv.reader(file)
header = next(reader) # Skip header row
indices = [header.index(col) for col in ["Protocol", "Port", "Domain", "Request Status", "Screenshot Path", " Source Path"]]
for row in reader:
"Protocol,Port,Domain,Request Status,Screenshot Path, Source Path"
protocol, port, subdomain_name, status, screenshot_path, source_path = tuple(row)
protocol, port, subdomain_name, status, screenshot_path, source_path = extract_columns(row, indices)
logger.info(f'{protocol}:{port}:{subdomain_name}:{status}')
subdomain_query = Subdomain.objects.filter(name=subdomain_name)
if self.scan:
Expand Down

0 comments on commit 6854031

Please sign in to comment.