Dev.to Security 🔐 Cybersecurity 👁 0 📖 2 min read

Local AI Code Review and Security Scanning in VS Code with Ollama and Hushavyr

I built Hushavyr because I wanted to review code and check for security issues inside VS Code while keeping my source code on my machine. It’s a free, open-source extension that combines static analysis with local AI cod

Local AI Code Review and Security Scanning in VS Code with Ollama and Hushavyr

I built Hushavyr because I wanted to review code and check for security issues inside VS Code while keeping my source code on my machine. It’s a free, open-source extension that combines static analysis with local AI code review through Ollama.

Hushavyr supports Java, Kotlin, Python, JavaScript, TypeScript, Go, Rust, C#, PHP, and Ruby. I’m using Java in this demo because the JDBC example makes it easy to see what the scanner found and what the proposed fix changed.

From a security finding to a diff in VS Code

In the demo, a Java method looks up a customer by order ID. The method concatenates orderId into the SQL string, which creates a SQL injection risk. Hushavyr flags the line and proposes a PreparedStatement. I can inspect the diff in VS Code before applying the change.

Hushavyr highlights a Java SQL injection risk in VS Code and shows the proposed PreparedStatement fix as a diff

Here’s the JDBC pattern behind the fix:

String sql = "SELECT customer FROM orders WHERE id = ?";

try (PreparedStatement statement = connection.prepareStatement(sql)) {
    statement.setString(1, orderId);

    try (ResultSet results = statement.executeQuery()) {
        return results.next() ? results.getString("customer") : null;
    }
}

The ? is a placeholder. setString binds the order ID separately as a value, so it can’t change the structure of this query.

I’d still check the full diff before applying it. Does the method return the same result when the order doesn’t exist? Does it close the statement and result set correctly? Those are the same questions I’d ask in a pull request review.

What runs locally

The built-in scanner can flag security issues and look for hardcoded secrets without loading an AI model. Optional analyzers such as Trivy and OSV-Scanner can check dependencies for known vulnerabilities.

Ollama runs the AI review on my machine. I can ask it to explain a finding in the context of the file or propose a code change. The security checks available for a file vary by language and installed analyzer.

Try it on your own code

  1. Install Hushavyr from the VS Code Marketplace.
  2. Open the Command Palette and run Hushavyr: Setup to choose a local model and any optional analyzers.
  3. Open a source file and run Hushavyr: Review Current File.
  4. If you request a fix, inspect the diff before applying it.

If you try it, tell me which language and local model you used. I’d especially like to hear about a finding you expected it to catch or a warning you’d dismiss. Those are concrete cases I can investigate.

Source code and issues on GitHub

This article was drafted with AI and prepared for publication by the project author.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.