OpenCTI-Platform / opencti

Open Cyber Threat Intelligence Platform
https://opencti.io
Other
6.31k stars 932 forks source link

Start error with manual install (after moving from Docker) #742

Closed smclinden closed 3 years ago

smclinden commented 4 years ago

Description

yarn run v1.22.4 $ node --max_old_space_size=8192 build/index.js {"level":"info","message":"[INIT] > Starting OPENCTI..."} {"level":"info","message":"[PRE-CHECK] > Grakn is alive"} {"level":"info","message":"[PRE-CHECK] > ElasticSearch is alive"} {"level":"info","message":"[PRE-CHECK] > Minio is alive"} {"level":"info","message":"[PRE-CHECK] > RabbitMQ is alive"} {"level":"info","message":"[PRE-CHECK] > Redis is alive"} {"level":"info","message":"[PRE-CHECK] > Python3 is available"} {"level":"info","message":"[INIT] > Existing platform detected, migration..."} {"level":"info","message":"[INIT] > Grakn schema loaded"} {"level":"info","message":"[INIT] > Elasticsearch indexes loaded"} {"error":{"name":"DatabaseError","_error":{},"_showLocations":false,"_showPath":false,"time_thrown":"2020-06-02T15:54:51.394Z","data":{"reason":"Expect only one response","category":"technical","terms":[{"internal_id_key.keyword":"88ec0c6a-13ce-5e39-b486-354fe4a7084f"},{"parent_types.keyword":"User"}],"hits":[{"_index":"stix_domain_entities_v2","_type":"_doc","_id":"V417944","_score":18.008339,"_source":{"firstname":"Admin","parent_types":["User","Identity","Stix-Domain-Entity","Stix-Domain"],"description":"Principal admin account","created_at":"2020-04-06T19:13:08.061Z","language":"auto","revoked":false,"index_version":"1.0","password":"$2a$10$TF6qlvBW0qKsv2BI6Bdt0.4eYCDt2VcCdn14GM5JXk/MRfkNnIYJu","base_type":"entity","created_at_year":"2020","updated_at":"2020-05-20T14:21:11.521Z","alias":[],"modified":"2020-05-20T14:21:11.521Z","created_at_day":"2020-04-06","id":"88ec0c6a-13ce-5e39-b486-354fe4a7084f","grakn_id":"V417944","user_email":"admin@opencti.io","created_at_month":"2020-04","internal_id_key":"88ec0c6a-13ce-5e39-b486-354fe4a7084f","stix_id_key":"identity--88ec0c6a-13ce-5e39-b486-354fe4a7084f","created":"2020-04-06T19:13:08.061Z","lastname":"OpenCTI","external":true,"entity_type":"user","name":"admin"}},{"_index":"stix_domain_entities_v2","_type":"_doc","_id":"V459000","_score":18.008339,"_source":{"user_email":"itsecops@mydomain.com","firstname":"Admin","internal_id_key":"88ec0c6a-13ce-5e39-b486-354fe4a7084f","created_at_month":"2020-06","parent_types":["User","Identity","Stix-Domain-Entity","Stix-Domain"],"stix_id_key":"identity--88ec0c6a-13ce-5e39-b486-354fe4a7084f","created":"2020-06-02T15:34:38.981Z","description":"Principal admin account","created_at":"2020-06-02T15:34:38.981Z","language":"auto","revoked":false,"lastname":"OpenCTI","external":true,"password":"$2a$10$jw2c1/yQ8fzUzw.8oV3VdOHdPxwGRMFoJU6wOeNlbq3dgsuPIHbbS","entity_type":"user","base_type":"entity","updated_at":"2020-06-02T15:34:38.981Z","created_at_year":"2020","name":"admin","alias":[],"modified":"2020-06-02T15:34:38.981Z","created_at_day":"2020-06-02","id":"88ec0c6a-13ce-5e39-b486-354fe4a7084f","grakn_id":"V459000"}}]},"internalData":{}},"level":"error","message":"[OPENCTI] GraphQL initialization fail"} error Command failed with exit code 1.

Environment

  1. Ubuntu 10.04
  2. OpenCTI 3.3.0
  3. OpenCTI client: Python
  4. Node: 12.16.1

Reproducible Steps

