Run query
Requirements to run a custom rules query
If you re-imported Projects in Snyk, you must Select new repo in Custom rules or wait for the next automated scan cycle. For details, see Re-importing existing repositories for the Snyk Code testing.
The query language is case-sensitive.
Run a query on a repository
Run queries against a repository from your Snyk Project list. The list contains repositories you previously uploaded to Snyk.
Log in to the Snyk Web UI and go to your Group and Organization.
Go to Custom rules.
(Optional) in the Get Started panel, you have access to the following:
Query examples: Examples of highly requested queries.
Query Templates: Pre-built templates of logical operators, conditions, and other components.
Query Predicates: Predefined criteria and conditions to be included in the result.
Go to Run query on a repository > Repositories and select a repo where you want to run the query. The repo is imported after you select it.
(Optional) If a repository is already selected, click Select new repo to run the query.
Write your query in the Code query panel with suggestive AI support.
Run query.
(Optional) Save the custom rule you created.
For more information, see Query examples.
Run a query on a code snippet
Run queries against code snippets to detect vulnerabilities, review and audit code, and assess compliance and regulatory requirements.
Log in to the Snyk Web UI and go to your Group and Organization.
Go to Custom rules.
Select Run query on a code snippet.
Select the programming language from the dropdown list and paste your code in the code snippet area.
You can run queries only on certain languages in the code snippet area. See the dropdown menu for the full list of available languages.
(Optional) Save the custom rule you created.
Analyze query results
When you run a query, the results show the matching parts of the tested code, highlighting which parts of the code are related to the query. Each match is shown when Snyk Code is testing a repository and can be triaged based on the finding.
Last updated