Skip to content

Commit

Permalink
[documentation] Adjust NodeJS version & Grakn version
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Hassine committed Dec 7, 2019
1 parent 565dcda commit eb1da22
Show file tree
Hide file tree
Showing 9 changed files with 270 additions and 6 deletions.
2 changes: 1 addition & 1 deletion opencti-documentation/docs/development/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_label: Development environment
## Prerequisites

- Docker
- Node.JS (>= 12)
- Node.JS (>= 12.* < 13.0.0)
- Python (>= 3)
- Yarn (>= 1.16)

Expand Down
4 changes: 2 additions & 2 deletions opencti-documentation/docs/installation/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ sidebar_label: Manual deployment

## Prerequisites

- Node.JS (>= 12)
- Grakn (>= 1.5.9)
- Node.JS (>= 12.* < 13.0.0)
- Grakn (== 1.5.9)
- Redis (>= 3.0)
- ElasticSearch (>= 7.5)
- Minio (>= 20191012)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
id: version-2.1.1-overview
title: OpenCTI Python client
sidebar_label: Overview
original_id: overview
---

The `pycti` library is designed to help OpenCTI users and developers to programatically interact with the GraphQL API. It has been architectured to be easy to use and easy to maintain. The Python library requires Python >= 3. Let's get started.

## Installation

```bash
$ pip install pycti
```

## Getting started

### Initialization

The main class contains all what you need to interact with the platform, you just have to initialize it:

```python
# coding: utf-8

from pycti import OpenCTIApiClient

# OpenCTI initialization
opencti_api_client = OpenCTIApiClient(api_url, api_token, log_level, ssl_verify)
```

| Argument | Type | Description |
| -------------------------- | ------------------ | --------------------------------------------------------------------|
| api_url (*required*) | String | The URL of the OpenCTI instance |
| api_token (*required*) | String | The OpenCTI token |
| log_level (*optional*) | String | Log level, could be 'debug', 'info', 'warning' or 'error' |
| ssl_verify (*optional*) | Boolean | Enable or disable the SSL certificate verification |
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
id: version-2.1.1-installation
title: Development environment installation
sidebar_label: Development environment
original_id: installation
---

## Prerequisites

- Docker
- Node.JS (>= 12.* < 13.0.0)
- Python (>= 3)
- Yarn (>= 1.16)

### Installation of dependencies (Ubuntu 18.04)

```bash
$ sudo apt-get install nodejs python3 python3-pip
$ sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
$ sudo echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
$ sudo apt-get update && sudo apt-get install yarn
```

### Docker stack

As OpenCTI has a dependency to ElasticSearch, you have to set the *vm.max_map_count* before running the containers, as mentioned in the [ElasticSearch documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-prod-mode).

```bash
$ sysctl -w vm.max_map_count=262144
```

Clone the latest version of the dev docker compose and start

```bash
$ git clone https://github.com/OpenCTI-Platform/docker.git
$ cd docker
$ docker-compose -f ./docker-compose-dev.yml up -d
```

## Clone the project

```bash
$ git clone https://github.com/OpenCTI-Platform/opencti.git
$ cd opencti
```

## Application dependencies

### Install the API dependencies

```bash
$ cd opencti-platform/sopencti-graphql
$ yarn install
```

### Install the frontend dependencies
```bash
$ cd ../opencti-front
$ yarn install
```

### Install the worker dependencies

```bash
$ cd ../../opencti-worker
$ pip3 install -r requirements.txt
```

## Config and run

### GraphQL API

#### Configure

```bash
$ cp config/default.json config/development.json
```
By default the configuration match the docker stack configuration.
You just need to change the user part:
```bash
"admin": {
"email": "[email protected]",
"password": "ChangeMe",
"token": "ChangeMe"
}
```

#### Start

```bash
$ cd opencti-graphql
$ yarn start
```

The first execution will create and migrate the schema.

### Worker

#### Configure

```bash
$ cd opencti-worker
$ cp config.yml.sample config.yml
```
Change the *config.yml* file according to your <admin token>

#### Start

```bash
$ python3 worker.py &
```

### Frontend

#### Start

```bash
$ cd opencti-frontend
$ yarn start
```

## Build for production use

### Build the application

```bash
$ cd opencti-frontend
$ yarn build
$ cd ../opencti-graphql
$ yarn build
```

### Start the production package

```bash
$ yarn serv
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
id: version-2.1.1-manual
title: Manual installation
sidebar_label: Manual deployment
original_id: manual
---

## Prerequisites

- Node.JS (>= 12.* < 13.0.0)
- Grakn (== 1.5.9)
- Redis (>= 3.0)
- ElasticSearch (>= 7.5)
- Minio (>= 20191012)
- RabbitMQ (>= 3.7)

## Prepare the installation

### Installation of dependencies

You have to install all the needed dependencies for the main application and the workers. The example below if for Ubuntu:

```bash
$ sudo apt-get install nodejs npm python3 python3-pip
```

### Download the application files

Download and extract the latest release file.

```bash
$ mkdir /path/to/your/app && cd /path/to/your/app
$ wget https://github.com/OpenCTI-Platform/opencti/releases/download/{RELEASE_VERSION}/opencti-release-{RELEASE_VERSION}.tar.gz
$ tar xvfz opencti-release-{RELEASE_VERSION}.tar.gz
```

## Install the main platform

### Configure the application

The main application has just one JSON configuration file to change.

```bash
$ cd opencti
$ cp config/default.json config/production.json
```

Change the *config/production.json* file according to your configuration of Grakn, Redis, ElasticSearch, RabbitMQ and default credentials (the `ADMIN_TOKEN` must be a [valid UUID](https://www.uuidgenerator.net/)).

### Start the application

The application is just a NodeJS process, the creation of the database schema and the migration will be done at starting.

```bash
$ node dist/server.js &
```

The default username and password are those you put in the `config/production.json` file.

## Install the worker

The OpenCTI worker is used to write the data coming from the RabbitMQ messages broker.

#### Configure the worker

```bash
$ cd worker
$ pip3 install -r requirements.txt
$ cp config.yml.sample config.yml
```

Change the *config.yml* file according to your OpenCTI token.

#### Start as many workers as you need
```bash
$ python3 worker.py &
$ python3 worker.py &
```

## Upgrade the platform

When upgrading the platform, you have to replace all files and run the migrations and the schema commands to get updates:

```bash
$ npm run schema
$ npm run migrate
```

Then start the platform.
1 change: 1 addition & 0 deletions opencti-documentation/website/versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
"2.1.1",
"2.1.0",
"2.0.0",
"1.1.2",
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"**/lodash": "4.17.15"
},
"engines": {
"node": ">= 12.*"
"node": ">= 12.* < 13.0.0"
},
"scripts": {
"start": "yarn relay && react-app-rewired start",
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
]
},
"engines": {
"node": ">= 12.*"
"node": ">= 12.* < 13.0.0"
},
"dependencies": {
"@babel/core": "^7.6.4",
Expand Down
3 changes: 2 additions & 1 deletion opencti-platform/opencti-graphql/src/domain/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const uploadJobImport = async (fileId, fileMime) => {
work_id: work.internal_id_key, // work(id)
job_id: job.internal_id_key, // job(id)
file_mime: fileMime, // Ex. application/json
file_path: `/storage/get/${fileId}` // Path to get the file
file_path: `/storage/get/${fileId}`, // Path to get the file
update: true
};
return pushToConnector(connector, message);
}, workList)
Expand Down

0 comments on commit eb1da22

Please sign in to comment.