TheHive-Project / TheHive-Project/Cortex

Initial administrator creation using the username/name "cortex" fails.

Open
#275 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.6k
Forks
264
PR merge metrics
No merged PRs in 30d

Description

Initial administrator creation using the username/name "cortex" fails.

Request Type

Bug

Work Environment
Question Answer
OS version (server) Ubuntu 18.04
OS version (client) Manjaro
Cortex version / git hash 3.0
Package Type Ubuntu
Browser type & version Chromium and Firefox
Problem Description

When setting up cortex, when creating the initial administrator user if the username and name are "cortex" the creation fails. Upon refreshing the browser the error "Error: User init is not found".

I've replicated this with a fresh build with no errors. Changing the name and username gives me a fully functional healthy cortex instance.

Steps to Reproduce
  1. Install Ubuntu 18.04
  2. Follow installation guide.
  3. Upon browsing to cortex, click "Update Database"
  4. When creating the new user, make the username and name "cortex".
  5. Request will hang indefinitely, anybody else browsing to cortex or refreshing the page will show "Error: User init is not found"
  6. Deleting the elastic index for cortex and redoing steps 3 and 4 with different username/name the issue does appear
Complementary information

tail -f /var/log/cortex/application.log
2020-06-24 01:01:01,527 [INFO] from com.sksamuel.elastic4s.http.ElasticClient$ in application-akka.actor.default-dispatcher-7 - Creating HTTP client on http://127.0.0.1:9200
2020-06-24 01:01:01,538 [INFO] from com.sksamuel.elastic4s.http.ElasticClient$ in application-akka.actor.default-dispatcher-4 - Creating HTTP client on http://127.0.0.1:9200
2020-06-24 01:01:01,583 [INFO] from com.sksamuel.elastic4s.http.ElasticClient$ in application-akka.actor.default-dispatcher-4 - Creating HTTP client on http://127.0.0.1:9200
2020-06-24 01:01:01,608 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-4 - Create a new empty database
2020-06-24 01:01:01,609 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-4 - Migrate database from version 0, add operations for version 2
2020-06-24 01:01:01,619 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-4 - Migrate database from version 0, add operations for version 3
2020-06-24 01:01:01,619 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-4 - Migrate database from version 0, add operations for version 4
2020-06-24 01:01:02,963 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from sequence
2020-06-24 01:01:03,015 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from artifact
2020-06-24 01:01:03,017 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from audit
2020-06-24 01:01:03,021 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from data
2020-06-24 01:01:03,023 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from dblist
2020-06-24 01:01:03,025 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from job
2020-06-24 01:01:03,028 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from organization
2020-06-24 01:01:03,030 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from report
2020-06-24 01:01:03,031 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from user
2020-06-24 01:01:03,033 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from worker
2020-06-24 01:01:03,036 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-5 - Migrating 0 entities from workerConfig
2020-06-24 01:01:03,957 [INFO] from org.elastic4play.services.MigrationSrv in application-akka.actor.default-dispatcher-12 - End of migration
2020-06-24 01:01:12,891 [INFO] from org.thp.cortex.services.ErrorHandler in application-akka.actor.default-dispatcher-5 - POST /api/user returned 400
org.elastic4play.ConflictError: [doc][cortex]: version conflict, document already exists (current version [1])
at org.elastic4play.database.DBConfiguration.$anonfun$execute$2(DBConfiguration.scala:146)
at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307)
at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Refreshing the browser after the post failure:
tail -f /var/log/cortex/application.log
2020-06-24 01:02:59,465 [INFO] from org.thp.cortex.services.ErrorHandler in application-akka.actor.default-dispatcher-4 - GET /api/user/current returned 404
org.elastic4play.NotFoundError: user init not found
at org.elastic4play.database.DBGet.$anonfun$apply$2(DBGet.scala:37)
at scala.Option.fold(Option.scala:175)
at org.elastic4play.database.DBGet.$anonfun$apply$1(DBGet.scala:37)
at scala.util.Success.$anonfun$map$1(Try.scala:255)
at scala.util.Success.map(Try.scala:213)
at scala.concurrent.Future.$anonfun$map$1(Future.scala:292)
at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:33)
at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:33)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce initial administrator creation with both username and name set to "cortex", then inspect the POST /api/user failure and the referenced DBConfiguration.scala:146 and DBGet.scala:37 stack frames. Confirm the behavior against a different username, and consider the issue done when creation succeeds and GET /api/user/current no longer reports that the init user is missing.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, scala
Domain
api, backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.