Skip to content

Conversation

@rinfx
Copy link
Collaborator

@rinfx rinfx commented Sep 22, 2025

Ⅰ. Describe what this PR did

compatible with old configurations

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@lingma-agents
Copy link

lingma-agents bot commented Sep 22, 2025

安全配置兼容性增强与风险等级控制

变更概述
  • 问题修复 - 修复了旧配置兼容性问题,确保系统在缺少新配置项时能够正常运行

    • 新增 RiskLevelAttackLevel 字段以支持更细粒度的风险控制
    • 在配置解析阶段增加默认值处理逻辑,提升系统健壮性
    • 调整风险判断逻辑,使用字符串形式的风险等级进行比较
  • 新功能 - 引入基于风险等级的访问控制机制

    • 增加 riskLevelBar 配置项用于设定可接受的风险阈值
    • 实现 isRiskLevelAcceptable 函数来评估请求是否符合预设风险标准
    • 默认将高风险 (HighRisk) 设为风险等级上限,防止未授权访问
  • 配置调整 - 更新配置结构体和解析逻辑以适应新的安全策略

    • 扩展 Data 结构体包含更多安全相关字段(如 AdviceDetail
    • 修改 AISecurityConfig 结构体添加 riskLevelBar 配置项
    • 优化配置加载过程,当缺少 action 配置时默认设置为 TextModerationPlus
  • 其他 - 代码结构调整与维护

    • 保持原有安全检测逻辑不变,仅增强其灵活性和兼容性
    • 通过增加字段注释提高代码可读性和维护性
变更文件
文件路径 变更说明
plugins/​wasm-go/​extensions/​ai-security-guard/​main.​go 新增风险等级控制字段和配置项,修改配置解析逻辑以支持向后兼容,并更新风险评估函数实现更灵活的安全控制。

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

--- ### Security configuration compatibility enhancement and risk level control
Change Overview

Issue Fixed - Fixed old configuration compatibility issues to ensure that the system works properly when new configuration items are missing

  • Added RiskLevel and AttackLevel fields to support finer granular risk control
  • Add default value processing logic in the configuration analysis stage to improve system robustness
  • Adjust risk judgment logic and compare risk levels in string form

New Features - Introducing access control mechanism based on risk level

  • Added the riskLevelBar configuration item to set acceptable risk thresholds
  • Implement the isRiskLevelAcceptable function to evaluate whether the request complies with the preset risk criteria
  • Set high risk (HighRisk) to the upper risk level limit by default to prevent unauthorized access

Configuration Adjustment - Update configuration structure and parsing logic to adapt to new security policies

  • Extended Data structure contains more security-related fields (such as Advice and Detail)
  • Modify the AISecurityConfig structure to add riskLevelBar configuration item
  • Optimize the configuration loading process, default setting to TextModerationPlus when action configuration is missing
  • Other - Code structure adjustment and maintenance
    • Keep the original security detection logic unchanged and only enhances its flexibility and compatibility
    • Improve code readability and maintenance by adding field comments
Change file
File path Change instructions
plugins/​wasm-go/​extensions/​ai-security-guard/​main.​go Added risk level control fields and configuration items, modified configuration parsing logic to support backward compatibility, and updated risk assessment functions to achieve more flexible security control.

💡 Tips

How to communicate with lingma-agents

📜 Reply to comments directly
Reply to this comment directly and lingma-agents will automatically process your request. For example:

  • _Add detailed comment description in the current code. _

  • _Please introduce the LRU transformation plan you mentioned in detail and explain it using pseudo-code. _

**📜 Mark ** at line of code
Create comments at a specific location in the file and @lingma-agents. For example:

  • _@lingma-agents Analyze the performance bottlenecks of this method and provide optimization suggestions. _

  • _@lingma-agents Generate optimization code for this method. _

📜 Ask a question during discussion
In any discussion @lingma-agents to get help. For example:

  • _@lingma-agents Please summarize the above discussion and propose solutions. _

  • _@lingma-agents Please generate optimization code based on the discussion content. _

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.97%. Comparing base (ef31e09) to head (b11b84d).
⚠️ Report is 722 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2941      +/-   ##
==========================================
+ Coverage   35.91%   44.97%   +9.06%     
==========================================
  Files          69       82      +13     
  Lines       11576    13377    +1801     
==========================================
+ Hits         4157     6016    +1859     
+ Misses       7104     7014      -90     
- Partials      315      347      +32     

see 80 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@johnlanni johnlanni changed the title [bugfix] compatible with old configs fix(ai-security-guard): compatible with old configs Sep 23, 2025
Copy link
Collaborator

@johnlanni johnlanni left a comment

Choose a reason for hiding this comment

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

LGTM

@johnlanni johnlanni merged commit 732aacd into alibaba:main Sep 23, 2025
18 checks passed
Tsukilc pushed a commit to Tsukilc/higress that referenced this pull request Sep 30, 2025
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