Skill: jianmo1997/shuyan-data-classification (version 1.0.1)

--- name: shuyan-data-classification description: "数安云智数据分类分级同步接口 - 用于批量处理字段信息的分类分级。支持敏感数据识别、数据分类、数据分级等功能。使用前需配置API地址和认证密钥。" homepage: https://localhost:8080 author: tanluzhe license: MIT version: "1.0.0" metadata: { "openclaw": { "emoji": "🔒", "requires": { "bins": ["curl"] }, "primaryEnv": "SHUYAN_API_KEY" }, } --- # 数安云智数据分类分级同步接口 这是一个用于批量处理字段信息分类分级的同步接口服务。 ## 接口信息 - **接口地址**: http://localhost:8080/api/llm_infer_zh_and_cls_and_type_v2_batchdata_sync - **认证方式**: Bearer Token - **Content-Type**: application/json ## 环境变量配置 ### 方式一：环境变量 ```bash # ~/.zshrc export SHUYAN_API_KEY="your-api-key-here" export SHUYAN_API_URL="http://localhost:8080" ``` ### 方式二：OpenClaw配置 在 `~/.openclaw/openclaw.json` 中配置： ```json { "skills": { "entries": { "shuyan-data-classification": { "enabled": true, "apiKey": "your-api-key-here", "apiUrl": "http://localhost:8080" } } } } ``` ## 使用场景 ✅ **USE this skill when:** - 需要对数据库字段进行敏感数据分类 - 需要识别数据敏感级别 - 需要批量处理数据分类分级 - 需要获取分类理由和置信度 ❌ **DON'T use this skill when:** - 单个字段的实时查询（效率较低） - 历史数据分析 ## 请求格式 ### 请求参数说明 | 字段名 | 类型 | 必填 | 描述 | |--------|------|------|------| | colNameCh | string | 否 | 字段中文名 | | colNameComment | string | 否 | 字段含义 | | colNameEn | string | 否 | 字段英文名 | | projectName | string | 否 | 业务系统 | | sampleList | array | 否 | 字段样例 | | sizeInBytes | integer | 否 | 数据大小（字节） | | standardCode | string | 是 | 分类标准代码 | | tableNameCh | string | 否 | 表中文名 | | tableNameEn | string | 否 | 表英文名 | | sensitivityLevelRedisKey | string | 否 | 分级标准代码 | | dataSize | string | 否 | 数据量 | | isDesensitize | integer | 否 | 是否脱敏（0: 未脱敏, 1: 已脱敏） | ## 命令示例 ### 批量分类分级同步 ```bash [REDACTED_SECRET]" API_URL="${SHUYAN_API_URL:-http://localhost:8080}" curl -s -X POST "${API_URL}/api/llm_infer_zh_and_cls_and_type_v2_batchdata_sync" \ -H "Authorization: Bearer ${API_KEY}" \ -H "Content-Type: application/json" \ -d '[ { "colNameCh": "用户姓名", "colNameComment": "用户的真实姓名", "colNameEn": "user_name", "projectName": "用户管理系统", "sampleList": ["张三", "李四", "王五"], "sizeInBytes": 1024, "standardCode": [REDACTED_SECRET], "tableNameCh": "用户表", "tableNameEn": "user", "sensitivityLevelRedisKey": "fenji_standard", "dataSize": "10000", "isDesensitize": 0 }, { "colNameCh": "身份证号", "colNameComment": "用户的身份证号码", "colNameEn": "id_card", "projectName": "用户管理系统", "sampleList": ["110101199001011234"], "sizeInBytes": 2048, "standardCode": [REDACTED_SECRET], "tableNameCh": "用户表", "tableNameEn": "user", "sensitivityLevelRedisKey": "fenji_standard", "dataSize": "10000", "isDesensitize": 1 } ]' ``` ## 响应格式 ### 成功响应 ```json { "code": 200, "message": "Batch processing completed successfully", "result": [ { "colNameCh": "用户姓名", "colNameComment": "用户的真实姓名", "colNameEn": "user_name", "confidence": 0, "itemName": "个人基本信息", "label": ["客户", "个人", "个人自然信息", "个人基本概况信息"], "projectName": "用户管理系统", "reasoningProcess": "字段含义为用户的真实姓名，属于个人基本情况数据", "standardCode": [REDACTED_SECRET], "tableNameCh": "用户表", "tableNameEn": "user", "sensitivityLevel": 2 } ] } ``` ### 响应字段说明 | 字段名 | 类型 | 描述 | |--------|------|------| | code | integer | 响应状态码（200: 成功, 500: 失败） | | message | string | 响应消息 | | result | array | 处理结果列表 | ### 结果项字段说明 | 字段名 | 类型 | 描述 | |--------|------|------| | colNameCh | string | 字段中文名 | | colNameComment | string | 字段含义 | | colNameEn | string | 字段英文名 | | confidence | integer | 置信度 | | itemName | string | 业务类型 | | label | array | 分类标签列表 | | projectName | string | 业务系统 | | reasoningProcess | string | 分类理由 | | standardCode | string | 标准代码 | | tableNameCh | string | 表中文名 | | tableNameEn | string | 表英文名 | | sensitivityLevel | integer | 敏感度等级（1-5，5为最高） | ## 敏感度等级说明 | 等级 | 说明 | |------|------| | 1 | 一般数据 | | 2 | 重要数据 | | 3 | 核心数据 | | 4 | 敏感数据 | | 5 | 绝密数据 | ## 错误处理 常见错误： | 错误信息 | 原因 | |----------|------| | No result returned from batch processing | 批量处理没有返回结果 | | Result is not a list | 返回结果不是列表格式 | | batch processing result length mismatch | 处理结果数量与输入数量不匹配 | ## 常见使用示例 ### 示例1：用户信息表分类 ```bash curl -s -X POST "http://localhost:8080/api/llm_infer_zh_and_cls_and_type_v2_batchdata_sync" \ -H "[REDACTED_SECRET]" \ -H "Content-Type: application/json" \ -d '[ { "colNameCh": "手机号", "colNameComment": "用户联系电话", "colNameEn": "phone", "projectName": "用户系统", "standardCode": [REDACTED_SECRET], "sensitivityLevelRedisKey": "fenji_standard" } ]' ``` ### 示例2：金融数据分类 ```bash curl -s -X POST "http://localhost:8080/api/llm_infer_zh_and_cls_and_type_v2_batchdata_sync" \ -H "[REDACTED_SECRET]" \ -H "Content-Type: application/json" \ -d '[ { "colNameCh": "银行账号", "colNameComment": "银行账户号码", "colNameEn": "bank_account", "projectName": "金融系统", "standardCode": [REDACTED_SECRET], "sensitivityLevelRedisKey": "fenji_standard" }, { "colNameCh": "交易金额", "colNameComment": "交易金额", "colNameEn": "amount", "projectName": "金融系统", "standardCode": [REDACTED_SECRET], "sensitivityLevelRedisKey": "fenji_standard" } ]' ``` ## 注意事项 1. 接口为同步处理，处理时间可能较长 2. 建议批量处理时控制单次请求数量（建议不超过100条） 3. 接口会自动对失败的字段进行重试

