Exemple #1
0
def TransformContainerAnalysisData(image_name, occurrence_filter=None):
    """Transforms the occurrence data from Container Analysis API."""
    occurrences = FetchOccurrencesForResource(image_name, occurrence_filter)
    analysis_obj = container_analysis_data_util.ContainerAndAnalysisData(
        image_name)
    for occurrence in occurrences:
        analysis_obj.add_record(occurrence)
    return analysis_obj
Exemple #2
0
def TransformContainerAnalysisData(image_name, occurrence_filter=None,
                                   deployments=False):
  """Transforms the occurrence data from Container Analysis API."""
  analysis_obj = container_analysis_data_util.ContainerAndAnalysisData(
      image_name)
  occs = FetchOccurrencesForResource(image_name, occurrence_filter)
  for occ in occs:
    analysis_obj.add_record(occ)
  if deployments:
    depl_occs = FetchDeploymentsForImage(image_name, occurrence_filter)
    for depl_occ in depl_occs:
      analysis_obj.add_record(depl_occ)
  analysis_obj.resolveSummaries()
  return analysis_obj
Exemple #3
0
def TransformContainerAnalysisData(
    image_name, occurrence_filter=filter_util.ContainerAnalysisFilter()):
    """Transforms the occurrence data from Container Analysis API."""
    analysis_obj = container_analysis_data_util.ContainerAndAnalysisData(
        image_name)
    project_id = RecoverProjectId(image_name)
    occs = requests.ListOccurrences(project_id, occurrence_filter.GetFilter())
    for occ in occs:
        analysis_obj.add_record(occ)

    if 'DEPLOYMENT' in occurrence_filter.kinds:
        dep_filter = occurrence_filter.WithKinds(['DEPLOYMENT'
                                                  ]).WithResources([])
        dep_occs = requests.ListOccurrences(project_id, dep_filter.GetFilter())
        image_string = six.text_type(image_name)
        for occ in dep_occs:
            if not occ.deployment:
                continue
            if image_string in occ.deployment.resourceUri:
                analysis_obj.add_record(occ)

    analysis_obj.resolveSummaries()
    return analysis_obj