vibe-audit-scan 1.2.11 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vibe-audit.js +31 -1
- package/package.json +1 -1
- package/src/commands/scan.js +1 -1
- package/src/utils/trivyInstaller.js +49 -5
- package/src/utils/welcome.js +9 -1
package/bin/vibe-audit.js
CHANGED
|
@@ -2,13 +2,37 @@
|
|
|
2
2
|
import { program } from 'commander';
|
|
3
3
|
import chalk from 'chalk';
|
|
4
4
|
import boxen from 'boxen';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import os from 'os';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
5
9
|
import { scan } from '../src/commands/scan.js';
|
|
6
10
|
import { login, logout, whoami } from '../src/commands/auth.js';
|
|
7
11
|
import { printWelcome, printHelpCheatsheet } from '../src/utils/welcome.js';
|
|
8
12
|
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = path.dirname(__filename);
|
|
15
|
+
const pkg = fs.readJsonSync(path.join(__dirname, '..', 'package.json'));
|
|
16
|
+
const version = pkg.version;
|
|
17
|
+
|
|
18
|
+
const WELCOME_MARKER = path.join(os.homedir(), '.vibe-audit-scan', '.welcome_shown');
|
|
19
|
+
|
|
20
|
+
function checkFirstRunWelcome() {
|
|
21
|
+
try {
|
|
22
|
+
if (!fs.existsSync(WELCOME_MARKER)) {
|
|
23
|
+
printWelcome();
|
|
24
|
+
fs.ensureDirSync(path.dirname(WELCOME_MARKER));
|
|
25
|
+
fs.writeFileSync(WELCOME_MARKER, 'true');
|
|
26
|
+
console.log('\n' + '='.repeat(107) + '\n');
|
|
27
|
+
}
|
|
28
|
+
} catch (err) {
|
|
29
|
+
// Fail-silent to not block main execution
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
9
33
|
program
|
|
10
34
|
.name('vibe')
|
|
11
|
-
.version(
|
|
35
|
+
.version(version, '-V, --version', 'output the version number')
|
|
12
36
|
.description('Vibe Audit CLI - Scan your codebase for vulnerabilities')
|
|
13
37
|
.configureOutput({
|
|
14
38
|
writeOut: (str) => {
|
|
@@ -102,8 +126,14 @@ program
|
|
|
102
126
|
|
|
103
127
|
// Handle vibe without command - show welcome screen
|
|
104
128
|
if (process.argv.length <= 2) {
|
|
129
|
+
try {
|
|
130
|
+
fs.ensureDirSync(path.dirname(WELCOME_MARKER));
|
|
131
|
+
fs.writeFileSync(WELCOME_MARKER, 'true');
|
|
132
|
+
} catch (err) {}
|
|
105
133
|
printWelcome();
|
|
106
134
|
process.exit(0);
|
|
135
|
+
} else {
|
|
136
|
+
checkFirstRunWelcome();
|
|
107
137
|
}
|
|
108
138
|
|
|
109
139
|
program.parse();
|
package/package.json
CHANGED
package/src/commands/scan.js
CHANGED
|
@@ -61,7 +61,7 @@ export async function scan(directory, options) {
|
|
|
61
61
|
? `${rawApiUrl}api/audit/gateway`
|
|
62
62
|
: `${rawApiUrl}/api/audit/gateway`;
|
|
63
63
|
|
|
64
|
-
console.log(
|
|
64
|
+
console.log('📡 Syncing report with Vibe Cloud Gateway...');
|
|
65
65
|
try {
|
|
66
66
|
const result = await sendToAPI(gatewayUrl, filteredData, directory, token, codeFiles);
|
|
67
67
|
console.log('✅ Scan data sent successfully!');
|
|
@@ -89,13 +89,57 @@ async function installLocalTrivy() {
|
|
|
89
89
|
|
|
90
90
|
// Download the asset
|
|
91
91
|
console.log(`📥 Downloading scanner updates v${latestVersion}...`);
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const tempPath = path.join(os.tmpdir(), `trivy_${latestVersion}.${ext}`);
|
|
93
|
+
const writer = fs.createWriteStream(tempPath);
|
|
94
|
+
|
|
95
|
+
const response = await axios({
|
|
96
|
+
url: asset.browser_download_url,
|
|
97
|
+
method: 'GET',
|
|
98
|
+
responseType: 'stream',
|
|
99
|
+
timeout: 30000 // 30s connection timeout
|
|
94
100
|
});
|
|
95
101
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
const totalLength = parseInt(response.headers['content-length'], 10) || 0;
|
|
103
|
+
let downloadedBytes = 0;
|
|
104
|
+
let lastPercentage = -10;
|
|
105
|
+
|
|
106
|
+
response.data.pipe(writer);
|
|
107
|
+
|
|
108
|
+
let downloadTimeout = setTimeout(() => {
|
|
109
|
+
response.data.destroy();
|
|
110
|
+
writer.destroy();
|
|
111
|
+
}, 60000); // 60s inactivity timeout
|
|
112
|
+
|
|
113
|
+
response.data.on('data', (chunk) => {
|
|
114
|
+
// Reset inactivity timeout
|
|
115
|
+
clearTimeout(downloadTimeout);
|
|
116
|
+
downloadTimeout = setTimeout(() => {
|
|
117
|
+
response.data.destroy();
|
|
118
|
+
writer.destroy();
|
|
119
|
+
}, 60000);
|
|
120
|
+
|
|
121
|
+
downloadedBytes += chunk.length;
|
|
122
|
+
if (totalLength > 0) {
|
|
123
|
+
const percentage = Math.floor((downloadedBytes / totalLength) * 10);
|
|
124
|
+
if (percentage > lastPercentage) {
|
|
125
|
+
lastPercentage = percentage;
|
|
126
|
+
console.log(`📥 Download progress: ${percentage * 10}% (${(downloadedBytes / 1024 / 1024).toFixed(1)}MB / ${(totalLength / 1024 / 1024).toFixed(1)}MB)...`);
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
console.log(`📥 Downloaded ${(downloadedBytes / 1024 / 1024).toFixed(1)}MB...`);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
await new Promise((resolve, reject) => {
|
|
134
|
+
writer.on('finish', () => {
|
|
135
|
+
clearTimeout(downloadTimeout);
|
|
136
|
+
resolve();
|
|
137
|
+
});
|
|
138
|
+
writer.on('error', (err) => {
|
|
139
|
+
clearTimeout(downloadTimeout);
|
|
140
|
+
reject(err);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
99
143
|
|
|
100
144
|
// Extract the binary
|
|
101
145
|
console.log('📦 Extracting scanner components...');
|
package/src/utils/welcome.js
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import boxen from 'boxen';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const pkg = fs.readJsonSync(path.join(__dirname, '..', '..', 'package.json'));
|
|
10
|
+
const version = pkg.version;
|
|
3
11
|
|
|
4
12
|
const asciiArt = [
|
|
5
13
|
'█████ █████ █████ ███████████ ██████████ █████████ █████ █████ ██████████ █████ ███████████ ',
|
|
@@ -48,7 +56,7 @@ export function printWelcome() {
|
|
|
48
56
|
console.log('');
|
|
49
57
|
|
|
50
58
|
const welcomeContent = `
|
|
51
|
-
${colors.brandBold('Vibe Audit')}${colors.muted(
|
|
59
|
+
${colors.brandBold('Vibe Audit')}${colors.muted(` v${version} | Terminal-First Security`)}
|
|
52
60
|
${colors.muted('-'.repeat(50))}
|
|
53
61
|
|
|
54
62
|
${colors.textBold('🚀 Ready to secure your code?')}
|