IHKREDDY

security-scan

Run security checks before PR including secrets, vulnerabilities, and best practices

IHKREDDY 0 Updated 5mo ago
GitHub

Install

npx skillscat add ihkreddy/agent-skills-ts/security-scan

Install via the SkillsCat registry.

SKILL.md

Security Scan

Performs comprehensive security analysis before PR submission, checking for secrets, vulnerabilities, insecure patterns, and security best practices.

๐ŸŽฏ Use Case Demo

Scenario: Pre-PR Security Review

Before (Manual Process):

Developer ready to submit PR, tries to remember security checks:

  • "Did I accidentally commit any secrets?"
  • "Are my dependencies secure?"
  • "Is my input validation sufficient?"
  • Forgets to check, security issue found in review (or worse, production)

Time: Often skipped, caught late or never

After (With This Skill):

Developer: "Run security scan before I create PR"

Agent Response:

๐Ÿ” SECURITY SCAN REPORT
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿ“… Scan Date: December 20, 2024
๐Ÿ“ Files Scanned: 12 changed files
๐Ÿ” Branch: feature/payment-integration

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ“Š SCAN SUMMARY
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

| Category | Status | Issues |
|----------|--------|--------|
| Secrets Detection | ๐Ÿ”ด FAIL | 2 found |
| Dependency Vulnerabilities | ๐ŸŸก WARN | 1 medium |
| Input Validation | ๐Ÿ”ด FAIL | 3 missing |
| SQL Injection | โœ… PASS | 0 found |
| XSS Prevention | โœ… PASS | 0 found |
| Authentication | โœ… PASS | Properly secured |
| Logging Security | ๐ŸŸก WARN | PII in logs |

Overall: ๐Ÿ”ด BLOCKED - Fix critical issues before PR

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿšจ CRITICAL: SECRETS DETECTED
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โ›” MUST FIX BEFORE PR - These will block your commit

1. API Key Detected
   ๐Ÿ“ Services/PaymentService.cs:34
   ```csharp
   private const string StripeKey = "sk_live_XXXXXXXXXXXXXXXXXXXX";

๐Ÿ”ง Fix: Move to environment variable or secrets manager

private readonly string _stripeKey = Environment.GetEnvironmentVariable("STRIPE_API_KEY");
  1. Connection String with Password
    ๐Ÿ“ appsettings.json:12
    "ConnectionString": "Server=db.prod.com;Password=SuperSecret123!"
    ๐Ÿ”ง Fix: Use Azure Key Vault or environment variables

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ”ด INPUT VALIDATION MISSING
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

  1. Missing Validation: CreateBooking endpoint
    ๐Ÿ“ Controllers/BookingsController.cs:45

    public async Task<IActionResult> Create([FromBody] BookingRequest request)
    {
        // No validation before processing
        await _service.CreateBooking(request);

    ๐Ÿ”ง Fix: Add FluentValidation or DataAnnotations

    public async Task<IActionResult> Create([FromBody] BookingRequest request)
    {
        if (!ModelState.IsValid)
            return BadRequest(ModelState);
  2. Email Not Validated
    ๐Ÿ“ Models/BookingRequest.cs:15

    public string Email { get; set; }  // No validation

    ๐Ÿ”ง Fix: Add email validation attribute

    [Required]
    [EmailAddress]
    public string Email { get; set; }
  3. Numeric Range Not Checked
    ๐Ÿ“ Models/SearchRequest.cs:8

    public int Passengers { get; set; }  // Could be negative or huge

    ๐Ÿ”ง Fix: Add range validation

    [Range(1, 9)]
    public int Passengers { get; set; }

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐ŸŸก WARNINGS (Recommended Fixes)
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

  1. Dependency Vulnerability
    ๐Ÿ“ฆ System.Text.Json 7.0.2
    CVE: CVE-2024-1234 (Medium severity)
    Fix: Upgrade to 7.0.4

    dotnet add package System.Text.Json --version 7.0.4
  2. PII in Logs
    ๐Ÿ“ Services/BookingService.cs:89

    _logger.LogInformation($"Booking created for {request.Email}");

    ๐Ÿ”ง Fix: Mask or remove PII from logs

    _logger.LogInformation($"Booking created for {MaskEmail(request.Email)}");

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
โœ… PASSED CHECKS
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

โœ… No SQL injection vulnerabilities

  • All queries use parameterized statements
  • Entity Framework properly configured

โœ… No XSS vulnerabilities

  • Output encoding in place
  • Content-Security-Policy configured

โœ… Authentication properly implemented

  • JWT validation configured
  • Endpoints have [Authorize] attributes

โœ… HTTPS enforced

  • UseHttpsRedirection() in place
  • HSTS configured

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
๐Ÿ“‹ ACTION REQUIRED
โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

Before creating PR, you must:

โ–ก Remove hardcoded secrets (2 issues)
โ–ก Add input validation (3 issues)

Recommended (not blocking):
โ–ก Update vulnerable dependency
โ–ก Remove PII from logs

Run "Apply security fixes" to auto-fix where possible.

โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
```

Result: Potential security breach prevented before code even reaches review


Agent Instructions

When this skill is activated:

  1. Secrets Detection:

    • Scan for API keys, tokens, passwords
    • Check for patterns: sk_live_, api_key, password=
    • Look in: source files, config files, .env files
    • Check git history for accidentally committed secrets
  2. Dependency Vulnerabilities:

    • Run dotnet list package --vulnerable
    • Check npm audit for Node.js
    • Cross-reference with CVE databases
  3. Input Validation:

    • Check all API endpoints for validation
    • Verify model attributes (Required, Range, etc.)
    • Look for raw string inputs without sanitization
  4. SQL Injection:

    • Look for string concatenation in queries
    • Verify parameterized queries usage
    • Check raw SQL execution
  5. XSS Prevention:

    • Check output encoding
    • Verify CSP headers
    • Look for @Html.Raw() usage
  6. Authentication/Authorization:

    • Verify [Authorize] attributes on endpoints
    • Check JWT configuration
    • Look for authorization bypass patterns
  7. Logging Security:

    • Check for PII in log statements
    • Verify sensitive data not logged
  8. Generate Report:

    • Categorize by severity
    • Provide specific fix recommendations
    • Block PR if critical issues found

Example Prompts

  • "Run security scan before PR"
  • "Check for security vulnerabilities"
  • "Are there any hardcoded secrets?"
  • "Scan my changes for security issues"
  • "Pre-commit security check"

Checks Performed

Check Description Severity
Secrets API keys, passwords, tokens ๐Ÿ”ด Critical
SQL Injection Unsanitized queries ๐Ÿ”ด Critical
Input Validation Missing or weak validation ๐Ÿ”ด High
Dependencies Known CVEs ๐ŸŸก Medium
XSS Cross-site scripting ๐Ÿ”ด High
PII Logging Personal data in logs ๐ŸŸก Medium
Auth Bypass Missing authorization ๐Ÿ”ด Critical

Benefits

Metric Before After Improvement
Security issues caught In production Before PR 100% earlier
Time to detect secrets Days/weeks Seconds Immediate
Developer security knowledge Variable Guided Learning tool
Security review time Hours Minutes 90% faster