Skip to main content

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

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.7.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.7.0
File Size Uploaded Provenance
miniapp_scanner-0.7.0.tar.gz 36.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 75.1 kB

Release files / miniapp_scanner-0.7.0.tar.gz

Download URL miniapp_scanner-0.7.0.tar.gz
Size 36.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a18402b039f98ac2321b791089c411b939c284f9961fa3d875a4b59b5e3ab2f6
BLAKE2b-256 checksum
How to use checksums
f4e59ef7533718e5ef20e8308d6aef0c6c8e0a5c75ab6e11190a7a7f785cec34
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.7.0-py3-none-any.whl

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

Security for miniapp-scanner 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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