
إجراء GitHub الذي يفحص ملفات نماذج التعلم الآلي بحثًا عن التعليمات البرمجية الضارة والثغرات الأمنية
احظر نماذج الذكاء الاصطناعي الخبيثة في خط أنابيبك بسطر واحد من YAML.
GuardModel هو إجراء GitHub يقوم تلقائيًا بمسح ملفات نماذج التعلم الآلي بحثًا عن البرامج الضارة والثغرات الأمنية والمخاطر في خطوط أنابيب CI/CD. فهو يمنع النماذج الخطيرة قبل وصولها إلى الإنتاج من خلال كشف هجمات إزالة التسلسل (pickle deserialization) والبرامج الضارة المضمنة و CVEs المعروفة.
أضفه إلى سير العمل الخاص بك:
name: GuardModel Security Scan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: guardmodel/scan@v1
هذا كل شيء! سيقوم GuardModel بمسح جميع ملفات النماذج وسيفشل الفحص إذا تم اكتشاف تهديدات.
أنشئ .guardmodel.yml في مستودعك:
version: 1
# Directories to scan
include:
- models/
- weights/
# Directories to ignore
exclude:
- tests/fixtures/
# Severity threshold to fail CI
fail_on: high # critical, high, medium, low, none
# Allowlist known-safe models by SHA256
allowlist:
- sha256: "abc123..."
reason: "Verified by security team"
# Maximum file sizes
max_file_size: 5GB
max_total_size: 20GB
يكتشف GuardModel:
os.system, subprocess, eval, execctypes, imports ديناميكيةفحص أمان GuardModel
الحالة: فشل - تم اكتشاف تهديدين
تظهر النتائج في علامة تبويب الأمان في GitHub مع:
# Install dependencies
npm install
pip install -r requirements.txt
# Build
npm run build
# Test
npm test
pytest tests/
# Package for release
npm run package
guardmodel/
├── action.yml # GitHub Action definition
├── src/ # TypeScript source
│ ├── index.ts # Entry point
│ ├── orchestrator.ts # Scan coordination
│ ├── config.ts # Configuration
│ ├── walker.ts # File discovery
│ └── reporters/ # Output formatters
├── python/
│ ├── agents/ # Scanner agents
│ │ ├── pickle_agent.py
│ │ ├── keras_agent.py
│ │ ├── onnx_agent.py
│ │ └── safetensors_agent.py
│ └── rules/ # Detection rules
└── tests/ # Test suite
MIT
المساهمات مرحب بها! رجاءً انظر CONTRIBUTING.md.
| Extension | Format | Scanner | Risk Level |
|---|
.pkl, .pickle | Python Pickle | Pickle Agent | حرج |
.pt, .pth | PyTorch | Pickle Agent | حرج |
.bin | PyTorch/Transformers | Pickle Agent | حرج |
.h5, .hdf5 | HDF5/Keras | Keras Agent | عالي |
.keras | Keras v3 | Keras Agent | عالي |
.onnx | ONNX | ONNX Agent | متوسط |
.safetensors | SafeTensors | SafeTensors Agent | منخفض |
| Input | Description | Default |
|---|
path | الدليل المراد مسحه | . |
config | مسار ملف الإعدادات | .guardmodel.yml |
fail-on | أدنى مستوى خطورة للفشل | high |
output-sarif | إنشاء مخرجات SARIF | true |
output-json | إنشاء مخرجات JSON | true |
comment-on-pr | نشر تعليق على PR | true |
max-file-size | الحد الأقصى لحجم الملف | 5GB |
| Output | Description |
|---|
status | حالة المسح (نجح، فشل، خطأ) |
findings-count | إجمالي النتائج |
critical-count | نتائج الخطورة الحرجة |
high-count | نتائج الخطورة العالية |
sarif-file | المسار إلى مخرجات SARIF |
json-file | المسار إلى مخرجات JSON |
scan-duration | المدة بالميلي ثانية |
| الملف | الخطورة | التهديد | التفاصيل |
|---|
models/model.pkl | حرج | تنفيذ_برمجي | تم اكتشاف استدعاء os.system |
models/utils.pt | عالي | شبكة | إنشاء socket.socket |