Run query

Conditions

If you re-imported Projects in Snyk, you need to Select new repo in Custom rules or wait for the next automated scan cycle. 🔗 Re-importing existing repositories for the Snyk Code test

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.

  1. Open Snyk Web UI and go to your Group and Organization.

  2. Go to Custom rules.

  3. (Optional) in the Get Started panel, you can access 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.

  4. 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.

  5. (Optional) If a repository is already selected, click Select new repo to run the query.

  6. Write your query in the Code query panel with suggestive AI support.

    Writing a query
    Writing a query
  7. Run query.

🔗 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.

  1. Open Snyk Web UI and go to your Group and Organization.

  2. Go to Custom rules.

  3. Select Run query on a code snippet.

  4. Select the programming language from the dropdown list and paste your code inside.

You can run queries only on certain languages in the code snippet area. See the dropdown menu for the full list of available languages.

Running a query on a code snippet.
Running a query on a code snippet

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 testing a repository and can be triaged per finding.

Last updated

Was this helpful?