Security and compliance auditing through file reading and analysis.
Use when auditing code for security vulnerabilities, checking configurations,
verifying compliance, detecting sensitive data exposure, or performing
integrity checks on files and codebases.
Triggers on tasks involving security audits, code reviews, compliance checks,
vulnerability scanning, or data privacy verification.
Comprehensive guide for auditing files and codebases using Desktop Commander
read tools. This skill covers security auditing, compliance checking, vulnerability
detection, and integrity verification techniques.
When to Use This Skill
Use this skill when:
Auditing code for security vulnerabilities
Checking for exposed secrets, API keys, or credentials
async function auditSecurityConfig(filePath) {
const content = await Desktop_Commander_read_file(filePath);
let config;
try {
config = JSON.parse(content);
} catch (e) {
return [{ error: 'Invalid JSON configuration' }];
}
const findings = [];
// Check for debug mode
if (config.debug === true || config.DEBUG === true) {
findings.push({
type: 'CONFIG',
severity: 'MEDIUM',
issue: 'Debug mode enabled',
recommendation: 'Disable debug mode in production',
});
}
// Check for weak passwords
if (config.password && config.password.length < 12) {
findings.push({
type: 'CONFIG',
severity: 'HIGH',
issue: 'Weak password detected',
recommendation: 'Use passwords with at least 12 characters',
});
}
// Check for default credentials
const defaultCredentials = ['admin', 'password', '123456', 'root'];
if (config.username && defaultCredentials.includes(config.username.toLowerCase())) {
findings.push({
type: 'CONFIG',
severity: 'CRITICAL',
issue: 'Default username detected',
recommendation: 'Change default credentials',
});
}
// Check for open CORS
if (config.cors && config.cors.origin === '*') {
findings.push({
type: 'CONFIG',
severity: 'MEDIUM',
issue: 'CORS allows all origins',
recommendation: 'Restrict CORS to specific domains',
});
}
// Check for SQL logging
if (config.logging && config.logging.sql === true) {
findings.push({
type: 'CONFIG',
severity: 'LOW',
issue: 'SQL logging enabled',
recommendation: 'Disable SQL logging in production',
});
}
return findings;
}
2. Environment File Audit
async function auditEnvironmentFile(filePath) {
const content = await Desktop_Commander_read_file(filePath);
const lines = content.split('\n');
const findings = [];
lines.forEach((line, index) => {
// Skip comments and empty lines
if (line.trim().startsWith('#') || !line.trim()) return;
const [key, ...valueParts] = line.split('=');
const value = valueParts.join('=');
// Check for sensitive values
if (key.match(/(SECRET|PASSWORD|TOKEN|KEY|CREDENTIAL)/i)) {
if (!value || value === '' || value === 'changeme' || value === 'xxx') {
findings.push({
type: 'ENV',
severity: 'HIGH',
issue: `Empty or default value for ${key}`,
line: index + 1,
recommendation: 'Set a secure value',
});
}
}
// Check for production URLs in dev files
if (key.match(/(URL|ENDPOINT)/i) && value.includes('localhost')) {
findings.push({
type: 'ENV',
severity: 'LOW',
issue: `Localhost URL in ${key}`,
line: index + 1,
recommendation: 'Verify this is not a production file',
});
}
});
return findings;
}
Compliance Auditing
1. GDPR Compliance Check
async function auditGDPRCompliance(filePath) {
const content = await Desktop_Commander_read_file(filePath);
const findings = [];
// Check for data retention policies
if (content.includes('userData') && !content.includes('retention')) {
findings.push({
type: 'COMPLIANCE',
standard: 'GDPR',
severity: 'HIGH',
issue: 'User data handling without retention policy',
recommendation: 'Implement data retention policies',
});
}
// Check for consent mechanisms
if (content.includes('collect') && !content.includes('consent')) {
findings.push({
type: 'COMPLIANCE',
standard: 'GDPR',
severity: 'MEDIUM',
issue: 'Data collection without consent mechanism',
recommendation: 'Implement user consent for data collection',
});
}
// Check for data deletion capabilities
if (content.includes('user') && !content.includes('delete') && !content.includes('erase')) {
findings.push({
type: 'COMPLIANCE',
standard: 'GDPR',
severity: 'MEDIUM',
issue: 'No data deletion capability found',
recommendation: 'Implement right to be forgotten',
});
}
return findings;
}
2. PCI-DSS Compliance Check
async function auditPCIDSSCompliance(filePath) {
const content = await Desktop_Commander_read_file(filePath);
const findings = [];
// Check for plaintext card storage
const cardPatterns = [
/card_number\s*[=:]\s*['"][^'"]+['"]/gi,
/credit_card\s*[=:]\s*['"][^'"]+['"]/gi,
/cardNumber\s*[=:]\s*['"][^'"]+['"]/gi,
];
for (const pattern of cardPatterns) {
if (pattern.test(content)) {
findings.push({
type: 'COMPLIANCE',
standard: 'PCI-DSS',
severity: 'CRITICAL',
issue: 'Plaintext credit card data detected',
recommendation: 'Never store card data in plaintext',
});
}
}
// Check for encryption usage
if (content.includes('card') && !content.includes('encrypt')) {
findings.push({
type: 'COMPLIANCE',
standard: 'PCI-DSS',
severity: 'HIGH',
issue: 'Card data handling without encryption',
recommendation: 'Use strong encryption for card data',
});
}
return findings;
}
// BAD - SQL Injection
const query = `SELECT * FROM users WHERE id = ${userId}`;
// BAD - Command Injection
exec(`rm ${userInput}`);
// BAD - Eval
eval(userCode);
// GOOD - Parameterized query
const query = 'SELECT * FROM users WHERE id = ?';
db.query(query, [userId]);
// GOOD - Safe exec
execFile('rm', [userInput]);
// GOOD - Safe evaluation
const result = Function('"use strict";return (' + userCode + ')')();
Python
# BAD - SQL Injection
cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")
# BAD - Command Injection
os.system(f"rm {user_input}")
# GOOD - Parameterized query
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
# GOOD - Safe subprocess
subprocess.run(["rm", user_input])