UNPKG

v0-mcp-ts

Version:

A powerful Model Context Protocol (MCP) server that integrates v0.dev AI capabilities for modern web development. Powered by Bun for 25x faster performance.

95 lines (81 loc) • 3.02 kB
#!/usr/bin/env node import { readFileSync } from 'fs'; import { join } from 'path'; console.log('šŸ”’ Security Check for v0-mcp-ts Build'); console.log('=====================================\n'); const buildFile = join(process.cwd(), 'dist', 'index.js'); try { const content = readFileSync(buildFile, 'utf8'); console.log('šŸ“ Build file:', buildFile); console.log('šŸ“Š File size:', Math.round(content.length / 1024), 'KB\n'); // Check for environment variable references const envRefs = content.match(/process\.env\[['"][\w_]+['"]\]/g) || []; console.log('šŸ” Environment variable references found:'); if (envRefs.length === 0) { console.log( ' āŒ No process.env references found (this might be a problem)' ); } else { envRefs.forEach((ref) => { console.log(` āœ… ${ref} (runtime reference - secure)`); }); } // Check for potential API key patterns const suspiciousPatterns = [ /v1:[a-zA-Z0-9]{20,}/g, // v0.dev API keys /sk-[a-zA-Z0-9]{20,}/g, // OpenAI keys /pk_[a-zA-Z0-9]{20,}/g, // Stripe keys /rk_[a-zA-Z0-9]{20,}/g, // Other API keys /[a-zA-Z0-9]{32,}/g, // Long strings that could be secrets ]; console.log('\n🚨 Checking for hardcoded secrets:'); let foundSecrets = false; suspiciousPatterns.forEach((pattern, index) => { const matches = content.match(pattern) || []; if (matches.length > 0) { foundSecrets = true; console.log( ` āš ļø Found ${matches.length} potential secrets matching pattern ${ index + 1 }` ); matches.slice(0, 3).forEach((match) => { console.log(` ${match.substring(0, 10)}...`); }); } }); if (!foundSecrets) { console.log(' āœ… No hardcoded secrets detected'); } // Check for NODE_ENV references const nodeEnvRefs = content.match(/NODE_ENV/g) || []; console.log(`\nšŸŒ NODE_ENV references: ${nodeEnvRefs.length}`); if (nodeEnvRefs.length > 0) { console.log(' āœ… NODE_ENV usage is normal and expected'); } // Final assessment console.log('\nšŸ“‹ Security Assessment:'); console.log('======================'); if (envRefs.length > 0 && !foundSecrets) { console.log( 'āœ… PASS: Environment variables are referenced but not hardcoded' ); console.log('āœ… PASS: No API keys or secrets found in build'); console.log('āœ… PASS: Variables will be loaded at runtime'); console.log( '\nšŸŽ‰ Your build is secure! Environment variables are properly handled.' ); } else if (foundSecrets) { console.log('āŒ FAIL: Potential secrets found in build'); console.log( 'āš ļø WARNING: Review the output above and remove any hardcoded secrets' ); process.exit(1); } else { console.log('āš ļø WARNING: No environment variable references found'); console.log(' This might indicate a build problem'); } } catch (error) { console.error('āŒ Error reading build file:', error.message); process.exit(1); }