Skip to content

Commit

Permalink
add some minor logging
Browse files Browse the repository at this point in the history
  • Loading branch information
talltechy committed Apr 19, 2024
1 parent 6997cb8 commit 7498338
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/rapid7/api_r7_isvm_sonar_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def main():
print("CSV file is not formatted correctly. It should have a 'target' column.")
return

# Add new columns for status code and response
df['status_code'] = ''
df['response'] = ''

# Clean data by stripping any leading/trailing whitespace from string data
df = df.apply(lambda x: x.map(str.strip) if x.dtype == "object" else x)

Expand All @@ -74,7 +78,7 @@ def main():
days = int(days) if days.isdigit() else 30

# Loop over rows in DataFrame
for _, row in df.iterrows():
for index, row in df.iterrows():
filters = []
target = row['target']

Expand Down Expand Up @@ -106,8 +110,15 @@ def main():
name = "Example Sonar Query"
name = target
status_code, response_text = create_sonar_query(url, name, criteria, username, password)
print("Status Code:", status_code)
print("Response:", response_text)

# Update status code and response in the DataFrame
df.at[index, 'status_code'] = status_code
df.at[index, 'response'] = response_text

# Save the updated DataFrame to the CSV file
df.to_csv(filepath, index=False)

print("Status code and response added to the CSV file.")

if __name__ == '__main__':
main()

0 comments on commit 7498338

Please sign in to comment.