google.cloud.forseti.notifier.notifiers.cscc_notifier module

Upload violations to GCS bucket as Findings.

class CsccNotifier(inv_index_id)[source]

Bases: object

Send violations to CSCC via API or via GCS bucket.

static _get_output_filename()[source]

Create the output filename. :returns: The output filename for the violations json. :rtype: str

_send_findings_to_cscc(violations, organization_id=None, source_id=None)[source]

Send violations to CSCC directly via the CSCC API.

Parameters:
  • violations (dict) – Violations to be uploaded as findings.
  • organization_id (str) – The id prefixed with ‘organizations/’.
  • source_id (str) – Unique ID assigned by CSCC, to the organization that the violations are originating from.
_send_findings_to_gcs(violations, gcs_path)[source]

Send violations to CSCC via upload to GCS (legacy mode). :param violations: Violations to be uploaded as findings. :type violations: dict :param gcs_path: The GCS bucket to upload the findings. :type gcs_path: str

_transform_for_api(violations, source_id=None)[source]

Transform forseti violations to findings for CSCC API.

Parameters:
  • violations (dict) – Violations to be sent to CSCC as findings.
  • source_id (str) – Unique ID assigned by CSCC, to the organization that the violations are originating from.
Returns:

violations in findings format; each violation is a dict.

Return type:

list

_transform_for_gcs(violations, gcs_upload_path)[source]

Transform forseti violations to GCS findings format.

Parameters:
  • violations (dict) – Violations to be uploaded as findings.
  • gcs_upload_path (str) – bucket and filename where the violations will be outputted on GCS
Returns:

violations in findings format; each violation is a dict.

Return type:

list

run(violations, gcs_path=None, mode=None, organization_id=None, source_id=None)[source]

Generate the temporary json file and upload to GCS.

Parameters:
  • violations (dict) – Violations to be uploaded as findings.
  • gcs_path (str) – The GCS bucket to upload the findings.
  • mode (str) – The mode in which to send the CSCC notification.
  • organization_id (str) – The id of the organization.
  • source_id (str) – Unique ID assigned by CSCC, to the organization that the violations are originating from.