@upx-us/shield 0.5.38 → 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,4 +1,5 @@
|
|
|
1
1
|
import { RawToolCall, EnrichmentContext } from '../base';
|
|
2
2
|
import { ExecEvent } from './event';
|
|
3
|
+
export declare function detectSecretInCommand(cmd: string): boolean;
|
|
3
4
|
export declare function splitChainedCommands(cmd: string): string[];
|
|
4
5
|
export declare function enrich(tool: RawToolCall, ctx: EnrichmentContext): ExecEvent;
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectSecretInCommand = detectSecretInCommand;
|
|
3
4
|
exports.splitChainedCommands = splitChainedCommands;
|
|
4
5
|
exports.enrich = enrich;
|
|
5
6
|
const base_1 = require("../base");
|
|
7
|
+
const SECRET_KEY_PREFIXES = ['sk-', 'pk_', 'key_', 'ghp_', 'ghs_', 'glpat-', 'xoxb-', 'xoxp-'];
|
|
8
|
+
const SECRET_ENV_PATTERN = /\b[A-Z_]*(SECRET|TOKEN|KEY|PASSWORD|PASSWD|API_KEY|APIKEY)[A-Z_]*=/i;
|
|
9
|
+
const LONG_HEX_BASE64 = /(?:[0-9a-fA-F]{41,}|[A-Za-z0-9+/=]{41,})/;
|
|
10
|
+
const BEARER_PATTERN = /\bBearer\s+\S+/i;
|
|
11
|
+
function detectSecretInCommand(cmd) {
|
|
12
|
+
if (!cmd)
|
|
13
|
+
return false;
|
|
14
|
+
for (const prefix of SECRET_KEY_PREFIXES) {
|
|
15
|
+
if (cmd.includes(prefix))
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (BEARER_PATTERN.test(cmd))
|
|
19
|
+
return true;
|
|
20
|
+
if (SECRET_ENV_PATTERN.test(cmd))
|
|
21
|
+
return true;
|
|
22
|
+
if (LONG_HEX_BASE64.test(cmd))
|
|
23
|
+
return true;
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
6
26
|
function splitChainedCommands(cmd) {
|
|
7
27
|
const segments = [];
|
|
8
28
|
let current = '';
|
|
@@ -74,6 +94,9 @@ function enrich(tool, ctx) {
|
|
|
74
94
|
cmd_has_sudo: /\bsudo\b/.test(cmd),
|
|
75
95
|
cmd_has_pipe: /\|/.test(cmd),
|
|
76
96
|
};
|
|
97
|
+
if (detectSecretInCommand(cmd)) {
|
|
98
|
+
meta['openclaw.secret_in_command'] = 'true';
|
|
99
|
+
}
|
|
77
100
|
for (const segRoot of allRootCommands) {
|
|
78
101
|
if (/^(kill|pkill|killall)$/.test(segRoot)) {
|
|
79
102
|
const pidMatch = cmd.match(/\bkill\s+(?:-\d+\s+)?(\d+)/);
|
|
@@ -19,6 +19,10 @@ function enrich(tool, ctx) {
|
|
|
19
19
|
file_is_system: isSystem,
|
|
20
20
|
file_is_config: ext ? configExts.includes(ext) : false,
|
|
21
21
|
};
|
|
22
|
+
const CONFIG_FILE_PATTERNS = /(?:\.env|config\.json|openclaw\.json|\.npmrc|\.yarnrc|\.gitconfig|settings\.json|docker-compose\.ya?ml|Dockerfile|\.bashrc|\.zshrc|\.profile)(?:$|\/)/;
|
|
23
|
+
if ((toolName === 'write' || toolName === 'edit') && (meta.file_is_config || CONFIG_FILE_PATTERNS.test(fp) || /\/\.env(?:\.|$)/.test(fp))) {
|
|
24
|
+
meta['openclaw.config_change'] = 'true';
|
|
25
|
+
}
|
|
22
26
|
if ((toolName === 'write' || toolName === 'edit') && isMemoryFile) {
|
|
23
27
|
meta.memory_auto_capture = 'true';
|
|
24
28
|
}
|
|
@@ -29,6 +33,9 @@ function enrich(tool, ctx) {
|
|
|
29
33
|
meta.edit_new_length = String(newText.length);
|
|
30
34
|
meta.edit_size_delta = String(newText.length - oldText.length);
|
|
31
35
|
}
|
|
36
|
+
if (toolName === 'write' && args.content) {
|
|
37
|
+
meta['openclaw.file_size_bytes'] = String(Buffer.byteLength(args.content, 'utf8'));
|
|
38
|
+
}
|
|
32
39
|
const event = {
|
|
33
40
|
timestamp: ctx.timestamp,
|
|
34
41
|
event_type: 'TOOL_CALL',
|
|
@@ -10,6 +10,32 @@ function enrich(tool, ctx) {
|
|
|
10
10
|
'openclaw.agent_id': ctx.agentId,
|
|
11
11
|
sub_action: args.action || null,
|
|
12
12
|
};
|
|
13
|
+
if (args.channel)
|
|
14
|
+
meta['openclaw.channel'] = args.channel;
|
|
15
|
+
if (args.target) {
|
|
16
|
+
if (!args.channel) {
|
|
17
|
+
if (/^telegram/i.test(String(args.target)) || /^-?\d{10,}/.test(String(args.target))) {
|
|
18
|
+
meta['openclaw.channel'] = 'telegram';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const targetStr = String(args.target);
|
|
22
|
+
if (targetStr.startsWith('-100'))
|
|
23
|
+
meta['openclaw.chat_type'] = 'group';
|
|
24
|
+
else if (targetStr.startsWith('-'))
|
|
25
|
+
meta['openclaw.chat_type'] = 'group';
|
|
26
|
+
else if (/^\d+$/.test(targetStr))
|
|
27
|
+
meta['openclaw.chat_type'] = 'private';
|
|
28
|
+
}
|
|
29
|
+
if (args.groupId || args.guildId)
|
|
30
|
+
meta['openclaw.chat_type'] = 'group';
|
|
31
|
+
if (args.channelId && !meta['openclaw.chat_type'])
|
|
32
|
+
meta['openclaw.chat_type'] = 'channel';
|
|
33
|
+
if (args.action === 'send' || args.action === 'edit') {
|
|
34
|
+
const content = args.message || args.caption || '';
|
|
35
|
+
if (content) {
|
|
36
|
+
meta['openclaw.message_content'] = content.length > 500 ? content.slice(0, 500) : content;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
13
39
|
if (args.buffer) {
|
|
14
40
|
meta.has_base64_payload = 'true';
|
|
15
41
|
const raw = typeof args.buffer === 'string' ? args.buffer.replace(/^data:[^;]+;base64,/, '') : '';
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED