Skip to content

add skill security scanner with LLM intent review#11

Merged
TangMeng12 merged 1 commit into
open-vela:devfrom
skyxiaobai:sync-4-skill-scanner
May 12, 2026
Merged

add skill security scanner with LLM intent review#11
TangMeng12 merged 1 commit into
open-vela:devfrom
skyxiaobai:sync-4-skill-scanner

Conversation

@skyxiaobai

Copy link
Copy Markdown
Collaborator

Note: Please adhere to Contributing Guidelines.

Summary

Update this section with information on why change is necessary,
what it exactly does and how, if new feature shows up, provide
references (dependencies, similar problems and solutions), etc.

Impact

Update this section, where applicable, on how change affects users,
build process, hardware, documentation, security, compatibility, etc.

Testing

Update this section with details on how did you verify the change,
what Host was used for build (OS, CPU, compiler, ..), what Target was
used for verification (arch, board:config, ..), etc. Providing build
and runtime logs from before and after change is highly appreciated.

Copilot AI review requested due to automatic review settings May 12, 2026 01:52
@skyxiaobai skyxiaobai requested a review from TangMeng12 as a code owner May 12, 2026 01:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces new network-facing capabilities (A2A HTTP endpoints and a XiaoZhi WebSocket channel), consolidates URL parsing into a shared helper, and adds a new Python-based “skill security scanner” script with optional LLM intent review.

Changes:

  • Added shared url_parse() utility and migrated multiple components to use it.
  • Added A2A server/client handler and wired it into the existing ws_server accept path.
  • Added XiaoZhi channel (WSS control + Opus/UDP helpers) and new build/Kconfig knobs; added scripts/skill_security_scan.py.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/tools/tool_fetch_url.c Switch URL parsing to shared url_parse() and reuse parsed host/port/path.
src/tools/mcp_client.c Remove local URL parser; use shared url_parse().
src/infra/url_parse.h New shared URL parser interface.
src/infra/url_parse.c New shared URL parser implementation.
src/infra/a2a_handler.h New A2A protocol handler interface.
src/infra/a2a_handler.c New A2A server/client implementation (HTTP routes + agent invoke bridge).
src/core/agent_mem.h Change heap status reporting behavior under CONFIG_DEBUG_MM.
src/channels/xiaozhi_udp.h New XiaoZhi UDP audio transport interface.
src/channels/xiaozhi_udp.c New XiaoZhi UDP + AES-CTR packet transport implementation.
src/channels/xiaozhi_state.h New XiaoZhi channel state machine definitions.
src/channels/xiaozhi_opus.h New Opus wrapper interface for XiaoZhi.
src/channels/xiaozhi_opus.c New Opus wrapper implementation (real + stub).
src/channels/xiaozhi_channel.h New XiaoZhi WSS channel API.
src/channels/xiaozhi_channel.c New XiaoZhi WSS channel implementation (OTA config fetch + reconnect).
src/channels/ws_server.c Route initial HTTP traffic to A2A handler before WS upgrade.
src/channels/weixin_channel.c Use shared url_parse() for base URL host extraction.
src/channels/nsh_commands.c Add CLI command to set XiaoZhi OTA endpoint.
src/channels/feishu_http.c Use shared url_parse() for WS URL parsing.
src/channels/cmd_llm.c Use shared url_parse() for URL-based LLM backend config.
src/agent_main.c Initialize/start/stop XiaoZhi channel when enabled.
scripts/skill_security_scan.py New skill security scanning tool (static + optional LLM intent review).
Kconfig Add new config toggles (BLE options, XiaoZhi channel).
include/agent_config.h Add XiaoZhi config keys.
CMakeLists.txt Add new sources; add conditional BLE/XiaoZhi source lists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +207 to +215
if (url_parse(s_ws_url, &ws_parsed) != 0) {
syslog(LOG_ERR, "[%s] Invalid WS URL: %s\n", TAG, s_ws_url);
return -EINVAL;
}

memcpy(s_ws_host, ws_parsed.host, sizeof(s_ws_host));
memcpy(s_ws_port, ws_parsed.port, sizeof(s_ws_port));
memcpy(s_ws_path, ws_parsed.path, sizeof(s_ws_path));