Steps to create the smallest reproducible scenario:

  1. After having issues with the current Docker, I downloaded the latest release of OpenCTI after installing all the dependencies and running them as Linux services. I did not replace anything from the prior Docker installation.
  2. I built all the Python requirements in a virtual environment which I activated before using Yarn.
  3. yarn serv

Expected Output

Startup without error

Actual Output

See above.

SamuelHassine commented 4 years ago

Hello,

This is a known issue and we are currently trying to deal with it. Please just wipe everything (including the Docker volumes by docker volume prune -a). It should work after that.

smclinden commented 4 years ago

Same error. I removed all Docker volumes, containers and images. Prior to that I had moved the docker volumes to local storage which I, also, deleted. I am now running everything as a process/daemon in Linux no containers.

Is there someplace where the data from the previous install might be cached? The services that I moved from docker were, in order of first to last:

redis grakn elasticsearch minio rabbitmq opencti

I, then, decided to delete everything from ES with:

curl -XDELETE localhost:9200/_all

And now I get:

yarn run v1.22.4

$ node --max_old_space_size=8192 build/index.js {"level":"info","message":"[INIT] > Starting OPENCTI..."} {"level":"info","message":"[PRE-CHECK] > Grakn is alive"} {"level":"info","message":"[PRE-CHECK] > ElasticSearch is alive"} {"level":"info","message":"[PRE-CHECK] > Minio is alive"} {"level":"info","message":"[PRE-CHECK] > RabbitMQ is alive"} {"level":"info","message":"[PRE-CHECK] > Redis is alive"} {"level":"info","message":"[PRE-CHECK] > Python3 is available"} {"level":"info","message":"[INIT] > Existing platform detected, migration..."} {"level":"info","message":"[INIT] > Grakn schema loaded"} {"level":"info","message":"[INIT] > Elasticsearch indexes loaded"} {"error":{},"level":"error","message":"[OPENCTI] GraphQL initialization fail"} error Command failed with exit code 1.

I verified that Minio was running:

root 4413 5750 0 14:56 pts/0 00:00:00 /apps/usr/bin/minio server /apps/data

and that Minio was listening on port 9000

tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 4413/minio

To access the service I needed to do the following:

./mc config host add local http://localhost:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY Added local successfully.

./mc config host ls gcs
URL : https://storage.googleapis.com AccessKey : YOUR-ACCESS-KEY-HERE SecretKey : YOUR-SECRET-KEY-HERE API : S3v2 Lookup : dns

local URL : http://localhost:9000 AccessKey : minioadmin SecretKey : minioadmin API : s3v4 Lookup : auto

play URL : https://play.min.io AccessKey : Q3AM3UQ867SPQQA43P2F SecretKey : zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG API : S3v4 Lookup : auto

s3
URL : https://s3.amazonaws.com AccessKey : YOUR-ACCESS-KEY-HERE SecretKey : YOUR-SECRET-KEY-HERE API : S3v4 Lookup : dns

I am then able to do:

./mc admin update local/ Server local/ updated successfully from 2020-05-29T14:08:49Z to 2020-06-01T17-28-03Z

But I am still getting the GraphQL error!

smclinden commented 4 years ago

More info:

% npm test

opencti-graphql@3.3.0 test /apps/usr/local/src/opencti-3.3.0/opencti jest --bail --testSequencer ./tests/utils/testSequencer.js --verbose --runInBand --forceExit --coverage --e test

PASS tests/01-unit/config/conf-test.js ✓ default configuration keys must exists (3ms)

PASS tests/01-unit/database/graknRoles-test.js ✓ default roles inversion (3ms)

PASS tests/01-unit/domain/user-test.js ✓ Validation of roles assertion (3ms)

