Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spycloud] Create external import connector #3347

Open
wants to merge 46 commits into
base: master
Choose a base branch
from

Conversation

Powlinett
Copy link
Member

Proposed changes

⚠️ This PR overrides previous Spycloud PR #3319

  • Use/adapt external import template
  • Validate config/env variables
  • Create Spycloud API client handling authentication, filters, retry strategy...
  • Create Spycloud classes (BreachCatalog and BreachRecord)
  • Create OpenCTI classes (Author, Incident, observables...)
  • Add unit tests
  • Add pyproject.toml
  • Update Docker build

Related issues

Checklist

  • I consider the submitted work as finished
  • 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

@Powlinett Powlinett added filigran team use to identify PR from the Filigran team do not merge Do not merge this PR until this tag will be removed new use to identify new integration labels Jan 29, 2025
@Powlinett Powlinett self-assigned this Jan 29, 2025
@Powlinett Powlinett linked an issue Jan 29, 2025 that may be closed by this pull request
@Powlinett Powlinett force-pushed the feature/2563-spycloud-observables branch from 2c7d44e to abf331c Compare January 29, 2025 16:57
Copy link
Contributor

@flavienSindou flavienSindou left a comment

Choose a reason for hiding this comment

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

Nice and clear documented code.
Some small remarks but a really good implementation.

You should add a test-requirements.txt file for the CI to launch your tests

I test the connector locally and I'll approve it.

Comment on lines +147 to +155
```mermaid
flowchart LR
A[Spycloud] -->|get data periodically| B(Connector)
B --> C{Process breach records}
C -->|convert to| D1[STIX bundle]
C -->|convert to| D2[STIX bundle]
C -->|convert to| D3[STIX bundle]
D1 & D2 & D3 -->|send to| E(OpenCTI)
```
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is considered as general documentation of the connector scheduler. I would replace it with a link to the dedicated page https://filigran.io/auto-backpressue-control-octi-connectors/#h-purpose-of-the-scheduler

from spycloud_connector.models.opencti import Author, Incident, TLPMarking


def mock_valid_author():
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicking ;)

Suggested change
def mock_valid_author():
def fake_valid_author():

return Author(name="Valid Author", identity_class="organization")


def mock_valid_markings():
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicking ;)

Suggested change
def mock_valid_markings():
def fake_valid_markings():

)


def mock_valid_author():
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def mock_valid_author():
def fake_valid_author():

return Author(name="Valid Author", identity_class="organization")


def mock_valid_markings():
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def mock_valid_markings():
def fake_valid_markings():

# When: we try to create a DomainName instance
# Then: a ValidationError should be raised
with pytest.raises(ValidationError) as err:
DomainName(**input_data_dict)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicking

Suggested change
DomainName(**input_data_dict)
DomainName.model_validate(**input_data_dict)

Usually a model called with constructor should fill all kwargs explicitly, when using de-serialization or structures you would rather use a dedicated factory.

data = mock_spycloud_client._request(method="GET", url=mock_request["url"])

# Then None should be returned
assert data is None
Copy link
Contributor

Choose a reason for hiding this comment

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

URL does not seem to be parametrized here and could be remove

{
"url": f"{TEST_API_BASE_URL}/breach/catalog/:breach_catalog_id",
"status_code": 200,
"response_body": get_data_sample("breach_catalog_api_response.json"),
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ This fake data file is not available.

@Powlinett Powlinett force-pushed the feature/2563-spycloud-observables branch from 0ae8871 to 484f99c Compare January 31, 2025 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Do not merge this PR until this tag will be removed filigran team use to identify PR from the Filigran team new use to identify new integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SpyCloud] Create the connector
2 participants