Scan codebases for Meta API policy violations
npm install meta-policy-scanner> A comprehensive CLI tool and npm package that scans codebases (local or GitHub) for Facebook/Instagram/Ads API policy violations, with dynamic rule management and automated documentation updates.


- š Code Scanning: Scan local directories or GitHub repositories
- šÆ SDK Detection: Identify official SDKs, wrappers, unofficial libraries, and policy violations
- š Dynamic Rules: Add, update, and manage violation rules via CLI
- š¤ Semantic Analysis: AI-powered semantic search using OpenAI embeddings
- š Auto-Updated Docs: Automatically scrape and update Meta policy documentation
- š CI/CD Ready: Easy integration with GitHub Actions, GitLab CI, etc.
- š Multiple Outputs: Console, JSON, and HTML report formats
``bash`
npm install -g meta-policy-scanner
`bashScan local directory
meta-scan scan ./my-project
$3
1. Set up Supabase (free tier works)
2. Get API keys: Firecrawl, OpenAI
3. Configure environment:
`bash
cp .env.example .env
Edit .env with your API keys
`4. Seed initial data:
`bash
meta-scan rules seed
meta-scan docs update
`See QUICK_START.md for detailed setup instructions.
Architecture
`
āāāāāāāāāāāāāāāāāāāāāāā
ā CLI Tool (npm) ā
ā - Commander CLI ā
ā - Scanner Engine ā
ā - Policy Analyzer ā
ā - Rule Manager ā
āāāāāāāāāāāā¬āāāāāāāāāāā
ā
āāāā Scan Sources
ā āā Local Directory
ā āā GitHub Repo (public/private)
ā
āāāā Supabase Backend
ā āā Violation Rules
ā āā SDK Patterns
ā āā Policy Docs
ā āā Vector Embeddings
ā
āāāā AI Services
āā OpenAI (embeddings)
āā Firecrawl (doc scraping)
`What It Detects
$3
- ā
Official Meta SDKs (facebook-nodejs-business-sdk, facebook-business, etc.)
- ā ļø Third-party wrappers (fb, fbgraph)
- ā Unofficial libraries (instagram-private-api, instagram-web-api)
- š Direct Graph API calls
- š Deprecated APIs (REST API, old versions, FQL)$3
- Rate limiting issues
- Token exposure in code
- Unauthorized data retention
- Missing permission checks
- Improper HUMAN_AGENT tag usage
- Deprecated API versions
- Missing error handling
- And more...CLI Commands
$3
`bash
Scan local directory
meta-scan scan ./my-projectScan GitHub repo (public)
meta-scan scan https://github.com/user/repoScan specific branch
meta-scan scan https://github.com/user/repo --branch=developScan private repo (requires GitHub PAT)
meta-scan scan https://github.com/org/private-repo --auth=$GITHUB_PATFilter by platform
meta-scan scan ./project --platform=instagramSet severity threshold
meta-scan scan ./project --severity=errorJSON output
meta-scan scan ./project --format=json --output=results.json
`$3
`bash
List all rules
meta-scan rules list
meta-scan rules list --platform=instagram --severity=errorShow rule details
meta-scan rules show RATE_LIMIT_MISSINGAdd new rule
meta-scan rules add --from-file=my-rule.json
meta-scan rules add --interactiveUpdate rule
meta-scan rules update RULE_CODE --severity=errorEnable/disable rules
meta-scan rules enable RULE_CODE
meta-scan rules disable RULE_CODEImport/export rules
meta-scan rules export ./backup.json
meta-scan rules import ./team-rules.jsonSeed built-in rules
meta-scan rules seedShow statistics
meta-scan rules stats
`$3
`bash
Update policy documentation
meta-scan docs updateShow status
meta-scan docs statusList indexed docs
meta-scan docs list
`Configuration
Create
.meta-scan.config.json in your project root:`json
{
"platforms": ["facebook", "instagram"],
"severity": "warning",
"ignore": ["/test/", "/dist/"],
"failOnErrors": true
}
`See meta-scan.config.example.json for all options.
CI/CD Integration
$3
`yaml
name: Meta Policy Scan
on: [pull_request]jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Scanner
run: npm install -g meta-policy-scanner
- name: Run Scan
run: meta-scan scan . --severity=error
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
`Built-in Rules
| Rule Code | Description | Severity |
|-----------|-------------|----------|
|
RATE_LIMIT_MISSING | No rate limit handling | error |
| HUMAN_AGENT_ABUSE | HUMAN_AGENT flag misuse | error |
| UNOFFICIAL_IG_LIBRARY | Unofficial IG library detected | error |
| TOKEN_EXPOSED | Access token in code | error |
| DEPRECATED_API_VERSION | Old API version | warning |
| NO_ERROR_HANDLING | Missing error handling | warning |
| DATA_RETENTION_VIOLATION | Data stored too long | warning |
| MISSING_PERMISSION_CHECK` | No permission verification | info |See example-rule-templates.json for complete rule definitions.
1. Pre-commit Hooks: Catch violations before code is committed
2. Pull Request Checks: Automated policy validation in PRs
3. Scheduled Audits: Regular scans of production code
4. Third-party Library Vetting: Scan dependencies for violations
5. Compliance Reporting: Generate policy compliance reports
- Quick Start Guide - Get started in 5 minutes
- Implementation Guide - Complete technical details
- Rule Templates - Example rule definitions
- Config Reference - Configuration options
- Node.js 18+ or Python 3.10+
- Supabase account (free tier works)
- Firecrawl API key
- OpenAI API key
- GitHub PAT (optional, for private repos)
Contributions welcome! Please read CONTRIBUTING.md first.
MIT License - see LICENSE for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@your-domain.com
- Meta Platform Policy Documentation
- Firecrawl for documentation scraping
- OpenAI for embeddings
- Supabase for backend infrastructure
---
Made with ā¤ļø for Meta API developers