We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
VirusTotal Connector error
Please replace every line in curly brackets { like this } with an appropriate answer, and remove this line.

## Description

When trying to enrich a artefact, VirusTotal report the following error every time 
<img width="1022" alt="Screenshot 2021-07-05 at 6 55 12 PM" src="https://user-images.githubusercontent.com/79446411/124463810-fc880300-ddc5-11eb-9564-2a8bded488cc.png">


When I access to the log, it shows the following error
`ERROR:root:Error in message processing, reporting error to API
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pycti/connector/opencti_connector_helper.py", line 152, in _data_handler
    message = self.callback(json_data["event"])
  File "/opt/opencti-connector-virustotal/virustotal.py", line 116, in _process_message
    return self._process_file(observable)
  File "/opt/opencti-connector-virustotal/virustotal.py", line 71, in _process_file
    if observable["name"] is None and len(attributes["names"]) > 0:
KeyError: 'name'
INFO:root:Reporting work update_received opencti-work--c2b1ef93-8b44-4915-b418-f759ee262f53
INFO:root:Message (delivery_tag=1) processed, thread terminated`

## Environment

1. AWS ubuntu-bionic-18.04-amd64-server
2. OpenCTI Version 4.5.5
3. OpenCTI client:  frontend
4. Other environment details: VirusTotal connector version : opencti/connector-virustotal:latest

## Reproducible Steps

Steps to create the smallest reproducible scenario:

## Expected Output

Successfully extract information from VirusTotal 

## Actual Output

Error occurred as mentioned above.
 
## Additional information

