flagrix 0.6.0 → 0.6.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2026.11.
|
|
3
|
-
"lastUpdated": "2026-11-
|
|
2
|
+
"version": "2026.11.19.001",
|
|
3
|
+
"lastUpdated": "2026-11-19T19:52:49.445Z",
|
|
4
4
|
"maliciousPackages": [
|
|
5
5
|
{
|
|
6
6
|
"name": "beavertail",
|
|
@@ -574,7 +574,7 @@
|
|
|
574
574
|
{
|
|
575
575
|
"id": "HARDCODED_API_KEY",
|
|
576
576
|
"name": "Hardcoded API Key",
|
|
577
|
-
"pattern": "(?:api[_-]?key|apikey|secret[_-]?key|auth[_-]?token|private[_-]?key)\\s*[:=]\\s*['\"]([^'\"]{20,})['\"]",
|
|
577
|
+
"pattern": "(?:api[_-]?key|apikey|secret[_-]?key|auth[_-]?token|private[_-]?key)(?<!algolia[\\s\\S]{0,300})\\s*[:=]\\s*['\"]([^'\"]{20,})['\"]",
|
|
578
578
|
"description": "Generic API key / secret key pattern assigned to a variable (obvious placeholders are downgraded by scanner context)",
|
|
579
579
|
"tags": [
|
|
580
580
|
"secrets",
|
|
@@ -1770,8 +1770,8 @@
|
|
|
1770
1770
|
{
|
|
1771
1771
|
"id": "COMPOSE_DOCKER_SOCKET_MOUNT",
|
|
1772
1772
|
"name": "Compose Service Mounts the Docker Socket",
|
|
1773
|
-
"pattern": "(?:^|\\n)[ \\t]*(?:-[ \\t]+[\\\"']?|source:[ \\t]*[\\\"']?)(?:\\/var)?\\/run\\/docker\\.sock",
|
|
1774
|
-
"description": "A service with /var/run/docker.sock controls the host daemon — container escape by design. Traefik, Portainer
|
|
1773
|
+
"pattern": "(?:^|\\n)[ \\t]*(?:-[ \\t]+[\\\"']?|source:[ \\t]*[\\\"']?)(?:\\/var)?\\/run\\/docker\\.sock(?<!image:[ \\t]*[\\\"']?[\\w./-]*(?:traefik|portainer|watchtower|docker-socket-proxy)[\\s\\S]{0,300})",
|
|
1774
|
+
"description": "A service with /var/run/docker.sock controls the host daemon — container escape by design. A service whose image is Traefik, Portainer, Watchtower or a socket proxy is skipped: the mount is how those tools work at all.\n",
|
|
1775
1775
|
"tags": [
|
|
1776
1776
|
"docker",
|
|
1777
1777
|
"compose",
|
|
@@ -789,6 +789,15 @@ var TEST_FILE_PATTERNS = [
|
|
|
789
789
|
/\.test\.[jt]sx?$/i,
|
|
790
790
|
/\.spec\.[jt]sx?$/i,
|
|
791
791
|
/_test\.[jt]sx?$/i,
|
|
792
|
+
// A suite named by its basename rather than by a `tests/` folder or a
|
|
793
|
+
// `.test.` infix: `js-api-tests.js`, `end-to-end-tests.js`, `parser-test.ts`.
|
|
794
|
+
// esbuild keeps its suite in `scripts/*-tests.js`, which every pattern above
|
|
795
|
+
// misses, so those files were read as build scripts with their string
|
|
796
|
+
// literals unmasked — and the `eval`, `new Function` and `fromCharCode`
|
|
797
|
+
// cases a bundler's own tests must contain matched as malware at critical
|
|
798
|
+
// severity. The separator class is what keeps this narrow: `latest.js` and
|
|
799
|
+
// `contest.js` have no separator before `test`, so they are untouched.
|
|
800
|
+
/(?:^|[/\-_.])tests?\.[cm]?[jt]sx?$/i,
|
|
792
801
|
/\.mock\.[jt]sx?$/i,
|
|
793
802
|
/fixtures?\//i,
|
|
794
803
|
/cypress\.config\.[jt]sx?$/i,
|
|
@@ -1044,6 +1053,21 @@ function resolveRepoPath(base, raw) {
|
|
|
1044
1053
|
}
|
|
1045
1054
|
return segments.length > 0 ? segments.join("/") : null;
|
|
1046
1055
|
}
|
|
1056
|
+
var FETCH_CONCURRENCY = 12;
|
|
1057
|
+
async function mapPool(items, limit, work) {
|
|
1058
|
+
const results = new Array(items.length);
|
|
1059
|
+
let next = 0;
|
|
1060
|
+
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
1061
|
+
while (true) {
|
|
1062
|
+
const index = next++;
|
|
1063
|
+
if (index >= items.length)
|
|
1064
|
+
return;
|
|
1065
|
+
results[index] = await work(items[index]);
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1068
|
+
await Promise.all(workers);
|
|
1069
|
+
return results;
|
|
1070
|
+
}
|
|
1047
1071
|
var MAX_FILES_TO_SCAN = 200;
|
|
1048
1072
|
var RUNS_ON_INSTALL_OR_BUILD = /^(?:scripts?|bin|tools?)\/|(?:^|\/)(?:pre|post)?install\.(?:[cm]?js|ts)$|(?:^|\/)setup\.(?:[cm]?js|ts|py)$|(?:^|\/)[\w.-]*\.config\.(?:[cm]?js|ts)$|^\.(?:husky|github|vscode|claude|cursor|devcontainer)\//;
|
|
1049
1073
|
var GENERATED_OR_VENDORED = /(?:^|\/)(?:dist|build|out|vendor|third_party|node_modules|coverage)\/|\.min\.[cm]?js$|\.bundle\.[cm]?js$|(?:^|\/)[\w.-]*\.generated\.[cm]?[jt]sx?$/;
|
|
@@ -1196,28 +1220,39 @@ async function scanGitHubRepo(repo, options) {
|
|
|
1196
1220
|
let fetchFailures = 0;
|
|
1197
1221
|
const declaredDependencies = [];
|
|
1198
1222
|
const localPackageNames = /* @__PURE__ */ new Set();
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
}
|
|
1223
|
+
const historySignals = fetchHistorySignals(`${repo.owner}/${repo.repo}`, branch, commitSha, headers);
|
|
1224
|
+
const readFile3 = async (file) => {
|
|
1225
|
+
if (rateLimited)
|
|
1226
|
+
return { state: "rate-limited" };
|
|
1204
1227
|
const contentUrl = `https://api.github.com/repos/${repo.owner}/${repo.repo}/contents/${file.path}?ref=${commitSha}`;
|
|
1205
1228
|
const contentResponse = await fetch(contentUrl, { headers });
|
|
1206
1229
|
if (!contentResponse.ok) {
|
|
1207
1230
|
if (isRateLimitResponse(contentResponse)) {
|
|
1208
1231
|
rateLimited = true;
|
|
1209
|
-
|
|
1210
|
-
continue;
|
|
1232
|
+
return { state: "rate-limited" };
|
|
1211
1233
|
}
|
|
1234
|
+
return { state: "failed" };
|
|
1235
|
+
}
|
|
1236
|
+
const fileData = await contentResponse.json();
|
|
1237
|
+
const binary = atob(fileData.content || "");
|
|
1238
|
+
return {
|
|
1239
|
+
state: "read",
|
|
1240
|
+
content: isFontFile(file.path) ? binary : decodeUtf8(binary)
|
|
1241
|
+
};
|
|
1242
|
+
};
|
|
1243
|
+
const analyzeFile = async (file, read) => {
|
|
1244
|
+
if (read.state === "rate-limited") {
|
|
1245
|
+
skip(file.path, "rate-limited");
|
|
1246
|
+
return;
|
|
1247
|
+
}
|
|
1248
|
+
if (read.state === "failed") {
|
|
1212
1249
|
fetchFailures++;
|
|
1213
1250
|
skip(file.path, "fetch-failed");
|
|
1214
|
-
|
|
1251
|
+
return;
|
|
1215
1252
|
}
|
|
1216
1253
|
filesScanned++;
|
|
1217
1254
|
scannedFiles.push(file.path);
|
|
1218
|
-
const
|
|
1219
|
-
const binary = atob(fileData.content || "");
|
|
1220
|
-
const content = isFontFile(file.path) ? binary : decodeUtf8(binary);
|
|
1255
|
+
const content = read.content;
|
|
1221
1256
|
if (isConfigFile(file.path) && !runsOffHost(file.path) || file.path.endsWith("package.json")) {
|
|
1222
1257
|
for (const target of extractCommandTargets(content, file.path)) {
|
|
1223
1258
|
if (commandTargets.size >= MAX_COMMAND_TARGETS)
|
|
@@ -1265,7 +1300,7 @@ async function scanGitHubRepo(repo, options) {
|
|
|
1265
1300
|
const masquerade = detectMasqueradedScript(content, file.path);
|
|
1266
1301
|
findings.push(...masquerade);
|
|
1267
1302
|
patternsMatched += masquerade.length;
|
|
1268
|
-
|
|
1303
|
+
return;
|
|
1269
1304
|
}
|
|
1270
1305
|
if (!isSource && (isConfigFile(file.path) || file.path.endsWith("package.json"))) {
|
|
1271
1306
|
const configFindings = applyYaraRules(content, yaraRules, file.path, configRuleScope(file.path));
|
|
@@ -1292,6 +1327,14 @@ async function scanGitHubRepo(repo, options) {
|
|
|
1292
1327
|
findings.push(...obfuscationFindings);
|
|
1293
1328
|
patternsMatched += obfuscationFindings.length;
|
|
1294
1329
|
}
|
|
1330
|
+
};
|
|
1331
|
+
for (let cursor = 0; cursor < filesToScan.length; ) {
|
|
1332
|
+
const generation = filesToScan.slice(cursor);
|
|
1333
|
+
cursor = filesToScan.length;
|
|
1334
|
+
const reads = await mapPool(generation, FETCH_CONCURRENCY, readFile3);
|
|
1335
|
+
for (let index = 0; index < generation.length; index++) {
|
|
1336
|
+
await analyzeFile(generation[index], reads[index]);
|
|
1337
|
+
}
|
|
1295
1338
|
}
|
|
1296
1339
|
if (options.osvFeed) {
|
|
1297
1340
|
const alreadyFlagged = new Set(findings.filter((finding) => finding.type === "SUSPICIOUS_DEPENDENCY" && finding.package).map((finding) => finding.package));
|
|
@@ -1340,7 +1383,7 @@ async function scanGitHubRepo(repo, options) {
|
|
|
1340
1383
|
const integrityFindings = await detectCodeIntegrityIssues(fileContents, allPaths, repo);
|
|
1341
1384
|
findings.push(...integrityFindings);
|
|
1342
1385
|
patternsMatched += integrityFindings.length;
|
|
1343
|
-
const historyFindings = await
|
|
1386
|
+
const historyFindings = await historySignals;
|
|
1344
1387
|
findings.push(...historyFindings);
|
|
1345
1388
|
patternsMatched += historyFindings.length;
|
|
1346
1389
|
const rawRiskScore = calculateRawRiskScore(findings);
|
|
@@ -1388,6 +1431,9 @@ async function scanPackageJson(content, maliciousPackages, filePath) {
|
|
|
1388
1431
|
try {
|
|
1389
1432
|
const pkg = JSON.parse(content);
|
|
1390
1433
|
const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
1434
|
+
const typosquatCandidates = Object.keys(allDeps).filter((name) => !name.startsWith("@")).map((name) => ({ name, typosquat: checkTyposquat(name) })).filter((candidate) => candidate.typosquat !== null);
|
|
1435
|
+
const downloadsByName = new Map(await Promise.all(typosquatCandidates.map(async ({ name }) => [name, await getNpmWeeklyDownloads(name)])));
|
|
1436
|
+
const typosquatOf = new Map(typosquatCandidates.map(({ name, typosquat }) => [name, typosquat]));
|
|
1391
1437
|
for (const [name, declaredVersion] of Object.entries(allDeps)) {
|
|
1392
1438
|
const malicious = maliciousPackages.find((m) => m.name === name);
|
|
1393
1439
|
if (malicious && isAffectedPackageVersion(malicious, declaredVersion)) {
|
|
@@ -1400,20 +1446,18 @@ async function scanPackageJson(content, maliciousPackages, filePath) {
|
|
|
1400
1446
|
description: `Known malicious package: ${name}`
|
|
1401
1447
|
});
|
|
1402
1448
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1449
|
+
const typosquat = typosquatOf.get(name);
|
|
1450
|
+
if (typosquat) {
|
|
1451
|
+
const weeklyDownloads = downloadsByName.get(name) ?? null;
|
|
1452
|
+
const shouldFlag = weeklyDownloads === null || weeklyDownloads < NPM_HIGH_DOWNLOAD_THRESHOLD;
|
|
1453
|
+
if (shouldFlag) {
|
|
1454
|
+
findings.push({
|
|
1455
|
+
severity: "medium",
|
|
1456
|
+
type: "TYPOSQUAT_PACKAGE",
|
|
1457
|
+
file: filePath,
|
|
1458
|
+
package: name,
|
|
1459
|
+
description: `Possible typosquat of "${typosquat}": ${name}`
|
|
1460
|
+
});
|
|
1417
1461
|
}
|
|
1418
1462
|
}
|
|
1419
1463
|
}
|
|
@@ -2060,7 +2104,13 @@ function detectBackdoors(content, filePath, coveredRuleIds = /* @__PURE__ */ new
|
|
|
2060
2104
|
{ pattern: /eval\s*\(\s*(?:request|req)(?:\.|\.body|\.query)/gi, type: "Remote Code Execution Endpoint", severity: "critical", ruleId: "BACKDOOR_RCE_ENDPOINT" },
|
|
2061
2105
|
{ pattern: /exec\s*\(\s*(?:request|req)(?:\.|\.body|\.query)/gi, type: "Command Injection Endpoint", severity: "critical", ruleId: "BACKDOOR_RCE_ENDPOINT" },
|
|
2062
2106
|
{ pattern: /require\s*\(\s*(?:request|req)(?:\.|\.body|\.query)/gi, type: "Dynamic Require", severity: "critical", ruleId: "BACKDOOR_DYNAMIC_REQUIRE" },
|
|
2063
|
-
|
|
2107
|
+
// The request has to be read as data (`req.body`, `req["x"]`), the way
|
|
2108
|
+
// the three patterns above all require. Matching a bare `req` flagged
|
|
2109
|
+
// `new Function('module', 'exports', 'require', src)` — the CommonJS
|
|
2110
|
+
// module wrapper every bundler and module loader writes — as a critical
|
|
2111
|
+
// backdoor, because `require` begins with `req`. esbuild's own build
|
|
2112
|
+
// script tripped it.
|
|
2113
|
+
{ pattern: /new\s+Function\s*\([^)]*\b(?:request|req)\s*(?:\.|\[)/gi, type: "Dynamic Function from Request", severity: "critical", ruleId: null },
|
|
2064
2114
|
{ pattern: /(?:password|auth)\s*(?:===?|==)\s*['"][^'"]{0,20}['"]\s*\)/gi, type: "Hardcoded Auth Bypass", severity: "critical", ruleId: "BACKDOOR_HARDCODED_AUTH" }
|
|
2065
2115
|
].filter(({ ruleId }) => !ruleId || !coveredRuleIds.has(ruleId));
|
|
2066
2116
|
for (const { pattern, type, severity } of backdoorPatterns) {
|
|
@@ -2469,21 +2519,21 @@ async function fetchUserFeatures(username, githubToken) {
|
|
|
2469
2519
|
if (githubToken) {
|
|
2470
2520
|
headers["Authorization"] = `Bearer ${githubToken}`;
|
|
2471
2521
|
}
|
|
2472
|
-
const userResponse = await
|
|
2522
|
+
const [userResponse, reposResponse, eventsResponse] = await Promise.all([
|
|
2523
|
+
fetch(`https://api.github.com/users/${username}`, { headers }),
|
|
2524
|
+
fetch(`https://api.github.com/users/${username}/repos?per_page=100&sort=updated`, { headers }),
|
|
2525
|
+
fetch(`https://api.github.com/users/${username}/events/public?per_page=30`, { headers })
|
|
2526
|
+
]);
|
|
2473
2527
|
if (!userResponse.ok) {
|
|
2474
2528
|
if (userResponse.status === 404)
|
|
2475
2529
|
throw new Error(`User "${username}" not found`);
|
|
2476
2530
|
throw await githubApiError(userResponse);
|
|
2477
2531
|
}
|
|
2478
|
-
const user = await userResponse.json();
|
|
2479
|
-
const reposResponse = await fetch(`https://api.github.com/users/${username}/repos?per_page=100&sort=updated`, { headers });
|
|
2480
2532
|
if (!reposResponse.ok)
|
|
2481
2533
|
throw await githubApiError(reposResponse, "Failed to fetch repositories");
|
|
2482
|
-
const repos = await reposResponse.json();
|
|
2483
|
-
const eventsResponse = await fetch(`https://api.github.com/users/${username}/events/public?per_page=30`, { headers });
|
|
2484
2534
|
if (!eventsResponse.ok)
|
|
2485
2535
|
throw await githubApiError(eventsResponse, "Failed to fetch events");
|
|
2486
|
-
const events = await eventsResponse.json();
|
|
2536
|
+
const [user, repos, events] = await Promise.all([userResponse.json(), reposResponse.json(), eventsResponse.json()]);
|
|
2487
2537
|
const now = Date.now();
|
|
2488
2538
|
const accountAgeDays = Math.floor((now - new Date(user.created_at).getTime()) / 864e5);
|
|
2489
2539
|
const followerFollowingRatio = user.followers === 0 ? user.following > 0 ? Infinity : 0 : user.following / user.followers;
|
package/dist/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
scanGitHubUser,
|
|
15
15
|
scanReport,
|
|
16
16
|
wantJson
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-NLLRSST4.js";
|
|
18
18
|
|
|
19
19
|
// src/cli.ts
|
|
20
20
|
import { parseArgs } from "util";
|
|
@@ -78,7 +78,7 @@ async function runScanUser(login, options) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// src/cli.ts
|
|
81
|
-
var VERSION = "0.6.
|
|
81
|
+
var VERSION = "0.6.2";
|
|
82
82
|
var HELP = `flagrix \u2014 scan GitHub repos and profiles for malware before you clone
|
|
83
83
|
|
|
84
84
|
Usage:
|
|
@@ -142,7 +142,7 @@ async function main() {
|
|
|
142
142
|
}
|
|
143
143
|
return runScanUser(target, { json: values.json, token: values.token });
|
|
144
144
|
case "mcp": {
|
|
145
|
-
const { runMcp } = await import("./mcp-
|
|
145
|
+
const { runMcp } = await import("./mcp-X3BOXV2Z.js");
|
|
146
146
|
return runMcp();
|
|
147
147
|
}
|
|
148
148
|
default:
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagrix",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "Scan GitHub repos and profiles for malware before you clone
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "Scan GitHub repos and profiles for malware before you clone \u2014 CLI and MCP server for the Flagrix scanner",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"zod": "^3.24.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@flagrix/scanner-core": "^0.7.
|
|
56
|
+
"@flagrix/scanner-core": "^0.7.1",
|
|
57
57
|
"@types/node": "^20.0.0",
|
|
58
58
|
"tsup": "^8.0.0",
|
|
59
59
|
"typescript": "^5.0.0",
|