Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
Fix csv file for scanner. (#204)
Browse files Browse the repository at this point in the history
* Fix csv file for scanner.

* tweak
  • Loading branch information
blueandgold committed Apr 11, 2017
1 parent b0b2037 commit 808f9ee
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions google/cloud/security/scanner/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,23 @@ def _output_results(all_violations, **kwargs):
**kwargs: The rest of the args.
"""
# Write the CSV.
csv_name = csv_writer.write_csv(
with csv_writer.write_csv(
resource_name='policy_violations',
data=_write_violations_output(all_violations),
write_header=True)
LOGGER.info('CSV filename: %s', csv_name)
write_header=True) as csv_file:
LOGGER.info('CSV filename: %s', csv_file.name)

# Scanner timestamp for output file and email.
now_utc = datetime.utcnow()
# Scanner timestamp for output file and email.
now_utc = datetime.utcnow()

# If output_path specified, upload to GCS.
if FLAGS.output_path:
_upload_csv_to_gcs(FLAGS.output_path, now_utc, csv_name)
# If output_path specified, upload to GCS.
if FLAGS.output_path:
_upload_csv_to_gcs(FLAGS.output_path, now_utc, csv_file.name)

# Send summary email.
if FLAGS.email_recipient is not None:
resource_counts = kwargs.get('resource_counts', {})
_send_email(csv_name, now_utc, all_violations, resource_counts)
# Send summary email.
if FLAGS.email_recipient is not None:
resource_counts = kwargs.get('resource_counts', {})
_send_email(csv_file.name, now_utc, all_violations, resource_counts)

def _upload_csv_to_gcs(output_path, now_utc, csv_name):
"""Upload CSV to Cloud Storage.
Expand Down

0 comments on commit 808f9ee

Please sign in to comment.