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

[VulnCheck] Initial Implementation of VulnCheck Connector #3257

Merged

Conversation

maddawik
Copy link
Contributor

@maddawik maddawik commented Jan 11, 2025

Proposed changes

This is the initial implementation of an external import connector for VulnCheck. It transforms several different data sources from our API, using our python-sdk, into STIX objects/relationships.

Some data sources ingest substantial volumes of data for parsing and generate a significant number of STIX objects and relationships as a result. These resource-intensive data sources have been highlighted in the documentation for user awareness.

Related issues

#3522

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

Further comments

We've made our best effort to make design decisions that are in-line with OpenCTI's plugin architecture - that said, please let me know if there are improvements that can be made!

@maddawik
Copy link
Contributor Author

maddawik commented Jan 11, 2025

I see that isort is failing in CI, however I'm unable to reproduce that locally with the same version of black and isort - please advise!

❯ poetry run black --version
black, 24.10.0 (compiled: yes)
Python (CPython) 3.12.8
❯ poetry run isort --profile black --check src/vclib/config_variables.py --verbose

                 _                 _
                (_) ___  ___  _ __| |_
                | |/ _/ / _ \/ '__  _/
                | |\__ \/\_\/| |  | |_
                |_|\___/\___/\_/   \_/

      isort your imports, so you don't have to.

                    VERSION 5.13.2

else-type place_module for os returned STDLIB
from-type place_module for pathlib returned STDLIB
else-type place_module for yaml returned THIRDPARTY
from-type place_module for pycti returned THIRDPARTY
from-type place_module for vclib.sources.data_source returned FIRSTPARTY
SUCCESS: /Users/user-name/vulncheck/opencti-connector/external-import/vulncheck/src/vclib/config_variables.py Everything Looks Good!
❯ poetry run isort --profile black --check src/vclib/connector_client.py --verbose

                 _                 _
                (_) ___  ___  _ __| |_
                | |/ _/ / _ \/ '__  _/
                | |\__ \/\_\/| |  | |_
                |_|\___/\___/\_/   \_/

      isort your imports, so you don't have to.

                    VERSION 5.13.2

else-type place_module for gzip returned STDLIB
else-type place_module for json returned STDLIB
else-type place_module for os returned STDLIB
else-type place_module for zipfile returned STDLIB
from-type place_module for datetime returned STDLIB
from-type place_module for typing returned STDLIB
else-type place_module for requests returned THIRDPARTY
else-type place_module for vulncheck_sdk returned THIRDPARTY
from-type place_module for pycti returned THIRDPARTY
from-type place_module for pydantic returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.advisory_botnet returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.advisory_ip_intel_record returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.advisory_ransomware_exploit returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.advisory_threat_actor_with_external_objects returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.advisory_vuln_check_kev returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.api_exploit_v3_result returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.api_initial_access returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.api_nvd20_cve returned THIRDPARTY
from-type place_module for vulncheck_sdk.models.api_nvd20_cve_extended returned THIRDPARTY
from-type place_module for vclib.config_variables returned FIRSTPARTY
from-type place_module for vclib.sources returned FIRSTPARTY
SUCCESS: /Users/user-name/vulncheck/opencti-connector/external-import/vulncheck/src/vclib/connector_client.py Everything Looks Good!

@maddawik maddawik force-pushed the initial-implementation branch 4 times, most recently from 77281d0 to 062d5b9 Compare January 12, 2025 04:56
@romain-filigran romain-filigran added this to the PRs backlog milestone Jan 12, 2025
@romain-filigran romain-filigran added the partner used to identify PR from patner label Jan 12, 2025
@maddawik maddawik force-pushed the initial-implementation branch 8 times, most recently from 0305d9b to 11be26b Compare January 18, 2025 19:44
Copy link
Member

@Powlinett Powlinett left a comment

Choose a reason for hiding this comment

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

Hi @maddawik, thank you for your contribution!

I succeed to launch the connector both locally and as a docker image (after a small fix, see my comment) ✅

For the formatting issue, where did you run isort? at the root of the connectors repository? or at the root of vulncheck directory?
If so, please try to run it at the root of the repo and see if it helps 🤞Let us know 😇

Thanks!

@richard-julien richard-julien force-pushed the master branch 2 times, most recently from 9818df2 to 0f4b30d Compare February 4, 2025 14:35
@maddawik maddawik force-pushed the initial-implementation branch from 11be26b to 5301186 Compare February 7, 2025 19:16
@maddawik
Copy link
Contributor Author

maddawik commented Feb 7, 2025

Hi @maddawik, thank you for your contribution!

I succeed to launch the connector both locally and as a docker image (after a small fix, see my comment) ✅

For the formatting issue, where did you run isort? at the root of the connectors repository? or at the root of vulncheck directory? If so, please try to run it at the root of the repo and see if it helps 🤞Let us know 😇

Thanks!

Hey @Powlinett , thank you for the feedback! 🎉 I have made updates per your suggestion and have also pushed some additional commits. I hope you'll forgive me for the additional changes, but I think they will be welcome ones! To make it a little easier to digest I've included a summary of the changes below:

Features

  • Updated the CONNECTOR_SCOPE config to use STIX objects for further filtering! 🥳
  • Split each data source into separate works for better clarity and transparency on the administrative UI

Fixes

  • Reduced the amount of in-memory processing required for parsing large data sources
  • Reduced overall cyclomatic complexity for all parsing and gathering functionality
  • Applied dependency injection where possible to make testing easier
  • Applied Docker best practices to the Dockerfile

I was also able to resolve the formatting issues using pipx to install isort and black versions globally, and then running it against the external-import/vulncheck/ dir.

Please let me know if you have any additional feedback! 😊

This refactors all of the data sources in a number of ways

- Updated scope config to use STIX objects for further filtering
- Split each data source into separate works for better clarity and transparency
on the administrative UI
- Reduced cyclomatic complexity for all parsing and gathering functionality
- Reduced the amount of in-memory processing required for parsing large data
sources
- Applied dependency injection where possible
- Generally using a more functional approach
- Run the app with a non-priveleged user
- Leverage a bind mount for `requirements.txt` for faster builds
- Remove additional entrypoint script
- Other Python best practices
@maddawik maddawik force-pushed the initial-implementation branch from 4e1f5d8 to 8883ac4 Compare February 9, 2025 05:02
@Powlinett
Copy link
Member

Looks good to me 👍

  • connector works both manually and as a docker image
  • didn't see any unexpected errors in logs
  • didn't see any errors during ingestion so far

Many thanks 🙌

@Powlinett Powlinett merged commit c56c08f into OpenCTI-Platform:master Feb 14, 2025
4 checks passed
@maddawik maddawik deleted the initial-implementation branch February 14, 2025 14:54
maximus-debski pushed a commit to maximus-debski/connectors that referenced this pull request Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
partner used to identify PR from patner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants