Skip to main content

GitHub Marketplace CI PyPI License: MIT 📝 第一篇:从零构建微信小程序安全扫描器 📝 第二篇:深入浅出:如何用 Python 实现一个小程序污点分析引擎 📝 第三篇:从 0 到 GitHub Marketplace:一个安全工具的开源全记录

miniapp-scanner

CI

miniapp-scanner

微信小程序静态安全扫描器:AST + 污点分析 + DSL 规则 + LLM 研判。

核心能力

  • 四引擎检测:正则 / AST / DSL / 污点数据流

  • 跨文件追踪:追踪 utils/request.js 等封装方法的完整传播链

  • 跨文件返回值传播:追踪 getUserInput() 返回值的污染传播

  • 别名分析:处理 const a=b; const c=a; c.evil() 间接传播

  • 控制流敏感:识别 if (false) 分支的不可达代码

  • YAML 规则库:25+ 条规则,改规则不用改代码

  • Web 应用支持:XSS(innerHTML / document.write)、DOM Clobbering

  • LLM 二次研判:AI 判断 TP/FP,过滤误报

  • LLM 自动报告:生成可交付的中文安全报告

  • 用户级配置:~/.miniapp-scanner.yaml,一次配置到处用

  • PR 自动扫描:GitHub Actions 在 PR 里自动评论扫描结果

  • 25 个单元测试:覆盖四引擎 + 所有规则

  • 支持的框架

  • ✅ 微信原生小程序

  • ✅ Taro(React 语法)

  • ✅ uni-app(Vue 语法)

  • ✅ Web 应用(React / Vue / 原生 JS)

  • ✅ React 组件(export default 支持)

  • ✅ Vue 单文件组件(<script> 支持)

安装

pip install -e ".[dev]"

## 🔧 集成到你的项目(GitHub Actions)

在你的项目里创建 `.github/workflows/security.yml`:

```yaml
name: Security Scan

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: MiniApp Security Scan
        uses: lathuninh/miniapp-scanner@main
        with:
          target: '.'
          fail-on-high: 'true'

security-scan:
  stage: test
  image: python:3.11
  script:
    - pip install miniapp-scanner
    - miniapp-scanner "src/" --json report.json
    - python -c "import json; d=json.load(open('report.json')); exit(1 if d['summary']['high'] > 0 else 0)"
  artifacts:
    paths:
      - report.json

stage('Security Scan') {
    steps {
        sh 'pip install miniapp-scanner'
        sh 'miniapp-scanner "src/" --json report.json'
        script {
            def report = readJSON file: 'report.json'
            if (report.summary.high > 0) {
                error("Found ${report.summary.high} high severity issues")
            }
        }
    }
}

pip install miniapp-scanner
miniapp-scanner "src/" --json report.json

# 有高危时退出码为 1,无高危时退出码为 0
# 可通过 $? 检查,让 CI 自动阻断合并

{
  "target": "src/",
  "project_type": "miniapp",
  "files_scanned": 52,
  "lines_scanned": 5774,
  "duration": 9.6,
  "summary": {
    "total": 9,
    "high": 2,
    "medium": 0,
    "low": 6,
    "info": 1
  },
  "findings": [
    {
      "rule_id": "DSL-003",
      "rule_name": "Sensitive data stored in local storage",
      "severity": "high",
      "file": "pages/authorize/index.js",
      "line": 115,
      "code": "wx.setStorageSync('token', ...)",
      "engine": "dsl",
      "trace": []
    }
  ]
}

Metadata

Release files for miniapp-scanner 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miniapp-scanner 0.6.0
File Size Uploaded
miniapp_scanner-0.6.0.tar.gz 35.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for miniapp-scanner 0.6.0
File Interpreter ABI Platform
miniapp_scanner-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 74.2 kB

Release files / miniapp_scanner-0.6.0.tar.gz

Download URL miniapp_scanner-0.6.0.tar.gz
Size 35.9 kB
Tags Source
SHA-256 checksum
How to use checksums
12936b90444b8ed1aa8af07d1779dae0321b2e0971894d5db643b838662866a3
BLAKE2b-256 checksum
How to use checksums
444749f00b3e36777aaf8c57b1aa3b3f282ce2281a6ab4a2757b8fe14979a9bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.10

Release files / miniapp_scanner-0.6.0-py3-none-any.whl

Download URL miniapp_scanner-0.6.0-py3-none-any.whl
Size 38.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e49fc65af9ef9c3fb8689cf423478bad24202d84f192b3cab3631ecf2e33e4c4
BLAKE2b-256 checksum
How to use checksums
3bba1d1f4acebb849847d10eab05895f623e9d80f3200662b6d7fc49afe0352d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

0.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page