<?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: Samitha Tharanga Wijesinghe</title>
    <description>The latest articles on DEV Community by Samitha Tharanga Wijesinghe (@samitha_tharanga).</description>
    <link>https://dev.to/samitha_tharanga</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%2F4053222%2F8f349f7a-f47d-435b-b4ca-07990e0016f8.png</url>
      <title>DEV Community: Samitha Tharanga Wijesinghe</title>
      <link>https://dev.to/samitha_tharanga</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/samitha_tharanga"/>
    <language>en</language>
    <item>
      <title>Stop AI Slop: I Built an Open-Source Security Layer for AI Coding Agents (Python + FastAPI)</title>
      <dc:creator>Samitha Tharanga Wijesinghe</dc:creator>
      <pubDate>Tue, 18 Aug 2026 17:34:23 +0000</pubDate>
      <link>https://dev.to/samitha_tharanga/stop-ai-slop-i-built-an-open-source-security-layer-for-ai-coding-agents-python-fastapi-3676</link>
      <guid>https://dev.to/samitha_tharanga/stop-ai-slop-i-built-an-open-source-security-layer-for-ai-coding-agents-python-fastapi-3676</guid>
      <description>&lt;h2&gt;
  
  
  Stop AI Slop: I Built an Open-Source Security Layer for LLM Coding Agents
&lt;/h2&gt;

&lt;p&gt;As developers, we are shipping code faster than ever thanks to AI assistants like Claude, ChatGPT, and Cursor. But let’s admit an uncomfortable truth: &lt;strong&gt;AI makes you faster, but it doesn't automatically make you safer.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AI models prioritize functionality and getting the logic to run over application security. Whenever I ask an AI to write a quick database query or a system utility script, it frequently returns hardcoded secrets, unsafe deserialization methods like &lt;code&gt;pickle&lt;/code&gt;, or classic SQL injection vectors. &lt;/p&gt;

&lt;p&gt;Instead of manually reviewing every single line or crossing my fingers during CI/CD pipelines, I decided to build a lightweight, Zero-Trust security middleware: &lt;strong&gt;Secure-MCP&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Secure-MCP?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Secure-MCP&lt;/strong&gt; is a lightweight, local-first SAST (Static Application Security Testing) middleware designed to intercept and scan LLM-generated Python code &lt;em&gt;before&lt;/em&gt; it ever touches a production codebase. &lt;/p&gt;

&lt;p&gt;Under the hood, it leverages Python's robust &lt;code&gt;bandit&lt;/code&gt; security analyzer, wrapped in a high-performance &lt;strong&gt;FastAPI&lt;/strong&gt; backend, and presented through a clean, modern Glassmorphism web interface.&lt;/p&gt;




&lt;h2&gt;
  
  
  How It Works (The Architecture)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Request:&lt;/strong&gt; The developer (or an automated AI agent) submits a generated code snippet to the &lt;code&gt;/api/v1/scan&lt;/code&gt; endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Secure Sandboxing:&lt;/strong&gt; The backend securely writes the snippet into a temporary file (&lt;code&gt;tempfile&lt;/code&gt;), ensuring no persistent disk pollution, and executes a JSON-formatted static analysis scan via &lt;code&gt;bandit&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Structured Report:&lt;/strong&gt; It returns a structured JSON payload breaking down vulnerabilities by severity (High, Medium, Low), complete with exact line numbers and offending code snippets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rate Limiting &amp;amp; Protection:&lt;/strong&gt; Built with &lt;code&gt;slowapi&lt;/code&gt; to prevent abuse and protect public endpoint resources.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  A Quick Peek at the Code
&lt;/h2&gt;

&lt;p&gt;Here is a snippet showing how the core scanning service handles temporary file execution and safety cleanups:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
python
import tempfile
import subprocess
import json
import os

