コード例 #1
0
def GroupAssetsReqHook(ref, args, req):
    """Hook up filter such that the CSCC filter is used rather than gcloud."""
    del ref
    req.parent = GetParent(args)
    req.groupAssetsRequest.filter = args.filter
    args.filter = ""
    return req
コード例 #2
0
def ListAssetsReqHook(ref, args, req):
    """Hook up filter such that the CSCC filter is used rather than gcloud."""
    del ref
    req.parent = GetParent(args)
    if req.fieldMask is not None:
        req.fieldMask = CleanUpUserInput(req.fieldMask)
    req.filter = args.filter
    args.filter = ""
    return req
コード例 #3
0
def GroupAssetsReqHook(ref, args, req):
    """Hook up filter such that the CSCC filter is used rather than gcloud."""
    del ref
    req.parent = GetParent(args)
    if not req.groupAssetsRequest:
        messages = sc_client.GetMessages()
        req.groupAssetsRequest = messages.GroupAssetsRequest()
    req.groupAssetsRequest.filter = args.filter
    args.filter = ""
    return req
コード例 #4
0
def _GetSourceNameForParent(args):
    """Returns relative resource name for a source."""
    resource_pattern = re.compile(
        "(organizations|projects|folders)/.*/sources/[0-9-]+")
    id_pattern = re.compile("[0-9-]+")
    if (not resource_pattern.match(args.source)
            and not id_pattern.match(args.source)):
        raise InvalidSCCInputError(
            "The source must either be the full resource "
            "name or the numeric source ID.")
    if resource_pattern.match(args.source):
        # Handle full resource name
        return args.source
    return GetParent(args) + "/sources/" + args.source
コード例 #5
0
def _GetAssetNameForParent(args):
    """Prepares asset relative path using organization and asset."""
    resource_pattern = re.compile(
        "^(organizations|projects|folders)/.*/assets/[0-9]+$")
    id_pattern = re.compile("^[0-9]+$")
    if (not resource_pattern.match(args.asset)
            and not id_pattern.match(args.asset)):
        raise InvalidSCCInputError(
            "Asset argument must match either be the full resource name of "
            "the asset or only the number asset id.")
    if resource_pattern.match(args.asset):
        # Handle asset id as full resource name
        return args.asset
    return GetParent(args) + "/assets/" + args.asset
コード例 #6
0
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
コード例 #7
0
def GroupFindingsReqHook(ref, args, req):
    """Generate a finding's name and parent using org, source and finding id."""
    del ref  # Unused.
    _ValidateMutexOnSourceAndParent(args)
    if not req.groupFindingsRequest:
        messages = sc_client.GetMessages()
        req.groupFindingsRequest = messages.GroupFindingsRequest()
    req.groupFindingsRequest.filter = args.filter
    args.filter = ""
    resource_pattern = re.compile(
        "(organizations|projects|folders)/[a-z0-9]+/sources/[0-9]+")
    parent = GetParent(args)
    if resource_pattern.match(parent):
        args.source = parent
    req.parent = _GetSourceNameForParent(args)
    return req
コード例 #8
0
def DescribeAssetReqHook(ref, args, req):
    """Generate organization name from organization id."""
    del ref
    req.parent = GetParent(args)
    req.filter = _GetNameOrResourceFilterForParent(args)
    return req