vanguard-cli 3.1.10 → 3.1.12
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/vanguard.js +17 -0
- package/lib/commands/integrate.js +101 -103
- package/package.json +1 -1
package/bin/vanguard.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
|
+
import chalk from 'chalk';
|
|
5
6
|
import { runConfigWizard } from '../lib/commands/config.js';
|
|
6
7
|
import { runIntegrate } from '../lib/commands/integrate.js';
|
|
7
8
|
import { handlePull, handleClone } from '../lib/commands/scan.js';
|
|
@@ -59,6 +60,22 @@ program
|
|
|
59
60
|
program.command('config').description('Configure AI providers').action(runConfigWizard);
|
|
60
61
|
program.command('integrate').description('Install "Invisible Protection" shell wrapper').action(runIntegrate);
|
|
61
62
|
|
|
63
|
+
program
|
|
64
|
+
.command('status')
|
|
65
|
+
.description('Check firewall protection status')
|
|
66
|
+
.action(() => {
|
|
67
|
+
showBanner();
|
|
68
|
+
const isInternal = process.env.VANGUARD_INTERNAL === '1';
|
|
69
|
+
console.log(chalk.bold('🔥 Firewall Status:'));
|
|
70
|
+
if (isInternal) {
|
|
71
|
+
console.log(chalk.green(' ✅ ACTIVE (Intercepted Session)'));
|
|
72
|
+
} else {
|
|
73
|
+
console.log(chalk.yellow(' ⚠️ OFFLINE (Direct CLI Access)'));
|
|
74
|
+
console.log(chalk.dim('\nTo activate Invisible Protection, run: vanguard integrate'));
|
|
75
|
+
}
|
|
76
|
+
showFooter();
|
|
77
|
+
});
|
|
78
|
+
|
|
62
79
|
|
|
63
80
|
program
|
|
64
81
|
.command('pull')
|
|
@@ -2,138 +2,136 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import os from 'os';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
|
-
import { execSync } from 'child_process';
|
|
6
5
|
import { createSpinner } from '../utils/spinner.js';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
};
|
|
7
|
+
// We use raw strings for templates to avoid JS interpolation issues
|
|
8
|
+
const BASH_ZSH_TEMPLATE = [
|
|
9
|
+
'# --- VANGUARD PROTECTION START ---',
|
|
10
|
+
'# Universal Interceptor for Bash/Zsh',
|
|
11
|
+
'git() {',
|
|
12
|
+
' if [ "$1" = "clone" ] && [ -z "$VANGUARD_INTERNAL" ]; then',
|
|
13
|
+
' export VANGUARD_INTERNAL=1',
|
|
14
|
+
' vanguard clone "${@:2}"',
|
|
15
|
+
' unset VANGUARD_INTERNAL',
|
|
16
|
+
' else',
|
|
17
|
+
' command git "$@"',
|
|
18
|
+
' fi',
|
|
19
|
+
'}',
|
|
20
|
+
'# --- VANGUARD PROTECTION END ---'
|
|
21
|
+
].join('\n');
|
|
22
|
+
|
|
23
|
+
const POWERSHELL_TEMPLATE = [
|
|
24
|
+
'# --- VANGUARD PROTECTION START ---',
|
|
25
|
+
'# Universal Interceptor for PowerShell',
|
|
26
|
+
'function git {',
|
|
27
|
+
' if ($args[0] -eq "clone" -and !$env:VANGUARD_INTERNAL) {',
|
|
28
|
+
' $env:VANGUARD_INTERNAL = "1"',
|
|
29
|
+
' try {',
|
|
30
|
+
' vanguard clone @(if ($args.Length -gt 1) { $args[1..($args.Length-1)] })',
|
|
31
|
+
' } finally {',
|
|
32
|
+
' $env:VANGUARD_INTERNAL = $null',
|
|
33
|
+
' }',
|
|
34
|
+
' } else {',
|
|
35
|
+
' & (Get-Command git -CommandType Application) @args',
|
|
36
|
+
' }',
|
|
37
|
+
'}',
|
|
38
|
+
'# --- VANGUARD PROTECTION END ---'
|
|
39
|
+
].join('\n');
|
|
40
|
+
|
|
41
|
+
const FISH_TEMPLATE = [
|
|
42
|
+
'# --- VANGUARD PROTECTION START ---',
|
|
43
|
+
'# Universal Interceptor for Fish',
|
|
44
|
+
'function git',
|
|
45
|
+
' if test "$argv[1]" = "clone"; and test -z "$VANGUARD_INTERNAL"',
|
|
46
|
+
' set -gx VANGUARD_INTERNAL 1',
|
|
47
|
+
' vanguard clone $argv[2..-1]',
|
|
48
|
+
' set -e VANGUARD_INTERNAL',
|
|
49
|
+
' else',
|
|
50
|
+
' command git $argv',
|
|
51
|
+
' end',
|
|
52
|
+
'end',
|
|
53
|
+
'# --- VANGUARD PROTECTION END ---'
|
|
54
|
+
].join('\n');
|
|
57
55
|
|
|
58
56
|
export async function runIntegrate() {
|
|
59
|
-
console.log(chalk.bold('🐚 Vanguard Shell Integrator\n'));
|
|
60
|
-
const spinner = createSpinner('🔍
|
|
57
|
+
console.log(chalk.bold('🐚 Vanguard Shell Integrator (Universal Edition)\n'));
|
|
58
|
+
const spinner = createSpinner('🔍 Probing environment for shell profiles...').start();
|
|
61
59
|
|
|
62
60
|
const home = os.homedir();
|
|
61
|
+
const isWin = os.platform() === 'win32';
|
|
63
62
|
let detected = [];
|
|
64
63
|
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
// 1. Detect Unix-based Shells (Linux/macOS)
|
|
65
|
+
const unixShells = [
|
|
66
|
+
{ name: 'zsh', file: '.zshrc', template: BASH_ZSH_TEMPLATE },
|
|
67
|
+
{ name: 'bash', file: '.bashrc', template: BASH_ZSH_TEMPLATE },
|
|
68
|
+
{ name: 'bash_profile', file: '.bash_profile', template: BASH_ZSH_TEMPLATE },
|
|
69
|
+
{ name: 'fish', file: '.config/fish/config.fish', template: FISH_TEMPLATE }
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
for (const shell of unixShells) {
|
|
73
|
+
const p = path.join(home, shell.file);
|
|
74
|
+
if (await fs.pathExists(p)) {
|
|
75
|
+
detected.push({ ...shell, path: p });
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
|
|
74
|
-
//
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
79
|
+
// 2. Detect PowerShell Profiles
|
|
80
|
+
const psFolders = [
|
|
81
|
+
path.join(home, 'Documents', 'PowerShell'),
|
|
82
|
+
path.join(home, 'Documents', 'WindowsPowerShell'),
|
|
83
|
+
path.join(home, 'OneDrive', 'Documents', 'PowerShell'),
|
|
84
|
+
path.join(home, 'OneDrive', 'Documents', 'WindowsPowerShell'),
|
|
85
|
+
path.join(home, 'OneDrive', 'Belgeler', 'PowerShell'),
|
|
86
|
+
path.join(home, 'OneDrive', 'Belgeler', 'WindowsPowerShell'),
|
|
87
|
+
path.join(home, '.config', 'powershell')
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
for (const folder of psFolders) {
|
|
91
|
+
const p = path.join(folder, 'Microsoft.PowerShell_profile.ps1');
|
|
92
|
+
if (await fs.pathExists(p)) {
|
|
93
|
+
detected.push({ name: 'powershell', path: p, template: POWERSHELL_TEMPLATE });
|
|
89
94
|
}
|
|
90
|
-
} else {
|
|
91
|
-
psProfiles.push(path.join(home, SCRIPTS.powershell.file));
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
detected.push({ name: 'powershell', path: profilePath, template: POWERSHELL_TEMPLATE });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
97
|
+
if (isWin && !detected.some(sh => sh.name === 'powershell')) {
|
|
98
|
+
const p = path.join(home, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1');
|
|
99
|
+
detected.push({ name: 'powershell', path: p, template: POWERSHELL_TEMPLATE });
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
if (detected.length === 0) {
|
|
103
|
-
spinner.fail('No
|
|
103
|
+
spinner.fail('No shell profiles found.');
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
spinner.succeed(`
|
|
107
|
+
spinner.succeed(`Identified ${detected.length} active Shell targets.`);
|
|
108
108
|
|
|
109
109
|
for (const shell of detected) {
|
|
110
|
-
const profilePath = shell.path;
|
|
111
|
-
const backupPath = `${profilePath}.backup`;
|
|
112
|
-
|
|
113
110
|
try {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
111
|
+
const profileContent = await fs.readFile(shell.path, 'utf-8').catch(() => '');
|
|
112
|
+
|
|
113
|
+
if (profileContent) {
|
|
114
|
+
await fs.copy(shell.path, `${shell.path}.vanguard_backup`);
|
|
118
115
|
} else {
|
|
119
|
-
await fs.ensureDir(path.dirname(
|
|
120
|
-
await fs.writeFile(profilePath, '');
|
|
116
|
+
await fs.ensureDir(path.dirname(shell.path));
|
|
121
117
|
}
|
|
122
118
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
if (profileContent.includes('VANGUARD PROTECTION START')) {
|
|
120
|
+
console.log(chalk.dim(` ⏩ ${shell.name} already protected. Synchronizing logic...`));
|
|
121
|
+
const newContent = profileContent.replace(
|
|
122
|
+
/# --- VANGUARD PROTECTION START ---[\s\S]*?# --- VANGUARD PROTECTION END ---/g,
|
|
123
|
+
shell.template.trim()
|
|
124
|
+
);
|
|
125
|
+
await fs.writeFile(shell.path, newContent);
|
|
129
126
|
} else {
|
|
130
|
-
await fs.appendFile(
|
|
127
|
+
await fs.appendFile(shell.path, `\n${shell.template}\n`);
|
|
128
|
+
console.log(chalk.green(` ✅ ${shell.name} protection INJECTED!`));
|
|
131
129
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
console.log(chalk.red(`❌ Failed to integrate with ${shell.name}: ${err.message}`));
|
|
130
|
+
} catch (e) {
|
|
131
|
+
console.log(chalk.red(` ❌ Error securing ${shell.name}: ${e.message}`));
|
|
135
132
|
}
|
|
136
133
|
}
|
|
137
134
|
|
|
138
|
-
console.log(chalk.bold('\n
|
|
135
|
+
console.log(chalk.bold('\n🛡️ Invisible Protection is now armed across your system.'));
|
|
136
|
+
console.log(chalk.cyan('👉 ACTION REQUIRED: Fully restart your terminal application to activate the shield.\n'));
|
|
139
137
|
}
|