class BanditScannerService:
    @staticmethod
    def scan_python_code(code_string: str):
        # Securely write to a temporary file
        with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as temp:
            temp.write(code_string)
            temp_path = temp.name

        try:
            # Run Bandit static analysis in JSON format
            cmd = ["bandit", "-f", "json", temp_path]
            result = subprocess.run(cmd, capture_output=True, text=True)

            # Parse the JSON report
            report = json.loads(result.stdout) if result.stdout else {"results": []}

            # Aggregate severity counts
            high, medium, low = 0, 0, 0
            for issue in report.get("results", []):
                sev = issue.get("issue_severity")
                if sev == "HIGH": high += 1
                elif sev == "MEDIUM": medium += 1
                elif sev == "LOW": low += 1

            return {
                "status": "completed",
                "total_issues": len(report.get("results", [])),
                "high_severity": high,
                "medium_severity": medium,
                "low_severity": low,
                "results": report.get("results", [])
            }
        finally:
            # Ensure cleanup happens even if something fails
            if os.path.exists(temp_path):
                os.remove(temp_path)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>python</category>
      <category>security</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Building Conjecture Forge: An Open-Source AI-Assisted Mathematical Discovery Engine</title>
      <dc:creator>Samitha Tharanga Wijesinghe</dc:creator>
      <pubDate>Wed, 29 Jul 2026 16:49:59 +0000</pubDate>
      <link>https://dev.to/samitha_tharanga/building-conjecture-forge-an-open-source-ai-assisted-mathematical-discovery-engine-34eb</link>
      <guid>https://dev.to/samitha_tharanga/building-conjecture-forge-an-open-source-ai-assisted-mathematical-discovery-engine-34eb</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for &lt;a href="https://dev.to/bugsmash"&gt;DEV's Summer Bug Smash: Clear the Lineup&lt;/a&gt; powered by &lt;a href="https://sentry.io/" rel="noopener noreferrer"&gt;Sentry&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Conjecture Forge&lt;/strong&gt; is an open-source, AI-Assisted Mathematical Discovery &amp;amp; Symbolic Computation Engine. Built using Python, FastAPI, SymPy, and React, it automatically parses mathematical expressions, computes precise derivatives, and generates intelligent mathematical hypotheses (conjectures) through a sleek dark-mode Glassmorphism UI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug Fix or Performance Improvement
&lt;/h2&gt;

&lt;p&gt;When users inputted malformed, highly complex, or unstructured mathematical expressions into the web engine, the backend parsing pipeline faced critical bottlenecks:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Uncaught Expression Exceptions:&lt;/strong&gt; Invalid syntax directly crashed the FastAPI worker threads due to unhandled exceptions thrown by SymPy's parsing engine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance Degradation:&lt;/strong&gt; Heavy symbolic computations and algebraic simplifications lacked structured error boundaries and safe validation schemas, causing latency spikes in the calculation loop.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;

&lt;p&gt;Here is the core code implementation for our updated validation and error-resilient computation pipeline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fastapi&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HTTPException&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pydantic&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BaseModel&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sympy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sp&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;FastAPI&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MathRequest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BaseModel&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;

&lt;span class="nd"&gt;@app.post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/api/compute&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;compute_conjecture&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;MathRequest&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Safely parse the expression using SymPy with strict boundary handling
&lt;/span&gt;        &lt;span class="n"&gt;expr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sympify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expression&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;derivative&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;original&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expr&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;derivative&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;derivative&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;status&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;success&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="c1"&gt;# Cleanly intercept parsing failures to prevent backend crashes
&lt;/span&gt;        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;HTTPException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;detail&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Invalid mathematical expression: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;My Improvements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To eliminate server crashes and ensure ultra-low latency, we implemented:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Pydantic Validation Guardrails:&lt;br&gt;
Incoming expression payloads are strictly validated before hitting the heavy mathematical core.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Resilient Error-Catching Middleware: &lt;br&gt;
Replaced generic server faults with descriptive, client-safe HTTP exceptions.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optimized Frontend Integration:&lt;br&gt;
Refactored the React frontend to handle asynchronous streaming and error responses smoothly, keeping the Glassmorphism UI fully responsive.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Use of Sentry&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To monitor production stability and track complex runtime exceptions in our Python/FastAPI backend, we integrated Sentry Error Monitoring:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Real-time Exception Tracking: Configured Sentry SDK to capture unhandled expression-parsing anomalies and performance bottlenecks instantly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Distributed Tracing: Monitored the request lifecycle from the React frontend down to the FastAPI/SymPy execution layer, ensuring zero latency degradation during heavy mathematical transformations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Best Use of Google AI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Conjecture Forge heavily relies on symbolic mathematics and automated pattern parsing, which acts as the foundational layer for AI-driven mathematical hypothesis (conjecture) generation. By combining SymPy's pattern recognition with structured automated evaluation, the engine parses deep mathematical behaviors efficiently, serving as a powerful analytical tool for researchers and students.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>python</category>
      <category>react</category>
      <category>bugsmash</category>
    </item>
  </channel>
</rss>
