Repository: OpenCTI-Platform/connectors

Issue:
[AbuseIPdb] Crash on listing  "Korea (Republic of)" entity
## Description

The AbuseIPDB enrichment connector stops gathering data as soon as there is an entity of "Korea (Republic of)" is found. 

## Actual Output

Example listing:
```
connector-abuseipdb_1                    | 2021-05-20T13:07:59.843767030Z INFO:root:Listing Stix-Domain-Objects with filters [{"key": "name", "values": ["Korea (Republic of)"]}].
connector-abuseipdb_1                    | 2021-05-20T13:07:59.859596474Z INFO:root:Listing Stix-Domain-Objects with filters [{"key": "aliases", "values": ["Korea (Republic of)"]}].
connector-abuseipdb_1                    | 2021-05-20T13:07:59.959406389Z ERROR:root:Error in message processing, reporting error to API
connector-abuseipdb_1                    | 2021-05-20T13:07:59.959533538Z Traceback (most recent call last):
connector-abuseipdb_1                    | 2021-05-20T13:07:59.959542290Z   File "/usr/local/lib/python3.9/site-packages/pycti/connector/opencti_connector_helper.py", line 145, in _data_handler
connector-abuseipdb_1                    | 2021-05-20T13:07:59.959548366Z     message = self.callback(json_data["event"])
connector-abuseipdb_1                    | 2021-05-20T13:07:59.959553788Z   File "/opt/opencti-connector-abuseipdb/abuseipdb.py", line 108, in _process_message
connector-abuseipdb_1                    | 2021-05-20T13:07:59.959559549Z     toId=country["id"],
connector-abuseipdb_1                    | 2021-05-20T13:07:59.959564881Z TypeError: 'NoneType' object is not subscriptable

``` 
## Additional information

The error above has been using IP address 143.198.132.45


Discussion:
The reason behind this crash is that the "Republic of Korea" has following names in the opencti geography dataset (https://github.com/OpenCTI-Platform/datasets/blob/master/data/geography.json#L4051-L4058):
* Republic of Korea (name)
* KOR (alias, ISO 3166-1 alpha-3 code)
* KO (alias, ISO 3166-1 alpha-2 code)

Due to those names there's no match with AbuseIPs naming scheme "Korea (Republic of)".

@SamuelHassine According to ISO [1] the official naming scheme should be "Korea (Republic of)". In cases like Iran the OpenCTI dataset seems to be correct, but for Korea it isn't. I think the easiest proper fix would be a change in the geography dataset from "Republic of Korea" to "Korea (Republic of)". Should I submit a PR for that change?

[1] https://www.iso.org/obp/ui/#search

Resolving patch:
diff --git a/abuseipdb/src/abuseipdb.py b/abuseipdb/src/abuseipdb.py
--- a/abuseipdb/src/abuseipdb.py
+++ b/abuseipdb/src/abuseipdb.py
@@ -100,16 +100,27 @@ def _process_message(self, data):
             return "IP found in AbuseIPDB WHITELIST."
         if len(data["reports"]) > 0:
             for report in data["reports"]:
-                country = self.helper.api.stix_domain_object.get_by_stix_id_or_name(
-                    name=report["reporterCountryName"]
-                )
-                self.helper.api.stix_sighting_relationship.create(
-                    fromId=observable_id,
-                    toId=country["id"],
-                    count=1,
-                    first_seen=report["reportedAt"],
-                    last_seen=report["reportedAt"],
+                country = self.helper.api.location.read(
+                    filters=[
+                        {
+                            "key": "x_opencti_aliases",
+                            "values": [report["reporterCountryCode"]],
+                        }
+                    ],
+                    getAll=True,
                 )
+                if country is None:
+                    self.helper.log_warning(
+                        f"No country found with Alpha 2 code {report['reporterCountryCode']}"
+                    )
+                else:
+                    self.helper.api.stix_sighting_relationship.create(
+                        fromId=observable_id,
+                        toId=country["id"],
+                        count=1,
+                        first_seen=report["reportedAt"],
+                        last_seen=report["reportedAt"],
+                    )
                 for category in report["categories"]:
                     category_text = self.extract_abuse_ipdb_category(category)
                     label = self.helper.api.label.create(value=category_text)


Test patch: