跳到正文
DEV Community· Kushal·· 5 小時前AI 評分44

SecureLocal AI:Hacktoberfest 第 2 週的本機優先 Python 安全審核工具

SecureLocal AI: A Local-First Python Security Auditor for Hacktoberfest Week 2

AI 導讀

SecureLocal AI 是為 Hacktoberfest 2026 第 2 週 Side Hustle 挑戰製作的離線優先 Python 桌面安全審核工具,使用 AST 靜態掃描七類啟發式模式,不會匯入或執行專案。

正文

What I built

For Hacktoberfest 2026 Week 2's Side Hustle challenge, I built SecureLocal AI: an offline-first desktop tool for a first-pass review of Python source code.

The scanner uses Python's built-in AST to flag seven heuristic patterns: dynamic execution, unsafe pickle deserialization, shell-enabled subprocess calls, possible hardcoded credentials, weak hashes, disabled TLS verification in recognized HTTP clients, and dynamically constructed SQL. It scans selected .py files without importing or executing the project, and its findings remain deterministic whether or not a language model is installed.

I tested the application end to end during development. This is an early working tool—not a claim of customer adoption or proven commercial demand.

Who might pay for it?

The plausible buyer is someone who needs a low-friction first review but cannot or does not want to upload source code to a hosted scanner: an independent Python consultant handling client repositories, or a small development team that wants a local triage step before human review. A paid offering might eventually be useful as a supported desktop workflow or team setup, but that is a market hypothesis, not a validated business. I have no paying customers, customer feedback, or commercial validation to report.

Why open innovation matters here

The static scanner is useful on its own. When a developer wants more context, SecureLocal AI can ask a locally running Ollama service to explain one selected finding using the open-weight Qwen2.5-Coder 3B model (qwen2.5-coder:3b). The model is optional; the app does not download it automatically. Install Ollama, start its local service, and pull the model yourself:

ollama pull qwen2.5-coder:3b
python app.py

The client defaults to http://127.0.0.1:11434 and rejects non-loopback endpoints. A normal scan makes no HTTP/API requests. Only after the user explicitly asks for an explanation does the app send a small, redacted finding context to local Ollama—not the project, source file, file path, or report. The model adds advice; it does not set severity, change the deterministic finding, edit files, or apply a fix. Its explanation is unverified and should be checked independently.

Running inference locally avoids per-request cloud-model charges and means source files do not need to leave the machine for this workflow. It is not cost-free: the user supplies the compute, electricity, storage, and initial model download, and local performance depends on their hardware. I have not measured or benchmarked it. Keeping the model choice and inference on the developer's machine also gives users more control than making a hosted model API a required dependency.

How the app works

The Tkinter interface lets me choose a project folder, start a scan, filter results by severity or text, and inspect a finding's rule, severity, confidence, location, redacted evidence, limitations, and remediation guidance. Findings can be exported as JSON or Markdown. Reports include the findings and relative paths, with credential-like evidence redacted; they do not include complete source files.

File discovery and scanning have safety limits and skip symbolic links, generated directories, oversized files, malformed source, and files that cannot be safely read. The app does not write to the scanned project. These controls reduce accidental exposure and unbounded work, but they do not protect against a compromised operating system or malicious local software. Review any report before sharing it.

Demo: screenshots from the repository

SecureLocal AI is a desktop application, so these existing screenshots are the demo rather than a hosted web instance.

Vulnerable scan and finding list

SecureLocal AI showing detected findings

Clean fixture scan

SecureLocal AI showing a clean fixture scan

Finding inspection

Finding details with severity, evidence, limitations, and remediation

Optional local-model explanation

An explanation from the locally running model

The image files are committed under docs/screenshots/. The image links above use their raw GitHub URLs so DEV can render the existing assets.

Testing and limitations

A recorded development result was 51 tests passing, exercising the scanner, rules and redaction, file discovery, exports, Ollama client behavior, and UI paths. The suite includes synthetic fixtures and mocked model responses; passing tests is evidence that those tested behaviors worked, not proof of complete security coverage or real-world detection accuracy.

The rules are heuristics: they can miss vulnerabilities and flag safe code, and they do not establish whether a value is attacker-controlled. This is Python-only first-pass triage, not full data-flow analysis, dependency scanning, a clean bill of health, or a replacement for review by a security professional.

Project and challenge

This post is an entry for the Side Hustle prompt: a small, specific tool built around open-weight AI, with its prospective users and the privacy/cost trade-offs stated plainly. No partner category is claimed.

來源:DEV Community · dev.to