flagrix 0.5.0 → 0.5.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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2026.10.
|
|
3
|
-
"lastUpdated": "2026-
|
|
2
|
+
"version": "2026.11.10.001",
|
|
3
|
+
"lastUpdated": "2026-11-10T16:39:28.787Z",
|
|
4
4
|
"maliciousPackages": [
|
|
5
5
|
{
|
|
6
6
|
"name": "beavertail",
|
|
@@ -897,9 +897,9 @@
|
|
|
897
897
|
},
|
|
898
898
|
{
|
|
899
899
|
"id": "BACKDOOR_HARDCODED_AUTH",
|
|
900
|
-
"name": "Hardcoded
|
|
900
|
+
"name": "Hardcoded Password Comparison",
|
|
901
901
|
"pattern": "(?:password|auth)\\s*(?:===?|==)\\s*['\"][^'\"]{0,20}['\"]\\s*\\)",
|
|
902
|
-
"description": "
|
|
902
|
+
"description": "Password or auth value compared against a hardcoded string literal (e.g. password == \"admin123\") — a pattern backdoors use, but also common in tests, examples and placeholder checks",
|
|
903
903
|
"tags": [
|
|
904
904
|
"backdoor",
|
|
905
905
|
"auth-bypass",
|
|
@@ -2745,11 +2745,11 @@ function scanReport(result) {
|
|
|
2745
2745
|
safeToClone: result.safeToClone && !coverage.unreliableClear
|
|
2746
2746
|
};
|
|
2747
2747
|
}
|
|
2748
|
-
function describeCoverage(coverage) {
|
|
2748
|
+
function describeCoverage(coverage, findingCount) {
|
|
2749
2749
|
if (coverage.complete) return "";
|
|
2750
2750
|
const read = `${coverage.filesRead} ${coverage.filesRead === 1 ? "file" : "files"} read`;
|
|
2751
2751
|
const counts = coverage.filesUnread > 0 ? `${read}, ${coverage.filesUnread} left unread` : read;
|
|
2752
|
-
const consequence = coverage.unreliableClear ? "
|
|
2752
|
+
const consequence = !coverage.unreliableClear ? "There may be more than what is reported here." : findingCount > 0 ? "What was read turned up only low-weight findings \u2014 that says nothing about the files left unread." : "Nothing was found in what was read \u2014 that is not the same as nothing being there.";
|
|
2753
2753
|
if (coverage.reason === "rate-limit") {
|
|
2754
2754
|
return `Stopped early \u2014 GitHub rate limit: ${counts}. Unauthenticated scans share 60 API requests an hour and one scan can need up to 200, so the rest of the repository was never looked at. A token raises the limit to 5,000/hour (--token, or GITHUB_TOKEN / FLAGRIX_GITHUB_TOKEN). ${consequence}`;
|
|
2755
2755
|
}
|
|
@@ -2810,7 +2810,7 @@ function renderRepoResult(result) {
|
|
|
2810
2810
|
);
|
|
2811
2811
|
if (!coverage.complete) {
|
|
2812
2812
|
lines.push("");
|
|
2813
|
-
for (const line of wrapNote(describeCoverage(coverage), " ")) lines.push(yellow(line));
|
|
2813
|
+
for (const line of wrapNote(describeCoverage(coverage, result.findings.length), " ")) lines.push(yellow(line));
|
|
2814
2814
|
}
|
|
2815
2815
|
for (const f of result.findings) {
|
|
2816
2816
|
lines.push("");
|
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-HL53V2DT.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.5.
|
|
81
|
+
var VERSION = "0.5.1";
|
|
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-KMJZQ5JQ.js");
|
|
146
146
|
return runMcp();
|
|
147
147
|
}
|
|
148
148
|
default:
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
scanGitHubUser,
|
|
12
12
|
scanReport,
|
|
13
13
|
securityScore
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HL53V2DT.js";
|
|
15
15
|
|
|
16
16
|
// src/commands/mcp.ts
|
|
17
17
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -30,7 +30,7 @@ function repoScanResponse(result, note) {
|
|
|
30
30
|
const summary = [
|
|
31
31
|
headline,
|
|
32
32
|
coverage.unreliableClear ? INCOMPLETE_GUIDANCE : GUIDANCE[result.riskLevel],
|
|
33
|
-
...coverage.complete ? [] : [describeCoverage(coverage)],
|
|
33
|
+
...coverage.complete ? [] : [describeCoverage(coverage, result.findings.length)],
|
|
34
34
|
...note ? [`Note: ${note}.`] : []
|
|
35
35
|
].join(" ");
|
|
36
36
|
return {
|
|
@@ -42,7 +42,7 @@ function repoScanResponse(result, note) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
async function runMcp() {
|
|
45
|
-
const server = new McpServer({ name: "flagrix", version: "0.5.
|
|
45
|
+
const server = new McpServer({ name: "flagrix", version: "0.5.1" });
|
|
46
46
|
server.registerTool(
|
|
47
47
|
"scan_github_repo",
|
|
48
48
|
{
|
package/docs/agent-gating.md
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Two ways to put Flagrix between an AI agent and untrusted code: the **MCP server**
|
|
4
4
|
(the agent decides to scan, or is instructed to) and the **Claude Code hook**
|
|
5
|
-
(
|
|
5
|
+
(recognized `git clone` / `gh repo clone` commands are gated, no cooperation
|
|
6
|
+
needed).
|
|
6
7
|
|
|
7
8
|
## Exit codes (the contract)
|
|
8
9
|
|
|
@@ -72,6 +73,22 @@ Copies of the hook script ship inside the npm package (`hooks/flagrix-clone-gate
|
|
|
72
73
|
Install the package globally first (`npm i -g flagrix`), or vendor the script into
|
|
73
74
|
your repo and point the hook at it. The hook only reacts to `git clone` /
|
|
74
75
|
`gh repo clone` commands targeting github.com; everything else passes through.
|
|
76
|
+
Git options before the subcommand are recognized (`git -C <dir> clone …`,
|
|
77
|
+
`git -c <key>=<value> clone …`, `git --git-dir=<dir> clone …`). It reads the
|
|
78
|
+
command text, not what the shell will run, so a clone hidden behind an alias,
|
|
79
|
+
a variable, a script or another tool (`curl … | sh`, a Makefile target) is not
|
|
80
|
+
seen. Treat it as a guard for an agent's ordinary clone commands, not a
|
|
81
|
+
sandbox.
|
|
82
|
+
|
|
83
|
+
What it scans: the branch the clone will check out. A `--branch <name>`,
|
|
84
|
+
`--branch=<name>` or `-b <name>` on the clone (including after `--` in
|
|
85
|
+
`gh repo clone owner/repo -- -b <name>`) is passed to the scan as `--ref`;
|
|
86
|
+
without one, the repository's default branch is scanned, which is what a plain
|
|
87
|
+
clone checks out. The verdict applies to the commit that ref pointed at when
|
|
88
|
+
the scan ran, so a push between the scan and the clone is not covered. Other
|
|
89
|
+
branches and tags the clone fetches but doesn't check out are not scanned, and
|
|
90
|
+
neither is anything you check out afterwards — scan those with
|
|
91
|
+
`npx flagrix scan <repo> --ref <ref>`.
|
|
75
92
|
|
|
76
93
|
## CI
|
|
77
94
|
|
|
@@ -3,41 +3,73 @@
|
|
|
3
3
|
#
|
|
4
4
|
# Scans any GitHub repo about to be cloned; blocks the clone (hook exit 2)
|
|
5
5
|
# when Flagrix rates it MEDIUM or HIGH risk, or when the scan could not read
|
|
6
|
-
# enough of the repository to give a verdict (exit 4).
|
|
7
|
-
#
|
|
6
|
+
# enough of the repository to give a verdict (exit 4). A `--branch`/`-b` on the
|
|
7
|
+
# clone is scanned as that ref; otherwise the repository's default branch is.
|
|
8
|
+
# See docs/agent-gating.md for the settings.json wiring.
|
|
8
9
|
set -euo pipefail
|
|
9
10
|
|
|
10
11
|
payload="$(cat)"
|
|
11
12
|
|
|
12
|
-
# Extract a github.com repo URL
|
|
13
|
-
url
|
|
13
|
+
# Extract a github.com repo URL — and the branch, if one is given — from a
|
|
14
|
+
# `git clone`/`gh repo clone` command. Prints "<url>\t<branch>" (branch may be
|
|
15
|
+
# empty), or nothing when the command is not a GitHub clone.
|
|
16
|
+
parsed="$(node -e '
|
|
14
17
|
let input = ""
|
|
15
18
|
process.stdin.on("data", (d) => (input += d))
|
|
16
19
|
process.stdin.on("end", () => {
|
|
17
20
|
try {
|
|
18
21
|
const cmd = JSON.parse(input)?.tool_input?.command ?? ""
|
|
19
|
-
|
|
22
|
+
// git takes global options before the subcommand (`git -C /tmp clone …`,
|
|
23
|
+
// `git -c http.proxy=… clone …`, `git --git-dir=… clone …`), so allow any
|
|
24
|
+
// run of them between `git` and `clone`.
|
|
25
|
+
const VALUE = String.raw`(?:"[^"]*"|\x27[^\x27]*\x27|\S+)`
|
|
26
|
+
const GIT_OPTS =
|
|
27
|
+
String.raw`(?:\s+(?:-[Cc]\s+|--(?:git-dir|work-tree|namespace|exec-path|config-env)\s+)` +
|
|
28
|
+
VALUE +
|
|
29
|
+
String.raw`|\s+--?[\w-]+(?:=` + VALUE + String.raw`)?)*`
|
|
30
|
+
const clone = cmd.match(
|
|
31
|
+
new RegExp(String.raw`\bgit` + GIT_OPTS + String.raw`\s+clone\b|\bgh\s+repo\s+clone\b`)
|
|
32
|
+
)
|
|
33
|
+
if (!clone) return
|
|
20
34
|
const m =
|
|
21
35
|
cmd.match(/https?:\/\/github\.com\/[\w.-]+\/[\w.-]+/) ||
|
|
22
36
|
cmd.match(/git@github\.com:[\w.-]+\/[\w.-]+/) ||
|
|
23
37
|
cmd.match(/\bclone\s+([\w.-]+\/[\w.-]+)(?:\s|$)/)?.slice(1)
|
|
24
|
-
if (m)
|
|
38
|
+
if (!m) return
|
|
39
|
+
// Only the clone itself counts: `git checkout -b x && git clone …` must
|
|
40
|
+
// not pick up the checkout branch. `gh repo clone o/r -- -b x` passes
|
|
41
|
+
// the flag through to git, so it is covered too.
|
|
42
|
+
const segment = cmd.slice(clone.index).split(/&&|\|\||[;|\n]/)[0]
|
|
43
|
+
const b = segment.match(/(?:^|\s)(?:--branch(?:=|\s+)|-b\s*)("[^"]+"|\x27[^\x27]+\x27|[^\s"\x27]+)/)
|
|
44
|
+
const branch = b ? b[1].replace(/^["\x27]|["\x27]$/g, "") : ""
|
|
45
|
+
process.stdout.write(String(Array.isArray(m) ? m[0] : m) + "\t" + branch)
|
|
25
46
|
} catch {}
|
|
26
47
|
})
|
|
27
48
|
' <<< "$payload")"
|
|
28
49
|
|
|
29
50
|
# Not a GitHub clone — allow.
|
|
30
|
-
[ -z "$
|
|
51
|
+
[ -z "$parsed" ] && exit 0
|
|
31
52
|
|
|
32
|
-
|
|
53
|
+
url="${parsed%%$'\t'*}"
|
|
54
|
+
ref="${parsed#*$'\t'}"
|
|
55
|
+
|
|
56
|
+
args=(scan "$url" --json)
|
|
57
|
+
target="$url"
|
|
58
|
+
if [ -n "$ref" ]; then
|
|
59
|
+
args+=(--ref "$ref")
|
|
60
|
+
target="$url (branch $ref)"
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
if npx -y flagrix "${args[@]}" > /dev/null 2>&1; then
|
|
33
64
|
exit 0 # low risk
|
|
34
65
|
else
|
|
35
66
|
code=$?
|
|
67
|
+
rerun="npx flagrix scan $url${ref:+ --ref $ref}"
|
|
36
68
|
case "$code" in
|
|
37
|
-
2) echo "Flagrix: MEDIUM risk — review https://github.com/flagrix-io/flagrix-cli#exit-codes before cloning $
|
|
38
|
-
3) echo "Flagrix: HIGH risk — do NOT clone $
|
|
39
|
-
4) echo "Flagrix: scan of $
|
|
40
|
-
*) echo "Flagrix: scan of $
|
|
69
|
+
2) echo "Flagrix: MEDIUM risk — review https://github.com/flagrix-io/flagrix-cli#exit-codes before cloning $target" >&2 ;;
|
|
70
|
+
3) echo "Flagrix: HIGH risk — do NOT clone $target (malicious patterns detected). Run: $rerun" >&2 ;;
|
|
71
|
+
4) echo "Flagrix: scan of $target was incomplete — not enough was read to give a verdict (usually GitHub's 60 req/h limit; set GITHUB_TOKEN). Run: $rerun" >&2 ;;
|
|
72
|
+
*) echo "Flagrix: scan of $target failed (exit $code) — blocking out of caution. Run: $rerun" >&2 ;;
|
|
41
73
|
esac
|
|
42
74
|
exit 2 # exit 2 = block the tool call in Claude Code
|
|
43
75
|
fi
|