def UpdateFindingSecurityMarksReqHook(ref, args, req):
    """Generate a security mark's name using org, source and finding id."""
    del ref  # Unused.
    _ValidateMutexOnFindingAndSourceAndOrganization(args)
    req.name = _GetFindingNameForParent(args) + "/securityMarks"
    if req.updateMask is not None:
        req.updateMask = CleanUpUserInput(req.updateMask)
    return req
Ejemplo n.º 2
0
def UpdateAssetSecurityMarksReqHook(ref, args, req):
    """Generate a security mark's name using org, source and finding."""
    del ref
    _ValidateMutexOnAssetAndOrganization(args)
    req.name = _GetAssetName(args) + "/securityMarks"
    if req.updateMask is not None:
        req.updateMask = CleanUpUserInput(req.updateMask)
    return req
Ejemplo n.º 3
0
def ListAssetsReqHook(ref, args, req):
    """Hook up filter such that the CSCC filter is used rather than gcloud."""
    del ref
    req.parent = GetOrganization(args)
    if req.fieldMask is not None:
        req.fieldMask = CleanUpUserInput(req.fieldMask)
    req.filter = args.filter
    args.filter = ""
    return req
Ejemplo n.º 4
0
def ListFindingsReqHook(ref, args, req):
    """Generates a finding's parent using org and source and hook up filter."""
    del ref
    _ValidateMutexOnSourceAndOrganization(args)
    req.parent = _GetSourceName(args)
    req.filter = args.filter
    if req.fieldMask is not None:
        req.fieldMask = CleanUpUserInput(req.fieldMask)
    args.filter = ""
    resource_pattern = re.compile("organizations/[0-9]+/sources/[0-9-]+")
    if resource_pattern.match(args.organization):
        args.source = args.organization
    return req
Ejemplo n.º 5
0
def UpdateBigQueryExportReqHook(ref, args, req):
    """Updates a BigQuery export."""
    del ref
    parent = _ValidateAndGetParent(args)
    if parent is not None:
        bq_export_id = _ValidateAndGetBigQueryExportId(args)
        req.name = parent + "/bigQueryExports/" + bq_export_id
    else:
        bq_export_name = _ValidateAndGetBigQueryExportFullResourceName(args)
        req.name = bq_export_name
    req.updateMask = CleanUpUserInput(req.updateMask)
    args.filter = ""
    return req
Ejemplo n.º 6
0
def UpdateFindingsReqHook(ref, args, req):
  """Generate a finding's name using org, source and finding id."""
  del ref
  _ValidateMutexOnFindingAndSourceAndOrganization(args)
  req.name = _GetFindingName(args)
  req.updateMask = CleanUpUserInput(req.updateMask)
  # All requests require an event time
  if args.event_time is None:
    # Formatting: 2019-03-22 21:24:36.208463 -> 2019-03-22T21:33:15.830Z"
    event_time = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ")
    if req.finding is None:
      req.finding = sc_client.GetMessages().Finding()
    req.finding.eventTime = event_time
    req.updateMask = req.updateMask + ",event_time"
  return req
def ListFindingsReqHook(ref, args, req):
    """Generates a finding's parent using org and source and hook up filter."""
    del ref  # Unused.
    _ValidateMutexOnSourceAndParent(args)
    req.parent = _GetSourceNameForParent(args)
    req.filter = args.filter
    if req.fieldMask is not None:
        req.fieldMask = CleanUpUserInput(req.fieldMask)
    args.filter = ""
    resource_pattern = re.compile(
        "(organizations|projects|folders)/.*/sources/[0-9-]+$")
    parent = GetParent(args)
    if resource_pattern.match(parent):
        args.source = parent
    return req