5.6 KiB
5.6 KiB
Security
This template includes integrated security scanning powered by Semgrep.
Security Dashboard
Access the Security Dashboard from the Security tab in your project:
- Security Score: Overall security health (0-100%)
- Issue Breakdown: Critical, High, Medium, and Low severity issues
- Scan History: View past security scans
- Detailed Reports: Line-by-line issue analysis with fix suggestions
Running Security Scans
Via Dashboard
- Navigate to the Security tab
- Click Run Scan button
- Wait for analysis to complete
- Review issues and recommendations
Via Lumina Skill
Use the built-in Semgrep security skill:
User: "Scan the code for security issues"
User: "Check for OWASP Top 10 vulnerabilities"
User: "What's our security score?"
The skill will:
- Auto-install Semgrep if not present
- Run comprehensive security analysis
- Generate actionable reports
- Update the Security Dashboard
Via Command Line
# Install Semgrep (if not installed) - OS-specific
# macOS (OSX)
brew install semgrep
# Linux
sudo apt-get update && sudo apt-get install -y semgrep
# Windows
choco install semgrep -y
# Universal (works on all platforms)
pip3 install semgrep
# Run security scan
semgrep --config=auto --json .
# OWASP Top 10 scan
semgrep --config=p/owasp-top-ten --json .
# Language-specific
semgrep --config=p/typescript --json .
semgrep --config=p/react --json .
Security Score Calculation
Your security score is calculated based on:
Base Score: 100 points
Deductions:
- Critical Issue: -10 points each
- High Issue: -5 points each
- Medium Issue: -2 points each
- Low Issue: -0.5 points each
Final Score: max(0, Base Score - Total Deductions)
Score Ratings:
- 90-100: Excellent ✅
- 70-89: Good 👍
- 50-69: Fair ⚠️
- 0-49: Poor ❌
Common Security Issues
Critical Issues
- SQL Injection vulnerabilities
- Command Injection
- Path Traversal
- Hardcoded secrets/credentials
- Insecure cryptography
High Issues
- XSS (Cross-Site Scripting)
- CSRF (Cross-Site Request Forgery)
- Insecure authentication
- Sensitive data exposure
- Insecure deserialization
Medium Issues
- Missing input validation
- Weak password policies
- Insecure session management
- Missing security headers
- Information disclosure
Low Issues
- Code smells
- Best practice violations
- Performance issues
- Deprecated functions
Fixing Security Issues
General Workflow
- Prioritize: Fix critical and high severity issues first
- Review: Understand the vulnerability and its impact
- Fix: Apply recommended fixes or security patches
- Test: Verify the fix doesn't break functionality
- Rescan: Run a new scan to confirm the issue is resolved
Using Lumina to Fix Issues
User: "Fix the SQL injection vulnerability in user-service.ts"
User: "Apply security patches for all critical issues"
User: "Review and fix the XSS issue on line 45"
Lumina will:
- Analyze the vulnerability
- Apply secure coding practices
- Update the code with fixes
- Run tests to verify
Continuous Security
Best Practices
- Regular Scans: Run security scans before every deployment
- Pre-commit Hooks: Add Semgrep to your git pre-commit hooks
- CI/CD Integration: Include security scans in your pipeline
- Dependency Updates: Keep dependencies up-to-date
- Security Reviews: Conduct code reviews with security focus
Pre-commit Hook Example
Add to .git/hooks/pre-commit:
#!/bin/bash
echo "Running security scan..."
semgrep --config=auto --error .
if [ $? -ne 0 ]; then
echo "Security issues found! Commit blocked."
echo "Run 'semgrep --config=auto .' to see details"
exit 1
fi
CI/CD Integration
GitHub Actions
name: Security Scan
on: [push, pull_request]
jobs:
semgrep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip3 install semgrep
- run: semgrep --config=auto --error .
GitLab CI
security_scan:
image: returntocorp/semgrep
script:
- semgrep --config=auto --error .
Security Rules
Semgrep scans use the following rule sets:
- auto: Automatically curated rules for your codebase
- p/security-audit: General security audit rules
- p/owasp-top-ten: OWASP Top 10 vulnerabilities
- p/typescript: TypeScript-specific security rules
- p/react: React security best practices
- p/javascript: JavaScript security patterns
False Positives
If you encounter false positives:
- Review the finding carefully
- Add inline comments to suppress if legitimate:
// nosemgrep: rule-id const result = potentiallyUnsafeOperation(); - Configure
.semgrepignoreto exclude files/patterns - Report false positives to improve Semgrep rules
Resources
Support
For security concerns or questions:
- Use the Semgrep security skill in Lumina
- Check the Security Dashboard for guidance
- Review Semgrep documentation
- Consult OWASP guidelines
Remember: Security is an ongoing process, not a one-time task. Regular scans and proactive security practices keep your application safe.