analyzer
Comprehensive code analyzer for JSX with dependency detection, API classification, and security scanning.
Features
- Dependency Detection: Extract
#include,require(), andimportstatements - String Analysis: Categorize strings (paths, URLs, emails)
- API Detection: Classify Adobe APIs (8+ categories)
- Security Scanning: Detect vulnerabilities (eval, hardcoded credentials, SQL injection)
- Function Graph: Build call dependency graph and detect cycles
- Static Analysis: Code metrics and complexity scoring
- No
unsafe: 100% safe Rust
Quick Start
use ;
use Token;
let tokens = vec!;
// Detect APIs
let apis = extract_from_tokens;
println!;
// Scan security
let scanner = new;
let issues = scanner.scan_tokens;
println!;
// Detect dependencies
let detector = new?;
let deps = detector.extract_from_tokens;
println!;
Analyzers
Dependency Detector
let detector = new?;
let deps = detector.extract_from_code?;
// → Dependency { name: "utils.jsx", include_type: Include, ... }
String Extractor
let extractor = new;
let strings = extractor.extract_from_tokens;
// Categorizes as path/URL/email
API Detector
Classifies Adobe APIs:
- Document:
activeDocument,open,close,save - Layer:
artLayers,layers,layerSets - Selection:
selection,select,deselect - Transform:
transform,scale,rotate - And 4 more categories
Security Scanner
let scanner = new;
let issues = scanner.scan_code?;
// → SecurityIssue { eval_usage, severity: Critical, ... }
Detects:
- ✅
eval()usage (CRITICAL) - ✅ Hardcoded credentials (HIGH)
- ✅ SQL injection patterns (HIGH)
- ✅ Dynamic code execution (CRITICAL)
- ✅ File I/O access (MEDIUM)
Graph Builder
let mut builder = new;
let graph = builder.build_graph;
// Detects cycles
let cycles = find_cycles;
// Calculate complexity
let complexity = calculate_complexity;
Performance
- 1,000 tokens: ~12ms total analysis
- Dependencies: 2ms
- Strings: 1ms
- APIs: 1ms
- Security: 5ms
- Graph: 3ms
Linear O(n) complexity per analyzer.
Examples
See examples/analyze_code.rs for complete working example.
Security Scoring
Base Score: 100
Deductions:
- Critical Issue: -30 points
- High Issue: -15 points
- Medium Issue: -5 points
- Low Issue: -1 point
Final Score: max(0, 100 - penalties)
Contributing
Contributions welcome! See CONTRIBUTING.md.
License
Licensed under the MIT License. See LICENSE file.
Related
- jsxbin-parser - Binary parsing
- jsx-generator - Code generation