path: shuyan-classify.sh
content: #!/bin/bash
# 数安云智数据分类分级同步接口
# 用法: shuyan-classify.sh <command> [args...]

[REDACTED_SECRET]"
API_URL="${SHUYAN_API_URL:-http://localhost:8080}"
ENDPOINT="/api/llm_infer_zh_and_cls_and_type_v2_batchdata_sync"

case "$1" in
  classify)
    shift
    if [ $# -lt 2 ]; then
      echo "用法: shuyan-classify.sh classify <colNameCh> <colNameComment> [colNameEn] [projectName]"
      exit 1
    fi
    colNameCh="$1"
    colNameComment="$2"
    colNameEn="${3:-}"
    projectName="${4:-default}"
    
    DATA=$(cat <<EOF
[
  {
    "colNameCh": "$colNameCh",
    "colNameComment": "$colNameComment",
    "colNameEn": "$colNameEn",
    "projectName": "$projectName",
    "standardCode": "llm_infer_zh_and_cls_and_type_v2_test",
    "sensitivityLevelRedisKey": "fenji_standard"
  }
]
EOF
)
    curl -s -X POST "${API_URL}${ENDPOINT}" \
      -H "Authorization: Bearer ${API_KEY}" \
      -H "Content-Type: application/json" \
      -d "$DATA"
    ;;
    
  classify-batch)
    shift
    if [ $# -lt 1 ]; then
      echo "用法: shuyan-classify.sh classify-batch <json_file>"
      exit 1
    fi
    JSON_FILE="$1"
    if [ ! -f "$JSON_FILE" ]; then
      echo "错误: 文件不存在: $JSON_FILE"
      exit 1
    fi
    curl -s -X POST "${API_URL}${ENDPOINT}" \
      -H "Authorization: Bearer ${API_KEY}" \
      -H "Content-Type: application/json" \
      -d @"$JSON_FILE"
    ;;
    
  test)
    curl -s -X POST "${API_URL}${ENDPOINT}" \
      -H "Authorization: Bearer ${API_KEY}" \
      -H "Content-Type: application/json" \
      -d '[
        {
          "colNameCh": "测试字段",
          "colNameComment": "测试用字段",
          "colNameEn": "test_field",
          "projectName": "测试系统",
          "standardCode": "llm_infer_zh_and_cls_and_type_v2_test",
          "sensitivityLevelRedisKey": "fenji_standard"
        }
      ]'
    ;;
    
  health)
    curl -s -o /dev/null -w "%{http_code}" "${API_URL}/health" 2>/dev/null || echo "API不可用"
    ;;
    
  help|--help|-h)
    echo "数安云智数据分类分级同步接口"
    echo ""
    echo "用法: shuyan-classify.sh <command> [args...]"
    echo ""
    echo "命令:"
    echo "  classify <字段中文名> <字段含义> [英文名] [项目名]  - 单字段分类"
    echo "  classify-batch <json_file>                              - 批量分类"
    echo "  test                                                 - 测试连接"
    echo "  health                                               - 健康检查"
    echo ""
    echo "环境变量:"
    echo "  SHUYAN_API_KEY   - API认证密钥 (默认: sk-secret-key)"
    echo "  SHUYAN_API_URL  - API地址 (默认: http://localhost:8080)"
    echo ""
    ;;
    
  *)
    echo "未知命令: $1"
    echo "使用 shuyan-classify.sh help 查看帮助"
    exit 1
    ;;