{"level":"info","message":"[API-PYTHON] > Traceback (most recent call last):"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/stix2patterns/v20/grammars/STIXPatternParser.py\", line 728, in observationExpression"} {"level":"info","message":"[API-PYTHON] > raise NoViableAltException(self)"} {"level":"info","message":"[API-PYTHON] > antlr4.error.Errors.NoViableAltException: None"} {"level":"info","message":"[API-PYTHON] > "} {"level":"info","message":"[API-PYTHON] > The above exception was the direct cause of the following exception:"} {"level":"info","message":"[API-PYTHON] > "} {"level":"info","message":"[API-PYTHON] > Traceback (most recent call last):"} {"level":"info","message":"[API-PYTHON] > File \"src/python/stix2_extract_observables.py\", line 56, in "} {"level":"info","message":"[API-PYTHON] > main()"} {"level":"info","message":"[API-PYTHON] > File \"src/python/stix2_extract_observables.py\", line 38, in main"} {"level":"info","message":"[API-PYTHON] > pattern = create_pattern_object(sys.argv[1])"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/stix2/pattern_visitor.py\", line 330, in create_pattern_object"} {"level":"info","message":"[API-PYTHON] > pattern_obj = Pattern(pattern)"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/stix2patterns/v20/pattern.py\", line 21, in init"} {"level":"info","message":"[API-PYTHON] > self.parse_tree = self.do_parse(pattern_str)"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/stix2patterns/v20/pattern.py\", line 113, in do_parse"} {"level":"info","message":"[API-PYTHON] > real_exc)"} {"level":"info","message":"[API-PYTHON] > File \"\", line 3, in raise_from"} {"level":"info","message":"[API-PYTHON] > stix2patterns.exceptions.ParseException: 1:0: no viable alternative at input 'fail'"} {"level":"warn","message":"[Python3] createStixPattern error > undefined"} {"level":"info","message":"[API-PYTHON] > Traceback (most recent call last):"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/stix2patterns/v20/grammars/STIXPatternParser.py\", line 728, in observationExpression"} {"level":"info","message":"[API-PYTHON] > raise NoViableAltException(self)"} {"level":"info","message":"[API-PYTHON] > antlr4.error.Errors.NoViableAltException: None"} {"level":"info","message":"[API-PYTHON] > "} {"level":"info","message":"[API-PYTHON] > The above exception was the direct cause of the following exception:"} {"level":"info","message":"[API-PYTHON] > "} {"level":"info","message":"[API-PYTHON] > Traceback (most recent call last):"} {"level":"info","message":"[API-PYTHON] > File \"src/python/stix2_extract_observables.py\", line 56, in "} {"level":"info","message":"[API-PYTHON] > main()"} {"level":"info","message":"[API-PYTHON] > File \"src/python/stix2_extract_observables.py\", line 38, in main"} {"level":"info","message":"[API-PYTHON] > pattern = create_pattern_object(sys.argv[1])"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/stix2/pattern_visitor.py\", line 330, in create_pattern_object"} {"level":"info","message":"[API-PYTHON] > pattern_obj = Pattern(pattern)"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/stix2patterns/v20/pattern.py\", line 21, in init"} {"level":"info","message":"[API-PYTHON] > self.parse_tree = self.do_parse(pattern_str)"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/stix2patterns/v20/pattern.py\", line 113, in do_parse"} {"level":"info","message":"[API-PYTHON] > real_exc)"} {"level":"info","message":"[API-PYTHON] > File \"\", line 3, in raise_from"} {"level":"info","message":"[API-PYTHON] > stix2patterns.exceptions.ParseException: 1:0: no viable alternative at input 'bad'"} {"level":"warn","message":"[Python3] extractObservables error > stix2patterns.exceptions.ParseException: 1:0: no viable alternative at input 'fail'"} {"level":"warn","message":"[Python3] extractObservables error > stix2patterns.exceptions.ParseException: 1:0: no viable alternative at input 'bad'"} {"level":"warn","message":"[Python3] createStixPattern error > undefined"} {"level":"warn","message":"[Python3] createStixPattern error > undefined"} PASS tests/01-unit/python/pythonBridge-test.js ✓ Check if python is well configured (434ms) ✓ Check extractObservables bad pattern (387ms) ✓ Check domain pattern (345ms) ✓ Check hash pattern (352ms) ✓ Check createStixPattern bad pattern (669ms) ✓ Check createStixPattern hash (323ms)

