Skip to content

feat(cloudflare-rules-list): add Cloudflare Rules List stream connector (#7043)#7044

Open
Khidr6G wants to merge 1 commit into
OpenCTI-Platform:masterfrom
Khidr6G:feat/cloudflare-rules-list-connector
Open

feat(cloudflare-rules-list): add Cloudflare Rules List stream connector (#7043)#7044
Khidr6G wants to merge 1 commit into
OpenCTI-Platform:masterfrom
Khidr6G:feat/cloudflare-rules-list-connector

Conversation

@Khidr6G

@Khidr6G Khidr6G commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Proposed changes

  • Add a new STREAM connector stream/cloudflare-rules-list that pushes IPv4
    threat-intelligence indicators and IPv4-Addr observables from OpenCTI into a
    Cloudflare Rules List (IP kind) for use in WAF and firewall rules.
  • Behavior: verify the target list on startup, perform a full sync of all IPv4
    indicators/observables, then listen to the OpenCTI live stream and keep the
    list in sync using Cloudflare's bulk list-items replace/snapshot API, with
    the bulk operation polled to completion and uploads throttled to at most once
    per CONNECTOR_SYNC_INTERVAL. Deletes are honored when
    CONNECTOR_LIVE_STREAM_LISTEN_DELETE=true.
  • Built on connectors-sdk + pydantic-settings, pycti==7.260715.0,
    python:3.12-alpine; includes __metadata__ (manifest, config schema,
    config doc, logo), README.md, docker-compose.yml, Dockerfile,
    entrypoint.sh, config.yml.sample, .env.sample.
  • Optional CLOUDFLARE_API_BASE_URL config (defaults to the public Cloudflare
    API) to allow pointing at a compatible gateway or a mock for testing.

Related issues

Checklist

  • I consider the submitted work as finished
  • I have signed my commits using GPG key.
  • I tested the code for its functionality using different use cases
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

Testing. The connector ships a unit-test suite (71 tests, 100% coverage of
the connector package, well above the 80% patch gate) that runs green under the
repository's run_test.sh flow (uv, Python 3.12, pycti from source,
connectors-sdk local). isort --profile black, black, flake8, and the
STIX-ID pylint checks all pass.

Beyond unit tests, it was validated end-to-end against a fresh OpenCTI
7.260715.0 stack with a mock Cloudflare API standing in for the account
(no real credentials required, via CLOUDFLARE_API_BASE_URL):

Scenario Expected Result
Startup list verification reads target list metadata (kind ip)
Full sync (2 indicators + 3 observables) snapshot of 5 IPs pushed
Live create (new observable) snapshot grows to 6 IPs
Live delete snapshot returns to 5 IPs

Design notes. The Cloudflare list-items API is snapshot-based (each upload
replaces the entire list), so the connector owns the list and maintains the full
set in memory, rebuilt by a full sync on every restart. _extract_ipv4 handles
both object shapes that reach a stream connector — the live-stream STIX shape
(type) and the OpenCTI API shape from the full sync (entity_type). Entity
selection (score, labels, markings) is intentionally delegated to the OpenCTI
live-stream definition rather than reimplemented in the connector; limitations
are documented in the README.

Copilot AI review requested due to automatic review settings July 17, 2026 22:55
@Filigran-Automation Filigran-Automation changed the title feat(cloudflare): add Cloudflare Rules List stream connector (#7043) feat(cloudflare-rules-list): add Cloudflare Rules List stream connector (#7043) Jul 17, 2026
@Filigran-Automation Filigran-Automation added the community Contribution from the community. label Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new STREAM connector under stream/cloudflare-rules-list/ that keeps a target Cloudflare Rules List (IP kind) synchronized with OpenCTI IPv4 indicators/observables using Cloudflare’s bulk snapshot/replace list-items API.

Changes:

  • Introduces a new connector package (cloudflare_rules_list) with a minimal Cloudflare API client, full-sync + live-stream processing, and sync throttling.
  • Adds runtime artifacts for deployment (Dockerfile, entrypoint, compose, sample config/env) and generated metadata (manifest, schema, config doc).
  • Adds a unit test suite covering settings, client behavior, and connector stream/sync logic.

Reviewed changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
stream/cloudflare-rules-list/tests/test-requirements.txt Test dependencies for the connector test suite.
stream/cloudflare-rules-list/tests/test_settings.py Validates pydantic-settings configuration parsing and defaults.
stream/cloudflare-rules-list/tests/test_main.py Verifies construction of settings/helper/client/connector wiring.
stream/cloudflare-rules-list/tests/test_connector.py Unit tests for stream message handling, full sync, and sync-to-Cloudflare behavior.
stream/cloudflare-rules-list/tests/test_client.py Unit tests for the Cloudflare API client request/operation polling behavior.
stream/cloudflare-rules-list/tests/conftest.py Test import path setup for src/ package layout.
stream/cloudflare-rules-list/tests/init.py Marks tests as a package (empty).
stream/cloudflare-rules-list/src/requirements.txt Runtime dependencies (pycti, connectors-sdk, pydantic-settings, requests).
stream/cloudflare-rules-list/src/main.py Runtime entry point wiring settings + OpenCTI helper + Cloudflare client.
stream/cloudflare-rules-list/src/config.yml.sample Sample YAML configuration for local/manual deployments.
stream/cloudflare-rules-list/src/cloudflare_rules_list/settings.py Connector configuration models and env-var mapping via connectors-sdk bases.
stream/cloudflare-rules-list/src/cloudflare_rules_list/connector.py Core connector logic: extraction, caching, full sync, throttled snapshot uploads.
stream/cloudflare-rules-list/src/cloudflare_rules_list/client.py Minimal Cloudflare Rules Lists API client + bulk operation polling.
stream/cloudflare-rules-list/src/cloudflare_rules_list/init.py Package exports for Connector and ConnectorSettings.
stream/cloudflare-rules-list/README.md User/developer documentation and behavioral notes for the connector.
stream/cloudflare-rules-list/entrypoint.sh Container entrypoint script.
stream/cloudflare-rules-list/Dockerfile Alpine-based container build for the connector.
stream/cloudflare-rules-list/docker-compose.yml Example compose service definition.
stream/cloudflare-rules-list/.env.sample Example environment variable configuration.
stream/cloudflare-rules-list/metadata/connector_manifest.json Connector catalog metadata (title/slug/image/etc.).
stream/cloudflare-rules-list/metadata/connector_config_schema.json Generated JSON schema for supported env vars/config options.
stream/cloudflare-rules-list/metadata/CONNECTOR_CONFIG_DOC.md Generated config documentation from the schema.

Comment on lines +166 to +172
def _sync_to_cloudflare(self) -> None:
"""Push the full IPv4 snapshot to the Cloudflare Rules List."""
self._last_sync_time = time.monotonic()

if not self._indicator_cache:
self.logger.info("No indicators to sync")
return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the amended commit

Comment on lines +63 to +72
try:
response = self._session.request(
method=method,
url=url,
json=data,
timeout=request_timeout,
)
response.raise_for_status()
return response.json()
except requests.exceptions.RequestException as exc:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the amended commit

Comment on lines +1 to +3
-r ../src/requirements.txt
pytest==9.0.3
pytest-mock==3.14.1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in the amended commit

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 23 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

stream/cloudflare-rules-list/src/cloudflare_rules_list/connector.py:176

  • _sync_to_cloudflare() stamps _last_sync_time before attempting the Cloudflare upload. If replace_list_items() (or the bulk operation) fails, the connector will still enter the throttle window and may not retry for up to sync_interval, delaying recovery from transient Cloudflare/API outages.
        self._last_sync_time = time.monotonic()

Comment on lines +251 to +259
list_info = self.client.get_list(self.list_id)
self.logger.info(
"Using Cloudflare list",
meta={
"name": list_info.get("name"),
"id": self.list_id,
"kind": list_info.get("kind"),
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Contribution from the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cloudflare): add Cloudflare Rules List stream connector

4 participants