Comment on lines +216 to +217
syslog(LOG_INFO, "[%s] OTA OK: ws=%s token=%.20s...\n",
TAG, s_ws_url, s_ws_token);
Comment thread src/infra/a2a_handler.c
Comment on lines +143 to +150
static void a2a_tap_cb(const agent_msg_t *msg, void *cookie)
{
a2a_invoke_ctx_t *ctx = (a2a_invoke_ctx_t *)cookie;
if (ctx->done) return; /* caller already timed out and moved on */
if (msg->content)
ctx->response = strdup(msg->content);
sem_post(&ctx->sem);
}
Comment thread src/core/agent_mem.h
Comment on lines +55 to +68
st->total_heap = 128 * 1024 * 1024;
st->free_heap = 128 * 1024 * 1024;
st->largest_block = 64 * 1024 * 1024;

#if !defined(CONFIG_DEBUG_MM)
/* Only call mallinfo when heap debug assertions are disabled,
* because CONFIG_DEBUG_MM enables strict node validation in
* mm_foreach that can assert on edge cases (e.g. tmpfs-only boot) */
struct mallinfo mi = mallinfo();
st->total_heap = mi.arena;
st->free_heap = mi.fordblks;
st->largest_block = mi.fordblks; /* conservative estimate */
if (mi.arena > 0) {
st->total_heap = mi.arena;
st->free_heap = mi.fordblks;
st->largest_block = mi.fordblks;
}
Comment thread CMakeLists.txt
Comment on lines +129 to +133
list(APPEND AGENT_SRCS src/infra/ble_gatt.c)
endif()

if(CONFIG_AI_AGENT_BLE_NET)
list(APPEND AGENT_SRCS src/infra/ble_net.c)
uint8_t* opus_out, size_t opus_cap,
uint32_t* out_sequence)
{
if (sockfd < 0 || !aes || !opus_out)
Comment on lines +102 to +107

mbedtls_aes_init(&ctx->aes);
int ret = mbedtls_aes_setkey_enc(&ctx->aes, key, 128);
if (ret != 0) {
syslog(LOG_ERR, "[%s] aes_setkey_enc failed: -0x%04x\n",
TAG, (unsigned)-ret);
Comment thread src/infra/url_parse.h
Comment on lines +17 to +19
#ifndef __URL_PARSE_H__
#define __URL_PARSE_H__

Comment thread src/infra/a2a_handler.h
Comment on lines +17 to +19
#ifndef __A2A_HANDLER_H__
#define __A2A_HANDLER_H__

Comment thread src/channels/ws_server.c
Comment on lines +368 to +378
/* Peek HTTP headers to decide: A2A HTTP or WebSocket upgrade */
char peek_buf[2048];
int peek_total = 0;
while (peek_total < (int)sizeof(peek_buf) - 1) {
int n = recv(fd, peek_buf + peek_total,
sizeof(peek_buf) - 1 - peek_total, 0);
if (n <= 0) { close(fd); return NULL; }
peek_total += n;
peek_buf[peek_total] = '\0';
if (strstr(peek_buf, "\r\n\r\n")) break;
}
Static analysis + LLM-assisted security scanner for agent_skills.
Detects dangerous tool usage, prompt injection, credential extraction,
data exfiltration, and stealth instructions in skill markdown files.

Features:
- Tool risk scoring tailored to embedded device capabilities
- Regex hard gates (critical findings cannot be overridden by LLM)
- LLM intent review (--llm-review) to reduce false positives
- Baseline diff mode (--baseline) for CI incremental scanning
- 3-level disposition: pass / review / block

Usage: python3 scripts/skill_security_scan.py [--llm-review] [--ci]

Signed-off-by: zhouwenjie1 <zhouwenjie1@xiaomi.com>
@skyxiaobai skyxiaobai force-pushed the sync-4-skill-scanner branch from c3b839e to 83d863c Compare May 12, 2026 02:40
@TangMeng12 TangMeng12 merged commit 6a5543c into open-vela:dev May 12, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants