# Импорт через лямбда-функцию используя файл отчета

У вас есть возможность импортировать отчеты в Security Center с помощью функции, представленной ниже.

<pre class="language-python"><code class="lang-python">import json
import urllib.request
import urllib3


def import_report(&#x3C;<a data-footnote-ref href="#user-content-fn-1">event</a>>):
    
    security_center_api_token = "Token " + &#x3C;<a data-footnote-ref href="#user-content-fn-2">security center api_key</a>>
    
    while True:
        try:
            url = 'https://&#x3C;<a data-footnote-ref href="#user-content-fn-3">security_center_address</a>>/api/v1/scan/import/'
            body = {
                "file": ("&#x3C;<a data-footnote-ref href="#user-content-fn-1">event</a>>.json", json.dumps(&#x3C;<a data-footnote-ref href="#user-content-fn-1">event</a>>)),
                "product_name": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">product name</a>>",
                "product_type": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">product_type</a>>",
                "scanner_name": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">scanner name</a>>",
                "branch": "<a data-footnote-ref href="#user-content-fn-1">&#x3C;branch_name></a>", 
                "repository": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">repository SSH URL</a>>",
                "docker_image": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">registry address</a>>", 
                "domain": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">domain</a>>", 
                "host": "&#x3C;<a data-footnote-ref href="#user-content-fn-1">host</a>>"
            }
            data, header = urllib3.encode_multipart_formdata(body)
            r = urllib.request.Request(url, data=data)
            r.add_header('Authorization', security_center_api_token)
            r.add_header('Content-Type', header)
            response = urllib.request.urlopen(r)
            print(response.getcode())
        except Exception as e:
            raise e
        break
    return {
        'statusCode': 200,
        'body': json.dumps('Event successfully imported')
    }
</code></pre>

Замените следующие параметры:

* ***\<event>*** названием вашего файла, содержащего отчет
* ***\<security center api key>*** ключом вашего [**токена авторизации**](/security-center/scanners/importing-reports-from-scanners-to-security-center.md#authorization-token)
* **\<security center address>** адресом вашего Security Center
* **\<product name>** названием вашего продукта
* **\<product\_type>** названием типа вашего продукта
* **\<scanner name>** [**названием вашего сканера**](/security-center/scanners/importing-reports-from-scanners-to-security-center/importing-reports-via-terminal-using-a-report-file.md#list-of-currently-supported-scanners)
* **\<branch>** (необязательно) именем ветки в репозитории исходного кода (если применимо). Этот параметр особенно полезен, когда вы хотите связать результаты сканирования с определенной веткой в вашем репозитории. Если параметр не указан, сканирование будет ассоциировано с веткой по умолчанию

Информация об активах, если используется [Auditor](/auditor/install.md)

* **\<repository>** Если ваш продукт это **код** в репозитории, введите адрес **репозитория** в определенном формате, например: <git@gitlab.com>:cybercodereview/security-center.git
* **\<docker\_image>** Если ваш продукт является **образом**, введите адрес **реестра**, в котором находится ваш продукт, например: registry.gitlab.com/cybercodereview/security-center/back/auto\_validator:latest
* **\<domain>** Если ваш продукт является **веб-ресурсом**, введите **доменное имя** вашего продукта, например: cybercodereview\.ru
* **\<host>** Если ваш продукт находится в **Интернете**, введите **IP-адрес** вашего продукта, например: 0.0.0.0

Поздравляем!🎉 Теперь ваша функция готова к отправке отчетов в Security Center

[^1]: replace

[^2]: заменить

[^3]: Заменить


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cybercodereview.ru/security-center/scanners/importing-reports-from-scanners-to-security-center/importing-reports-via-lambda-function-using-a-report-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
