flagrix 0.1.1 → 0.1.3
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "2026.07.08.002",
|
|
3
|
-
"lastUpdated": "2026-07-
|
|
3
|
+
"lastUpdated": "2026-07-09T09:25:31.727Z",
|
|
4
4
|
"maliciousPackages": [
|
|
5
5
|
{
|
|
6
6
|
"name": "beavertail",
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
{
|
|
161
161
|
"id": "INVISIBLEFERRET_KEYLOG",
|
|
162
162
|
"name": "InvisibleFerret Keylogger",
|
|
163
|
-
"pattern": "keyboard\\.on_press|pynput\\.keyboard|
|
|
163
|
+
"pattern": "keyboard\\.on_press|pynput\\.keyboard|from\\s+pynput",
|
|
164
164
|
"description": "Keylogger pattern using pynput — used by Lazarus Group's InvisibleFerret Python malware",
|
|
165
165
|
"tags": [
|
|
166
166
|
"lazarus",
|
|
@@ -679,7 +679,7 @@
|
|
|
679
679
|
{
|
|
680
680
|
"id": "OBF_EVAL",
|
|
681
681
|
"name": "eval() Usage",
|
|
682
|
-
"pattern": "eval\\s*\\([^)]{0,200}\\)",
|
|
682
|
+
"pattern": "eval\\s*\\(\\s*[^)\\s][^)]{0,200}\\)",
|
|
683
683
|
"description": "eval() executes arbitrary dynamic code. While there are legitimate uses, eval() is the #1 technique for executing hidden malicious payloads.\n",
|
|
684
684
|
"tags": [
|
|
685
685
|
"eval",
|
|
@@ -361,6 +361,138 @@ function collectEvidence(content, patterns, max = MAX_EVIDENCE_LINES) {
|
|
|
361
361
|
return evidence;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
// node_modules/@flagrix/scanner-core/dist/utils/mask.js
|
|
365
|
+
var REGEX_ALLOWED_AFTER_CHAR = /* @__PURE__ */ new Set([..."=(:,[!&|?{};+*%^<>~"]);
|
|
366
|
+
var REGEX_ALLOWED_AFTER_WORD = /* @__PURE__ */ new Set(["return", "case", "typeof", "in", "of", "do", "void", "delete"]);
|
|
367
|
+
function maskRegexLiterals(content) {
|
|
368
|
+
return content.split("\n").map(maskLine).join("\n");
|
|
369
|
+
}
|
|
370
|
+
function maskLine(line) {
|
|
371
|
+
let out = "";
|
|
372
|
+
let i = 0;
|
|
373
|
+
while (i < line.length) {
|
|
374
|
+
const ch = line[i];
|
|
375
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
376
|
+
const end = stringEnd(line, i);
|
|
377
|
+
out += line.slice(i, end);
|
|
378
|
+
i = end;
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (ch === "/" && line[i + 1] === "/") {
|
|
382
|
+
out += line.slice(i);
|
|
383
|
+
break;
|
|
384
|
+
}
|
|
385
|
+
if (ch === "/" && regexCanStartAfter(out)) {
|
|
386
|
+
const end = regexEnd(line, i);
|
|
387
|
+
if (end !== -1) {
|
|
388
|
+
out += " ".repeat(end - i);
|
|
389
|
+
i = end;
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
out += ch;
|
|
394
|
+
i++;
|
|
395
|
+
}
|
|
396
|
+
return out;
|
|
397
|
+
}
|
|
398
|
+
function regexCanStartAfter(before) {
|
|
399
|
+
const trimmed = before.trimEnd();
|
|
400
|
+
if (trimmed === "")
|
|
401
|
+
return true;
|
|
402
|
+
if (REGEX_ALLOWED_AFTER_CHAR.has(trimmed.slice(-1)))
|
|
403
|
+
return true;
|
|
404
|
+
const word = trimmed.match(/[A-Za-z_$][A-Za-z0-9_$]*$/)?.[0];
|
|
405
|
+
return word !== void 0 && REGEX_ALLOWED_AFTER_WORD.has(word);
|
|
406
|
+
}
|
|
407
|
+
function regexEnd(line, start) {
|
|
408
|
+
let i = start + 1;
|
|
409
|
+
let inClass = false;
|
|
410
|
+
let body = 0;
|
|
411
|
+
for (; i < line.length; i++) {
|
|
412
|
+
const ch = line[i];
|
|
413
|
+
if (ch === "\\") {
|
|
414
|
+
i++;
|
|
415
|
+
body++;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (inClass) {
|
|
419
|
+
if (ch === "]")
|
|
420
|
+
inClass = false;
|
|
421
|
+
} else if (ch === "[") {
|
|
422
|
+
inClass = true;
|
|
423
|
+
} else if (ch === "/") {
|
|
424
|
+
if (body === 0)
|
|
425
|
+
return -1;
|
|
426
|
+
let end = i + 1;
|
|
427
|
+
while (end < line.length && /[a-z]/i.test(line[end]))
|
|
428
|
+
end++;
|
|
429
|
+
return end;
|
|
430
|
+
}
|
|
431
|
+
body++;
|
|
432
|
+
}
|
|
433
|
+
return -1;
|
|
434
|
+
}
|
|
435
|
+
function stringEnd(line, start) {
|
|
436
|
+
const quote = line[start];
|
|
437
|
+
let i = start + 1;
|
|
438
|
+
for (; i < line.length; i++) {
|
|
439
|
+
if (line[i] === "\\") {
|
|
440
|
+
i++;
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (line[i] === quote)
|
|
444
|
+
return i + 1;
|
|
445
|
+
}
|
|
446
|
+
return line.length;
|
|
447
|
+
}
|
|
448
|
+
function maskStringLiterals(content) {
|
|
449
|
+
let out = "";
|
|
450
|
+
let i = 0;
|
|
451
|
+
let quote = null;
|
|
452
|
+
while (i < content.length) {
|
|
453
|
+
const ch = content[i];
|
|
454
|
+
if (quote) {
|
|
455
|
+
if (ch === "\\") {
|
|
456
|
+
out += " ";
|
|
457
|
+
i += 2;
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
if (ch === quote) {
|
|
461
|
+
quote = null;
|
|
462
|
+
out += ch;
|
|
463
|
+
} else {
|
|
464
|
+
out += ch === "\n" ? "\n" : " ";
|
|
465
|
+
}
|
|
466
|
+
i++;
|
|
467
|
+
continue;
|
|
468
|
+
}
|
|
469
|
+
if (ch === '"' || ch === "'" || ch === "`") {
|
|
470
|
+
quote = ch;
|
|
471
|
+
out += ch;
|
|
472
|
+
i++;
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
if (ch === "/" && content[i + 1] === "/") {
|
|
476
|
+
let j = content.indexOf("\n", i);
|
|
477
|
+
if (j === -1)
|
|
478
|
+
j = content.length;
|
|
479
|
+
out += content.slice(i, j);
|
|
480
|
+
i = j;
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
if (ch === "/" && content[i + 1] === "*") {
|
|
484
|
+
const close = content.indexOf("*/", i + 2);
|
|
485
|
+
const j = close === -1 ? content.length : close + 2;
|
|
486
|
+
out += content.slice(i, j);
|
|
487
|
+
i = j;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
out += ch;
|
|
491
|
+
i++;
|
|
492
|
+
}
|
|
493
|
+
return out;
|
|
494
|
+
}
|
|
495
|
+
|
|
364
496
|
// node_modules/@flagrix/scanner-core/dist/github/api-error.js
|
|
365
497
|
async function githubApiError(response, fallback = "GitHub API error") {
|
|
366
498
|
let apiMessage = "";
|
|
@@ -549,8 +681,13 @@ async function scanGitHubRepo(repo, options) {
|
|
|
549
681
|
continue;
|
|
550
682
|
const fileData = await contentResponse.json();
|
|
551
683
|
const content = atob(fileData.content || "");
|
|
684
|
+
const isJsTs = /\.(?:js|ts)$/.test(file.path);
|
|
685
|
+
let matchable = isJsTs ? maskRegexLiterals(content) : content;
|
|
686
|
+
if (isJsTs && isTestFile(file.path)) {
|
|
687
|
+
matchable = maskStringLiterals(matchable);
|
|
688
|
+
}
|
|
552
689
|
if (SCANNABLE_EXTENSIONS.some((ext) => file.path.endsWith(ext))) {
|
|
553
|
-
fileContents.push({ path: file.path, content });
|
|
690
|
+
fileContents.push({ path: file.path, content: matchable });
|
|
554
691
|
}
|
|
555
692
|
if (file.path.endsWith("package.json")) {
|
|
556
693
|
const pkgFindings = await scanPackageJson(content, maliciousPackages, file.path);
|
|
@@ -567,10 +704,10 @@ async function scanGitHubRepo(repo, options) {
|
|
|
567
704
|
patternsMatched += pyFindings.length;
|
|
568
705
|
}
|
|
569
706
|
if (SCANNABLE_EXTENSIONS.some((ext) => file.path.endsWith(ext))) {
|
|
570
|
-
const yaraFindings = applyYaraRules(
|
|
707
|
+
const yaraFindings = applyYaraRules(matchable, yaraRules, file.path);
|
|
571
708
|
findings.push(...yaraFindings);
|
|
572
709
|
patternsMatched += yaraFindings.length;
|
|
573
|
-
const obfuscationFindings = detectObfuscation(
|
|
710
|
+
const obfuscationFindings = detectObfuscation(matchable, file.path, loadedRuleIds);
|
|
574
711
|
findings.push(...obfuscationFindings);
|
|
575
712
|
patternsMatched += obfuscationFindings.length;
|
|
576
713
|
}
|
|
@@ -612,7 +749,8 @@ async function scanGitHubRepo(repo, options) {
|
|
|
612
749
|
patternsMatched += supplyChainFindings.length;
|
|
613
750
|
}
|
|
614
751
|
}
|
|
615
|
-
const
|
|
752
|
+
const allPaths = tree.tree.filter((i) => i.type === "blob").map((i) => i.path);
|
|
753
|
+
const integrityFindings = await detectCodeIntegrityIssues(fileContents, allPaths, repo);
|
|
616
754
|
findings.push(...integrityFindings);
|
|
617
755
|
patternsMatched += integrityFindings.length;
|
|
618
756
|
const riskScore = calculateRiskScore(findings);
|
|
@@ -762,7 +900,8 @@ function detectObfuscation(content, filePath, coveredRuleIds = /* @__PURE__ */ n
|
|
|
762
900
|
});
|
|
763
901
|
}
|
|
764
902
|
const evalPatterns = [
|
|
765
|
-
|
|
903
|
+
// Non-empty argument required: bare "eval()" appears in prose/docs.
|
|
904
|
+
{ pattern: /eval\s*\(\s*[^)\s][^)]{0,200}\)/gi, name: "eval", ruleId: BUILTIN_OBFUSCATION_RULE_IDS.eval },
|
|
766
905
|
{ pattern: /new\s+Function\s*\([^)]{0,200}\)/gi, name: "Function constructor", ruleId: BUILTIN_OBFUSCATION_RULE_IDS.newFunction },
|
|
767
906
|
{ pattern: /setTimeout\s*\(\s*["'`][^"'`]{0,200}["'`]/gi, name: "setTimeout with string", ruleId: BUILTIN_OBFUSCATION_RULE_IDS.timerString },
|
|
768
907
|
{ pattern: /setInterval\s*\(\s*["'`][^"'`]{0,200}["'`]/gi, name: "setInterval with string", ruleId: BUILTIN_OBFUSCATION_RULE_IDS.timerString }
|
|
@@ -1284,7 +1423,7 @@ function detectSuspiciousFileAccess(content, filePath, coveredRuleIds = /* @__PU
|
|
|
1284
1423
|
}
|
|
1285
1424
|
return findings;
|
|
1286
1425
|
}
|
|
1287
|
-
async function detectCodeIntegrityIssues(files, _repo) {
|
|
1426
|
+
async function detectCodeIntegrityIssues(files, allPaths, _repo) {
|
|
1288
1427
|
const findings = [];
|
|
1289
1428
|
for (const file of files) {
|
|
1290
1429
|
if (file.path.endsWith(".min.js") || file.path.endsWith(".min.css"))
|
|
@@ -1306,8 +1445,9 @@ async function detectCodeIntegrityIssues(files, _repo) {
|
|
|
1306
1445
|
}
|
|
1307
1446
|
}
|
|
1308
1447
|
}
|
|
1309
|
-
const
|
|
1310
|
-
|
|
1448
|
+
const basename = (p) => p.split("/").pop() ?? p;
|
|
1449
|
+
const hasLicense = allPaths.some((p) => /^(LICENSE|COPYING)/i.test(basename(p)));
|
|
1450
|
+
if (!hasLicense && allPaths.length > 5) {
|
|
1311
1451
|
findings.push({
|
|
1312
1452
|
severity: "low",
|
|
1313
1453
|
type: "CODE_INTEGRITY_ISSUE",
|
|
@@ -1315,8 +1455,8 @@ async function detectCodeIntegrityIssues(files, _repo) {
|
|
|
1315
1455
|
codeExplanation: "\u{1F4C4} Missing license file. Legitimate open-source projects typically include a license. Absence may indicate a quickly assembled malicious repository."
|
|
1316
1456
|
});
|
|
1317
1457
|
}
|
|
1318
|
-
const hasReadme =
|
|
1319
|
-
if (!hasReadme &&
|
|
1458
|
+
const hasReadme = allPaths.some((p) => /^README/i.test(basename(p)));
|
|
1459
|
+
if (!hasReadme && allPaths.length > 5) {
|
|
1320
1460
|
findings.push({
|
|
1321
1461
|
severity: "low",
|
|
1322
1462
|
type: "CODE_INTEGRITY_ISSUE",
|
package/dist/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
scanGitHubRepo,
|
|
12
12
|
scanGitHubUser,
|
|
13
13
|
wantJson
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BOICDXGY.js";
|
|
15
15
|
|
|
16
16
|
// src/cli.ts
|
|
17
17
|
import { parseArgs } from "util";
|
|
@@ -132,7 +132,7 @@ async function main() {
|
|
|
132
132
|
}
|
|
133
133
|
return runScanUser(target, { json: values.json, token: values.token });
|
|
134
134
|
case "mcp": {
|
|
135
|
-
const { runMcp } = await import("./mcp-
|
|
135
|
+
const { runMcp } = await import("./mcp-CWPBDBCD.js");
|
|
136
136
|
return runMcp();
|
|
137
137
|
}
|
|
138
138
|
default:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagrix",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Scan GitHub repos and profiles for malware before you clone — CLI and MCP server for the Flagrix scanner",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"zod": "^3.24.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@flagrix/scanner-core": "^0.1.
|
|
54
|
+
"@flagrix/scanner-core": "^0.1.3",
|
|
55
55
|
"@types/node": "^20.0.0",
|
|
56
56
|
"tsup": "^8.0.0",
|
|
57
57
|
"typescript": "^5.0.0",
|