@kenhkl/agent-moss 0.17.29 → 0.17.30
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/dist/cli.js +20 -2
- package/dist/engine/coordinator.js +20 -2
- package/dist/server.js +20 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -5667,6 +5667,22 @@ function splitCommandSegments2(actionDetail) {
|
|
|
5667
5667
|
if (start < actionDetail.length) segments.push(actionDetail.slice(start));
|
|
5668
5668
|
return segments;
|
|
5669
5669
|
}
|
|
5670
|
+
function stripSearchPatternLiterals(actionDetail) {
|
|
5671
|
+
const parts = [];
|
|
5672
|
+
for (const seg of splitCommandSegments2(actionDetail)) {
|
|
5673
|
+
const low = seg.trim().toLowerCase();
|
|
5674
|
+
const words = low.length ? low.split(/\s+/) : [];
|
|
5675
|
+
let idx = 0;
|
|
5676
|
+
while (idx < words.length && COMMAND_PREFIX_WORDS.has(words[idx])) idx++;
|
|
5677
|
+
const isSearch = idx < words.length && TEXT_SEARCH_COMMANDS.has(words[idx]);
|
|
5678
|
+
if (isSearch && !low.includes("--pre")) {
|
|
5679
|
+
parts.push(seg.replace(/'[^']*'|"[^"]*"/g, " "));
|
|
5680
|
+
} else {
|
|
5681
|
+
parts.push(seg);
|
|
5682
|
+
}
|
|
5683
|
+
}
|
|
5684
|
+
return parts.join("");
|
|
5685
|
+
}
|
|
5670
5686
|
function severityRank(s) {
|
|
5671
5687
|
const ranks = { low: 1, medium: 2, high: 3, critical: 4 };
|
|
5672
5688
|
return ranks[s] || 0;
|
|
@@ -5962,7 +5978,7 @@ function isSshKeygenGenerate(command) {
|
|
|
5962
5978
|
}
|
|
5963
5979
|
function checkDangerousPatterns(actionType, actionDetail) {
|
|
5964
5980
|
if (actionType === "file_write" || actionType === "file_edit") return null;
|
|
5965
|
-
const scan = stripHeredocContent(stripShellDocsOnly(actionDetail));
|
|
5981
|
+
const scan = stripSearchPatternLiterals(stripHeredocContent(stripShellDocsOnly(actionDetail)));
|
|
5966
5982
|
const isTempPath = TEMP_DIRS2.some(
|
|
5967
5983
|
(td) => new RegExp(`(?:^|[\\s/])${td.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:[\\s/]|$)`).test(actionDetail)
|
|
5968
5984
|
) || /(?:^|[\s;]|&&\s*|\|\|\s*)var\/tmp(?:[/\s;]|$)/.test(actionDetail);
|
|
@@ -6109,7 +6125,7 @@ function checkLateralMovement(actionDetail) {
|
|
|
6109
6125
|
}
|
|
6110
6126
|
return null;
|
|
6111
6127
|
}
|
|
6112
|
-
var INJECTION_KEYWORDS, DANGEROUS_PATTERNS2, DANGEROUS_PATTERNS_WINDOWS, DANGEROUS_PATTERNS_MACOS, DANGEROUS_PATTERNS_HARMONY, LOOPBACK_URL_RE, HEURISTIC_RULES, LOOPBACK_HOSTS, TEMP_DIRS2, PATH_CONTEXT_TRIGGER_RE, HOME_PREFIX_RE, PY_EXEC_IO_RE, PY_PRINT_RE, PY_BIGNUM_RE, PY_INLINE_C_RE, PY_CMD_SUBST_C_RE, QUOTED_SAFE_PASSWORD_PATTERN_SOURCES, COMMAND_SEGMENT_TOKEN_RE, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
6128
|
+
var INJECTION_KEYWORDS, DANGEROUS_PATTERNS2, DANGEROUS_PATTERNS_WINDOWS, DANGEROUS_PATTERNS_MACOS, DANGEROUS_PATTERNS_HARMONY, LOOPBACK_URL_RE, HEURISTIC_RULES, LOOPBACK_HOSTS, TEMP_DIRS2, PATH_CONTEXT_TRIGGER_RE, HOME_PREFIX_RE, PY_EXEC_IO_RE, PY_PRINT_RE, PY_BIGNUM_RE, PY_INLINE_C_RE, PY_CMD_SUBST_C_RE, QUOTED_SAFE_PASSWORD_PATTERN_SOURCES, COMMAND_SEGMENT_TOKEN_RE, TEXT_SEARCH_COMMANDS, COMMAND_PREFIX_WORDS, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
6113
6129
|
var init_heuristic = __esm({
|
|
6114
6130
|
"src/engine/heuristic.ts"() {
|
|
6115
6131
|
"use strict";
|
|
@@ -6152,6 +6168,8 @@ var init_heuristic = __esm({
|
|
|
6152
6168
|
"\\bchpasswd\\b"
|
|
6153
6169
|
]);
|
|
6154
6170
|
COMMAND_SEGMENT_TOKEN_RE = /['";\n]|&&|\|\|/g;
|
|
6171
|
+
TEXT_SEARCH_COMMANDS = /* @__PURE__ */ new Set(["grep", "egrep", "fgrep", "rg", "ag", "ack", "ack-grep"]);
|
|
6172
|
+
COMMAND_PREFIX_WORDS = /* @__PURE__ */ new Set(["sudo", "command", "nohup", "time"]);
|
|
6155
6173
|
SENSITIVE_EXCLUDED_PREFIXES = HEURISTIC_RULES.sensitive_excluded_prefixes ?? [];
|
|
6156
6174
|
SEARCH_ACTION_PREFIXES = HEURISTIC_RULES.search_action_prefixes ?? [];
|
|
6157
6175
|
SEARCH_ACTION_EXACT = HEURISTIC_RULES.search_action_exact ?? [];
|
|
@@ -4826,6 +4826,22 @@ function splitCommandSegments2(actionDetail) {
|
|
|
4826
4826
|
if (start < actionDetail.length) segments.push(actionDetail.slice(start));
|
|
4827
4827
|
return segments;
|
|
4828
4828
|
}
|
|
4829
|
+
function stripSearchPatternLiterals(actionDetail) {
|
|
4830
|
+
const parts = [];
|
|
4831
|
+
for (const seg of splitCommandSegments2(actionDetail)) {
|
|
4832
|
+
const low = seg.trim().toLowerCase();
|
|
4833
|
+
const words = low.length ? low.split(/\s+/) : [];
|
|
4834
|
+
let idx = 0;
|
|
4835
|
+
while (idx < words.length && COMMAND_PREFIX_WORDS.has(words[idx])) idx++;
|
|
4836
|
+
const isSearch = idx < words.length && TEXT_SEARCH_COMMANDS.has(words[idx]);
|
|
4837
|
+
if (isSearch && !low.includes("--pre")) {
|
|
4838
|
+
parts.push(seg.replace(/'[^']*'|"[^"]*"/g, " "));
|
|
4839
|
+
} else {
|
|
4840
|
+
parts.push(seg);
|
|
4841
|
+
}
|
|
4842
|
+
}
|
|
4843
|
+
return parts.join("");
|
|
4844
|
+
}
|
|
4829
4845
|
function severityRank(s) {
|
|
4830
4846
|
const ranks = { low: 1, medium: 2, high: 3, critical: 4 };
|
|
4831
4847
|
return ranks[s] || 0;
|
|
@@ -5121,7 +5137,7 @@ function isSshKeygenGenerate(command) {
|
|
|
5121
5137
|
}
|
|
5122
5138
|
function checkDangerousPatterns(actionType, actionDetail) {
|
|
5123
5139
|
if (actionType === "file_write" || actionType === "file_edit") return null;
|
|
5124
|
-
const scan = stripHeredocContent(stripShellDocsOnly(actionDetail));
|
|
5140
|
+
const scan = stripSearchPatternLiterals(stripHeredocContent(stripShellDocsOnly(actionDetail)));
|
|
5125
5141
|
const isTempPath = TEMP_DIRS2.some(
|
|
5126
5142
|
(td) => new RegExp(`(?:^|[\\s/])${td.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:[\\s/]|$)`).test(actionDetail)
|
|
5127
5143
|
) || /(?:^|[\s;]|&&\s*|\|\|\s*)var\/tmp(?:[/\s;]|$)/.test(actionDetail);
|
|
@@ -5268,7 +5284,7 @@ function checkLateralMovement(actionDetail) {
|
|
|
5268
5284
|
}
|
|
5269
5285
|
return null;
|
|
5270
5286
|
}
|
|
5271
|
-
var INJECTION_KEYWORDS, DANGEROUS_PATTERNS2, DANGEROUS_PATTERNS_WINDOWS, DANGEROUS_PATTERNS_MACOS, DANGEROUS_PATTERNS_HARMONY, LOOPBACK_URL_RE, HEURISTIC_RULES, LOOPBACK_HOSTS, TEMP_DIRS2, PATH_CONTEXT_TRIGGER_RE, HOME_PREFIX_RE, PY_EXEC_IO_RE, PY_PRINT_RE, PY_BIGNUM_RE, PY_INLINE_C_RE, PY_CMD_SUBST_C_RE, QUOTED_SAFE_PASSWORD_PATTERN_SOURCES, COMMAND_SEGMENT_TOKEN_RE, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
5287
|
+
var INJECTION_KEYWORDS, DANGEROUS_PATTERNS2, DANGEROUS_PATTERNS_WINDOWS, DANGEROUS_PATTERNS_MACOS, DANGEROUS_PATTERNS_HARMONY, LOOPBACK_URL_RE, HEURISTIC_RULES, LOOPBACK_HOSTS, TEMP_DIRS2, PATH_CONTEXT_TRIGGER_RE, HOME_PREFIX_RE, PY_EXEC_IO_RE, PY_PRINT_RE, PY_BIGNUM_RE, PY_INLINE_C_RE, PY_CMD_SUBST_C_RE, QUOTED_SAFE_PASSWORD_PATTERN_SOURCES, COMMAND_SEGMENT_TOKEN_RE, TEXT_SEARCH_COMMANDS, COMMAND_PREFIX_WORDS, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
5272
5288
|
var init_heuristic = __esm({
|
|
5273
5289
|
"src/engine/heuristic.ts"() {
|
|
5274
5290
|
"use strict";
|
|
@@ -5311,6 +5327,8 @@ var init_heuristic = __esm({
|
|
|
5311
5327
|
"\\bchpasswd\\b"
|
|
5312
5328
|
]);
|
|
5313
5329
|
COMMAND_SEGMENT_TOKEN_RE = /['";\n]|&&|\|\|/g;
|
|
5330
|
+
TEXT_SEARCH_COMMANDS = /* @__PURE__ */ new Set(["grep", "egrep", "fgrep", "rg", "ag", "ack", "ack-grep"]);
|
|
5331
|
+
COMMAND_PREFIX_WORDS = /* @__PURE__ */ new Set(["sudo", "command", "nohup", "time"]);
|
|
5314
5332
|
SENSITIVE_EXCLUDED_PREFIXES = HEURISTIC_RULES.sensitive_excluded_prefixes ?? [];
|
|
5315
5333
|
SEARCH_ACTION_PREFIXES = HEURISTIC_RULES.search_action_prefixes ?? [];
|
|
5316
5334
|
SEARCH_ACTION_EXACT = HEURISTIC_RULES.search_action_exact ?? [];
|
package/dist/server.js
CHANGED
|
@@ -5357,6 +5357,22 @@ function splitCommandSegments2(actionDetail) {
|
|
|
5357
5357
|
if (start < actionDetail.length) segments.push(actionDetail.slice(start));
|
|
5358
5358
|
return segments;
|
|
5359
5359
|
}
|
|
5360
|
+
function stripSearchPatternLiterals(actionDetail) {
|
|
5361
|
+
const parts = [];
|
|
5362
|
+
for (const seg of splitCommandSegments2(actionDetail)) {
|
|
5363
|
+
const low = seg.trim().toLowerCase();
|
|
5364
|
+
const words = low.length ? low.split(/\s+/) : [];
|
|
5365
|
+
let idx = 0;
|
|
5366
|
+
while (idx < words.length && COMMAND_PREFIX_WORDS.has(words[idx])) idx++;
|
|
5367
|
+
const isSearch = idx < words.length && TEXT_SEARCH_COMMANDS.has(words[idx]);
|
|
5368
|
+
if (isSearch && !low.includes("--pre")) {
|
|
5369
|
+
parts.push(seg.replace(/'[^']*'|"[^"]*"/g, " "));
|
|
5370
|
+
} else {
|
|
5371
|
+
parts.push(seg);
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
return parts.join("");
|
|
5375
|
+
}
|
|
5360
5376
|
function severityRank(s) {
|
|
5361
5377
|
const ranks = { low: 1, medium: 2, high: 3, critical: 4 };
|
|
5362
5378
|
return ranks[s] || 0;
|
|
@@ -5652,7 +5668,7 @@ function isSshKeygenGenerate(command) {
|
|
|
5652
5668
|
}
|
|
5653
5669
|
function checkDangerousPatterns(actionType, actionDetail) {
|
|
5654
5670
|
if (actionType === "file_write" || actionType === "file_edit") return null;
|
|
5655
|
-
const scan = stripHeredocContent(stripShellDocsOnly(actionDetail));
|
|
5671
|
+
const scan = stripSearchPatternLiterals(stripHeredocContent(stripShellDocsOnly(actionDetail)));
|
|
5656
5672
|
const isTempPath = TEMP_DIRS2.some(
|
|
5657
5673
|
(td) => new RegExp(`(?:^|[\\s/])${td.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?:[\\s/]|$)`).test(actionDetail)
|
|
5658
5674
|
) || /(?:^|[\s;]|&&\s*|\|\|\s*)var\/tmp(?:[/\s;]|$)/.test(actionDetail);
|
|
@@ -5799,7 +5815,7 @@ function checkLateralMovement(actionDetail) {
|
|
|
5799
5815
|
}
|
|
5800
5816
|
return null;
|
|
5801
5817
|
}
|
|
5802
|
-
var INJECTION_KEYWORDS, DANGEROUS_PATTERNS2, DANGEROUS_PATTERNS_WINDOWS, DANGEROUS_PATTERNS_MACOS, DANGEROUS_PATTERNS_HARMONY, LOOPBACK_URL_RE, HEURISTIC_RULES, LOOPBACK_HOSTS, TEMP_DIRS2, PATH_CONTEXT_TRIGGER_RE, HOME_PREFIX_RE, PY_EXEC_IO_RE, PY_PRINT_RE, PY_BIGNUM_RE, PY_INLINE_C_RE, PY_CMD_SUBST_C_RE, QUOTED_SAFE_PASSWORD_PATTERN_SOURCES, COMMAND_SEGMENT_TOKEN_RE, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
5818
|
+
var INJECTION_KEYWORDS, DANGEROUS_PATTERNS2, DANGEROUS_PATTERNS_WINDOWS, DANGEROUS_PATTERNS_MACOS, DANGEROUS_PATTERNS_HARMONY, LOOPBACK_URL_RE, HEURISTIC_RULES, LOOPBACK_HOSTS, TEMP_DIRS2, PATH_CONTEXT_TRIGGER_RE, HOME_PREFIX_RE, PY_EXEC_IO_RE, PY_PRINT_RE, PY_BIGNUM_RE, PY_INLINE_C_RE, PY_CMD_SUBST_C_RE, QUOTED_SAFE_PASSWORD_PATTERN_SOURCES, COMMAND_SEGMENT_TOKEN_RE, TEXT_SEARCH_COMMANDS, COMMAND_PREFIX_WORDS, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
5803
5819
|
var init_heuristic = __esm({
|
|
5804
5820
|
"src/engine/heuristic.ts"() {
|
|
5805
5821
|
"use strict";
|
|
@@ -5842,6 +5858,8 @@ var init_heuristic = __esm({
|
|
|
5842
5858
|
"\\bchpasswd\\b"
|
|
5843
5859
|
]);
|
|
5844
5860
|
COMMAND_SEGMENT_TOKEN_RE = /['";\n]|&&|\|\|/g;
|
|
5861
|
+
TEXT_SEARCH_COMMANDS = /* @__PURE__ */ new Set(["grep", "egrep", "fgrep", "rg", "ag", "ack", "ack-grep"]);
|
|
5862
|
+
COMMAND_PREFIX_WORDS = /* @__PURE__ */ new Set(["sudo", "command", "nohup", "time"]);
|
|
5845
5863
|
SENSITIVE_EXCLUDED_PREFIXES = HEURISTIC_RULES.sensitive_excluded_prefixes ?? [];
|
|
5846
5864
|
SEARCH_ACTION_PREFIXES = HEURISTIC_RULES.search_action_prefixes ?? [];
|
|
5847
5865
|
SEARCH_ACTION_EXACT = HEURISTIC_RULES.search_action_exact ?? [];
|