Skip to content

Commit

Permalink
Update connectors
Browse files Browse the repository at this point in the history
  • Loading branch information
weiiwang01 committed Jan 8, 2025
1 parent 980ba73 commit d97b412
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion connector-template/charmcraft.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See LICENSE file for licensing details.

name: opencti-{{ name }}-connector
title: OpenCTI {{ display_name }} Charm
title: OpenCTI {{ display_name_short }} Charm
summary: OpenCTI {{ display_name }} charm.
links:
documentation: https://discourse.charmhub.io
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

name: opencti-cisa-kve-connector
title: OpenCTI CISA Known Exploited Vulnerabilities Charm
name: opencti-cisa-kev-connector
title: OpenCTI CISA KEV Charm
summary: OpenCTI CISA Known Exploited Vulnerabilities charm.
links:
documentation: https://discourse.charmhub.io
Expand Down Expand Up @@ -62,10 +62,10 @@ parts:
charm: {}

containers:
opencti-cisa-kve-connector:
resource: opencti-cisa-kve-connector-image
opencti-cisa-kev-connector:
resource: opencti-cisa-kev-connector-image
resources:
opencti-cisa-kve-connector-image:
opencti-cisa-kev-connector-image:
type: oci-image
description: OCI image for the OpenCTI CISA Known Exploited Vulnerabilities connector.

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.

name: opencti-cisa-kve-connector
name: opencti-cisa-kev-connector
base: [email protected]
version: &version '6.4.5'
summary: OpenCTI CISA Known Exploited Vulnerabilities Connector
Expand All @@ -12,7 +12,7 @@ platforms:
amd64:

parts:
cisa-kve-connector:
cisa-kev-connector:
source: https://github.com/OpenCTI-Platform/connectors.git
source-type: git
source-tag: *version
Expand All @@ -29,9 +29,9 @@ parts:
ls -lah
mkdir -p $CRAFT_PART_INSTALL/opt
cd external-import/cisa-known-exploited-vulnerabilities
cp -rp src $CRAFT_PART_INSTALL/opt/opencti-connector-cisa-kve
cp -rp src $CRAFT_PART_INSTALL/opt/opencti-connector-cisa-kev
cat entrypoint.sh | grep opencti-connector-cisa-kve
cat entrypoint.sh | grep opencti-connector-cisa-kev
mkdir -p $CRAFT_PART_INSTALL/usr/local/lib/python3.12/dist-packages
pip install \
--target $CRAFT_PART_INSTALL/usr/local/lib/python3.12/dist-packages \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from charms.opencti.v0.opencti_connector import OpenctiConnectorCharm


class OpenctiCisaKveConnectorCharm(OpenctiConnectorCharm):
class OpenctiCisaKevConnectorCharm(OpenctiConnectorCharm):
connector_type = "EXTERNAL_IMPORT"

@property
Expand All @@ -22,4 +22,4 @@ def charm_dir(self) -> pathlib.Path:


if __name__ == "__main__":
ops.main(OpenctiCisaKveConnectorCharm)
ops.main(OpenctiCisaKevConnectorCharm)
2 changes: 1 addition & 1 deletion connectors/cyber_campaign/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See LICENSE file for licensing details.

name: opencti-cyber-campaign-connector
title: OpenCTI APT & Cybercriminals Campaign Collection Charm
title: OpenCTI APT & Cyber Campaign Charm
summary: OpenCTI APT & Cybercriminals Campaign Collection charm.
links:
documentation: https://discourse.charmhub.io
Expand Down
2 changes: 1 addition & 1 deletion connectors/malwarebazaar/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See LICENSE file for licensing details.

name: opencti-malwarebazaar-connector
title: OpenCTI MalwareBazaar Recent Additions Charm
title: OpenCTI MalwareBazaar Charm
summary: OpenCTI MalwareBazaar Recent Additions charm.
links:
documentation: https://discourse.charmhub.io
Expand Down
2 changes: 1 addition & 1 deletion connectors/virustotal_livehunt/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See LICENSE file for licensing details.

