-
Notifications
You must be signed in to change notification settings - Fork 0
Query filtering #16
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
Query filtering #16
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a --filter flag to the Sonar Docker image inspector tool, enabling users to filter packages using Cloudsmith's Package Search Syntax (e.g., downloads:>0, uploaded:<'30 days ago'). The filtering capability works at two levels: identifying which images to scan when no specific image is provided, and filtering digests within tag manifests during analysis.
Changes:
- Added
--filtercommand-line argument with filtering logic that queries Cloudsmith API using search syntax - Modified
fetch_tag_data()andget_image_analysis()functions to accept and process filter criteria based on matched digests - Updated documentation in README.md and CHANGELOG.md to describe the new filtering feature
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Docker/Sonar/sonar.py | Core implementation of filtering logic including new parameter handling, digest matching, parent lookup for filtered children, and query construction |
| Docker/Sonar/README.md | Added documentation for the --filter flag and usage example |
| CHANGELOG.md | Added changelog entry for the new filtering feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ## [Unreleased] | ||
|
|
||
| ### Sonar | ||
| - Added `--filter` flag which accepts the (Package Search Syntax)[https://docs.cloudsmith.com/artifact-management/search-filter-sort-packages] string. e.g. `--filter "downloads:>0"`. |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The markdown link syntax is incorrect. It should use square brackets for the text and parentheses for the URL, not the reverse.
| - Added `--filter` flag which accepts the (Package Search Syntax)[https://docs.cloudsmith.com/artifact-management/search-filter-sort-packages] string. e.g. `--filter "downloads:>0"`. | |
| - Added `--filter` flag which accepts the [Package Search Syntax](https://docs.cloudsmith.com/artifact-management/search-filter-sort-packages) string. e.g. `--filter "downloads:>0"`. |
|
|
||
| # Fetch parent package info | ||
| api_url = f"https://api.cloudsmith.io/v1/packages/{workspace}/{repo}/?query=version:{ntag}" | ||
| api_url = f"https://api.cloudsmith.io/v1/packages/{workspace}/{repo}/?query=tag:{ntag}" |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API query change from 'version:' to 'tag:' may have unintended consequences. In Docker image APIs, 'version' typically refers to the package version field (which for manifest lists is the digest), while 'tag' refers to the Docker tag. This change should be validated to ensure it correctly retrieves the parent package information for all scenarios, especially when filtering is not active. If the intent was only to support the new filtering feature, this change affects all queries and could break existing functionality.
| api_url = f"https://api.cloudsmith.io/v1/packages/{workspace}/{repo}/?query=tag:{ntag}" | |
| query_field = "tag" if filtering_digests is not None else "version" | |
| api_url = f"https://api.cloudsmith.io/v1/packages/{workspace}/{repo}/?query={query_field}:{ntag}" |
|
|
||
| return groups | ||
|
|
||
| # filepath: /Users/cmoynes/dev/support-engineering/Docker/Sonar/sonar.py |
Copilot
AI
Jan 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file path comment appears to be development/debugging residue and should be removed. It doesn't serve a functional purpose in the code and looks like it was accidentally left from IDE or development tools.
| # filepath: /Users/cmoynes/dev/support-engineering/Docker/Sonar/sonar.py |
📄 Summary
--filterflag which accepts the (Package Search Syntax)[https://docs.cloudsmith.com/artifact-management/search-filter-sort-packages] string. e.g.--filter "downloads:>0".🔍 Related Issues
Link to any related GitHub issues (e.g.,
Fixes #12,Closes #34):🧪 Type of Change
Please check the relevant type tag for this PR title:
[FIX]Bug fix[NEW]New thing[REFACTOR]Internal changes such as code restructuring or optimization that does not alter functionality[DOC]Documentation-only changes[CHORE]Maintenance, cleanup, or CI configuration🧪 How Has This Been Tested?
Describe how you tested your changes. Include CI runs, local tests, manual verification, or screenshots if applicable.
📸 Screenshots (if applicable)
If UI or logs are affected, include before/after screenshots or output.
✅ Checklist