flagrix 0.5.0 → 0.6.0

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.19.001",
3
- "lastUpdated": "2026-10-19T19:29:18.424Z",
2
+ "version": "2026.11.18.001",
3
+ "lastUpdated": "2026-11-18T14:13:43.540Z",
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 Auth Bypass",
900
+ "name": "Hardcoded Password Comparison",
901
901
  "pattern": "(?:password|auth)\\s*(?:===?|==)\\s*['\"][^'\"]{0,20}['\"]\\s*\\)",
902
- "description": "Hardcoded password check — always-true backdoor condition in auth logic",
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",
@@ -1738,6 +1738,181 @@
1738
1738
  ".yaml"
1739
1739
  ]
1740
1740
  },
1741
+ {
1742
+ "id": "DOWNLOAD_FROM_IP_EXEC",
1743
+ "name": "Download From a Bare IP Address Executed",
1744
+ "pattern": "\\b(?:curl|wget|iwr|Invoke-WebRequest|Invoke-RestMethod)\\b[^\\n|]{0,200}https?:\\/\\/(?!127\\.|10\\.|0\\.|192\\.168\\.|172\\.(?:1[6-9]|2[0-9]|3[01])\\.)\\d{1,3}(?:\\.\\d{1,3}){3}[^\\n|]{0,200}\\|\\s*(?:sudo\\s+)?(?:(?:ba|z)?sh|dash|python3?|perl|node|iex)\\b|\\b(?:curl|wget)\\b[^\\n]{0,200}https?:\\/\\/(?!127\\.|10\\.|0\\.|192\\.168\\.|172\\.(?:1[6-9]|2[0-9]|3[01])\\.)\\d{1,3}(?:\\.\\d{1,3}){3}[^\\n]{0,200}(?:&&|;|\\n)[ \\t]*(?:sudo[ \\t]+)?(?:(?:ba|z)?sh|python3?|node)[ \\t]",
1745
+ "description": "Fetches a script from a hard-coded public IP and runs it. Release tooling uses names, not addresses; loopback and RFC1918 ranges are excluded so local dev scripts don't match.\n",
1746
+ "tags": [
1747
+ "download-exec",
1748
+ "clickfix",
1749
+ "loader"
1750
+ ],
1751
+ "severity": "high",
1752
+ "confidence": "high"
1753
+ },
1754
+ {
1755
+ "id": "DOCKERFILE_RUNS_ASSET_FILE",
1756
+ "name": "Container Build Runs a Font/Image/Text File",
1757
+ "pattern": "(?:^|\\n)[ \\t]*RUN\\b[^\\n]{0,300}\\b(?:node|bun|deno run|python3?)[ \\t]+[^\\n \\t\\\"']{0,120}\\.(?:woff2?|ttf|otf|eot|svg|png|jpe?g|gif|ico|webp|css|scss|dict|txt|md|dat|log)\\b",
1758
+ "description": "`RUN node app/fonts/fa-solid-900.woff2` — the Contagious Interview masquerade moved into the image build, where review attention is lowest.\n",
1759
+ "tags": [
1760
+ "docker",
1761
+ "masquerade",
1762
+ "contagious-interview"
1763
+ ],
1764
+ "severity": "critical",
1765
+ "confidence": "high",
1766
+ "fileExtensions": [
1767
+ ".dockerfile.sh"
1768
+ ]
1769
+ },
1770
+ {
1771
+ "id": "COMPOSE_DOCKER_SOCKET_MOUNT",
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 and Watchtower do this legitimately, so it is a review signal, not a verdict.\n",
1775
+ "tags": [
1776
+ "docker",
1777
+ "compose",
1778
+ "privilege-escalation"
1779
+ ],
1780
+ "severity": "high",
1781
+ "confidence": "medium",
1782
+ "fileExtensions": [
1783
+ ".compose.yml"
1784
+ ]
1785
+ },
1786
+ {
1787
+ "id": "COMPOSE_HOST_FILESYSTEM_MOUNT",
1788
+ "name": "Compose Service Mounts the Host Filesystem",
1789
+ "pattern": "(?:^|\\n)[ \\t]*-[ \\t]+[\\\"']?(?:\\/(?:etc|root|home|Users)(?:\\/[^\\n:]{0,60})?|\\/|\\$\\{?HOME\\}?(?:\\/[^\\n:]{0,60})?|~(?:\\/[^\\n:]{0,60})?):",
1790
+ "description": "Binds /, /etc, /root, /home or the host home directory into a container — everything in it, credentials included, becomes readable and writable by the image. Project-relative mounts (./data:/data) do not match.\n",
1791
+ "tags": [
1792
+ "docker",
1793
+ "compose",
1794
+ "credential-access"
1795
+ ],
1796
+ "severity": "high",
1797
+ "confidence": "medium",
1798
+ "fileExtensions": [
1799
+ ".compose.yml"
1800
+ ]
1801
+ },
1802
+ {
1803
+ "id": "COMPOSE_PRIVILEGED_CONTAINER",
1804
+ "name": "Compose Service Drops Container Isolation",
1805
+ "pattern": "(?:^|\\n)[ \\t]*(?:privileged[ \\t]*:[ \\t]*(?:true|yes)\\b|pid[ \\t]*:[ \\t]*[\\\"']?host\\b|cap_add[ \\t]*:[\\s\\S]{0,120}?\\bSYS_(?:ADMIN|PTRACE)\\b)",
1806
+ "description": "privileged: true, pid: host or CAP_SYS_ADMIN / CAP_SYS_PTRACE give a service the host's devices and process table. Some dev setups need it (dind, hardware access), so treat it as context for the rest of the scan.\n",
1807
+ "tags": [
1808
+ "docker",
1809
+ "compose",
1810
+ "privilege-escalation"
1811
+ ],
1812
+ "severity": "medium",
1813
+ "confidence": "medium",
1814
+ "fileExtensions": [
1815
+ ".compose.yml"
1816
+ ]
1817
+ },
1818
+ {
1819
+ "id": "COMPOSE_COMMAND_DOWNLOAD_EXEC",
1820
+ "name": "Compose Service Command Pipes a Download into a Shell",
1821
+ "pattern": "(?:^|\\n)[ \\t]*(?:command|entrypoint)[ \\t]*:[\\s\\S]{0,300}?\\b(?:curl|wget)\\b[^\\n]{0,200}\\|[ \\t]*(?:sudo[ \\t]+)?(?:(?:ba|z)?sh|python3?|node|perl)\\b",
1822
+ "description": "`command: curl ... | sh` in a compose service: the image's own build is not doing the install, a remote script is, every time the stack comes up.\n",
1823
+ "tags": [
1824
+ "docker",
1825
+ "compose",
1826
+ "download-exec"
1827
+ ],
1828
+ "severity": "high",
1829
+ "confidence": "medium",
1830
+ "fileExtensions": [
1831
+ ".compose.yml"
1832
+ ]
1833
+ },
1834
+ {
1835
+ "id": "DEVCONTAINER_COMMAND_DOWNLOAD_EXEC",
1836
+ "name": "Devcontainer Lifecycle Command Pipes a Download into a Shell",
1837
+ "pattern": "\\\"(?:initialize|onCreate|updateContent|postCreate|postStart|postAttach)Command\\\"[ \\t]*:[\\s\\S]{0,300}?(?:\\bcurl\\b|\\bwget\\b|\\biwr\\b|Invoke-WebRequest|Invoke-RestMethod)[\\s\\S]{0,300}?\\|[ \\t]*(?:sudo[ \\t]+)?(?:(?:ba|z)?sh|cmd|iex|powershell|pwsh|python3?|node)\\b",
1838
+ "description": "initializeCommand runs on the host and onCreate/postCreateCommand run as soon as the editor opens the folder — the devcontainer form of the Contagious Interview task file. CONFIG_COMMAND_DOWNLOAD_EXEC only covers the \"command\" key, which these configs do not use.\n",
1839
+ "tags": [
1840
+ "devcontainer",
1841
+ "auto-exec",
1842
+ "download",
1843
+ "contagious-interview"
1844
+ ],
1845
+ "severity": "critical",
1846
+ "confidence": "high",
1847
+ "fileExtensions": [
1848
+ ".json"
1849
+ ],
1850
+ "fileNames": [
1851
+ "devcontainer.json",
1852
+ ".devcontainer.json"
1853
+ ]
1854
+ },
1855
+ {
1856
+ "id": "DEVCONTAINER_RUNS_ASSET_FILE",
1857
+ "name": "Devcontainer Lifecycle Command Runs a Font/Image/Text File",
1858
+ "pattern": "\\\"(?:initialize|onCreate|updateContent|postCreate|postStart|postAttach)Command\\\"[ \\t]*:[\\s\\S]{0,200}?\\b(?:node|bun|deno|python3?)\\b[^\\\"\\n]{0,120}\\.(?:woff2?|ttf|otf|eot|svg|png|jpe?g|gif|ico|webp|css|scss|dict|txt|md|dat|log)\\b",
1859
+ "description": "`postCreateCommand: node .devcontainer/card4.jpeg` — JS disguised as an asset, started by opening the folder.\n",
1860
+ "tags": [
1861
+ "devcontainer",
1862
+ "auto-exec",
1863
+ "masquerade",
1864
+ "contagious-interview"
1865
+ ],
1866
+ "severity": "critical",
1867
+ "confidence": "high",
1868
+ "fileExtensions": [
1869
+ ".json"
1870
+ ],
1871
+ "fileNames": [
1872
+ "devcontainer.json",
1873
+ ".devcontainer.json"
1874
+ ]
1875
+ },
1876
+ {
1877
+ "id": "DEVCONTAINER_PRIVILEGED_HOST_MOUNT",
1878
+ "name": "Devcontainer Runs Privileged or Mounts the Host Home",
1879
+ "pattern": "\\\"privileged\\\"[ \\t]*:[ \\t]*true|\\\"runArgs\\\"[ \\t]*:[\\s\\S]{0,200}?--privileged|\\\"(?:mounts|workspaceMount)\\\"[ \\t]*:[\\s\\S]{0,200}?source=(?:\\/[,\\\"]|\\$\\{localEnv:HOME\\}[,\\\"]|\\/(?:etc|root|home|Users)[,\\\"\\/])",
1880
+ "description": "privileged: true, --privileged in runArgs, or a mount whose source is / or the whole host home directory. Mounting single dotfiles (~/.ssh, ~/.gitconfig) is ordinary and does not match.\n",
1881
+ "tags": [
1882
+ "devcontainer",
1883
+ "privilege-escalation",
1884
+ "credential-access"
1885
+ ],
1886
+ "severity": "medium",
1887
+ "confidence": "medium",
1888
+ "fileExtensions": [
1889
+ ".json"
1890
+ ],
1891
+ "fileNames": [
1892
+ "devcontainer.json",
1893
+ ".devcontainer.json"
1894
+ ]
1895
+ },
1896
+ {
1897
+ "id": "PASTE_RUN_UNTRUSTED_HOST",
1898
+ "name": "Docs Tell You to Pipe a Paste Site into a Shell",
1899
+ "pattern": "\\b(?:curl|wget|iwr|irm|Invoke-WebRequest|Invoke-RestMethod)\\b[^\\n|]{0,200}(?:pastebin\\.com|paste\\.ee|paste\\.rs|rentry\\.(?:co|org)|hastebin\\.com|bit\\.ly|tinyurl\\.com|is\\.gd|cutt\\.ly|rebrand\\.ly|shorturl\\.at|tiny\\.cc|rb\\.gy|t\\.ly|short\\.gy|transfer\\.sh|0x0\\.st|file\\.io|gist\\.githubusercontent\\.com)\\/[^\\n|]{0,200}\\|[ \\t]*(?:sudo[ \\t]+)?(?:(?:ba|z)?sh|iex|powershell|pwsh|python3?|node)\\b",
1900
+ "description": "Install instructions that run a script from a paste site, a URL shortener or a raw gist. Vendor one-liners (brew, rustup, bun) are left out — the host is what makes this a lure.\n",
1901
+ "tags": [
1902
+ "clickfix",
1903
+ "download-exec",
1904
+ "social-engineering",
1905
+ "prompt-injection"
1906
+ ],
1907
+ "severity": "high",
1908
+ "confidence": "medium",
1909
+ "fileExtensions": [
1910
+ ".md",
1911
+ ".mdc",
1912
+ ".txt",
1913
+ ".rst"
1914
+ ]
1915
+ },
1741
1916
  {
1742
1917
  "id": "OBF_BASE64_HEAVY",
1743
1918
  "name": "Heavy Base64 Encoding",
@@ -859,7 +859,7 @@ function applyYaraRules(content, rules, filePath, scopePath = filePath) {
859
859
  if (rule.fileExtensions && rule.fileExtensions.length > 0 && !rule.fileExtensions.some((ext) => scopePath.endsWith(ext))) {
860
860
  continue;
861
861
  }
862
- if (rule.fileNames && rule.fileNames.length > 0 && !rule.fileNames.includes(scopePath.split("/").pop() ?? scopePath)) {
862
+ if (rule.fileNames && rule.fileNames.length > 0 && !rule.fileNames.includes(filePath.split("/").pop() ?? filePath)) {
863
863
  continue;
864
864
  }
865
865
  const regex = new RegExp(rule.pattern, CASE_SENSITIVE_RULE_IDS.has(rule.id) ? "g" : "gi");
@@ -933,18 +933,53 @@ var SCANNABLE_EXTENSIONS = [
933
933
  ".html",
934
934
  ".htm"
935
935
  ];
936
+ var CONTAINER_BUILD_FILE = /(?:^|\/)(?:[\w.-]+[-.])?(?:Dockerfile|Containerfile)(?:[-.][\w.-]+)?$/i;
937
+ var COMPOSE_FILE = /(?:^|\/)(?:[\w-]+-)?compose(?:\.[\w-]+)*\.ya?ml$/i;
936
938
  var CONFIG_FILE_PATTERNS = [
937
939
  /(?:^|\/)\.vscode\/(?:tasks|settings|launch|mcp)\.json$/,
938
940
  /(?:^|\/)\.claude\/settings(?:\.local)?\.json$/,
939
941
  /(?:^|\/)\.(?:cursor|amazonq|gemini|windsurf|roo|kiro)\/(?:mcp|settings)\.json$/,
940
942
  /(?:^|\/)\.mcp\.json$/,
943
+ // devcontainer: initializeCommand runs on the host, and
944
+ // onCreate/postCreateCommand the moment an editor opens the folder.
945
+ /(?:^|\/)\.devcontainer\.json$/,
946
+ /(?:^|\/)\.devcontainer\/(?:[^/]+\/)?devcontainer\.json$/,
947
+ // `docker build` / `docker compose up` is a one-command execution path:
948
+ // RUN steps, `command:`, privileged containers, docker-socket mounts.
949
+ CONTAINER_BUILD_FILE,
950
+ COMPOSE_FILE,
941
951
  /^\.github\/workflows\/[^/]+\.ya?ml$/,
942
- /^README(?:\.md|\.txt|\.rst)?$/i,
952
+ /(?:^|\/)README(?:\.md|\.txt|\.rst)?$/i,
943
953
  /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI)\.md$/,
944
954
  /(?:^|\/)\.(?:cursorrules|windsurfrules|clinerules)$/,
945
- /(?:^|\/)\.cursor\/rules\/[^/]+\.mdc?$/,
946
- /^\.github\/copilot-instructions\.md$/
955
+ /(?:^|\/)\.cursor\/rules\/.*\.mdc?$/,
956
+ // Prompts, slash commands, subagents and skills: markdown a coding agent
957
+ // executes on request, with the same reach as a hook.
958
+ /(?:^|\/)\.claude\/(?:commands|agents)\/.*\.md$/,
959
+ /(?:^|\/)\.claude\/skills\/[^/]+\/SKILL\.md$/,
960
+ /^\.github\/copilot-instructions\.md$/,
961
+ /^\.github\/(?:instructions|prompts)\/[^/]+\.md$/
947
962
  ];
963
+ function configRuleScope(path) {
964
+ if (CONTAINER_BUILD_FILE.test(path))
965
+ return `${path}.dockerfile.sh`;
966
+ if (COMPOSE_FILE.test(path))
967
+ return `${path}.compose.yml`;
968
+ return path;
969
+ }
970
+ var INSTRUCTION_CONFIG = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI)\.md$|(?:^|\/)\.(?:cursorrules|windsurfrules|clinerules)$|(?:^|\/)\.cursor\/rules\/|(?:^|\/)\.claude\/(?:commands|agents|skills)\/|^\.github\/(?:copilot-instructions\.md$|(?:instructions|prompts)\/)/;
971
+ var README_CONFIG = /(?:^|\/)README(?:\.md|\.txt|\.rst)?$/i;
972
+ function sortByPriority(items, priority) {
973
+ const rank = new Map(items.map((item, index) => [item, index]));
974
+ items.sort((a, b) => priority(a.path) - priority(b.path) || rank.get(a) - rank.get(b));
975
+ }
976
+ function configPriority(path) {
977
+ if (README_CONFIG.test(path))
978
+ return 2;
979
+ if (INSTRUCTION_CONFIG.test(path))
980
+ return 1;
981
+ return 0;
982
+ }
948
983
  var UTF8 = new TextDecoder("utf-8");
949
984
  function decodeUtf8(binary) {
950
985
  const bytes = new Uint8Array(binary.length);
@@ -964,11 +999,14 @@ function isFontFile(path) {
964
999
  var MAX_CONFIG_FILES = 25;
965
1000
  var MAX_COMMAND_TARGETS = 10;
966
1001
  var CI_WORKFLOW = /^\.github\/workflows\//;
1002
+ function runsOffHost(path) {
1003
+ return CI_WORKFLOW.test(path) || CONTAINER_BUILD_FILE.test(path) || COMPOSE_FILE.test(path);
1004
+ }
967
1005
  var RUNTIME_INVOCATION = /\b(?:node|nodejs|bun|deno\s+run|tsx|ts-node)((?:\s+-{1,2}[\w-]+(?:=[^\s"'`]*)?)*)\s+\\?["']?([^\s"'`&|;<>()]+)/g;
968
1006
  var INLINE_CODE_FLAG = /(?:^|\s)(?:-[ep]|--eval|--print)(?:\s|=|$)/;
969
1007
  var RUNTIME_ARGS_FORM = /"command"\s*:\s*"(?:node|nodejs|bun|deno|tsx|ts-node)"\s*,\s*"args"\s*:\s*\[\s*"([^"]+)"/g;
970
- var PROJECT_DIR_VARIABLE = /\\?["']?\$\{?(?:CLAUDE_PROJECT_DIR|workspaceFolder|workspaceRoot)\}?\\?["']?(?=\/)/g;
971
- var DOT_DIR_CONFIG = /^(?:(.*)\/)?\.(?:vscode|claude|cursor|amazonq|gemini|windsurf|roo|kiro|github)\//;
1008
+ var PROJECT_DIR_VARIABLE = /\\?["']?\$\{?(?:CLAUDE_PROJECT_DIR|workspaceFolder|workspaceRoot|localWorkspaceFolder|containerWorkspaceFolder)\}?\\?["']?(?=\/)/g;
1009
+ var DOT_DIR_CONFIG = /^(?:(.*)\/)?\.(?:vscode|claude|cursor|amazonq|gemini|windsurf|roo|kiro|github|devcontainer)\//;
972
1010
  function extractCommandTargets(content, configPath) {
973
1011
  const dotDir = configPath.match(DOT_DIR_CONFIG);
974
1012
  const base = dotDir ? dotDir[1] ?? "" : configPath.includes("/") ? configPath.slice(0, configPath.lastIndexOf("/")) : "";
@@ -1007,6 +1045,18 @@ function resolveRepoPath(base, raw) {
1007
1045
  return segments.length > 0 ? segments.join("/") : null;
1008
1046
  }
1009
1047
  var MAX_FILES_TO_SCAN = 200;
1048
+ 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
+ var GENERATED_OR_VENDORED = /(?:^|\/)(?:dist|build|out|vendor|third_party|node_modules|coverage)\/|\.min\.[cm]?js$|\.bundle\.[cm]?js$|(?:^|\/)[\w.-]*\.generated\.[cm]?[jt]sx?$/;
1050
+ var SUPPORTING_SOURCE = /(?:^|\/)(?:__mocks__|mocks?|examples?|samples?|demos?)\//i;
1051
+ function sourcePriority(path) {
1052
+ if (GENERATED_OR_VENDORED.test(path))
1053
+ return 3;
1054
+ if (isTestFile(path) || SUPPORTING_SOURCE.test(path))
1055
+ return 2;
1056
+ if (RUNS_ON_INSTALL_OR_BUILD.test(path))
1057
+ return 0;
1058
+ return 1;
1059
+ }
1010
1060
  var MAX_FILE_SIZE_BYTES = 1024 * 1024;
1011
1061
  var MAX_SKIPPED_FILES_LISTED = 500;
1012
1062
  var NPM_DOWNLOAD_CACHE = /* @__PURE__ */ new Map();
@@ -1074,27 +1124,25 @@ async function scanGitHubRepo(repo, options) {
1074
1124
  skippedFiles.push({ path, reason });
1075
1125
  }
1076
1126
  };
1077
- const extraFiles = [];
1078
- let configSelected = 0;
1079
- let fontsSelected = 0;
1127
+ const configCandidates = [];
1128
+ const fontFiles = [];
1080
1129
  const sourceBlobs = [];
1081
1130
  for (const item of tree.tree) {
1082
1131
  if (item.type !== "blob")
1083
1132
  continue;
1084
- const config = isConfigFile(item.path);
1133
+ const config = isConfigFile(item.path) && !SCANNABLE_EXTENSIONS.some((ext) => item.path.endsWith(ext));
1085
1134
  const font = !config && isFontFile(item.path);
1086
1135
  if (config || font) {
1087
1136
  const sizeLimit = font ? MAX_FONT_BYTES : MAX_FILE_SIZE_BYTES;
1088
1137
  if (item.size !== void 0 && item.size > sizeLimit) {
1089
1138
  skip(item.path, "too-large");
1090
- } else if (config ? configSelected >= MAX_CONFIG_FILES : fontsSelected >= MAX_FONT_FILES) {
1091
- skip(item.path, "over-file-limit");
1092
- } else {
1093
- if (config)
1094
- configSelected++;
1139
+ } else if (font) {
1140
+ if (fontFiles.length >= MAX_FONT_FILES)
1141
+ skip(item.path, "over-file-limit");
1095
1142
  else
1096
- fontsSelected++;
1097
- extraFiles.push(item);
1143
+ fontFiles.push(item);
1144
+ } else {
1145
+ configCandidates.push(item);
1098
1146
  }
1099
1147
  continue;
1100
1148
  }
@@ -1103,13 +1151,20 @@ async function scanGitHubRepo(repo, options) {
1103
1151
  skip(item.path, "unsupported-type");
1104
1152
  } else if (item.size !== void 0 && item.size > MAX_FILE_SIZE_BYTES) {
1105
1153
  skip(item.path, "too-large");
1106
- } else if (sourceBlobs.length >= MAX_FILES_TO_SCAN) {
1107
- skip(item.path, "over-file-limit");
1108
1154
  } else {
1109
1155
  sourceBlobs.push(item);
1110
1156
  }
1111
1157
  }
1112
- const filesToScan = [...extraFiles, ...sourceBlobs];
1158
+ sortByPriority(sourceBlobs, sourcePriority);
1159
+ for (const item of sourceBlobs.splice(MAX_FILES_TO_SCAN)) {
1160
+ skip(item.path, "over-file-limit");
1161
+ }
1162
+ const configFiles = configCandidates;
1163
+ sortByPriority(configFiles, configPriority);
1164
+ for (const item of configFiles.splice(MAX_CONFIG_FILES)) {
1165
+ skip(item.path, "over-file-limit");
1166
+ }
1167
+ const filesToScan = [...configFiles, ...fontFiles, ...sourceBlobs];
1113
1168
  const blobsByPath = new Map(tree.tree.filter((item) => item.type === "blob").map((item) => [item.path, item]));
1114
1169
  const queued = new Set(filesToScan.map((item) => item.path));
1115
1170
  const commandTargets = /* @__PURE__ */ new Set();
@@ -1163,7 +1218,7 @@ async function scanGitHubRepo(repo, options) {
1163
1218
  const fileData = await contentResponse.json();
1164
1219
  const binary = atob(fileData.content || "");
1165
1220
  const content = isFontFile(file.path) ? binary : decodeUtf8(binary);
1166
- if (isConfigFile(file.path) && !CI_WORKFLOW.test(file.path) || file.path.endsWith("package.json")) {
1221
+ if (isConfigFile(file.path) && !runsOffHost(file.path) || file.path.endsWith("package.json")) {
1167
1222
  for (const target of extractCommandTargets(content, file.path)) {
1168
1223
  if (commandTargets.size >= MAX_COMMAND_TARGETS)
1169
1224
  break;
@@ -1213,10 +1268,10 @@ async function scanGitHubRepo(repo, options) {
1213
1268
  continue;
1214
1269
  }
1215
1270
  if (!isSource && (isConfigFile(file.path) || file.path.endsWith("package.json"))) {
1216
- const configFindings = applyYaraRules(content, yaraRules, file.path);
1271
+ const configFindings = applyYaraRules(content, yaraRules, file.path, configRuleScope(file.path));
1217
1272
  findings.push(...configFindings);
1218
1273
  patternsMatched += configFindings.length;
1219
- if (/^README/i.test(file.path)) {
1274
+ if (/^README/i.test(file.path.split("/").pop() ?? file.path)) {
1220
1275
  const socialFindings = detectSocialEngineering(content, file.path);
1221
1276
  findings.push(...socialFindings);
1222
1277
  patternsMatched += socialFindings.length;
@@ -2745,11 +2800,11 @@ function scanReport(result) {
2745
2800
  safeToClone: result.safeToClone && !coverage.unreliableClear
2746
2801
  };
2747
2802
  }
2748
- function describeCoverage(coverage) {
2803
+ function describeCoverage(coverage, findingCount) {
2749
2804
  if (coverage.complete) return "";
2750
2805
  const read = `${coverage.filesRead} ${coverage.filesRead === 1 ? "file" : "files"} read`;
2751
2806
  const counts = coverage.filesUnread > 0 ? `${read}, ${coverage.filesUnread} left unread` : read;
2752
- const consequence = coverage.unreliableClear ? "Nothing was found in what was read \u2014 that is not the same as nothing being there." : "There may be more than what is reported here.";
2807
+ 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
2808
  if (coverage.reason === "rate-limit") {
2754
2809
  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
2810
  }
@@ -2810,7 +2865,7 @@ function renderRepoResult(result) {
2810
2865
  );
2811
2866
  if (!coverage.complete) {
2812
2867
  lines.push("");
2813
- for (const line of wrapNote(describeCoverage(coverage), " ")) lines.push(yellow(line));
2868
+ for (const line of wrapNote(describeCoverage(coverage, result.findings.length), " ")) lines.push(yellow(line));
2814
2869
  }
2815
2870
  for (const f of result.findings) {
2816
2871
  lines.push("");
package/dist/cli.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  scanGitHubUser,
15
15
  scanReport,
16
16
  wantJson
17
- } from "./chunk-B67OPHC4.js";
17
+ } from "./chunk-AJ6RU6CY.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.0";
81
+ var VERSION = "0.6.0";
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-VIZ2IITR.js");
145
+ const { runMcp } = await import("./mcp-DTIELX77.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-B67OPHC4.js";
14
+ } from "./chunk-AJ6RU6CY.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.0" });
45
+ const server = new McpServer({ name: "flagrix", version: "0.5.1" });
46
46
  server.registerTool(
47
47
  "scan_github_repo",
48
48
  {
@@ -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
- (every `git clone` is gated, no cooperation needed).
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). See docs/agent-gating.md
7
- # for the settings.json wiring.
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 from a `git clone`/`gh repo clone` command.
13
- url="$(node -e '
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
- if (!/\b(git\s+clone|gh\s+repo\s+clone)\b/.test(cmd)) return
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) process.stdout.write(String(Array.isArray(m) ? m[0] : 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 "$url" ] && exit 0
51
+ [ -z "$parsed" ] && exit 0
31
52
 
32
- if npx -y flagrix scan "$url" --json > /dev/null 2>&1; then
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 $url" >&2 ;;
38
- 3) echo "Flagrix: HIGH risk — do NOT clone $url (malicious patterns detected). Run: npx flagrix scan $url" >&2 ;;
39
- 4) echo "Flagrix: scan of $url was incomplete — not enough was read to give a verdict (usually GitHub's 60 req/h limit; set GITHUB_TOKEN). Run: npx flagrix scan $url" >&2 ;;
40
- *) echo "Flagrix: scan of $url failed (exit $code) — blocking out of caution. Run: npx flagrix scan $url" >&2 ;;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flagrix",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
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",
@@ -53,7 +53,7 @@
53
53
  "zod": "^3.24.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@flagrix/scanner-core": "^0.6.0",
56
+ "@flagrix/scanner-core": "^0.7.0",
57
57
  "@types/node": "^20.0.0",
58
58
  "tsup": "^8.0.0",
59
59
  "typescript": "^5.0.0",