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

Enhance query filters to handle Uuid and enable analysis graph to use filters. #920

Merged

Conversation

JimFuller-RedHat
Copy link
Collaborator

@JimFuller-RedHat JimFuller-RedHat commented Oct 14, 2024

Enhances query.rs to be able to perform comparisons with Uuid when supplied via inline query params.

Enabling the analysis graph (api/v1/analysis) to filter on sbom_id, node_id and exact name.

api/v1/analysis/root-component?q=name=A&node_id=SPDXRef-A&sbom_id=urn:uuid:019289ff-232c-7780-b0d5-22b6e5dc4be5

where we retain contains style search with:

api/v1/analysis/root-component?q=libcurl

to filter exact match use:

api/v1/analysis/root-component?q=name=libcurl

and similar for dep endpoints eg.

api/v1/analysis/dep?q=name=A&node_id=SPDXRef-A&sbom_id=urn:uuid:019289ff-232c-7780-b0d5-22b6e5dc4be5
api/v1/analysis/dep?q=libcurl
api/v1/analysis/dep?q=name=libcurl

Note - In real usage - the above inline query name=values&name=value should always be escaped.

Most of the 'moving parts' of this feature is due to querying both an ORM and non ORM entity at the same time (sbom_node and analysis graph) ... kept most of the code changes within analysis graph.

@JimFuller-RedHat JimFuller-RedHat self-assigned this Oct 14, 2024
@JimFuller-RedHat JimFuller-RedHat marked this pull request as draft October 14, 2024 09:46
Copy link
Contributor

@ctron ctron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I'll defer to @jcrossley3

@JimFuller-RedHat JimFuller-RedHat marked this pull request as ready for review October 14, 2024 09:49
@JimFuller-RedHat JimFuller-RedHat force-pushed the add-filters-graph branch 2 times, most recently from 482d4a4 to 5ad90f4 Compare October 14, 2024 10:04
Copy link
Contributor

@jcrossley3 jcrossley3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad you figured it out!

common/src/db/query.rs Show resolved Hide resolved
modules/analysis/src/service.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@jcrossley3 jcrossley3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to fix the graph_read_gaurd typo while you're in there?

common/src/db/query.rs Show resolved Hide resolved
modules/analysis/src/service.rs Show resolved Hide resolved
modules/analysis/src/service.rs Show resolved Hide resolved
@JimFuller-RedHat JimFuller-RedHat added this pull request to the merge queue Oct 14, 2024
Merged via the queue into trustification:main with commit 109a45c Oct 14, 2024
1 check passed
@JimFuller-RedHat JimFuller-RedHat deleted the add-filters-graph branch October 14, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants