This summary should give you a detailed setup description for initiating the OpenCTI setup environment
necessary for developing on the OpenCTI platform, a client library or the connectors.
This page document how to set up an "All-in-One" development environment for OpenCTI.
The devenv will contain data of 3 different repositories:
In development dependencies are deployed trough containers.
A development compose file is available in ~/opencti/opencti-platform/opencti-dev
cd~/docker
#Start the stack in backgrounddocker-compose-f./docker-compose-dev.ymlup-d
You now have all the dependencies of OpenCTI running and waiting for product to run.
Backend / API
Python virtual env
The GraphQL API is developed in JS and with some python code.
As it's an "all-in-one" installation, the python environment will be installed in a virtual environment.
The API can be specifically configured with files depending on the starting profile.
By default, the default.json file is used and will be correctly configured for local usage except for admin password.
So you need to create a development profile file. You can duplicate the default file and adapt if you need.
The platform will start logging some interesting information
{"category":"APP","level":"info","message":"[OPENCTI] Starting platform","timestamp":"2023-07-02T16:37:10.984Z","version":"5.8.7"}
{"category":"APP","level":"info","message":"[OPENCTI] Checking dependencies statuses","timestamp":"2023-07-02T16:37:10.987Z","version":"5.8.7"}
{"category":"APP","level":"info","message":"[SEARCH] Elasticsearch (8.5.2) client selected / runtime sorting enabled","timestamp":"2023-07-02T16:37:11.014Z","version":"5.8.7"}
{"category":"APP","level":"info","message":"[CHECK] Search engine is alive","timestamp":"2023-07-02T16:37:11.015Z","version":"5.8.7"}
...
{"category":"APP","level":"info","message":"[INIT] Platform initialization done","timestamp":"2023-07-02T16:37:11.622Z","version":"5.8.7"}
{"category":"APP","level":"info","message":"[OPENCTI] API ready on port 4000","timestamp":"2023-07-02T16:37:12.382Z","version":"5.8.7"}
If you want to start on another profile you can use the -e parameter.
For example here to use the profile.json configuration file.
yarnstart-eprofile
Code check
Before pushing your code you need to validate the syntax and ensure the testing will be validated.
For validation
yarn lint
yarn check-ts
For testing
For starting the test you will need to create a test.json configuration file.
You can use the same dependencies by only adapting all prefix for all dependencies.
Tests are using dedicated indices in the Elastic database (prefixed with test-* or the prefix that you have set up in test.json).
The following command will run the complete test suite using vitest, which might take more than 30 minutes.
It starts by cleaning up the test database and seeding a minimal dataset.
The file vitest.config.test.ts can be edited to run only a specific file pattern.
yarn test:dev
We also provide utility scripts to ease the development of new tests, especially integration tests that rely on the sample data
loaded after executing 00-inject/loader-test.ts.
To solely initialize the test database with this sample dataset run:
yarn test:dev:init
And then, execute the following command to run the pattern specified in the file vitest.config.test.ts, or add a file name
to the command line to run only this test file.
yarn test:dev:resume
This last command will NOT cleanup & initialize the test database and thus will be quicker to execute.
Frontend
Install / start
Before starting the backend you need to install the nodejs modules
After the build you can start the production build with yarn serv.
This build will use the production.json configuration file.
$cd../opencti-graphql
$yarnserv
Continuous Integration and features cross repository
When a feature requires changes in two or more repositories in opencti, connectors and client-python; then some specific convention must be used to have the continuous integration build them all together.
Naming convention of branch
The Pull Request on opencti repository should be (issue or bug)/number + optional, example: issue/7062-contributing
The pull request on connector or client-python should refer to the opencti one by starting with "opencti/" and then the same name. Example: opencti/issue/7062-contributing
Note that if there are several matches, the first one is taken. So for example having issue/7062-contributing and issue/7062 that are both marked as "multi-repository" is not a good idea.
Labels
All Pull Requests involved must have the label multi-repository added in GitHub.