@kenhkl/agent-moss 0.17.19 → 0.17.20
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 -35
- package/dist/engine/coordinator.js +20 -35
- package/dist/server.js +20 -35
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4916,6 +4916,9 @@ function stripHeredocContent(actionDetail) {
|
|
|
4916
4916
|
);
|
|
4917
4917
|
}
|
|
4918
4918
|
function normalizePathSegments(text, foldQuotes = false) {
|
|
4919
|
+
if (!text.includes("//") && !text.includes("/./") && !text.includes("Q") && !text.includes("PROT")) {
|
|
4920
|
+
return text;
|
|
4921
|
+
}
|
|
4919
4922
|
const protTokens = [];
|
|
4920
4923
|
let t = text.replace(/\b(https?|ftp|file):\/\//gi, (m) => {
|
|
4921
4924
|
const scheme = m.slice(0, m.indexOf(":"));
|
|
@@ -4946,43 +4949,24 @@ function pathScanVariants(actionDetailLower) {
|
|
|
4946
4949
|
}
|
|
4947
4950
|
function splitCommandSegments2(actionDetail) {
|
|
4948
4951
|
const segments = [];
|
|
4949
|
-
let
|
|
4950
|
-
let
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
cur += ch;
|
|
4961
|
-
continue;
|
|
4962
|
-
}
|
|
4963
|
-
if (ch === ";" || ch === "\n") {
|
|
4964
|
-
segments.push(cur);
|
|
4965
|
-
segments.push(ch);
|
|
4966
|
-
cur = "";
|
|
4967
|
-
continue;
|
|
4968
|
-
}
|
|
4969
|
-
if (ch === "&" && actionDetail[i + 1] === "&") {
|
|
4970
|
-
segments.push(cur);
|
|
4971
|
-
segments.push("&&");
|
|
4972
|
-
cur = "";
|
|
4973
|
-
i++;
|
|
4952
|
+
let start = 0;
|
|
4953
|
+
let cursor = 0;
|
|
4954
|
+
while (true) {
|
|
4955
|
+
COMMAND_SEGMENT_TOKEN_RE.lastIndex = cursor;
|
|
4956
|
+
const match = COMMAND_SEGMENT_TOKEN_RE.exec(actionDetail);
|
|
4957
|
+
if (!match) break;
|
|
4958
|
+
const token = match[0];
|
|
4959
|
+
if (token === "'" || token === '"') {
|
|
4960
|
+
const end = actionDetail.indexOf(token, match.index + 1);
|
|
4961
|
+
if (end < 0) break;
|
|
4962
|
+
cursor = end + 1;
|
|
4974
4963
|
continue;
|
|
4975
4964
|
}
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
cur = "";
|
|
4980
|
-
i++;
|
|
4981
|
-
continue;
|
|
4982
|
-
}
|
|
4983
|
-
cur += ch;
|
|
4965
|
+
segments.push(actionDetail.slice(start, match.index));
|
|
4966
|
+
segments.push(token);
|
|
4967
|
+
start = cursor = match.index + token.length;
|
|
4984
4968
|
}
|
|
4985
|
-
if (
|
|
4969
|
+
if (start < actionDetail.length) segments.push(actionDetail.slice(start));
|
|
4986
4970
|
return segments;
|
|
4987
4971
|
}
|
|
4988
4972
|
function severityRank(s) {
|
|
@@ -5427,7 +5411,7 @@ function checkLateralMovement(actionDetail) {
|
|
|
5427
5411
|
}
|
|
5428
5412
|
return null;
|
|
5429
5413
|
}
|
|
5430
|
-
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, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
5414
|
+
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;
|
|
5431
5415
|
var init_heuristic = __esm({
|
|
5432
5416
|
"src/engine/heuristic.ts"() {
|
|
5433
5417
|
"use strict";
|
|
@@ -5468,6 +5452,7 @@ var init_heuristic = __esm({
|
|
|
5468
5452
|
"\\bpasswd\\s+--stdin\\b",
|
|
5469
5453
|
"\\bchpasswd\\b"
|
|
5470
5454
|
]);
|
|
5455
|
+
COMMAND_SEGMENT_TOKEN_RE = /['";\n]|&&|\|\|/g;
|
|
5471
5456
|
SENSITIVE_EXCLUDED_PREFIXES = HEURISTIC_RULES.sensitive_excluded_prefixes ?? [];
|
|
5472
5457
|
SEARCH_ACTION_PREFIXES = HEURISTIC_RULES.search_action_prefixes ?? [];
|
|
5473
5458
|
SEARCH_ACTION_EXACT = HEURISTIC_RULES.search_action_exact ?? [];
|
|
@@ -4086,6 +4086,9 @@ function stripHeredocContent(actionDetail) {
|
|
|
4086
4086
|
);
|
|
4087
4087
|
}
|
|
4088
4088
|
function normalizePathSegments(text, foldQuotes = false) {
|
|
4089
|
+
if (!text.includes("//") && !text.includes("/./") && !text.includes("Q") && !text.includes("PROT")) {
|
|
4090
|
+
return text;
|
|
4091
|
+
}
|
|
4089
4092
|
const protTokens = [];
|
|
4090
4093
|
let t = text.replace(/\b(https?|ftp|file):\/\//gi, (m) => {
|
|
4091
4094
|
const scheme = m.slice(0, m.indexOf(":"));
|
|
@@ -4116,43 +4119,24 @@ function pathScanVariants(actionDetailLower) {
|
|
|
4116
4119
|
}
|
|
4117
4120
|
function splitCommandSegments2(actionDetail) {
|
|
4118
4121
|
const segments = [];
|
|
4119
|
-
let
|
|
4120
|
-
let
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
cur += ch;
|
|
4131
|
-
continue;
|
|
4132
|
-
}
|
|
4133
|
-
if (ch === ";" || ch === "\n") {
|
|
4134
|
-
segments.push(cur);
|
|
4135
|
-
segments.push(ch);
|
|
4136
|
-
cur = "";
|
|
4137
|
-
continue;
|
|
4138
|
-
}
|
|
4139
|
-
if (ch === "&" && actionDetail[i + 1] === "&") {
|
|
4140
|
-
segments.push(cur);
|
|
4141
|
-
segments.push("&&");
|
|
4142
|
-
cur = "";
|
|
4143
|
-
i++;
|
|
4122
|
+
let start = 0;
|
|
4123
|
+
let cursor = 0;
|
|
4124
|
+
while (true) {
|
|
4125
|
+
COMMAND_SEGMENT_TOKEN_RE.lastIndex = cursor;
|
|
4126
|
+
const match = COMMAND_SEGMENT_TOKEN_RE.exec(actionDetail);
|
|
4127
|
+
if (!match) break;
|
|
4128
|
+
const token = match[0];
|
|
4129
|
+
if (token === "'" || token === '"') {
|
|
4130
|
+
const end = actionDetail.indexOf(token, match.index + 1);
|
|
4131
|
+
if (end < 0) break;
|
|
4132
|
+
cursor = end + 1;
|
|
4144
4133
|
continue;
|
|
4145
4134
|
}
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
cur = "";
|
|
4150
|
-
i++;
|
|
4151
|
-
continue;
|
|
4152
|
-
}
|
|
4153
|
-
cur += ch;
|
|
4135
|
+
segments.push(actionDetail.slice(start, match.index));
|
|
4136
|
+
segments.push(token);
|
|
4137
|
+
start = cursor = match.index + token.length;
|
|
4154
4138
|
}
|
|
4155
|
-
if (
|
|
4139
|
+
if (start < actionDetail.length) segments.push(actionDetail.slice(start));
|
|
4156
4140
|
return segments;
|
|
4157
4141
|
}
|
|
4158
4142
|
function severityRank(s) {
|
|
@@ -4597,7 +4581,7 @@ function checkLateralMovement(actionDetail) {
|
|
|
4597
4581
|
}
|
|
4598
4582
|
return null;
|
|
4599
4583
|
}
|
|
4600
|
-
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, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
4584
|
+
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;
|
|
4601
4585
|
var init_heuristic = __esm({
|
|
4602
4586
|
"src/engine/heuristic.ts"() {
|
|
4603
4587
|
"use strict";
|
|
@@ -4638,6 +4622,7 @@ var init_heuristic = __esm({
|
|
|
4638
4622
|
"\\bpasswd\\s+--stdin\\b",
|
|
4639
4623
|
"\\bchpasswd\\b"
|
|
4640
4624
|
]);
|
|
4625
|
+
COMMAND_SEGMENT_TOKEN_RE = /['";\n]|&&|\|\|/g;
|
|
4641
4626
|
SENSITIVE_EXCLUDED_PREFIXES = HEURISTIC_RULES.sensitive_excluded_prefixes ?? [];
|
|
4642
4627
|
SEARCH_ACTION_PREFIXES = HEURISTIC_RULES.search_action_prefixes ?? [];
|
|
4643
4628
|
SEARCH_ACTION_EXACT = HEURISTIC_RULES.search_action_exact ?? [];
|
package/dist/server.js
CHANGED
|
@@ -4624,6 +4624,9 @@ function stripHeredocContent(actionDetail) {
|
|
|
4624
4624
|
);
|
|
4625
4625
|
}
|
|
4626
4626
|
function normalizePathSegments(text, foldQuotes = false) {
|
|
4627
|
+
if (!text.includes("//") && !text.includes("/./") && !text.includes("Q") && !text.includes("PROT")) {
|
|
4628
|
+
return text;
|
|
4629
|
+
}
|
|
4627
4630
|
const protTokens = [];
|
|
4628
4631
|
let t = text.replace(/\b(https?|ftp|file):\/\//gi, (m) => {
|
|
4629
4632
|
const scheme = m.slice(0, m.indexOf(":"));
|
|
@@ -4654,43 +4657,24 @@ function pathScanVariants(actionDetailLower) {
|
|
|
4654
4657
|
}
|
|
4655
4658
|
function splitCommandSegments2(actionDetail) {
|
|
4656
4659
|
const segments = [];
|
|
4657
|
-
let
|
|
4658
|
-
let
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
cur += ch;
|
|
4669
|
-
continue;
|
|
4670
|
-
}
|
|
4671
|
-
if (ch === ";" || ch === "\n") {
|
|
4672
|
-
segments.push(cur);
|
|
4673
|
-
segments.push(ch);
|
|
4674
|
-
cur = "";
|
|
4675
|
-
continue;
|
|
4676
|
-
}
|
|
4677
|
-
if (ch === "&" && actionDetail[i + 1] === "&") {
|
|
4678
|
-
segments.push(cur);
|
|
4679
|
-
segments.push("&&");
|
|
4680
|
-
cur = "";
|
|
4681
|
-
i++;
|
|
4660
|
+
let start = 0;
|
|
4661
|
+
let cursor = 0;
|
|
4662
|
+
while (true) {
|
|
4663
|
+
COMMAND_SEGMENT_TOKEN_RE.lastIndex = cursor;
|
|
4664
|
+
const match = COMMAND_SEGMENT_TOKEN_RE.exec(actionDetail);
|
|
4665
|
+
if (!match) break;
|
|
4666
|
+
const token = match[0];
|
|
4667
|
+
if (token === "'" || token === '"') {
|
|
4668
|
+
const end = actionDetail.indexOf(token, match.index + 1);
|
|
4669
|
+
if (end < 0) break;
|
|
4670
|
+
cursor = end + 1;
|
|
4682
4671
|
continue;
|
|
4683
4672
|
}
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
cur = "";
|
|
4688
|
-
i++;
|
|
4689
|
-
continue;
|
|
4690
|
-
}
|
|
4691
|
-
cur += ch;
|
|
4673
|
+
segments.push(actionDetail.slice(start, match.index));
|
|
4674
|
+
segments.push(token);
|
|
4675
|
+
start = cursor = match.index + token.length;
|
|
4692
4676
|
}
|
|
4693
|
-
if (
|
|
4677
|
+
if (start < actionDetail.length) segments.push(actionDetail.slice(start));
|
|
4694
4678
|
return segments;
|
|
4695
4679
|
}
|
|
4696
4680
|
function severityRank(s) {
|
|
@@ -5135,7 +5119,7 @@ function checkLateralMovement(actionDetail) {
|
|
|
5135
5119
|
}
|
|
5136
5120
|
return null;
|
|
5137
5121
|
}
|
|
5138
|
-
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, SENSITIVE_EXCLUDED_PREFIXES, SEARCH_ACTION_PREFIXES, SEARCH_ACTION_EXACT, HOME_TARGET_RE, HOME_ASSIGN_RE;
|
|
5122
|
+
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;
|
|
5139
5123
|
var init_heuristic = __esm({
|
|
5140
5124
|
"src/engine/heuristic.ts"() {
|
|
5141
5125
|
"use strict";
|
|
@@ -5176,6 +5160,7 @@ var init_heuristic = __esm({
|
|
|
5176
5160
|
"\\bpasswd\\s+--stdin\\b",
|
|
5177
5161
|
"\\bchpasswd\\b"
|
|
5178
5162
|
]);
|
|
5163
|
+
COMMAND_SEGMENT_TOKEN_RE = /['";\n]|&&|\|\|/g;
|
|
5179
5164
|
SENSITIVE_EXCLUDED_PREFIXES = HEURISTIC_RULES.sensitive_excluded_prefixes ?? [];
|
|
5180
5165
|
SEARCH_ACTION_PREFIXES = HEURISTIC_RULES.search_action_prefixes ?? [];
|
|
5181
5166
|
SEARCH_ACTION_EXACT = HEURISTIC_RULES.search_action_exact ?? [];
|