Skip to content

Commit 6f3d4e2

Browse files
committed
[domaintools]: fix connector problems
1 parent f85a29f commit 6f3d4e2

File tree

8 files changed

+40
-37
lines changed

8 files changed

+40
-37
lines changed

internal-enrichment/domaintools/__metadata__/connector_config_schema.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
"type": "string"
2121
},
2222
"CONNECTOR_SCOPE": {
23-
"description": "The scope of the connector, e.g. 'flashpoint'.",
23+
"default": [
24+
"Domain-Name,Ipv4-Addr"
25+
],
26+
"description": "The scope of the connector.",
2427
"items": {
2528
"type": "string"
2629
},
@@ -49,12 +52,10 @@
4952
"type": "boolean"
5053
},
5154
"DOMAINTOOLS_API_USERNAME": {
52-
"default": "ChangeMe",
5355
"description": "The username required for the authentication on DomainTools API.",
5456
"type": "string"
5557
},
5658
"DOMAINTOOLS_API_KEY": {
57-
"default": "ChangeMe",
5859
"description": "The password required for the authentication on DomainTools API.",
5960
"format": "password",
6061
"type": "string",
@@ -69,7 +70,8 @@
6970
"required": [
7071
"OPENCTI_URL",
7172
"OPENCTI_TOKEN",
72-
"CONNECTOR_SCOPE"
73+
"DOMAINTOOLS_API_USERNAME",
74+
"DOMAINTOOLS_API_KEY"
7375
],
7476
"additionalProperties": true
7577
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
version: '3'
21
services:
32
connector-domaintools:
43
image: opencti/connector-domaintools:latest
54
environment:
65
- OPENCTI_URL=http://localhost
76
- OPENCTI_TOKEN=ChangeMe
87
- CONNECTOR_ID=ChangeMe
9-
- CONNECTOR_NAME=DomainTools
10-
- CONNECTOR_SCOPE=Domain-Name,Ipv4-Addr
11-
- CONNECTOR_AUTO=false # Enable/disable auto-enrichment of observables
8+
#- CONNECTOR_LOG_LEVEL=info
9+
#- CONNECTOR_NAME=DomainTools
10+
#- CONNECTOR_SCOPE=Domain-Name,Ipv4-Addr
11+
#- CONNECTOR_AUTO=false # Enable/disable auto-enrichment of observables
1212
- DOMAINTOOLS_API_USERNAME=ChangeMe
1313
- DOMAINTOOLS_API_KEY=ChangeMe
14-
- DOMAINTOOLS_MAX_TLP=TLP:AMBER
14+
#- DOMAINTOOLS_MAX_TLP=TLP:AMBER
1515
restart: always

internal-enrichment/domaintools/src/config.yml.sample

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ opencti:
44

55
connector:
66
id: 'ChangeMe'
7-
type: 'INTERNAL_ENRICHMENT'
8-
name: 'DomainTools'
9-
scope: 'Domain-Name,Ipv4-Addr'
10-
auto: false # Enable/disable auto-enrichment of observables
11-
confidence_level: 80 # From 0 (Unknown) to 100 (Fully trusted)
12-
log_level: 'info'
7+
#name: 'DomainTools'
8+
#scope: 'Domain-Name,Ipv4-Addr'
9+
#auto: false # Enable/disable auto-enrichment of observables
10+
#log_level: 'info'
1311

1412
domaintools:
1513
api_username: 'ChangeMe'
1614
api_key: 'ChangeMe'
17-
max_tlp: 'TLP:AMBER'
15+
#max_tlp: 'TLP:AMBER'
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""DomainTools connector module."""
22

3-
from connector.connector import DomainToolsConnector
4-
from connector.settings import ConnectorSettings
3+
from .connector import DomainToolsConnector
4+
from .settings import ConnectorSettings
55

66
__all__ = ["DomainToolsConnector", "ConnectorSettings"]

internal-enrichment/domaintools/src/connector/builder.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import stix2
88
import validators
9+
from connectors_sdk.models import OrganizationAuthor
910
from pycti import STIX_EXT_OCTI_SCO, OpenCTIConnectorHelper, StixCoreRelationship
1011

1112
from .constants import EntityType
@@ -18,16 +19,16 @@ class DtBuilder:
1819
"""
1920

2021
def __init__(
21-
self, helper: OpenCTIConnectorHelper, author: stix2.Identity, stix_objects: []
22+
self, helper: OpenCTIConnectorHelper, author: OrganizationAuthor, stix_objects
2223
):
2324
"""Initialize DtBuilder."""
2425
self.helper = helper
2526
self.author = author
2627

2728
# Use custom properties to set the author and the confidence level of the object.
2829
self.extensions = {}
29-
self.extensions[STIX_EXT_OCTI_SCO] = {"created_by_ref": author["id"]}
30-
self.bundle = stix_objects + [self.author]
30+
self.extensions[STIX_EXT_OCTI_SCO] = {"created_by_ref": author.id}
31+
self.bundle = stix_objects + [self.author.to_stix2_object()]
3132

3233
def reset_score(self):
3334
"""Reset the score used."""
@@ -263,8 +264,7 @@ def create_relationship(
263264
Created relationship.
264265
"""
265266
kwargs = {
266-
"created_by_ref": self.author,
267-
"confidence": self.helper.connect_confidence_level,
267+
"created_by_ref": self.author.id,
268268
}
269269
if description is not None:
270270
kwargs["description"] = description

internal-enrichment/domaintools/src/connector/connector.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
from typing import Dict
55

66
import domaintools
7-
import stix2
87
import validators
9-
from connector.settings import ConnectorSettings
10-
from pycti import Identity, OpenCTIConnectorHelper
8+
from connectors_sdk.models import OrganizationAuthor
9+
from pycti import OpenCTIConnectorHelper
1110

1211
from .builder import DtBuilder
1312
from .constants import DEFAULT_RISK_SCORE, DOMAIN_FIELDS, EMAIL_FIELDS, EntityType
@@ -19,19 +18,19 @@ class DomainToolsConnector:
1918
_DEFAULT_AUTHOR = "DomainTools"
2019
_CONNECTOR_RUN_INTERVAL_SEC = 60 * 60
2120

22-
def __init__(self, config: ConnectorSettings, helper: OpenCTIConnectorHelper):
21+
def __init__(self, config, helper: OpenCTIConnectorHelper):
2322
self.config = config
2423
self.helper = helper
25-
self.api = domaintools.API(
26-
self.config.domaintools.api_username, self.config.domaintools.api_key
24+
self.api = domaintools.api.API(
25+
self.config.domaintools.api_username,
26+
self.config.domaintools.api_key.get_secret_value(),
2727
)
2828
self.max_tlp = self.config.domaintools.max_tlp
29-
self.author = stix2.Identity(
30-
id=Identity.generate_id(self._DEFAULT_AUTHOR, "organization"),
29+
self.author = OrganizationAuthor(
3130
name=self._DEFAULT_AUTHOR,
32-
identity_class="organization",
33-
description=" DomainTools is a leading provider of Whois and other DNS profile data for threat intelligence enrichment. It is a part of the Datacenter Group (DCL Group SA). DomainTools data helps security analysts investigate malicious activity on their networks.",
34-
confidence=self.helper.connect_confidence_level,
31+
description="DomainTools is a leading provider of Whois and other DNS profile data for "
32+
"threat intelligence enrichment. It is a part of the Datacenter Group (DCL Group SA). "
33+
"DomainTools data helps security analysts investigate malicious activity on their networks.",
3534
)
3635
self.helper.metric.state("idle")
3736

internal-enrichment/domaintools/src/connector/settings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
BaseConfigModel,
33
BaseConnectorSettings,
44
BaseInternalEnrichmentConnectorConfig,
5+
ListFromString,
56
)
67
from pydantic import Field, SecretStr
78

@@ -16,6 +17,10 @@ class InternalEnrichmentConnectorConfig(BaseInternalEnrichmentConnectorConfig):
1617
description="The name of the connector.",
1718
default="Domaintools",
1819
)
20+
scope: ListFromString = Field(
21+
description="The scope of the connector.",
22+
default=["Domain-Name,Ipv4-Addr"],
23+
)
1924

2025

2126
class DomaintoolsConfig(BaseConfigModel):
@@ -25,11 +30,9 @@ class DomaintoolsConfig(BaseConfigModel):
2530

2631
api_username: str = Field(
2732
description="The username required for the authentication on DomainTools API.",
28-
default="ChangeMe",
2933
)
3034
api_key: SecretStr = Field(
3135
description="The password required for the authentication on DomainTools API.",
32-
default="ChangeMe",
3336
)
3437
max_tlp: str = Field(
3538
description="The maximal TLP of the observable being enriched.",

internal-enrichment/domaintools/src/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import traceback
22

3-
from connector import ConnectorSettings, DomainToolsConnector
3+
from connector.connector import DomainToolsConnector
4+
from connector.settings import ConnectorSettings
45
from pycti import OpenCTIConnectorHelper
56

67
if __name__ == "__main__":

0 commit comments

Comments
 (0)