Skip to content

create_scan

create_scan(
    resource_id: ResourceId,
    scan_name: ScanName,
    *,
    config_overrides: Optional[CodeGuruSecurityClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    scan_type: Optional[ScanType] = None,
    analysis_type: Optional[AnalysisType] = None,
    tags: Optional[TagMap] = None,
) -> CreateScanResponse

Use to create a scan using code uploaded to an Amazon S3 bucket.

Parameters:

  • client_token (Optional[ClientToken], default: None ) –

    The idempotency token for the request. Amazon CodeGuru Security uses this value to prevent the accidental creation of duplicate scans if there are failures and retries.

  • resource_id (ResourceId) –

    The identifier for the resource object to be scanned.

  • scan_name (ScanName) –

    The unique name that CodeGuru Security uses to track revisions across multiple scans of the same resource. Only allowed for a STANDARD scan type.

  • scan_type (Optional[ScanType], default: None ) –

    The type of scan, either Standard or Express. Defaults to Standard type if missing.

    Express scans run on limited resources and use a limited set of detectors to analyze your code in near-real time. Standard scans have standard resource limits and use the full set of detectors to analyze your code.

  • analysis_type (Optional[AnalysisType], default: None ) –

    The type of analysis you want CodeGuru Security to perform in the scan, either Security or All. The Security type only generates findings related to security. The All type generates both security findings and quality findings. Defaults to Security type if missing.

  • tags (Optional[TagMap], default: None ) –

    An array of key-value pairs used to tag a scan. A tag is a custom attribute label with two parts:

    • A tag key. For example, CostCenter, Environment, or Secret. Tag keys are case sensitive.

    • An optional tag value field. For example, 111122223333, Production, or a team name. Omitting the tag value is the same as using an empty string. Tag values are case sensitive.

Raises:

Source code in docs_src/capo_codeguru_security/_services/code_guru_security.py
def create_scan(
    self,
    resource_id: "capo_codeguru_security.types.resource_id.ResourceId",
    scan_name: "capo_codeguru_security.types.scan_name.ScanName",
    *,
    config_overrides: Optional[CodeGuruSecurityClientConfig] = None,
    client_token: Optional[
        "capo_codeguru_security.types.client_token.ClientToken"
    ] = None,
    scan_type: Optional["capo_codeguru_security.types.scan_type.ScanType"] = None,
    analysis_type: Optional[
        "capo_codeguru_security.types.analysis_type.AnalysisType"
    ] = None,
    tags: Optional["capo_codeguru_security.types.tag_map.TagMap"] = None,
) -> "capo_codeguru_security.types.create_scan_response.CreateScanResponse":
    """<p>Use to create a scan using code uploaded to an Amazon S3 bucket.</p>

    Args:
        client_token: <p>The idempotency token for the request. Amazon CodeGuru Security uses this value to prevent the accidental creation of duplicate scans if there are failures and retries.</p>
        resource_id: <p>The identifier for the resource object to be scanned.</p>
        scan_name: <p>The unique name that CodeGuru Security uses to track revisions across multiple scans of the same resource. Only allowed for a <code>STANDARD</code> scan type. </p>
        scan_type: <p>The type of scan, either <code>Standard</code> or <code>Express</code>. Defaults to <code>Standard</code> type if missing.</p> <p> <code>Express</code> scans run on limited resources and use a limited set of detectors to analyze your code in near-real time. <code>Standard</code> scans have standard resource limits and use the full set of detectors to analyze your code.</p>
        analysis_type: <p>The type of analysis you want CodeGuru Security to perform in the scan, either <code>Security</code> or <code>All</code>. The <code>Security</code> type only generates findings related to security. The <code>All</code> type generates both security findings and quality findings. Defaults to <code>Security</code> type if missing.</p>
        tags: <p>An array of key-value pairs used to tag a scan. A tag is a custom attribute label with two parts:</p> <ul> <li> <p>A tag key. For example, <code>CostCenter</code>, <code>Environment</code>, or <code>Secret</code>. Tag keys are case sensitive.</p> </li> <li> <p>An optional tag value field. For example, <code>111122223333</code>, <code>Production</code>, or a team name. Omitting the tag value is the same as using an empty string. Tag values are case sensitive.</p> </li> </ul>

    Raises:
        capo_codeguru_security.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_codeguru_security.errors.conflict_exception.ConflictException: <p>The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request.</p>
        capo_codeguru_security.errors.internal_server_exception.InternalServerException: <p>The server encountered an internal error and is unable to complete the request.</p>
        capo_codeguru_security.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource specified in the request was not found.</p>
        capo_codeguru_security.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_codeguru_security.errors.validation_exception.ValidationException: <p>The input fails to satisfy the specified constraints.</p>
        capo_codeguru_security.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_codeguru_security.types.create_scan_request.CreateScanRequest]",
    ) -> OperationResponse[
        "capo_codeguru_security.types.create_scan_response.CreateScanResponse"
    ]:
        import capo_codeguru_security._operations.aws_code_guru_security.create_scan

        output, http_response = (
            capo_codeguru_security._operations.aws_code_guru_security.create_scan.create_scan(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateScan")
    )
    input_: capo_codeguru_security.types.create_scan_request.CreateScanRequest = {
        "resource_id": resource_id,
        "scan_name": scan_name,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if scan_type is not None:
        input_["scan_type"] = scan_type
    if analysis_type is not None:
        input_["analysis_type"] = analysis_type
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output