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

[Bug] Several API Endpoints could never get called due to the routing structure #1492

Closed
Explie opened this issue Aug 26, 2020 · 0 comments
Closed
Assignees
Labels
bug TheHive4 TheHive4 related issues
Milestone

Comments

@Explie
Copy link
Contributor

Explie commented Aug 26, 2020

Several API Endpoints could never get called due to the routing structure

Request Type

Bug

Work Environment

Question Answer
OS version (server) Ubuntu
OS version (client) 20.04
TheHive version / git hash 4.0.0-1 (commit#:cf775dcdf8196ab12cd9eccd92f27d1f3edfd527)
Package Type From source

Problem Description

The Play routing hierarchy for the API v0 will result in calls never being executed.
E.g.: When calling /api/v0/case/task the intended behaviour would be to follow this routing entry:
Line 110: case GET(p"/case/task") => queryExecutor.task.search
But instead the entry:
Line 63: case GET(p"/case/$caseId") => caseCtrl.get(caseId) will be called with the $caseID = "task".

This is due to the nature of Play iterating through the routing entries from top to bottom. (atleast that is what it looks like in the debugger)

It looks like the example above is currently the only entry where this problem occurs but it is not limited to this in the future

Steps to Reproduce

  1. Start TheHive4
  2. Call to /api/v0/case/task
  3. Returns RichCase not found
  4. With debugger attached you can see that it calls /v0/CaseCtrl.scala: get(caseIdOrNumber) and not queryExecutor.task.search

Possible Solutions

Not using nested resource for naming of REST API endpoints or restructure of the routing hierarchy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug TheHive4 TheHive4 related issues
Projects
None yet
Development

No branches or pull requests

2 participants