- 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 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.
Writing a query
-
Run query.
-
(Optional) Save the custom rule you created.
For more information, see Query examples.
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.
{% hint style="info" %} You can run queries only on certain languages in the code snippet area. See the dropdown menu for the full list of available languages. {% endhint %}
Running a query on a code snippet
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.
\