<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tural Dadashov</title>
    <description>The latest articles on DEV Community by Tural Dadashov (@dadashovvvh).</description>
    <link>https://dev.to/dadashovvvh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4120923%2Fd4f5452a-bb37-4c0e-b9f6-5e329ed72b0b.jpeg</url>
      <title>DEV Community: Tural Dadashov</title>
      <link>https://dev.to/dadashovvvh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dadashovvvh"/>
    <language>en</language>
    <item>
      <title>How I Built a Local, AI-Powered Code Security Scanner</title>
      <dc:creator>Tural Dadashov</dc:creator>
      <pubDate>Fri, 11 Sep 2026 12:46:39 +0000</pubDate>
      <link>https://dev.to/dadashovvvh/how-i-built-a-local-ai-powered-code-security-scanner-1bai</link>
      <guid>https://dev.to/dadashovvvh/how-i-built-a-local-ai-powered-code-security-scanner-1bai</guid>
      <description>&lt;h2&gt;
  
  
  The Problem I Kept Running Into
&lt;/h2&gt;

&lt;p&gt;I've been working with local LLMs for a while, and one question kept coming up from people in regulated industries: &lt;em&gt;"How do we use AI on our code if we can't send it to the cloud?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Banks can't send source code to Snyk. Hospitals can't upload patient-data-adjacent code to Checkmarx. Government teams run air-gapped networks where cloud tools simply don't exist.&lt;/p&gt;

&lt;p&gt;The usual answer is "use an on-premise scanner" — but most of those are enterprise-priced, hard to set up, and still require a data pipeline to some central server.&lt;/p&gt;

&lt;p&gt;So I built something simpler.&lt;/p&gt;

&lt;h2&gt;
  
  
  What CodeGuardian Does
&lt;/h2&gt;

&lt;p&gt;It's a local code security scanner. You give it a file, it gives you back a list of security issues with line numbers.&lt;/p&gt;

&lt;p&gt;Runs entirely on your machine. No API calls. No telemetry. No data leaves your network.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Stack
&lt;/h2&gt;

&lt;p&gt;Nothing exotic:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Python 3.12 + FastAPI&lt;/strong&gt; for the API layer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ollama + Qwen 2.5 7B&lt;/strong&gt; (16K context) for the LLM&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docker + Docker Compose&lt;/strong&gt; for deployment&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;MIT license&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The interesting part isn't the stack — it's how the scanning works.&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Actually Works
&lt;/h2&gt;

&lt;p&gt;I tried pure LLM scanning first. It was slow, expensive, and hallucinated constantly. It would flag safe code as "potential SQL injection" and miss obvious &lt;code&gt;eval()&lt;/code&gt; calls.&lt;/p&gt;

&lt;p&gt;So I went hybrid:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;AST analysis first.&lt;/strong&gt; Python's &lt;code&gt;ast&lt;/code&gt; module catches deterministic issues — &lt;code&gt;eval()&lt;/code&gt;, &lt;code&gt;exec()&lt;/code&gt;, hardcoded passwords — with zero false positives. No tokens spent.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLM only for the ambiguous cases.&lt;/strong&gt; SQL injection patterns, context-dependent flaws, logic issues that need semantic understanding.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Result: ~90% coverage, and the LLM only sees what actually needs reasoning.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Real Test
&lt;/h2&gt;

&lt;p&gt;I ran it against a file with intentionally planted vulnerabilities. Here's what it found:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[eval() function]        → CRITICAL
[SQL injection]          → CRITICAL
[Hardcoded password]     → HIGH
[Command injection]      → HIGH

4 vulnerabilities in 7 seconds.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>ai</category>
      <category>security</category>
      <category>python</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
