jailbreakr 1.0.0 ā 1.0.1
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/index.js +38 -7
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,22 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
3
5
|
const glob = require('glob');
|
|
4
6
|
const axios = require('axios');
|
|
5
7
|
|
|
8
|
+
// Path to save user credentials locally (e.g., C:\Users\YourName\.jailbreakr)
|
|
9
|
+
const CONFIG_FILE = path.join(os.homedir(), '.jailbreakr');
|
|
10
|
+
|
|
6
11
|
async function run() {
|
|
7
12
|
const args = process.argv.slice(2);
|
|
8
|
-
const command = args[0] || 'scan'; // default
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
const command = args[0] || 'scan'; // default command is "scan"
|
|
14
|
+
|
|
15
|
+
// 1. LOGIN COMMAND (`npx jailbreakr login <your_api_key>`)
|
|
16
|
+
if (command === 'login') {
|
|
17
|
+
const keyInput = args[1];
|
|
18
|
+
if (!keyInput) {
|
|
19
|
+
console.log("ā Error: Please provide your API key.");
|
|
20
|
+
console.log("š Example: npx jailbreakr login jbr_test_12345");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Save API key to user's home directory
|
|
25
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify({ apiKey: keyInput }));
|
|
26
|
+
console.log("ā
Successfully logged in! Your API key is saved locally.");
|
|
27
|
+
console.log("š You can now run `npx jailbreakr scan` in any project folder.\n");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 2. CHECK FOR SAVED API KEY OR ENV VARIABLE
|
|
32
|
+
let userApiKey = process.env.JAILBREAKR_KEY;
|
|
33
|
+
if (!userApiKey && fs.existsSync(CONFIG_FILE)) {
|
|
34
|
+
try {
|
|
35
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
36
|
+
userApiKey = config.apiKey;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
// Ignore read errors
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
11
42
|
if (!userApiKey) {
|
|
12
|
-
console.log("ā Error:
|
|
13
|
-
console.log("
|
|
43
|
+
console.log("ā Error: You are not logged in.");
|
|
44
|
+
console.log("š Run `npx jailbreakr login <your_key>` first to authenticate.");
|
|
14
45
|
return;
|
|
15
46
|
}
|
|
16
47
|
|
|
17
48
|
console.log("\nš [Jailbreakr] Scanning project files for prompt & security flaws...");
|
|
18
49
|
|
|
19
|
-
//
|
|
50
|
+
// 3. SCAN LOCAL FILES
|
|
20
51
|
const files = glob.sync("**/*.{js,ts,py}", { ignore: "node_modules/**" });
|
|
21
52
|
let codeSnippets = [];
|
|
22
53
|
|
|
@@ -60,7 +91,7 @@ async function run() {
|
|
|
60
91
|
console.log(analysis.fixes || "No patches required.");
|
|
61
92
|
}
|
|
62
93
|
} else {
|
|
63
|
-
console.log("\nš” Tip: Run `
|
|
94
|
+
console.log("\nš” Tip: Run `npx jailbreakr fix` to automatically patch these flaws.");
|
|
64
95
|
}
|
|
65
96
|
|
|
66
97
|
} catch (err) {
|
package/package.json
CHANGED