DependencyTrack / DependencyTrack/dependency-track

REST API search is returning wrong entries

Open
#2,310 4 comments 0 reactions 0 assignees View on GitHub
api docs defect in triage
Dominant language
Java
Stars
4.2k
Forks
811
Avg merge
8h 39m
Merged PRs (30d)
237

Description

### Current Behavior

I got several projects named like the following pattern:

- Project X / Application 1 [server01.foo.local]
- Project X / Application 2 [server01.foo.local]
- Project X / Application 3 [server01.foo.local]
- Project Y / Application 1 [server02.foo.local]
- Project Y / Application 2 [server02.foo.local]

For each project there are inactive versions, too.

**CASE 1:**

If I use the REST API and search for certain project which contains a specific string in their name and is active I use a request like this:

`https://depndencytrack.local/api/v1/search/project?query=(name:"server01.foo.local" AND active:true)`

The server responds:
```
{
"results": {
"project": []
}
}
```

**CASE 2:**

If I use the REST API and search for certain project which contains a specific string in their name I use a request like this:

`https://depndencytrack.local/api/v1/search/project?query=(name:"server01.foo.local")`

The server responds with all available projects.

**ADDITIONAL**
Unfortunately there is no documentation available how to use this search functionality. I suspected to use the [standard lucene syntax](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html) .

### Steps to Reproduce

1. Add the project names
2. Add at least two versions for one project and set Active to false
3. Make REST requests

### Expected Behavior

**CASE 1:**

The server is responding only projects with a name which is containing "server01.foo.local" and is currently active.

**CASE 2:**

The server is responding only projects with a name which is containing "server01.foo.local". This response contains active and inactive projects.

### Dependency-Track Version

4.6.x

### Dependency-Track Distribution

Container Image

### Database Server

MySQL

### Database Server Version

10.5.16

### Browser

Microsoft Edge

### Checklist

- [X] I have read and understand the [contributing guidelines](https://github.com/DependencyTrack/dependency-track/blob/master/CONTRIBUTING.md#filing-issues)
- [X] I have checked the [existing issues](https://github.com/DependencyTrack/dependency-track/issues) for whether this defect was already reported

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.