security-scanning
Security scanning with dependency audits, secret detection, static analysis, and vulnerability management. Use when checking for vulnerabilities, scanning dependencies, or enforcing security gates.
When & Why to Use This Skill
This Claude skill provides a comprehensive security toolkit for modern software development, enabling automated dependency audits, secret detection, and static application security testing (SAST). It empowers developers to proactively identify vulnerabilities, prevent sensitive data leaks, and enforce rigorous security gates within CI/CD pipelines to ensure application integrity and compliance with industry standards like OWASP.
Use Cases
- Automated Dependency Auditing: Identify and remediate known vulnerabilities in Node.js and TypeScript project dependencies using Bun, npm, or Snyk integrations.
- Secret Leak Prevention: Implement pre-commit hooks and Gitleaks scanning to detect exposed API keys, tokens, and passwords before they are committed to version control.
- Static Code Analysis (SAST): Utilize ESLint security plugins and strict TypeScript configurations to catch common coding flaws, injection risks, and insecure patterns.
- CI/CD Security Gates: Integrate automated security checks into GitHub Actions or other CI tools to block deployments that fail vulnerability thresholds or compliance audits.
- Compliance & Best Practices: Audit projects against the OWASP Top 10 and implement secure HTTP headers to protect web applications from common attack vectors.
| name | security-scanning |
|---|---|
| description | Security scanning with dependency audits, secret detection, static analysis, and vulnerability management. Use when checking for vulnerabilities, scanning dependencies, or enforcing security gates. |
| license | MIT |
| author | liaison-toolkit |
| version | "1.0" |
| keywords | "security, audit, vulnerability, secrets, sast, compliance" |
Security Scanning
Security vulnerability detection, secret scanning, and compliance checking for TypeScript and Node.js projects.
When to use this skill
Use this skill when:
- Checking for dependency vulnerabilities
- Scanning for exposed secrets in code or commits
- Running static code analysis
- Enforcing security gates before deployment
- Reviewing code for security issues
- Auditing package manifests
Dependency Auditing
Bun Audit
# Check for vulnerabilities in dependencies
bun audit
# Fix vulnerabilities automatically (interactive)
bun audit --fix
# Check production dependencies only
bun audit --production
# Generate audit report
bun audit --report-format json > audit-report.json
npm Audit (alternative)
# Standard audit
npm audit
# Fix vulnerabilities automatically
npm audit fix
# Audit specific severity levels
npm audit --audit-level moderate
npm audit --audit-level high
Snyk Integration
# Install Snyk CLI
bun install -g snyk
# Scan dependencies
snyk test
# Scan with all vulnerabilities shown
snyk test --severity-threshold=low
# Generate SARIF report
snyk test --sarif-file security-results.sarif
Dependency Allowlists
// .npmrc or .yarnrc
{
"auditConfig": {
"allowlist": [
"package@1.0.0",
"another-package@2.x.x"
]
}
}
Secret Detection
Git Pre-commit Hooks
# .git/hooks/pre-commit
#!/bin/bash
# Scan for secrets before committing
SECRETS=$(git diff --cached --name-only | xargs grep -lE 'password|secret|key|token')
if [ -n "$SECRETS" ]; then
echo "Error: Potential secrets found in staged files:"
echo "$SECRETS"
exit 1
fi
Gitleaks Integration
# Install gitleaks
bun install -g gitleaks
# Scan repository
gitleaks detect --source HEAD
# Scan with config
gitleaks detect --config .gitleaks.toml
# Prevent leaks in commits
gitleaks protect
Secret Patterns
// Common secret patterns to detect
const SECRET_PATTERNS = [
/password\s*=\s*['"][^'"]+['"]/i,
/api[_-]?key\s*=\s*['"][^'"]+['"]/i,
/secret[_-]?key\s*=\s*['"][^'"]+['"]/i,
/token\s*=\s*['"][^'"]+['"]/i,
/bearer\s+[\s:]+['"][a-z0-9]{20,}/i,
/aws[_-]access[_-]key[_-]id\s*=\s*['"][a-z0-9]{20,}/i,
/private[_-]key\s*=\s*-----BEGIN\s+(RSA|EC|OPENSSH)/i,
];
// Scan files
function scanForSecrets(content: string): string[] {
const secrets: string[] = [];
for (const pattern of SECRET_PATTERNS) {
const matches = content.match(pattern);
if (matches) secrets.push(...matches);
}
return secrets;
}
Static Code Analysis
TypeScript Strict Mode
// tsconfig.json
{
"compilerOptions": {
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}
ESLint Security Rules
// .eslintrc.js
module.exports = {
rules: {
'no-eval': 'error',
'no-implied-eval': 'error',
'no-new-func': 'error',
'no-script-url': 'error',
'security/detect-object-injection': 'error',
'security/detect-non-literal-regexp': 'error',
'security/detect-possible-timing-attacks': 'error'
}
};
Security Linting Tools
# ESLint with security plugin
bun eslint src --plugin security
# Bandit for Python (if applicable)
bandit -r src/
# Semgrep for custom security rules
semgrep --config security.yaml src/
Vulnerability Management
CVSS Scoring
CVSS Base Score:
0.0 - 3.9: LOW
4.0 - 6.9: MEDIUM
7.0 - 10.0: HIGH
10.1 - 10.0: CRITICAL
Fixing Vulnerabilities
# Review vulnerability report
bun audit --json | jq '.vulnerabilities[] | select(.severity == "high")'
# Update vulnerable package
bun update package-name
# Update all vulnerable packages
bun update
# Install specific patched version
bun install package-name@patched-version
Security Gates
CI Security Check
# .github/workflows/security.yml
name: Security Scan
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run security audit
run: |
bun audit --json > audit-results.json
- name: Check for vulnerabilities
run: |
HIGH_VULNS=$(jq '.vulnerabilities | length | select(.severity == "high") | length' audit-results.json)
if [ "$HIGH_VULNS" -gt 0 ]; then
echo "Found $HIGH_VULNS high severity vulnerabilities"
exit 1
fi
- name: Upload results
uses: actions/upload-artifact@v4
with:
name: audit-results
path: audit-results.json
Pre-deployment Checklist
# Security checks before deployment
bun run security-check
# Should verify:
# - No high/critical vulnerabilities
# - No secrets in code
# - All security linting passes
# - Dependencies are up to date
# - No deprecated packages used
Compliance Standards
OWASP Top 10
| Issue | Prevention |
|---|---|
| Injection | Use prepared statements, parameterized queries |
| Broken Authentication | Implement proper auth mechanisms |
| Sensitive Data Exposure | Encrypt data at rest |
| XML External Entities | Use safe XML parsers |
| Broken Access Control | Implement RBAC |
| Security Misconfiguration | Follow security best practices |
| XSS | Sanitize user input, escape output |
| Insecure Deserialization | Use safe deserialization |
| Using Components with Known Vulnerabilities | Keep dependencies updated |
| Insufficient Logging | Log security events |
Security Headers
// Set security headers
import { NextResponse } from 'next/server';
export function GET(request: Request) {
return NextResponse.json(data, {
headers: {
'Content-Security-Policy': "default-src 'self'",
'X-Frame-Options': 'DENY',
'X-Content-Type-Options': 'nosniff',
'Strict-Transport-Security': 'max-age=31536000; includeSubDomains',
'X-XSS-Protection': '1; mode=block'
}
});
}
Verification
After implementing security checks:
- Dependency audit runs on every build
- Secret detection in pre-commit hooks
- Security gate blocks vulnerable deployments
- High/critical vulnerabilities addressed promptly
- Static analysis findings are reviewed
- Security headers configured
- No secrets in repository history
- Security documentation is maintained
Examples from liaison-toolkit
Example 1: Security Audit in CI
# .github/workflows/security.yml
- name: Audit dependencies
run: |
bun audit --json > results.json
- name: Check for critical vulnerabilities
run: |
CRITICAL=$(jq '.vulnerabilities | map(select(.severity == "critical")) | length' results.json)
if [ "$CRITICAL" -gt 0 ]; then
echo "CRITICAL vulnerabilities found!"
exit 1
fi
Example 2: Pre-commit Secret Scan
# .githooks/pre-commit
#!/usr/bin/env bun
import { execSync } from 'child_process';
const FILES = execSync('git diff --cached --name-only', { encoding: 'utf-8' });
const SECRET_PATTERNS = ['password', 'secret', 'api_key', 'token', 'private_key'];
for (const file of FILES.split('\n')) {
if (!file.trim()) continue;
const content = execSync(`git show :${file}`, { encoding: 'utf-8' });
for (const pattern of SECRET_PATTERNS) {
if (content.toLowerCase().includes(pattern)) {
console.error(`Error: Potential secret found in ${file}`);
process.exit(1);
}
}
}