esac


path: shuyan_classify.py
content: #!/usr/bin/env python3
"""
数安云智数据分类分级同步接口
用法: python shuyan_classify.py <command> [args...]

安装依赖:
    pip install requests

环境变量:
    SHUYAN_API_KEY   - API认证密钥
    SHUYAN_API_URL  - API地址 (默认: http://localhost:8080)
"""

import os
import sys
import json
import argparse
import requests
from typing import Optional, List, Dict, Any

[REDACTED_SECRET]"SHUYAN_API_KEY", "sk-secret-key")
API_URL = os.environ.get("SHUYAN_API_URL", "http://localhost:8080")
ENDPOINT = "/api/llm_infer_zh_and_cls_and_type_v2_batchdata_sync"


class ShuyanClassifier:
    """数安云智数据分类分级接口封装"""
    
    def __init__(self, api_key: str = None, api_url: str = None):
        self.[REDACTED_SECRET] or API_KEY
        self.api_url = api_url or API_URL
        self.endpoint = f"{self.api_url}{ENDPOINT}"
    
    def _headers(self) -> Dict[str, str]:
        return {
            "Authorization": f"Bearer {self.api_key}",
            "Content-Type": "application/json"
        }
    
    def classify_single(
        self,
        col_name_ch: str,
        col_name_comment: str,
        col_name_en: str = "",
        project_name: str = "default",
        standard_code: str = "llm_infer_zh_and_cls_and_type_v2_test",
        sensitivity_key: str = "fenji_standard",
        **kwargs
    ) -> Dict[str, Any]:
        """单字段分类"""
        data = {
            "colNameCh": col_name_ch,
            "colNameComment": col_name_comment,
            "colNameEn": col_name_en,
            "projectName": project_name,
            "standardCode": standard_code,
            "sensitivityLevelRedisKey": sensitivity_key,
        }
        # 添加其他可选字段
        for key, value in kwargs.items():
            if value is not None:
                data[key] = value
        
        response = requests.post(
            self.endpoint,
            headers=self._headers(),
            json=[data],
            timeout=60
        )
        response.raise_for_status()
        return response.json()
    
    def classify_batch(
        self,
        items: List[Dict[str, Any]]
    ) -> Dict[str, Any]:
        """批量分类"""
        response = requests.post(
            self.endpoint,
            headers=self._headers(),
            json=items,
            timeout=120
        )
        response.raise_for_status()
        return response.json()
    
    def health_check(self) -> bool:
        """健康检查"""
        try:
            response = requests.get(f"{self.api_url}/health", timeout=5)
            return response.status_code == 200
        except:
            return False


