Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 【高危语句规则】新增高危语句规则管理功能的API,给上层SaaS使用 #2383 #2485

Merged
merged 7 commits into from
Nov 15, 2023

Conversation

liuliaozhong
Copy link
Collaborator

No description provided.

"bk_app_code": "esb_test",
"bk_app_secret": "xxx",
"bk_token": "xxx",
"script_language": [1],
Copy link
Collaborator

Choose a reason for hiding this comment

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

一次只检查一种脚本,这里不应该是 array

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

"level": 1,
"action": null,
"code": "103701001",
"description": "脚本首行没有定义合法的脚本类型,例如: #!/bin/bash"
Copy link
Collaborator

Choose a reason for hiding this comment

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

demo 尽量用英文,方便在中英文文档之间共享

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已修改

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

"lineContent": "rm /tmp",
"matchContent": "rm /tmp",
"level": 1,
"action": null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里的 action 为啥是 null?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

内置高危语句检测没有action属性

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

"line_content": "rm /tmp",
"matchContent": "rm",
"level": 3,
"action": 2,
Copy link
Collaborator

Choose a reason for hiding this comment

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

脚本检测API 似乎不应该返回 action 字段,因为只是检测,并不会进行拦截等操作

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

@@ -0,0 +1,80 @@
### 功能描述

脚本检测。
Copy link
Collaborator

Choose a reason for hiding this comment

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

脚本检测 -> 高危脚本检测

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

"matchContent": "rm",
"level": 3,
"action": 2,
"code": null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

错误代码并非高危语句检测需要的字段,可以不返回

"expression": "rm",
"script_language_list": [1],
"description": "drangerous!!!",
"order": 1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

暂时隐藏 order 优先级参数,无需返回

dest_path: /api/job/v3/job-manage/delete_dangerous_rule/
dest_http_method: DELETE

- path: /v2/jobv3/get_dangerous_rule_list/
Copy link
Collaborator

Choose a reason for hiding this comment

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

待确认。需要咨询下 ESB 是否支持用 GET 传 RequestBody

@@ -26,6 +26,7 @@ validation.constraints.InvalidBkCloudId.message=管控区域 ID 非法
validation.constraints.InvalidIp.message=IP 非法
validation.constraints.InvalidJobTimeout_empty.message=作业超时时间不能为空
validation.constraints.InvalidJobTimeout_outOfRange.message=作业超时时间必须在{min}-{max}之间
validation.constraints.InvalidJobHighRiskGrammarId_empty.message=语法检测ID不能为空
Copy link
Collaborator

Choose a reason for hiding this comment

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

语法检测ID不能为空有点奇怪,改成“高危语句规则 ID"可能更加合理

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已修改

"data": [
{
"line": 1,
"lineContent": "rm /tmp",
Copy link
Collaborator

Choose a reason for hiding this comment

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

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式。 lineContent->line_content

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

dto是下划线格式,文档从别处copy的,没注意,已改

{
"line": 1,
"lineContent": "rm /tmp",
"matchContent": "rm /tmp",
Copy link
Collaborator

Choose a reason for hiding this comment

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

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改

{
"line": 1,
"line_content": "rm /tmp",
"matchContent": "rm",
Copy link
Collaborator

Choose a reason for hiding this comment

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

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改

"data": [
{
"line": 1,
"lineContent": "rm /tmp",
Copy link
Collaborator

Choose a reason for hiding this comment

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

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改

{
"line": 1,
"lineContent": "rm /tmp",
"matchContent": "rm /tmp",
Copy link
Collaborator

Choose a reason for hiding this comment

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

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改

{
"line": 1,
"line_content": "rm /tmp",
"matchContent": "rm",
Copy link
Collaborator

Choose a reason for hiding this comment

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

api 所有的字段格式都需要是下划线分隔的,而不是驼峰方式

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改

if (id > 0) {
return EsbResp.buildSuccessResp(null);
}
return EsbResp.buildCommonFailResp(ErrorCode.INTERNAL_ERROR);
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里可以重构下,如果删除报错,直接在 Service 里边处理,抛出异常,而不是用 id 来判断结果

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已放在service处理

@@ -49,4 +49,6 @@ public interface DangerousRuleDAO {
int getMaxPriority();

int getMinPriority();

int updateDangerousRuleStatus(String userName, Long id, Integer status);
Copy link
Collaborator

Choose a reason for hiding this comment

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

status 参数直接使用枚举类型,方法会更加清晰

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

已改

@wangyu096 wangyu096 merged commit 4a042d0 into TencentBlueKing:master Nov 15, 2023
4 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.

2 participants