name: opencti-virustotal-livehunt-connector
title: OpenCTI VirusTotal Livehunt Notifications Charm
title: OpenCTI VirusTotal Livehunt Charm
summary: OpenCTI VirusTotal Livehunt Notifications charm.
links:
documentation: https://discourse.charmhub.io
Expand Down
14 changes: 11 additions & 3 deletions scripts/gen_connector_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def render_template(
config,
output_dir,
connector_name: str | None = None,
display_name_short: str | None = None,
charm_override: str = "",
generate_entrypoint: str = "",
install_location: str | None = None,
Expand Down Expand Up @@ -162,6 +163,9 @@ def render_template(
connector_type=connector_type,
version=version,
display_name=display_name,
display_name_short=(
display_name if display_name_short is None else display_name_short
),
config=yaml.safe_dump(
{"config": {"options": sort_config(config)}}, width=99999, sort_keys=False
),
Expand Down Expand Up @@ -244,9 +248,9 @@ def generate_alienvault_connector(location: pathlib.Path, version: str):
)


@connector_generator("cisa-kve")
@connector_generator("cisa-kev")
def generate_cisa_known_exploited_vulnerabilities_connector(location: pathlib.Path, version: str):
"""Generate opencti cisa-known-exploited-vulnerabilities (cisa-kve) connector.
"""Generate opencti cisa-known-exploited-vulnerabilities (cisa-kev) connector.
https://github.com/OpenCTI-Platform/connectors/tree/master/external-import/cisa-known-exploited-vulnerabilities
"""
Expand All @@ -256,11 +260,12 @@ def generate_cisa_known_exploited_vulnerabilities_connector(location: pathlib.Pa
)
config["cisa-create-infrastructures"]["type"] = "boolean"
render_template(
name="cisa-kve",
name="cisa-kev",
connector_name="cisa-known-exploited-vulnerabilities",
connector_type="EXTERNAL_IMPORT",
version=version,
display_name="CISA Known Exploited Vulnerabilities",
display_name_short="CISA KEV",
output_dir=location,
config=config,
)
Expand Down Expand Up @@ -330,6 +335,7 @@ def gen_cyber_campaign_collection_connector(location: pathlib.Path, version: str
connector_type="EXTERNAL_IMPORT",
version=version,
display_name="APT & Cybercriminals Campaign Collection",
display_name_short="APT & Cyber Campaign",
output_dir=location,
config={
"connector-scope": {
Expand Down Expand Up @@ -519,6 +525,7 @@ def gen_malwarebazaar_recent_additions_connector(location: pathlib.Path, version
connector_type="EXTERNAL_IMPORT",
version=version,
display_name="MalwareBazaar Recent Additions",
display_name_short="MalwareBazaar",
output_dir=location,
config={
"connector-log-level": {
Expand Down Expand Up @@ -779,6 +786,7 @@ def gen_virustotal_livehunt_notifications_connector(location: pathlib.Path, vers
connector_type="EXTERNAL_IMPORT",
version=version,
display_name="VirusTotal Livehunt Notifications",
display_name_short="VirusTotal Livehunt",
output_dir=location,
config={
**DEFAULT_CONFIG,
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_connectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def _add_connector_test_params(
)

_add_connector_test_params(
name="cisa-kve",
connector_name="cisa-kve",
name="cisa-kev",
connector_name="cisa-kev",
charm_config={
"connector-scope": "cisa",
"connector-run-and-terminate": False,
Expand All @@ -147,7 +147,7 @@ def _add_connector_test_params(
environment={
"OPENCTI_URL": "http://opencti-endpoints.test-opencti-connector.svc:8080",
"OPENCTI_TOKEN": "00000000-0000-0000-0000-000000000000",
"CONNECTOR_NAME": "opencti-cisa-kve-connector",
"CONNECTOR_NAME": "opencti-cisa-kev-connector",
"CONNECTOR_SCOPE": "cisa",
"CONNECTOR_RUN_AND_TERMINATE": "false",
"CONNECTOR_LOG_LEVEL": "error",
Expand Down

0 comments on commit d97b412

Please sign in to comment.