AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How Snyk DeepCode AI Creates Custom Security Rules Using Natural Language Queries

Annika Bernklau · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Writing custom static analysis rules has historically felt like writing a mini-compiler. If your application security team wanted to enforce an internal security policy—such as blocking direct calls to an unapproved cryptography library or catching missing tenant validation middleware—you had to write abstract syntax tree (AST) matchers, fiddle with Datalog queries, or wrestle with brittle regular expressions.

Snyk DeepCode AI approaches this problem differently. Through DeepCode AI Search, it translates natural language queries into semantic code queries, allowing security engineers to define compliance patterns in plain English. At 365Finds, we analyzed how this pipeline translates conversational prompts into deterministic AST searches, how engineers can build and tune custom rules, and where the practical limits lie.


How Snyk DeepCode AI Processes Natural Language into Code Rules

The core engine of Snyk DeepCode AI relies on a hybrid AI architecture. It does not simply feed your proprietary codebase into an off-the-shelf generative model. Instead, it pairs generative parsing with deterministic symbolic analysis:

  1. Intent Translation via Generative AI: When a security engineer types a query like "Find unescaped user input passed directly into internal RPC logging without passing through our maskPII sanitizer", the generative layer interprets the linguistic components. It identifies the target programming language, candidates for data sources (user inputs), sinks (logging sinks), and required intermediary transformations (sanitizers).
  2. Semantic Graph Mapping (Symbolic AI): Snyk DeepCode AI does not run lexical string searches. It builds code representation graphs—combining Abstract Syntax Trees (ASTs), Control Flow Graphs (CFGs), and Data Flow Graphs (DFGs). The generative translation maps onto these symbolic graphs to trace whether data actually flows from a source to a sink across method boundaries and module imports.
  3. Deterministic Verification: Because symbolic engines govern the code graph traversal, the rule avoids generative hallucination. Either a reachable path exists in the code graph, or it does not.
  4. Custom Rule Packaging: Once the semantic search identifies the targeted pattern, DeepCode AI allows the engineer to persist that query as a permanent custom rule within Snyk Code, enforcing it continuously across IDEs and CI/CD pipelines.

Step-by-Step Guide: Creating Custom Rules with DeepCode AI Search

Step 1: Define the Security Invariant

Before typing a query, establish the exact tripartite pattern of your rule:

Step 2: Formulate the Natural Language Query in DeepCode AI Search

Open the DeepCode AI Search interface within your Snyk workspace. Formulate a prompt that specifies the contextual constraints rather than generic keywords.

DeepCode AI Search interprets the structural intent and displays matching code snippets across your selected repositories in real time.

Step 3: Inspect AST Matches and Validate Precision

Review the surfaced snippets. Check for:

DeepCode AI provides interactive query refinement hints and autocomplete tokens. Adjust the query to restrict scopes (e.g., filtering out *.test.ts files or specifying exact package imports).

Step 4: Configure Severity and Remediation Guidance

Once the pattern matches expected violations, click Save as Custom Rule. Configure the rule metadata:

Step 5: Automate Rule Enforcement in Snyk Code

After saving, Snyk Code automatically distributes the custom rule:


Practical Implementation Examples

Compliance ScenarioNatural Language Query InputSemantic Detection Logic
Bypassed Tenant Isolation"Find multi-tenant database queries where organizationId is not present in where clause"Checks that database model calls under ctx.db enforce org_id parameter binding in the query scope.
Insecure Cryptographic Primitives"Find uses of crypto.createHash with md5 or sha1 outside of test fixtures"Detects legacy hash algorithm invocations within production source files while ignoring test files.
PII Leakage in Logging"Find user.password or user.ssn passed to logger.info without passing through maskField"Traces data flow of designated model properties to logging sinks without an intermediary sanitizer.

365Finds Institutional Evaluation

At 365Finds, our assessment of Snyk DeepCode AI's natural language rule creation highlights significant productivity advantages alongside critical AppSec caveats:

References