{"level":"info","message":"[PRE-CHECK] > Grakn is alive"} {"level":"info","message":"[PRE-CHECK] > ElasticSearch is alive"} {"level":"info","message":"[PRE-CHECK] > Minio is alive"} {"level":"info","message":"[PRE-CHECK] > RabbitMQ is alive"} {"level":"info","message":"[PRE-CHECK] > Redis is alive"} {"level":"info","message":"[PRE-CHECK] > Python3 is available"} {"level":"info","message":"[INIT] > Existing platform detected, migration..."} {"level":"info","message":"[INIT] > Grakn schema loaded"} {"level":"info","message":"[INIT] > Elasticsearch indexes loaded"} {"level":"info","message":"OPENCTI Ready on port 4000"} {"level":"info","message":"[API-PYTHON] > INFO:root:Listing Threat-Actors with filters null."} {"type":"READ_ERROR","operation_query":"query ThreatActors($filters:[ThreatActorsFiltering]$search:String$first:Int$after:ID$orderBy:ThreatActorsOrdering$orderMode:OrderingMode){threatActors(filters:$filters search:$search first:$first after:$after orderBy:$orderBy orderMode:$orderMode){edges{node{id stix_id_key stix_label entity_type parent_types name alias description graph_data goal sophistication resource_level primary_motivation secondary_motivation personal_motivation created modified created_at updated_at createdByRef{node{id entity_type stix_id_key stix_label name alias description created modified ...on Organization{organization_class}}relation{id}}markingDefinitions{edges{node{id entity_type stix_id_key definition_type definition level color created modified}relation{id}}}tags{edges{node{id tag_type value color}relation{id}}}externalReferences{edges{node{id entity_type stix_id_key source_name description url hash external_id created modified}relation{id}}}}}pageInfo{startCursor endCursor hasNextPage hasPreviousPage globalCount}}}","inner_relation_creation":0,"operation":"ThreatActors","time":34,"variables":{"filters":null,"search":null,"first":1,"after":null,"orderBy":null,"orderMode":null},"size":85,"error":{"data":{"category":"technical"},"stacktrace":["AuthRequired: You must be logged in to do this.","at error (/apps/usr/local/src/opencti-3.3.0/opencti/src/config/errors.js:8:10)","at AuthRequired (/apps/usr/local/src/opencti-3.3.0/opencti/src/config/errors.js:19:3)","at AuthDirective.authenticationControl (/apps/usr/local/src/opencti-3.3.0/opencti/src/graphql/authDirective.js:34:22)","at field.resolve (/apps/usr/local/src/opencti-3.3.0/opencti/src/graphql/authDirective.js:66:19)","at field.resolve (/apps/usr/local/src/opencti-3.3.0/opencti/node_modules/graphql-extensions/src/index.ts:274:18)","at resolveFieldValueOrError (/apps/usr/local/src/opencti-3.3.0/opencti/node_modules/graphql/execution/execute.js:467:18)","at resolveField (/apps/usr/local/src/opencti-3.3.0/opencti/node_modules/graphql/execution/execute.js:434:16)","at executeFields (/apps/usr/local/src/opencti-3.3.0/opencti/node_modules/graphql/execution/execute.js:275:18)","at executeOperation (/apps/usr/local/src/opencti-3.3.0/opencti/node_modules/graphql/execution/execute.js:219:122)","at executeImpl (/apps/usr/local/src/opencti-3.3.0/opencti/node_modules/graphql/execution/execute.js:104:14)","at Object.execute (/apps/usr/local/src/opencti-3.3.0/opencti/node_modules/graphql/execution/execute.js:64:35)","at /apps/usr/local/src/opencti-3.3.0/opencti/node_modules/apollo-server-core/src/requestPipeline.ts:479:22","at Generator.next ()","at /apps/usr/local/src/opencti-3.3.0/opencti/node_modules/apollo-server-core/dist/requestPipeline.js:8:71"]},"level":"error","message":"API Call"} {"level":"info","message":"[API-PYTHON] > INFO:root:{\"errors\":[{\"message\":\"API Call\",\"extensions\":{\"code\":\"INTERNAL_SERVER_ERROR\"}}]}"} {"level":"info","message":"[API-PYTHON] > "} {"level":"info","message":"[API-PYTHON] > ERROR:root:OpenCTI API is not reachable. Waiting for OpenCTI API to start or check your configuration..."} {"level":"info","message":"[API-PYTHON] > Traceback (most recent call last):"} {"level":"info","message":"[API-PYTHON] > File \"src/python/local_importer.py\", line 27, in "} {"level":"info","message":"[API-PYTHON] > testLocalImporter.inject()"} {"level":"info","message":"[API-PYTHON] > File \"src/python/local_importer.py\", line 16, in inject"} {"level":"info","message":"[API-PYTHON] > opencti_api_client = OpenCTIApiClient(self.api_url, self.api_token)"} {"level":"info","message":"[API-PYTHON] > File \"/usr/local/lib/python3.6/dist-packages/pycti/api/opencti_api_client.py\", line 111, in init"} {"level":"info","message":"[API-PYTHON] > \"OpenCTI API is not reachable. Waiting for OpenCTI API to start or check your configuration...\""} {"level":"info","message":"[API-PYTHON] > ValueError: OpenCTI API is not reachable. Waiting for OpenCTI API to start or check your configuration..."} FAIL tests/02-integration/00-inject/loader-test.js (6.777s) Database provision ✕ should platform init (2006ms) ✕ Should import creation succeed (1176ms) ✕ Should import update succeed (486ms) ✕ Should worker consume succeed (453ms)