{ Any additional information, including logs or screenshots if you have any. }


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `virustotal/src/virustotal.py`
Content:
```
1 from time import sleep
2 import yaml
3 import os
4 import requests
5 import json
6 
7 from pycti import OpenCTIConnectorHelper, get_config_variable
8 
9 
10 class VirusTotalConnector:
11     def __init__(self):
12         # Instantiate the connector helper from config
13         config_file_path = os.path.dirname(os.path.abspath(__file__)) + "/config.yml"
14         config = (
15             yaml.load(open(config_file_path), Loader=yaml.FullLoader)
16             if os.path.isfile(config_file_path)
17             else {}
18         )
19         self.helper = OpenCTIConnectorHelper(config)
20         self.token = get_config_variable(
21             "VIRUSTOTAL_TOKEN", ["virustotal", "token"], config
22         )
23         self.max_tlp = get_config_variable(
24             "VIRUSTOTAL_MAX_TLP", ["virustotal", "max_tlp"], config
25         )
26         self.api_url = "https://www.virustotal.com/api/v3"
27         self.headers = {
28             "x-apikey": self.token,
29             "accept": "application/json",
30             "content-type": "application/json",
31         }
32         self._CONNECTOR_RUN_INTERVAL_SEC = 60 * 60
33 
34     def _process_file(self, observable):
35         response = requests.request(
36             "GET",
37             self.api_url + "/files/" + observable["observable_value"],
38             headers=self.headers,
39         )
40         json_data = json.loads(response.text)
41         if "error" in json_data:
42             if json_data["error"]["message"] == "Quota exceeded":
43                 self.helper.log_info("Quota reached, waiting 1 hour.")
44                 sleep(self._CONNECTOR_RUN_INTERVAL_SEC)
45             elif "not found" in json_data["error"]["message"]:
46                 self.helper.log_info("File not found on VirusTotal.")
47                 return "File not found on VirusTotal."
48             else:
49                 raise ValueError(json_data["error"]["message"])
50         if "data" in json_data:
51             data = json_data["data"]
52             attributes = data["attributes"]
53             # Update the current observable
54             final_observable = self.helper.api.stix_cyber_observable.update_field(
55                 id=observable["id"], key="hashes.MD5", value=attributes["md5"]
56             )
57             final_observable = self.helper.api.stix_cyber_observable.update_field(
58                 id=final_observable["id"], key="hashes.SHA-1", value=attributes["sha1"]
59             )
60             final_observable = self.helper.api.stix_cyber_observable.update_field(
61                 id=final_observable["id"],
62                 key="hashes.SHA-256",
63                 value=attributes["sha256"],
64             )
65             if observable["entity_type"] == "StixFile":
66                 self.helper.api.stix_cyber_observable.update_field(
67                     id=final_observable["id"],
68                     key="size",
69                     value=str(attributes["size"]),
70                 )
71             if observable["name"] is None and len(attributes["names"]) > 0:
72                 self.helper.api.stix_cyber_observable.update_field(
73                     id=final_observable["id"], key="name", value=attributes["names"][0]
74                 )
75                 del attributes["names"][0]
76                 if len(attributes["names"]) > 0:
77                     self.helper.api.stix_cyber_observable.update_field(
78                         id=final_observable["id"],
79                         key="x_opencti_additional_names",
80                         value=attributes["names"],
81                     )
82 
83             # Create external reference
84             external_reference = self.helper.api.external_reference.create(
85                 source_name="VirusTotal",
86                 url="https://www.virustotal.com/gui/file/" + attributes["sha256"],
87                 description=attributes["magic"],
88             )
89 
90             # Create tags
91             for tag in attributes["tags"]:
92                 tag_vt = self.helper.api.label.create(value=tag, color="#0059f7")
93                 self.helper.api.stix_cyber_observable.add_label(
94                     id=final_observable["id"], label_id=tag_vt["id"]
95                 )
96 
97             self.helper.api.stix_cyber_observable.add_external_reference(
98                 id=final_observable["id"],
99                 external_reference_id=external_reference["id"],
100             )
101 
102             return "File found on VirusTotal, knowledge attached."
103 
104     def _process_message(self, data):
105         entity_id = data["entity_id"]
106         observable = self.helper.api.stix_cyber_observable.read(id=entity_id)
107         # Extract TLP
108         tlp = "TLP:WHITE"
109         for marking_definition in observable["objectMarking"]:
110             if marking_definition["definition_type"] == "TLP":
111                 tlp = marking_definition["definition"]
112         if not OpenCTIConnectorHelper.check_max_tlp(tlp, self.max_tlp):
113             raise ValueError(
114                 "Do not send any data, TLP of the observable is greater than MAX TLP"
115             )
116         return self._process_file(observable)
117 
118     # Start the main loop
119     def start(self):
120         self.helper.listen(self._process_message)
121 
122 
123 if __name__ == "__main__":
124     virusTotalInstance = VirusTotalConnector()
125     virusTotalInstance.start()
126
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/virustotal/src/virustotal.py b/virustotal/src/virustotal.py
--- a/virustotal/src/virustotal.py
+++ b/virustotal/src/virustotal.py
@@ -1,10 +1,9 @@
-from time import sleep
-import yaml
+import json
 import os
 import requests
-import json
-
+import yaml
 from pycti import OpenCTIConnectorHelper, get_config_variable
+from time import sleep
 
 
 class VirusTotalConnector:
@@ -68,17 +67,20 @@
                     key="size",
                     value=str(attributes["size"]),
                 )
-            if observable["name"] is None and len(attributes["names"]) > 0:
-                self.helper.api.stix_cyber_observable.update_field(
-                    id=final_observable["id"], key="name", value=attributes["names"][0]
-                )
-                del attributes["names"][0]
-                if len(attributes["names"]) > 0:
+                if observable["name"] is None and len(attributes["names"]) > 0:
                     self.helper.api.stix_cyber_observable.update_field(
                         id=final_observable["id"],
-                        key="x_opencti_additional_names",
-                        value=attributes["names"],
+                        key="name",
+                        value=attributes["names"][0],
                     )
+                    del attributes["names"][0]
+
+            if len(attributes["names"]) > 0:
+                self.helper.api.stix_cyber_observable.update_field(
+                    id=final_observable["id"],
+                    key="x_opencti_additional_names",
+                    value=attributes["names"],
+                )
 
             # Create external reference
             external_reference = self.helper.api.external_reference.create(

{"golden_diff": "diff --git a/virustotal/src/virustotal.py b/virustotal/src/virustotal.py\n--- a/virustotal/src/virustotal.py\n+++ b/virustotal/src/virustotal.py\n@@ -1,10 +1,9 @@\n-from time import sleep\n-import yaml\n+import json\n import os\n import requests\n-import json\n-\n+import yaml\n from pycti import OpenCTIConnectorHelper, get_config_variable\n+from time import sleep\n \n \n class VirusTotalConnector:\n@@ -68,17 +67,20 @@\n                     key=\"size\",\n                     value=str(attributes[\"size\"]),\n                 )\n-            if observable[\"name\"] is None and len(attributes[\"names\"]) > 0:\n-                self.helper.api.stix_cyber_observable.update_field(\n-                    id=final_observable[\"id\"], key=\"name\", value=attributes[\"names\"][0]\n-                )\n-                del attributes[\"names\"][0]\n-                if len(attributes[\"names\"]) > 0:\n+                if observable[\"name\"] is None and len(attributes[\"names\"]) > 0:\n                     self.helper.api.stix_cyber_observable.update_field(\n                         id=final_observable[\"id\"],\n-                        key=\"x_opencti_additional_names\",\n-                        value=attributes[\"names\"],\n+                        key=\"name\",\n+                        value=attributes[\"names\"][0],\n                     )\n+                    del attributes[\"names\"][0]\n+\n+            if len(attributes[\"names\"]) > 0:\n+                self.helper.api.stix_cyber_observable.update_field(\n+                    id=final_observable[\"id\"],\n+                    key=\"x_opencti_additional_names\",\n+                    value=attributes[\"names\"],\n+                )\n \n             # Create external reference\n             external_reference = self.helper.api.external_reference.create(\n", "issue": "VirusTotal Connector error\nPlease replace every line in curly brackets { like this } with an appropriate answer, and remove this line.\r\n\r\n## Description\r\n\r\nWhen trying to enrich a artefact, VirusTotal report the following error every time \r\n<img width=\"1022\" alt=\"Screenshot 2021-07-05 at 6 55 12 PM\" src=\"https://user-images.githubusercontent.com/79446411/124463810-fc880300-ddc5-11eb-9564-2a8bded488cc.png\">\r\n\r\n\r\nWhen I access to the log, it shows the following error\r\n`ERROR:root:Error in message processing, reporting error to API\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.9/site-packages/pycti/connector/opencti_connector_helper.py\", line 152, in _data_handler\r\n    message = self.callback(json_data[\"event\"])\r\n  File \"/opt/opencti-connector-virustotal/virustotal.py\", line 116, in _process_message\r\n    return self._process_file(observable)\r\n  File \"/opt/opencti-connector-virustotal/virustotal.py\", line 71, in _process_file\r\n    if observable[\"name\"] is None and len(attributes[\"names\"]) > 0:\r\nKeyError: 'name'\r\nINFO:root:Reporting work update_received opencti-work--c2b1ef93-8b44-4915-b418-f759ee262f53\r\nINFO:root:Message (delivery_tag=1) processed, thread terminated`\r\n\r\n## Environment\r\n\r\n1. AWS ubuntu-bionic-18.04-amd64-server\r\n2. OpenCTI Version 4.5.5\r\n3. OpenCTI client:  frontend\r\n4. Other environment details: VirusTotal connector version : opencti/connector-virustotal:latest\r\n\r\n## Reproducible Steps\r\n\r\nSteps to create the smallest reproducible scenario:\r\n\r\n## Expected Output\r\n\r\nSuccessfully extract information from VirusTotal \r\n\r\n## Actual Output\r\n\r\nError occurred as mentioned above.\r\n \r\n## Additional information\r\n\r\n{ Any additional information, including logs or screenshots if you have any. }\r\n\n", "before_files": [{"content": "from time import sleep\nimport yaml\nimport os\nimport requests\nimport json\n\nfrom pycti import OpenCTIConnectorHelper, get_config_variable\n\n\nclass VirusTotalConnector:\n    def __init__(self):\n        # Instantiate the connector helper from config\n        config_file_path = os.path.dirname(os.path.abspath(__file__)) + \"/config.yml\"\n        config = (\n            yaml.load(open(config_file_path), Loader=yaml.FullLoader)\n            if os.path.isfile(config_file_path)\n            else {}\n        )\n        self.helper = OpenCTIConnectorHelper(config)\n        self.token = get_config_variable(\n            \"VIRUSTOTAL_TOKEN\", [\"virustotal\", \"token\"], config\n        )\n        self.max_tlp = get_config_variable(\n            \"VIRUSTOTAL_MAX_TLP\", [\"virustotal\", \"max_tlp\"], config\n        )\n        self.api_url = \"https://www.virustotal.com/api/v3\"\n        self.headers = {\n            \"x-apikey\": self.token,\n            \"accept\": \"application/json\",\n            \"content-type\": \"application/json\",\n        }\n        self._CONNECTOR_RUN_INTERVAL_SEC = 60 * 60\n\n    def _process_file(self, observable):\n        response = requests.request(\n            \"GET\",\n            self.api_url + \"/files/\" + observable[\"observable_value\"],\n            headers=self.headers,\n        )\n        json_data = json.loads(response.text)\n        if \"error\" in json_data:\n            if json_data[\"error\"][\"message\"] == \"Quota exceeded\":\n                self.helper.log_info(\"Quota reached, waiting 1 hour.\")\n                sleep(self._CONNECTOR_RUN_INTERVAL_SEC)\n            elif \"not found\" in json_data[\"error\"][\"message\"]:\n                self.helper.log_info(\"File not found on VirusTotal.\")\n                return \"File not found on VirusTotal.\"\n            else:\n                raise ValueError(json_data[\"error\"][\"message\"])\n        if \"data\" in json_data:\n            data = json_data[\"data\"]\n            attributes = data[\"attributes\"]\n            # Update the current observable\n            final_observable = self.helper.api.stix_cyber_observable.update_field(\n                id=observable[\"id\"], key=\"hashes.MD5\", value=attributes[\"md5\"]\n            )\n            final_observable = self.helper.api.stix_cyber_observable.update_field(\n                id=final_observable[\"id\"], key=\"hashes.SHA-1\", value=attributes[\"sha1\"]\n            )\n            final_observable = self.helper.api.stix_cyber_observable.update_field(\n                id=final_observable[\"id\"],\n                key=\"hashes.SHA-256\",\n                value=attributes[\"sha256\"],\n            )\n            if observable[\"entity_type\"] == \"StixFile\":\n                self.helper.api.stix_cyber_observable.update_field(\n                    id=final_observable[\"id\"],\n                    key=\"size\",\n                    value=str(attributes[\"size\"]),\n                )\n            if observable[\"name\"] is None and len(attributes[\"names\"]) > 0:\n                self.helper.api.stix_cyber_observable.update_field(\n                    id=final_observable[\"id\"], key=\"name\", value=attributes[\"names\"][0]\n                )\n                del attributes[\"names\"][0]\n                if len(attributes[\"names\"]) > 0:\n                    self.helper.api.stix_cyber_observable.update_field(\n                        id=final_observable[\"id\"],\n                        key=\"x_opencti_additional_names\",\n                        value=attributes[\"names\"],\n                    )\n\n            # Create external reference\n            external_reference = self.helper.api.external_reference.create(\n                source_name=\"VirusTotal\",\n                url=\"https://www.virustotal.com/gui/file/\" + attributes[\"sha256\"],\n                description=attributes[\"magic\"],\n            )\n\n            # Create tags\n            for tag in attributes[\"tags\"]:\n                tag_vt = self.helper.api.label.create(value=tag, color=\"#0059f7\")\n                self.helper.api.stix_cyber_observable.add_label(\n                    id=final_observable[\"id\"], label_id=tag_vt[\"id\"]\n                )\n\n            self.helper.api.stix_cyber_observable.add_external_reference(\n                id=final_observable[\"id\"],\n                external_reference_id=external_reference[\"id\"],\n            )\n\n            return \"File found on VirusTotal, knowledge attached.\"\n\n    def _process_message(self, data):\n        entity_id = data[\"entity_id\"]\n        observable = self.helper.api.stix_cyber_observable.read(id=entity_id)\n        # Extract TLP\n        tlp = \"TLP:WHITE\"\n        for marking_definition in observable[\"objectMarking\"]:\n            if marking_definition[\"definition_type\"] == \"TLP\":\n                tlp = marking_definition[\"definition\"]\n        if not OpenCTIConnectorHelper.check_max_tlp(tlp, self.max_tlp):\n            raise ValueError(\n                \"Do not send any data, TLP of the observable is greater than MAX TLP\"\n            )\n        return self._process_file(observable)\n\n    # Start the main loop\n    def start(self):\n        self.helper.listen(self._process_message)\n\n\nif __name__ == \"__main__\":\n    virusTotalInstance = VirusTotalConnector()\n    virusTotalInstance.start()\n", "path": "virustotal/src/virustotal.py"}], "after_files": [{"content": "import json\nimport os\nimport requests\nimport yaml\nfrom pycti import OpenCTIConnectorHelper, get_config_variable\nfrom time import sleep\n\n\nclass VirusTotalConnector:\n    def __init__(self):\n        # Instantiate the connector helper from config\n        config_file_path = os.path.dirname(os.path.abspath(__file__)) + \"/config.yml\"\n        config = (\n            yaml.load(open(config_file_path), Loader=yaml.FullLoader)\n            if os.path.isfile(config_file_path)\n            else {}\n        )\n        self.helper = OpenCTIConnectorHelper(config)\n        self.token = get_config_variable(\n            \"VIRUSTOTAL_TOKEN\", [\"virustotal\", \"token\"], config\n        )\n        self.max_tlp = get_config_variable(\n            \"VIRUSTOTAL_MAX_TLP\", [\"virustotal\", \"max_tlp\"], config\n        )\n        self.api_url = \"https://www.virustotal.com/api/v3\"\n        self.headers = {\n            \"x-apikey\": self.token,\n            \"accept\": \"application/json\",\n            \"content-type\": \"application/json\",\n        }\n        self._CONNECTOR_RUN_INTERVAL_SEC = 60 * 60\n\n    def _process_file(self, observable):\n        response = requests.request(\n            \"GET\",\n            self.api_url + \"/files/\" + observable[\"observable_value\"],\n            headers=self.headers,\n        )\n        json_data = json.loads(response.text)\n        if \"error\" in json_data:\n            if json_data[\"error\"][\"message\"] == \"Quota exceeded\":\n                self.helper.log_info(\"Quota reached, waiting 1 hour.\")\n                sleep(self._CONNECTOR_RUN_INTERVAL_SEC)\n            elif \"not found\" in json_data[\"error\"][\"message\"]:\n                self.helper.log_info(\"File not found on VirusTotal.\")\n                return \"File not found on VirusTotal.\"\n            else:\n                raise ValueError(json_data[\"error\"][\"message\"])\n        if \"data\" in json_data:\n            data = json_data[\"data\"]\n            attributes = data[\"attributes\"]\n            # Update the current observable\n            final_observable = self.helper.api.stix_cyber_observable.update_field(\n                id=observable[\"id\"], key=\"hashes.MD5\", value=attributes[\"md5\"]\n            )\n            final_observable = self.helper.api.stix_cyber_observable.update_field(\n                id=final_observable[\"id\"], key=\"hashes.SHA-1\", value=attributes[\"sha1\"]\n            )\n            final_observable = self.helper.api.stix_cyber_observable.update_field(\n                id=final_observable[\"id\"],\n                key=\"hashes.SHA-256\",\n                value=attributes[\"sha256\"],\n            )\n            if observable[\"entity_type\"] == \"StixFile\":\n                self.helper.api.stix_cyber_observable.update_field(\n                    id=final_observable[\"id\"],\n                    key=\"size\",\n                    value=str(attributes[\"size\"]),\n                )\n                if observable[\"name\"] is None and len(attributes[\"names\"]) > 0:\n                    self.helper.api.stix_cyber_observable.update_field(\n                        id=final_observable[\"id\"],\n                        key=\"name\",\n                        value=attributes[\"names\"][0],\n                    )\n                    del attributes[\"names\"][0]\n\n            if len(attributes[\"names\"]) > 0:\n                self.helper.api.stix_cyber_observable.update_field(\n                    id=final_observable[\"id\"],\n                    key=\"x_opencti_additional_names\",\n                    value=attributes[\"names\"],\n                )\n\n            # Create external reference\n            external_reference = self.helper.api.external_reference.create(\n                source_name=\"VirusTotal\",\n                url=\"https://www.virustotal.com/gui/file/\" + attributes[\"sha256\"],\n                description=attributes[\"magic\"],\n            )\n\n            # Create tags\n            for tag in attributes[\"tags\"]:\n                tag_vt = self.helper.api.label.create(value=tag, color=\"#0059f7\")\n                self.helper.api.stix_cyber_observable.add_label(\n                    id=final_observable[\"id\"], label_id=tag_vt[\"id\"]\n                )\n\n            self.helper.api.stix_cyber_observable.add_external_reference(\n                id=final_observable[\"id\"],\n                external_reference_id=external_reference[\"id\"],\n            )\n\n            return \"File found on VirusTotal, knowledge attached.\"\n\n    def _process_message(self, data):\n        entity_id = data[\"entity_id\"]\n        observable = self.helper.api.stix_cyber_observable.read(id=entity_id)\n        # Extract TLP\n        tlp = \"TLP:WHITE\"\n        for marking_definition in observable[\"objectMarking\"]:\n            if marking_definition[\"definition_type\"] == \"TLP\":\n                tlp = marking_definition[\"definition\"]\n        if not OpenCTIConnectorHelper.check_max_tlp(tlp, self.max_tlp):\n            raise ValueError(\n                \"Do not send any data, TLP of the observable is greater than MAX TLP\"\n            )\n        return self._process_file(observable)\n\n    # Start the main loop\n    def start(self):\n        self.helper.listen(self._process_message)\n\n\nif __name__ == \"__main__\":\n    virusTotalInstance = VirusTotalConnector()\n    virusTotalInstance.start()\n", "path": "virustotal/src/virustotal.py"}]}