argus-ci 1.1.0 → 1.1.2
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 +41 -92
- package/dist/hooks/setup.d.ts +6 -3
- package/dist/hooks/setup.d.ts.map +1 -1
- package/dist/hooks/setup.js +147 -52
- package/dist/hooks/setup.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,26 +20,16 @@ Catches: injection, XSS, hardcoded secrets, insecure crypto, path traversal, pro
|
|
|
20
20
|
## Requirements
|
|
21
21
|
|
|
22
22
|
- Node.js ≥ 18
|
|
23
|
-
-
|
|
24
|
-
- `ANTHROPIC_API_KEY` — only needed for the conversational agent interface
|
|
23
|
+
- `ANTHROPIC_API_KEY` — only needed for the conversational agent (`argus-ci chat`)
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## Install
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install -g argus-ci
|
|
32
|
-
# or use without installing:
|
|
33
|
-
npx argus-ci
|
|
34
|
-
```
|
|
25
|
+
> **Semgrep is installed automatically** by `npx argus-ci setup`. No manual install needed.
|
|
35
26
|
|
|
36
27
|
---
|
|
37
28
|
|
|
38
29
|
## 1. Add to your AI editor (MCP)
|
|
39
30
|
|
|
40
|
-
|
|
31
|
+
Open **Cursor Settings → MCP** and add:
|
|
41
32
|
|
|
42
|
-
**Cursor** — Settings → MCP → add:
|
|
43
33
|
```json
|
|
44
34
|
{
|
|
45
35
|
"argus-ci": {
|
|
@@ -61,13 +51,7 @@ This is the main use case. Once added, your AI agent will automatically scan eve
|
|
|
61
51
|
}
|
|
62
52
|
```
|
|
63
53
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
# Copy the trigger instructions into your repo
|
|
68
|
-
cp node_modules/argus-ci/CLAUDE.md ./CLAUDE.md
|
|
69
|
-
cp node_modules/argus-ci/.cursorrules ./.cursorrules
|
|
70
|
-
```
|
|
54
|
+
The MCP server registers as **"argus"** in Cursor's tool panel.
|
|
71
55
|
|
|
72
56
|
### MCP tools available
|
|
73
57
|
|
|
@@ -80,9 +64,9 @@ cp node_modules/argus-ci/.cursorrules ./.cursorrules
|
|
|
80
64
|
|
|
81
65
|
---
|
|
82
66
|
|
|
83
|
-
## 2.
|
|
67
|
+
## 2. Run setup in your repo
|
|
84
68
|
|
|
85
|
-
|
|
69
|
+
One command does everything — installs Semgrep, copies AI trigger files, and installs the pre-commit hook.
|
|
86
70
|
|
|
87
71
|
```bash
|
|
88
72
|
cd your-repo
|
|
@@ -91,92 +75,61 @@ npx argus-ci setup
|
|
|
91
75
|
|
|
92
76
|
Output:
|
|
93
77
|
```
|
|
94
|
-
|
|
95
|
-
Using semgrep 1.x.x
|
|
96
|
-
|
|
97
|
-
The hook will:
|
|
98
|
-
• Run on every git commit automatically
|
|
99
|
-
• Scan only the files you're committing (fast)
|
|
100
|
-
• Block the commit if any ERROR-severity issues are found
|
|
101
|
-
• Allow commits with only warnings
|
|
102
|
-
|
|
103
|
-
To remove: argus-ci setup --remove
|
|
104
|
-
To bypass: git commit --no-verify (emergency only)
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## 3. Conversational agent
|
|
78
|
+
🚀 argus-ci setup
|
|
110
79
|
|
|
111
|
-
|
|
80
|
+
⚙️ Semgrep not found — installing automatically...
|
|
81
|
+
→ brew install semgrep
|
|
82
|
+
✓ Semgrep installed (semgrep 1.x.x)
|
|
83
|
+
✓ CLAUDE.md written
|
|
84
|
+
✓ .cursorrules written
|
|
85
|
+
✓ Pre-commit hook installed
|
|
112
86
|
|
|
113
|
-
|
|
114
|
-
# Interactive REPL
|
|
115
|
-
argus-ci chat
|
|
116
|
-
|
|
117
|
-
# One-shot
|
|
118
|
-
argus-ci chat "review PR https://github.com/org/repo/pull/142"
|
|
119
|
-
argus-ci pr https://github.com/org/repo/pull/142
|
|
120
|
-
argus-ci scan --branch feature/auth
|
|
121
|
-
```
|
|
87
|
+
✅ Setup complete. argus-ci is now active in this repo.
|
|
122
88
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
```
|
|
89
|
+
What happens next:
|
|
90
|
+
• Every file your AI agent writes is scanned automatically (via MCP)
|
|
91
|
+
• Every commit is scanned — errors block the commit
|
|
92
|
+
• CLAUDE.md and .cursorrules tell your AI agent to run scans automatically
|
|
128
93
|
|
|
129
|
-
|
|
94
|
+
To review a PR: npx argus-ci pr <github-url>
|
|
95
|
+
To remove the hook: npx argus-ci setup --remove
|
|
130
96
|
```
|
|
131
|
-
You: review PR https://github.com/org/repo/pull/87
|
|
132
97
|
|
|
133
|
-
|
|
98
|
+
The setup does three things automatically:
|
|
99
|
+
- **Semgrep** — installed via Homebrew on macOS, pip3 elsewhere. Skipped if already installed.
|
|
100
|
+
- **CLAUDE.md / .cursorrules** — copied into the repo root. Tell the AI agent to call `scan_files` after every code generation.
|
|
101
|
+
- **Pre-commit hook** — written to `.git/hooks/pre-commit`. Blocks commits with ERROR-severity findings.
|
|
134
102
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
| Severity | Count |
|
|
138
|
-
|----------|-------|
|
|
139
|
-
| 🔴 Error | 2 |
|
|
140
|
-
| 🟡 Warning | 1 |
|
|
141
|
-
|
|
142
|
-
### `src/auth/login.ts`
|
|
143
|
-
|
|
144
|
-
**🔴 ERROR** — Line 34
|
|
145
|
-
> Timing attack: comparing secrets with === allows attackers to measure
|
|
146
|
-
> response time and guess tokens byte by byte.
|
|
147
|
-
`if (token === storedToken) {`
|
|
148
|
-
_Rule: `javascript.lang.security.audit.timing-attack`_
|
|
149
|
-
_CWE: CWE-208_
|
|
150
|
-
|
|
151
|
-
**Fix:** Use `crypto.timingSafeEqual(Buffer.from(token), Buffer.from(storedToken))`
|
|
152
|
-
```
|
|
103
|
+
To remove: `npx argus-ci setup --remove`
|
|
104
|
+
Emergency bypass: `git commit --no-verify` (not recommended)
|
|
153
105
|
|
|
154
106
|
---
|
|
155
107
|
|
|
156
|
-
##
|
|
108
|
+
## 3. Conversational agent
|
|
157
109
|
|
|
158
|
-
|
|
159
|
-
# Scan staged files (same as what the pre-commit hook runs)
|
|
160
|
-
argus-ci scan
|
|
110
|
+
Review a PR or branch in plain English. Requires `ANTHROPIC_API_KEY`.
|
|
161
111
|
|
|
162
|
-
|
|
163
|
-
|
|
112
|
+
```bash
|
|
113
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
164
114
|
|
|
165
|
-
#
|
|
166
|
-
argus-ci
|
|
115
|
+
# One-shot PR review
|
|
116
|
+
argus-ci pr https://github.com/org/repo/pull/142
|
|
167
117
|
|
|
168
|
-
#
|
|
169
|
-
argus-ci
|
|
118
|
+
# Interactive REPL
|
|
119
|
+
argus-ci chat
|
|
120
|
+
# You: review PR https://github.com/org/repo/pull/142
|
|
121
|
+
# You: check branch feature/payments
|
|
122
|
+
# You: what issues are in my current changes
|
|
170
123
|
```
|
|
171
124
|
|
|
172
125
|
---
|
|
173
126
|
|
|
174
|
-
##
|
|
127
|
+
## 4. GitHub Actions (CI gate)
|
|
175
128
|
|
|
176
129
|
Add to `.github/workflows/argus-ci.yml`:
|
|
177
130
|
|
|
178
131
|
```yaml
|
|
179
|
-
name:
|
|
132
|
+
name: argus-ci security scan
|
|
180
133
|
|
|
181
134
|
on:
|
|
182
135
|
pull_request:
|
|
@@ -207,11 +160,7 @@ jobs:
|
|
|
207
160
|
|
|
208
161
|
## Rulesets
|
|
209
162
|
|
|
210
|
-
Auto-detected from your project.
|
|
211
|
-
|
|
212
|
-
```bash
|
|
213
|
-
argus-ci scan --config '{"rulesets":["p/secrets","p/owasp-top-ten","p/nodejs"]}'
|
|
214
|
-
```
|
|
163
|
+
Auto-detected from your project. No config needed.
|
|
215
164
|
|
|
216
165
|
| Ruleset | When used |
|
|
217
166
|
|---------|-----------|
|
|
@@ -239,4 +188,4 @@ argus-ci scan --config '{"rulesets":["p/secrets","p/owasp-top-ten","p/nodejs"]}'
|
|
|
239
188
|
|
|
240
189
|
## License
|
|
241
190
|
|
|
242
|
-
MIT © [Venkat Swara Moyya](https://github.com/
|
|
191
|
+
MIT © [Venkat Swara Moyya](https://github.com/Naidu2404)
|
package/dist/hooks/setup.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* argus-ci setup — single command that does everything:
|
|
3
|
+
* 1. Auto-installs Semgrep if missing (brew on macOS, pip3 elsewhere)
|
|
4
|
+
* 2. Copies CLAUDE.md + .cursorrules trigger files into the repo
|
|
5
|
+
* 3. Installs the pre-commit git hook
|
|
6
|
+
*
|
|
7
|
+
* Usage: npx argus-ci setup
|
|
5
8
|
*/
|
|
6
9
|
export declare function setupHook(cwd: string): Promise<void>;
|
|
7
10
|
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/hooks/setup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/hooks/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA4CH,wBAAsB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+B1D"}
|
package/dist/hooks/setup.js
CHANGED
|
@@ -1,93 +1,190 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* argus-ci setup — single command that does everything:
|
|
3
|
+
* 1. Auto-installs Semgrep if missing (brew on macOS, pip3 elsewhere)
|
|
4
|
+
* 2. Copies CLAUDE.md + .cursorrules trigger files into the repo
|
|
5
|
+
* 3. Installs the pre-commit git hook
|
|
6
|
+
*
|
|
7
|
+
* Usage: npx argus-ci setup
|
|
5
8
|
*/
|
|
6
|
-
import { existsSync, mkdirSync, writeFileSync, chmodSync, readFileSync } from "fs";
|
|
7
|
-
import { join } from "path";
|
|
9
|
+
import { existsSync, mkdirSync, writeFileSync, chmodSync, readFileSync, copyFileSync, } from "fs";
|
|
10
|
+
import { join, dirname } from "path";
|
|
11
|
+
import { spawnSync } from "child_process";
|
|
12
|
+
import { fileURLToPath } from "url";
|
|
13
|
+
import { platform } from "os";
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = dirname(__filename);
|
|
16
|
+
// Resolve the package root (two levels up from dist/hooks/)
|
|
17
|
+
const PKG_ROOT = join(__dirname, "..", "..");
|
|
8
18
|
const HOOK_MARKER = "# argus-ci-hook";
|
|
9
19
|
const HOOK_SCRIPT = `#!/usr/bin/env sh
|
|
10
20
|
${HOOK_MARKER}
|
|
11
21
|
# Semgrep quality gate — runs on every commit.
|
|
12
|
-
# Remove with: argus-ci setup --remove
|
|
22
|
+
# Remove with: npx argus-ci setup --remove
|
|
13
23
|
# Bypass (emergency only): git commit --no-verify
|
|
14
24
|
|
|
15
|
-
echo "🔍
|
|
25
|
+
echo "🔍 argus-ci: scanning staged files..."
|
|
16
26
|
|
|
17
|
-
# Run argus-ci scan on staged files
|
|
18
|
-
# Exit code 1 = errors found → block commit
|
|
19
|
-
# Exit code 0 = clean → allow commit
|
|
20
27
|
npx --yes argus-ci scan --staged
|
|
21
|
-
|
|
22
28
|
EXIT_CODE=$?
|
|
23
29
|
|
|
24
30
|
if [ $EXIT_CODE -ne 0 ]; then
|
|
25
31
|
echo ""
|
|
26
|
-
echo "❌
|
|
27
|
-
echo " Fix the issues above, then
|
|
28
|
-
echo "
|
|
32
|
+
echo "❌ Security issues found — commit blocked."
|
|
33
|
+
echo " Fix the issues above, then commit again."
|
|
34
|
+
echo " Emergency bypass: git commit --no-verify"
|
|
29
35
|
exit 1
|
|
30
36
|
fi
|
|
31
37
|
|
|
32
|
-
echo "✅
|
|
38
|
+
echo "✅ argus-ci: all clear."
|
|
33
39
|
exit 0
|
|
34
40
|
`;
|
|
41
|
+
// ─── Main export ──────────────────────────────────────────────────────────────
|
|
35
42
|
export async function setupHook(cwd) {
|
|
36
43
|
const remove = process.argv.includes("--remove");
|
|
37
|
-
|
|
44
|
+
if (remove) {
|
|
45
|
+
const hookPath = join(cwd, ".git", "hooks", "pre-commit");
|
|
46
|
+
await removeHook(hookPath);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
console.log("\n🚀 argus-ci setup\n");
|
|
50
|
+
// Step 1: ensure Semgrep is installed
|
|
51
|
+
await ensureSemgrep();
|
|
52
|
+
// Step 2: copy trigger files into the repo
|
|
53
|
+
copyTriggerFiles(cwd);
|
|
54
|
+
// Step 3: install the pre-commit hook
|
|
55
|
+
installPreCommitHook(cwd);
|
|
56
|
+
console.log(`
|
|
57
|
+
✅ Setup complete. argus-ci is now active in this repo.
|
|
58
|
+
|
|
59
|
+
What happens next:
|
|
60
|
+
• Every file your AI agent writes is scanned automatically (via MCP)
|
|
61
|
+
• Every commit is scanned — errors block the commit
|
|
62
|
+
• CLAUDE.md and .cursorrules tell your AI agent to run scans automatically
|
|
63
|
+
|
|
64
|
+
To review a PR: npx argus-ci pr <github-url>
|
|
65
|
+
To remove the hook: npx argus-ci setup --remove
|
|
66
|
+
`);
|
|
67
|
+
}
|
|
68
|
+
// ─── Step 1: auto-install Semgrep ────────────────────────────────────────────
|
|
69
|
+
async function ensureSemgrep() {
|
|
70
|
+
if (isSemgrepInstalled()) {
|
|
71
|
+
const v = getSemgrepVersion();
|
|
72
|
+
console.log(` ✓ Semgrep already installed (${v})`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
console.log(" ⚙️ Semgrep not found — installing automatically...");
|
|
76
|
+
const os = platform();
|
|
77
|
+
let installed = false;
|
|
78
|
+
if (os === "darwin") {
|
|
79
|
+
// Try Homebrew first on macOS
|
|
80
|
+
if (commandExists("brew")) {
|
|
81
|
+
console.log(" → brew install semgrep");
|
|
82
|
+
const r = spawnSync("brew", ["install", "semgrep"], { stdio: "inherit" });
|
|
83
|
+
installed = r.status === 0;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!installed) {
|
|
87
|
+
// Fallback: pip3 / pip (works on macOS, Linux, Windows)
|
|
88
|
+
const pipCmd = commandExists("pip3") ? "pip3" : "pip";
|
|
89
|
+
console.log(` → ${pipCmd} install semgrep`);
|
|
90
|
+
const r = spawnSync(pipCmd, ["install", "semgrep"], { stdio: "inherit" });
|
|
91
|
+
installed = r.status === 0;
|
|
92
|
+
}
|
|
93
|
+
if (!installed || !isSemgrepInstalled()) {
|
|
94
|
+
console.error(`
|
|
95
|
+
❌ Could not install Semgrep automatically.
|
|
96
|
+
Please install it manually then re-run setup:
|
|
97
|
+
|
|
98
|
+
brew install semgrep (macOS)
|
|
99
|
+
pip install semgrep (any platform)
|
|
100
|
+
`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
const v = getSemgrepVersion();
|
|
104
|
+
console.log(` ✓ Semgrep installed (${v})`);
|
|
105
|
+
}
|
|
106
|
+
function isSemgrepInstalled() {
|
|
107
|
+
const candidates = ["semgrep", "/usr/local/bin/semgrep", "/opt/homebrew/bin/semgrep"];
|
|
108
|
+
for (const cmd of candidates) {
|
|
109
|
+
const r = spawnSync(cmd, ["--version"], { encoding: "utf8" });
|
|
110
|
+
if (r.status === 0)
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
// Try python module form
|
|
114
|
+
const r = spawnSync("python3", ["-m", "semgrep", "--version"], { encoding: "utf8" });
|
|
115
|
+
return r.status === 0;
|
|
116
|
+
}
|
|
117
|
+
function getSemgrepVersion() {
|
|
118
|
+
const r = spawnSync("semgrep", ["--version"], { encoding: "utf8" });
|
|
119
|
+
if (r.status === 0)
|
|
120
|
+
return r.stdout.trim().split("\n")[0];
|
|
121
|
+
const r2 = spawnSync("python3", ["-m", "semgrep", "--version"], { encoding: "utf8" });
|
|
122
|
+
return r2.stdout?.trim().split("\n")[0] ?? "unknown";
|
|
123
|
+
}
|
|
124
|
+
function commandExists(cmd) {
|
|
125
|
+
const r = spawnSync(platform() === "win32" ? "where" : "which", [cmd], { encoding: "utf8" });
|
|
126
|
+
return r.status === 0;
|
|
127
|
+
}
|
|
128
|
+
// ─── Step 2: copy trigger files ───────────────────────────────────────────────
|
|
129
|
+
function copyTriggerFiles(cwd) {
|
|
130
|
+
const files = [
|
|
131
|
+
{ src: join(PKG_ROOT, "CLAUDE.md"), dest: join(cwd, "CLAUDE.md") },
|
|
132
|
+
{ src: join(PKG_ROOT, ".cursorrules"), dest: join(cwd, ".cursorrules") },
|
|
133
|
+
];
|
|
134
|
+
for (const { src, dest } of files) {
|
|
135
|
+
if (!existsSync(src)) {
|
|
136
|
+
console.log(` ⚠️ Could not find ${src} in package — skipping`);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (existsSync(dest)) {
|
|
140
|
+
// Check if already contains argus-ci instructions
|
|
141
|
+
const existing = readFileSync(dest, "utf8");
|
|
142
|
+
if (existing.includes("argus-ci") || existing.includes("scan_files")) {
|
|
143
|
+
console.log(` ✓ ${dest.split("/").pop()} already contains argus-ci instructions`);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
// Append to existing file
|
|
147
|
+
const appended = existing.trimEnd() + "\n\n" + readFileSync(src, "utf8");
|
|
148
|
+
writeFileSync(dest, appended, "utf8");
|
|
149
|
+
console.log(` ✓ argus-ci instructions appended to existing ${dest.split("/").pop()}`);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
copyFileSync(src, dest);
|
|
153
|
+
console.log(` ✓ ${dest.split("/").pop()} written`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// ─── Step 3: install pre-commit hook ─────────────────────────────────────────
|
|
158
|
+
function installPreCommitHook(cwd) {
|
|
38
159
|
const gitDir = join(cwd, ".git");
|
|
39
160
|
if (!existsSync(gitDir)) {
|
|
40
|
-
console.
|
|
41
|
-
|
|
161
|
+
console.warn(" ⚠️ No .git directory found — skipping pre-commit hook");
|
|
162
|
+
console.warn(" Run from a git repo root to install the commit gate.");
|
|
163
|
+
return;
|
|
42
164
|
}
|
|
43
165
|
const hooksDir = join(gitDir, "hooks");
|
|
44
166
|
const hookPath = join(hooksDir, "pre-commit");
|
|
45
|
-
if (remove) {
|
|
46
|
-
await removeHook(hookPath);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
// Create hooks dir if needed
|
|
50
167
|
if (!existsSync(hooksDir))
|
|
51
168
|
mkdirSync(hooksDir, { recursive: true });
|
|
52
|
-
// Check if a hook already exists (not ours)
|
|
53
169
|
if (existsSync(hookPath)) {
|
|
54
170
|
const existing = readFileSync(hookPath, "utf8");
|
|
55
171
|
if (existing.includes(HOOK_MARKER)) {
|
|
56
|
-
console.log("
|
|
172
|
+
console.log(" ✓ Pre-commit hook already installed");
|
|
57
173
|
return;
|
|
58
174
|
}
|
|
59
|
-
// Append to existing hook
|
|
175
|
+
// Append to existing hook rather than overwrite
|
|
60
176
|
const appended = existing.trimEnd() + "\n\n" + HOOK_SCRIPT;
|
|
61
177
|
writeFileSync(hookPath, appended, "utf8");
|
|
62
178
|
chmodSync(hookPath, 0o755);
|
|
63
|
-
console.log("
|
|
179
|
+
console.log(" ✓ argus-ci appended to existing pre-commit hook");
|
|
64
180
|
}
|
|
65
181
|
else {
|
|
66
182
|
writeFileSync(hookPath, HOOK_SCRIPT, "utf8");
|
|
67
183
|
chmodSync(hookPath, 0o755);
|
|
68
|
-
console.log("
|
|
69
|
-
}
|
|
70
|
-
// Verify semgrep is available
|
|
71
|
-
const { spawnSync } = await import("child_process");
|
|
72
|
-
const check = spawnSync("semgrep", ["--version"], { encoding: "utf8" });
|
|
73
|
-
if (check.status !== 0) {
|
|
74
|
-
console.log("\n⚠️ semgrep not found on PATH.");
|
|
75
|
-
console.log(" Install it before the hook will work:");
|
|
76
|
-
console.log(" → pip install semgrep");
|
|
77
|
-
console.log(" → brew install semgrep\n");
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
const version = check.stdout.trim();
|
|
81
|
-
console.log(` Using semgrep ${version}`);
|
|
184
|
+
console.log(" ✓ Pre-commit hook installed");
|
|
82
185
|
}
|
|
83
|
-
console.log("\nThe hook will:");
|
|
84
|
-
console.log(" • Run on every git commit automatically");
|
|
85
|
-
console.log(" • Scan only the files you're committing (fast)");
|
|
86
|
-
console.log(" • Block the commit if any ERROR-severity issues are found");
|
|
87
|
-
console.log(" • Allow commits with only warnings");
|
|
88
|
-
console.log("\nTo remove: argus-ci setup --remove");
|
|
89
|
-
console.log("To bypass: git commit --no-verify (emergency only)\n");
|
|
90
186
|
}
|
|
187
|
+
// ─── Remove ───────────────────────────────────────────────────────────────────
|
|
91
188
|
async function removeHook(hookPath) {
|
|
92
189
|
if (!existsSync(hookPath)) {
|
|
93
190
|
console.log("No pre-commit hook found.");
|
|
@@ -98,20 +195,18 @@ async function removeHook(hookPath) {
|
|
|
98
195
|
console.log("argus-ci hook not found in pre-commit hook.");
|
|
99
196
|
return;
|
|
100
197
|
}
|
|
101
|
-
// If the entire file is our hook, delete it
|
|
102
198
|
if (content.trim() === HOOK_SCRIPT.trim()) {
|
|
103
199
|
const { unlinkSync } = await import("fs");
|
|
104
200
|
unlinkSync(hookPath);
|
|
105
201
|
console.log("✅ argus-ci pre-commit hook removed.");
|
|
106
202
|
return;
|
|
107
203
|
}
|
|
108
|
-
// Otherwise strip our section from the file
|
|
109
204
|
const lines = content.split("\n");
|
|
110
205
|
const markerIdx = lines.findIndex((l) => l.includes(HOOK_MARKER));
|
|
111
|
-
if (markerIdx
|
|
206
|
+
if (markerIdx >= 0) {
|
|
112
207
|
const stripped = lines.slice(0, markerIdx).join("\n").trimEnd() + "\n";
|
|
113
208
|
writeFileSync(hookPath, stripped, "utf8");
|
|
114
|
-
console.log("✅ argus-ci
|
|
209
|
+
console.log("✅ argus-ci removed from pre-commit hook.");
|
|
115
210
|
}
|
|
116
211
|
}
|
|
117
212
|
//# sourceMappingURL=setup.js.map
|
package/dist/hooks/setup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/hooks/setup.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/hooks/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,UAAU,EAAE,SAAS,EAAE,aAAa,EACpC,SAAS,EAAE,YAAY,EAAE,YAAY,GACtC,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAE9B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAI,OAAO,CAAC,UAAU,CAAC,CAAC;AAEvC,4DAA4D;AAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE7C,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC,MAAM,WAAW,GAAG;EAClB,WAAW;;;;;;;;;;;;;;;;;;;;CAoBZ,CAAC;AAEF,iFAAiF;AAEjF,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAW;IACzC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEjD,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QA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