Inspector2 / Client / batch_get_code_snippet

batch_get_code_snippet#

Inspector2.Client.batch_get_code_snippet(**kwargs)#

Retrieves code snippets from findings that Amazon Inspector detected code vulnerabilities in.

See also: AWS API Documentation

Request Syntax

response = client.batch_get_code_snippet(
    findingArns=[
        'string',
    ]
)
Parameters:

findingArns (list) –

[REQUIRED]

An array of finding ARNs for the findings you want to retrieve code snippets from.

  • (string) –

Return type:

dict

Returns:

Response Syntax

{
    'codeSnippetResults': [
        {
            'codeSnippet': [
                {
                    'content': 'string',
                    'lineNumber': 123
                },
            ],
            'endLine': 123,
            'findingArn': 'string',
            'startLine': 123,
            'suggestedFixes': [
                {
                    'code': 'string',
                    'description': 'string'
                },
            ]
        },
    ],
    'errors': [
        {
            'errorCode': 'INTERNAL_ERROR'|'ACCESS_DENIED'|'CODE_SNIPPET_NOT_FOUND'|'INVALID_INPUT',
            'errorMessage': 'string',
            'findingArn': 'string'
        },
    ]
}

Response Structure

  • (dict) –

    • codeSnippetResults (list) –

      The retrieved code snippets associated with the provided finding ARNs.

      • (dict) –

        Contains information on a code snippet retrieved by Amazon Inspector from a code vulnerability finding.

        • codeSnippet (list) –

          Contains information on the retrieved code snippet.

          • (dict) –

            Contains information on the lines of code associated with a code snippet.

            • content (string) –

              The content of a line of code

            • lineNumber (integer) –

              The line number that a section of code is located at.

        • endLine (integer) –

          The line number of the last line of a code snippet.

        • findingArn (string) –

          The ARN of a finding that the code snippet is associated with.

        • startLine (integer) –

          The line number of the first line of a code snippet.

        • suggestedFixes (list) –

          Details of a suggested code fix.

          • (dict) –

            A suggested fix for a vulnerability in your Lambda function code.

            • code (string) –

              The fix’s code.

            • description (string) –

              The fix’s description.

    • errors (list) –

      Any errors Amazon Inspector encountered while trying to retrieve the requested code snippets.

      • (dict) –

        Contains information about any errors encountered while trying to retrieve a code snippet.

        • errorCode (string) –

          The error code for the error that prevented a code snippet from being retrieved.

        • errorMessage (string) –

          The error message received when Amazon Inspector failed to retrieve a code snippet.

        • findingArn (string) –

          The ARN of the finding that a code snippet couldn’t be retrieved for.

Exceptions

  • Inspector2.Client.exceptions.ValidationException

  • Inspector2.Client.exceptions.AccessDeniedException

  • Inspector2.Client.exceptions.ThrottlingException

  • Inspector2.Client.exceptions.InternalServerException