def cmd_classify(args):
    """单字段分类命令"""
    classifier = ShuyanClassifier(args.api_key, args.api_url)
    
    try:
        result = classifier.classify_single(
            col_name_ch=args.column_ch,
            col_name_comment=args.comment,
            col_name_en=args.column_en or "",
            project_name=args.project or "default"
        )
        print(json.dumps(result, ensure_ascii=False, indent=2))
    except requests.exceptions.RequestException as e:
        print(f"错误: {e}", file=sys.stderr)
        sys.exit(1)


def cmd_classify_batch(args):
    """批量分类命令"""
    classifier = ShuyanClassifier(args.api_key, args.api_url)
    
    # 读取JSON文件
    try:
        with open(args.file, 'r', encoding='utf-8') as f:
            items = json.load(f)
    except FileNotFoundError:
        print(f"错误: 文件不存在: {args.file}", file=sys.stderr)
        sys.exit(1)
    except json.JSONDecodeError as e:
        print(f"错误: JSON格式错误: {e}", file=sys.stderr)
        sys.exit(1)
    
    try:
        result = classifier.classify_batch(items)
        print(json.dumps(result, ensure_ascii=False, indent=2))
    except requests.exceptions.RequestException as e:
        print(f"错误: {e}", file=sys.stderr)
        sys.exit(1)


def cmd_test(args):
    """测试连接"""
    classifier = ShuyanClassifier(args.api_key, args.api_url)
    
    test_data = [{
        "colNameCh": "测试字段",
        "colNameComment": "测试用字段",
        "colNameEn": "test_field",
        "projectName": "测试系统",
        "standardCode": "llm_infer_zh_and_cls_and_type_v2_test",
        "sensitivityLevelRedisKey": "fenji_standard"
    }]
    
    try:
        result = classifier.classify_batch(test_data)
        print("✅ API连接成功!")
        print(json.dumps(result, ensure_ascii=False, indent=2))
    except requests.exceptions.RequestException as e:
        print(f"❌ API连接失败: {e}", file=sys.stderr)
        sys.exit(1)


def cmd_health(args):
    """健康检查"""
    classifier = ShucanClassifier(args.api_key, args.api_url)
    
    if classifier.health_check():
        print("✅ 服务健康")
    else:
        print("❌ 服务不可用")
        sys.exit(1)


def main():
    parser = argparse.ArgumentParser(
        description="数安云智数据分类分级同步接口",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog="""
示例:
  %(prog)s classify 用户姓名 用户真实姓名 user_name 用户系统
  %(prog)s classify-batch data.json
  %(prog)s test
  %(prog)s health

环境变量:
  SHUYAN_API_KEY   API认证密钥 (默认: sk-secret-key)
  SHUYAN_API_URL  API地址 (默认: http://localhost:8080)
        """
    )
    
    parser.add_argument(
        "--api-key",
        default=None,
        help="API认证密钥"
    )
    parser.add_argument(
        "--api-url",
        default=None,
        help="API服务地址"
    )
    
    subparsers = parser.add_subparsers(dest="command", help="可用命令")
    
    # classify 命令
    parser_classify = subparsers.add_parser(
        "classify",
        help="单字段分类"
    )
    parser_classify.add_argument("column_ch", help="字段中文名")
    parser_classify.add_argument("comment", help="字段含义/注释")
    parser_classify.add_argument("column_en", nargs="?", default="", help="字段英文名")
    parser_classify.add_argument("project", nargs="?", default="default", help="项目/系统名称")
    parser_classify.set_defaults(func=cmd_classify)
    
    # classify-batch 命令
    parser_batch = subparsers.add_parser(
        "classify-batch",
        help="批量字段分类"
    )
    parser_batch.add_argument("file", help="JSON文件路径")
    parser_batch.set_defaults(func=cmd_classify_batch)
    
    # test 命令
    parser_test = subparsers.add_parser(
        "test",
        help="测试API连接"
    )
    parser_test.set_defaults(func=cmd_test)
    
    # health 命令
    parser_health = subparsers.add_parser(
        "health",
        help="健康检查"
    )
    parser_health.set_defaults(func=cmd_health)
    
    args = parser.parse_args()
    
    if args.command is None:
        parser.print_help()
        sys.exit(1)
    
    args.func(args)


if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: suspicious (HIGH)