● Database provision › should platform init

expect(received).resolves.toBe()

Received promise rejected instead of resolved
Rejected to value: [TypeError: Cannot read property 'user_email' of null]

  10 | 
  11 |   it('should platform init',  () => {
> 12 |     return expect(platformInit(true)).resolves.toBe(true);
     |            ^
  13 |   }, FIVE_MINUTES);
  14 | 
  15 |   it('Should import creation succeed', async () => {

  at expect (node_modules/expect/build/index.js:134:15)
  at Object.<anonymous> (tests/02-integration/00-inject/loader-test.js:12:12)

● Database provision › Should import creation succeed

Failed: Object {
  "message": "ERROR:root:OpenCTI API is not reachable. Waiting for OpenCTI API to start or check your configuration...",
  "status": "error",
}

  13 |   }, FIVE_MINUTES);
  14 | 
> 15 |   it('Should import creation succeed', async () => {
     |   ^
  16 |     const httpServer = await listenServer();
  17 |     const execution = await execPython3(PYTHON_PATH, 'local_importer.py', importOpts);
  18 |     expect(execution).not.toBeNull();

  at Env.it (node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:89:24)
  at Suite.<anonymous> (tests/02-integration/00-inject/loader-test.js:15:3)
  at Object.<anonymous> (tests/02-integration/00-inject/loader-test.js:7:1)

● Database provision › Should import update succeed

listen EADDRINUSE: address already in use 0.0.0.0:4000

  18 |     try {
  19 |       const httpServer = createHttpServer();
> 20 |       httpServer.listen(PORT, () => {
     |                  ^
  21 |         logger.info(`OPENCTI Ready on port ${PORT}`);
  22 |         resolve(httpServer);
  23 |       });

  at src/httpServer.js:20:18
  at listenServer (src/httpServer.js:17:10)
  at Object.<anonymous> (tests/02-integration/00-inject/loader-test.js:25:30)

● Database provision › Should worker consume succeed

listen EADDRINUSE: address already in use 0.0.0.0:4000

  18 |     try {
  19 |       const httpServer = createHttpServer();
> 20 |       httpServer.listen(PORT, () => {
     |                  ^
  21 |         logger.info(`OPENCTI Ready on port ${PORT}`);
  22 |         resolve(httpServer);
  23 |       });

  at src/httpServer.js:20:18
  at listenServer (src/httpServer.js:17:10)
  at Object.<anonymous> (tests/02-integration/00-inject/loader-test.js:33:30)
---------------------------- --------- ---------- --------- --------- ------------------------------------------------------------------------------------------------------------------------ File % Stmts % Branch % Funcs % Lines Uncovered Line #s
All files 21.74 8.98 7.13 22.53
database 22.74 11.1 20.11 23.89
elasticSearch.js 16.77 6.47 10.98 17.82 ...399-472,479,488-493,496-533,539,553-677,719-723,735-739,742-746,750,772-782,797-805,808-810,823-837,848-894,900-970
grakn.js 21.77 10.84 27.88 22.69 ...,1584-1592,1595-1603,1606-1614,1617-1627,1645-1750,1759,1765-1853,1859-1887,1891-1927,1932-1944,1948-1952,1965-2005
graknRoles.js 58.82 50 50 58.82 158-166
minio.js 22.22 14.75 12.5 25 26-28,55-61,65-71,75-78,84-85,98-109,114-123,135-156,162-177
rabbitmq.js 45.26 0 26.32 51.22 53-63,71-111,128-161,165-167,203,207,211-212,217-229
redis.js 42.03 53.85 17.39 43.75 50,66-68,82-101,114-115,124-144,156-159,162-163
stix.js 17.14 0 0 17.54 ...207,222-231,247-256,275-284,296-305,319-328,342-351,368-377,395-404,418-427,438-447,454-471,487-502,517-542,546-596
utils.js 22.52 25 28.57 23.08 21-56,60-80,90,92,100-117,126-163
domain 22.84 1.25 1.17 23.75
attackPattern.js 33.33 0 0 33.33 14-17,20,24-25,29-34
attribute.js 17.86 100 0 19.23 17-23,32,37-63
campaign.js 31.25 0 0 31.25 14-17,20,25,28-29,34-40
city.js 33.33 0 0 33.33 14-17,20,23-28,32-36
connector.js 19.05 0 0 21.05 20,31-32,35-44,51,53,58-73,76-82,85-107,110-111
country.js 33.33 0 0 33.33 14-17,20,23-28,32-36
courseOfAction.js 33.33 0 0 33.33 14-17,20,24-25,29-34
enrichment.js 23.08 0 0 23.08 10,14-31
externalReference.js 29.03 100 0 29.03 17,20,24-28,32,35-38,42-44,47-51,56-58,62-64
file.js 15.79 0 0 16.67 9-36,43-46,49-51
grant.js 23.08 0 0 25 7-8,12-38
group.js 30.56 100 0 33.33 19,22,26-32,35-41,45-46,51-55,60-62,66-68,72-73,76-77
identity.js 13.64 0 0 13.64 9-18,21-37,41-46
incident.js 31.58 0 0 31.58 17-20,23,28-29,32,38-44,48-57
indicator.js 9.68 0 0 9.84 68-105,109-112,115,119-191,195-201
inference.js 19.23 0 0 20 109-120,124-131,135-142
intrusionSet.js 27.27 0 0 27.27 7-10,13,17-23
killChainPhase.js 28.13 0 0 28.13 17,21,25-34,38,41-44,48-50,53-57,62-64,68-70
log.js 42.86 0 0 60 10-17
malware.js 33.33 0 0 33.33 6-9,12,16-17
markingDefinition.js 29.17 0 0 29.17 15-18,22,26-27,31,34-38,43-45,49-51
note.js 28.3 0 0 29.41 22-25,28,33-35,38-45,49-51,54-62,66-68,71-78,82,93-94,97-99,120-132,138-139
opinion.js 28.3 0 0 29.41 22-25,28,33-35,38-45,49-51,54-62,66-68,71-78,82,93-94,97-99,120-132,138-139
organization.js 33.33 0 0 33.33 14-17,20,23-28,32-36
rabbitmqMetrics.js 12.5 0 0 12.5 7-19
region.js 33.33 0 0 33.33 15-18,21,24-29,32-37,41-47,50-54
report.js 25.68 0 0 26.76 28-31,34,39-41,44-51,55-57,60-68,72-74,77-84,88-90,103-104,107-110,146-158,165-189
sector.js 33.33 0 0 33.33 15-18,21,24-29,32-37,41-47,50-54
settings.js 24 0 0 26.09 23-37,41-42,46-48,53-55,60-64
stixDomainEntity.js 11.76 0 0 11.98 ...8-81,84,103-168,186-190,193,204-205,208-219,222-229,233-237,241-252,255-276,286-314,317-328,333-440,447-449,453-455
stixEntity.js 23.53 0 0 23.53 19-35,39,47-53,56-62,65-71,74-80,83-88,91-96,99-104,108-109,113-125,129-145
stixObservable.js 16.67 0 0 16.96 38,41-44,56-59,62,68-76,79-85,88-138,141,144-150,154-166,170-174,184-200,206-208,212-214,228-292,303-307,310,314-315
stixObservableRelation.js 30.43 0 0 30.43 16,19-25,30-36,39,43,46,49-53
stixRelation.js 22.73 0 0 23.26 22,25-31,59-68,71,74-78,82-88,92-94,100-102,106-108
stixSighting.js 25 0 0 25.64 21,24-30,50-60,63,66-70,74-80,84-86,92-94,98-100
subType.js 50 100 0 100
tag.js 31.82 100 0 36.84 14,17,21-22,27-31,36-37,40-41
threatActor.js 33.33 0 0 33.33 7-10,13,17-18
tool.js 33.33 0 0 33.33 7-10,13,17-18
user.js 23.91 7.53 8.22 25 ...340,343-349,352-355,358-361,364-373,376-381,390-398,401-409,413-427,430-441,444-447,453-480,494-505,514-515,534-553
vulnerability.js 33.33 0 0 33.33 7-10,13,17-18
work.js 20.31 0 0 25 10,25-27,31,41-50,54,63-72,76,84-94,98,102-104,108-109,124-141,145-148
workspace.js 25.49 0 0 26 25,28,31,40-43,49,62-67,71-77,81-96,100-104,108-110,116-118,122-124
graphql 52.43 42.11 50 57.65
authDirective.js 51.02 37.93 60 59.46 14-17,36-51
graphql.js 48 40.91 80 47.83 34-40,49-54
loggerPlugin.js 70.59 66.67 42.86 78.57 7,15,24
schema.js 100 100 100 100
subscriptionWrapper.js 12.5 100 0 14.29 4-16
python 86.11 100 88.89 85.29
pythonBridge.js 86.11 100 88.89 85.29 70-75
resolvers 6.68 0 0 6.81
attackPattern.js 7.69 100 0 7.69 16-43
attribute.js 14.29 100 0 14.29 5-13
campaign.js 7.14 0 0 7.14 14-41
city.js 8.33 100 0 8.33 14-34
connector.js 7.14 100 0 7.14 14-30
country.js 8.33 100 0 8.33 14-34
courseOfAction.js 8.33 100 0 8.33 14-39
externalReference.js 8.33 100 0 8.33 20-38
file.js 16.67 100 0 16.67 7-15
globalObject.js 16.67 0 0 20 5-9
group.js 7.14 100 0 7.14 18-35
identity.js 5 0 0 5.26 15-49
incident.js 6.67 0 0 6.67 21-51
indicator.js 8.33 100 0 8.33 14-40
inference.js 25 100 0 25 5-9
intrusionSet.js 9.09 100 0 9.09 14-35
killChainPhase.js 7.69 100 0 7.69 20-36
log.js 25 100 0 25 6-10
malware.js 8.33 100 0 8.33 15-39
markingDefinition.js 8.33 100 0 9.09 19-36
note.js 3.57 0 0 3.57 30-90
opinion.js 3.57 0 0 3.57 30-90
organization.js 8.33 100 0 8.33 14-38
rabbitmqMetrics.js 50 100 0 50 5
region.js 7.14 100 0 7.14 14-36
report.js 3.57 0 0 3.57 30-90
sector.js 7.14 100 0 7.14 14-37
settings.js 10 0 0 10 17-29
stixDomainEntity.js 3.33 0 0 3.45 32-84
stixEntity.js 5 0 0 5.56 18-45
stixObservable.js 4.17 0 0 4.35 32-73
stixObservableRelation.js 7.69 0 0 7.69 18-37
stixRelation.js 4.55 100 0 4.76 24-64
stixSighting.js 5 100 0 5.26 23-61
subType.js 50 100 0 50 5
tag.js 10 100 0 10 10-26
threatActor.js 9.09 100 0 9.09 14-35
tool.js 8.33 100 0 8.33 15-39
user.js 1.67 0 0 1.75 46-130
vulnerability.js 9.09 100 0 9.09 14-35
workspace.js 5.56 100 0 5.56 24-45
---------------------------- --------- ---------- --------- --------- ------------------------------------------------------------------------------------------------------------------------

Summary of all failing tests FAIL tests/02-integration/00-inject/loader-test.js (6.777s) ● Database provision › should platform init

expect(received).resolves.toBe()

Received promise rejected instead of resolved
Rejected to value: [TypeError: Cannot read property 'user_email' of null]

  10 | 
  11 |   it('should platform init',  () => {
> 12 |     return expect(platformInit(true)).resolves.toBe(true);
     |            ^
  13 |   }, FIVE_MINUTES);
  14 | 
  15 |   it('Should import creation succeed', async () => {

  at expect (node_modules/expect/build/index.js:134:15)
  at Object.<anonymous> (tests/02-integration/00-inject/loader-test.js:12:12)

● Database provision › Should import creation succeed

Failed: Object {
  "message": "ERROR:root:OpenCTI API is not reachable. Waiting for OpenCTI API to start or check your configuration...",
  "status": "error",
}

  13 |   }, FIVE_MINUTES);
  14 | 
> 15 |   it('Should import creation succeed', async () => {
     |   ^
  16 |     const httpServer = await listenServer();
  17 |     const execution = await execPython3(PYTHON_PATH, 'local_importer.py', importOpts);
  18 |     expect(execution).not.toBeNull();

  at Env.it (node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:89:24)
  at Suite.<anonymous> (tests/02-integration/00-inject/loader-test.js:15:3)
  at Object.<anonymous> (tests/02-integration/00-inject/loader-test.js:7:1)

● Database provision › Should import update succeed

listen EADDRINUSE: address already in use 0.0.0.0:4000

  18 |     try {
  19 |       const httpServer = createHttpServer();
> 20 |       httpServer.listen(PORT, () => {
     |                  ^
  21 |         logger.info(`OPENCTI Ready on port ${PORT}`);
  22 |         resolve(httpServer);
  23 |       });

  at src/httpServer.js:20:18
  at listenServer (src/httpServer.js:17:10)
  at Object.<anonymous> (tests/02-integration/00-inject/loader-test.js:25:30)

● Database provision › Should worker consume succeed

listen EADDRINUSE: address already in use 0.0.0.0:4000

  18 |     try {
  19 |       const httpServer = createHttpServer();
> 20 |       httpServer.listen(PORT, () => {
     |                  ^
  21 |         logger.info(`OPENCTI Ready on port ${PORT}`);
  22 |         resolve(httpServer);
  23 |       });

  at src/httpServer.js:20:18
  at listenServer (src/httpServer.js:17:10)
  at Object.<anonymous> (tests/02-integration/00-inject/loader-test.js:33:30)

Test Suites: 1 failed, 4 passed, 5 of 44 total Tests: 4 failed, 9 passed, 13 total Snapshots: 0 total Time: 12.052s Ran all test suites matching /test/i. npm ERR! Test failed. See above for more details.

richard-julien commented 4 years ago

In my opinion the error you have its because you clean correctly grakn but not elastic. Today opencti doesnt not clean elastic for you if grakn start fresh and so in your case the admin user was indexed twice, preventing the platform to start.

You have to be sure when you start fresh that all the dependencies are clean.

Please verify and remove all attached volumes for grakn/elastic etc and try to restart.

smclinden commented 4 years ago

I tried wiping everything clean, rebooting and doing a fresh install and got the same output.

I agree that this appears to be a credential issue but not sure where. There are buckets for grakn and opencti-bucket (the latter is empty).

My default.json is as follows:

{ "app": { "port": 4000, "logs": "./logs", "logs_level": "info", "cookie_secure": false, "base_path" : "", "platform_demo": false, "performance_logger": false, "admin": { "email": "my email", "password": "my password", "token": "4f2869be-1456-404a-a3b3-bb3bffacd1ba" } }, "grakn": { "hostname": "localhost", "port": 48555, "timeout": 30000 }, "redis": { "hostname": "localhost", "port": 6379 }, "elasticsearch": { "url": "http://localhost:9200", "noQueryCache": false }, "minio": { "endpoint": "localhost", "port": 9000, "use_ssl": false, "access_key": "minioakey", "secret_key": "minioskey" }, "rabbitmq": { "hostname": "localhost", "port": 5672, "port_management": 15672, "management_ssl": false, "username": "guest", "password": "guest" }, "providers": { "local": { "strategy": "LocalStrategy" } } }

Rouxgaru commented 4 years ago

I'm having this exact same issue. Fresh install and everything. I'll be happy to include any files, but it's the same error after the npm test.

richard-julien commented 3 years ago

Ticket is now old and so i close it. Please open another ticket if you still have some issue.