Skip to content

Commit

Permalink
Merge pull request #2221 from yaklang/yj/feat/audit-code-v3
Browse files Browse the repository at this point in the history
Yj/feat/audit code v3
  • Loading branch information
luoluoTH authored Dec 20, 2024
2 parents 12a472d + 7ce71cd commit 5367825
Show file tree
Hide file tree
Showing 30 changed files with 2,290 additions and 375 deletions.
48 changes: 48 additions & 0 deletions app/main/handlers/syntaxFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,38 @@ module.exports = (win, getClient) => {
handlerHelper.registerHandler(win, stream, streamSyntaxFlowScanMap, token)
})

// 规则执行-任务列表
const asyncQuerySyntaxFlowScanTask = (params) => {
return new Promise((resolve, reject) => {
getClient().QuerySyntaxFlowScanTask(params, (err, data) => {
if (err) {
reject(err)
return
}
resolve(data)
})
})
}
ipcMain.handle("QuerySyntaxFlowScanTask", async (e, params) => {
return await asyncQuerySyntaxFlowScanTask(params)
})

// 规则执行-任务列表/删除
const asyncDeleteSyntaxFlowScanTask = (params) => {
return new Promise((resolve, reject) => {
getClient().DeleteSyntaxFlowScanTask(params, (err, data) => {
if (err) {
reject(err)
return
}
resolve(data)
})
})
}
ipcMain.handle("DeleteSyntaxFlowScanTask", async (e, params) => {
return await asyncDeleteSyntaxFlowScanTask(params)
})

const asyncQuerySyntaxFlowResult = (params) => {
return new Promise((resolve, reject) => {
getClient().QuerySyntaxFlowResult(params, (err, data) => {
Expand All @@ -64,6 +96,22 @@ module.exports = (win, getClient) => {
return await asyncQuerySyntaxFlowResult(params)
})

const asyncDeleteSyntaxFlowResult = (params) => {
return new Promise((resolve, reject) => {
getClient().DeleteSyntaxFlowResult(params, (err, data) => {
if (err) {
reject(err)
return
}
resolve(data)
})
})
}
// 删除审计结果
ipcMain.handle("DeleteSyntaxFlowResult", async (e, params) => {
return await asyncDeleteSyntaxFlowResult(params)
})

const asyncQuerySSAPrograms = (params) => {
return new Promise((resolve, reject) => {
getClient().QuerySSAPrograms(params, (err, data) => {
Expand Down
46 changes: 35 additions & 11 deletions app/protos/grpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,9 @@ service Yak {
rpc SyntaxFlowScan(stream SyntaxFlowScanRequest) returns (stream SyntaxFlowScanResponse);
rpc QuerySyntaxFlowScanTask(QuerySyntaxFlowScanTaskRequest) returns (QuerySyntaxFlowScanTaskResponse);
rpc DeleteSyntaxFlowScanTask(DeleteSyntaxFlowScanTaskRequest) returns (DbOperateMessage);
// query result
// query result
rpc QuerySyntaxFlowResult (QuerySyntaxFlowResultRequest) returns (QuerySyntaxFlowResultResponse);
rpc DeleteSyntaxFlowResult (DeleteSyntaxFlowResultRequest) returns (DeleteSyntaxFlowResultResponse);
//query ssa program
rpc QuerySSAPrograms(QuerySSAProgramRequest)returns(QuerySSAProgramResponse);
rpc UpdateSSAProgram(UpdateSSAProgramRequest)returns(DbOperateMessage);
Expand Down Expand Up @@ -3063,6 +3064,9 @@ message QueryRisksRequest {
repeated int64 Ids = 14;

string RuntimeId = 15;

// ssa program
repeated string SSAProgramNames = 16;
}

message QueryRisksResponse {
Expand Down Expand Up @@ -3963,6 +3967,7 @@ message YakScriptParam {
string JsonSchema = 10;

string SuggestionDataExpression = 11;
string UISchema = 12;
}

message YakScript {
Expand Down Expand Up @@ -5580,9 +5585,9 @@ message SSAProgram{
string Language = 6;
string EngineVersion = 7;

// need re-compile
// need re-compile
bool Recompile = 8;
// risk number
// risk number
int64 HighRiskNumber = 9;
int64 CriticalRiskNumber = 10;
int64 WarnRiskNumber = 11;
Expand All @@ -5591,19 +5596,19 @@ message SSAProgram{
}

message SSAProgramInput {
string Name = 1; // index
string Description = 2;
string Name = 1; // index
string Description = 2;
}

message SSAProgramFilter{
repeated string ProgramNames = 1;
repeated string Languages = 2;
repeated int64 Ids = 3;
repeated string ProgramNames = 1;
repeated string Languages = 2;
repeated int64 Ids = 3;

// update range
int64 BeforeUpdatedAt = 5;
int64 AfterUpdatedAt = 6;
// fuzz search
// fuzz search
string Keyword = 7 ;
// id range
int64 AfterID = 8;
Expand Down Expand Up @@ -5677,14 +5682,16 @@ message SyntaxFlowScanRequest{

// 启动扫描任务
SyntaxFlowRuleFilter Filter = 2; // 用于指定扫描的规则
repeated string ProgramName = 3; // 用于指定扫描的程序
repeated string ProgramName = 3; // 用于指定扫描的程序
// 恢复扫描任务
string ResumeTaskId = 5; // 恢复任务ID

// 其他参数
bool IgnoreLanguage = 4; // 是否忽略语言 默认为false 将会只运行和当前项目语言一致的规则,最后运行的规则可能会比当前选中的规则少一些。
}

// for new rule scan task
SyntaxFlowRuleInput RuleInput = 6; // 用于新建规则时的调试功能
}

message QuerySyntaxFlowScanTaskRequest{
Paging Pagination = 1;
Expand All @@ -5697,6 +5704,8 @@ message SyntaxFlowScanTaskFilter{
repeated string TaskIds = 3;
int64 FromId = 4;
int64 UntilId = 5;
string keyword = 6; // fuzz search program-name
repeated string Kind = 7; // "debug" | "scan";
}

message QuerySyntaxFlowScanTaskResponse{
Expand All @@ -5723,6 +5732,9 @@ message SyntaxFlowScanTask {
int64 RiskCount =12;
// query process
int64 TotalQuery =13;

SyntaxFlowScanRequest Config = 14;
string Kind = 15; // "debug" | "scan"
}

message DeleteSyntaxFlowScanTaskRequest{
Expand Down Expand Up @@ -5758,6 +5770,7 @@ message SyntaxFlowResultFilter {
int64 BeforeID = 8;

repeated string Severity = 9; // "info", "low", "middle", "critical", "high"
repeated string Kind = 10 ; // "query" | "debug" | "scan"
}

message QuerySyntaxFlowResultRequest{
Expand Down Expand Up @@ -5794,6 +5807,17 @@ message SyntaxFlowResult {
uint64 RiskCount = 11;

string RuleContent = 12;
string Kind = 13; // "query" | "debug" | "scan"
}

message DeleteSyntaxFlowResultRequest{
bool DeleteContainRisk = 1; // 是否删除带风险的结果
bool DeleteAll = 2; // DeleteAll 的保护
SyntaxFlowResultFilter Filter = 3;
}

message DeleteSyntaxFlowResultResponse{
DbOperateMessage Message = 1;
}

message QueryPluginEnvRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,51 +14,53 @@
// box-shadow: 0 0 0 2px var(--input-box-shadow-color);
}

.ant-form-item {
// display: flex;
// flex-direction: row;
// .ant-form-item-label {
// flex: 8;
// text-align: right;
// label::after {
// content: ":";
// position: relative;
// top: -0.5px;
// margin: 0 8px 0 2px;
// z-index: 1;
// display: inline-flex;
// align-items: center;
// }
// }
// .ant-form-item-control {
// flex: 16;
// }
.json-schema-row-form {
.ant-form-item {
display: flex;
flex-direction: row;
.ant-form-item-label {
flex: 8;
text-align: right;
label::after {
content: ":";
position: relative;
top: -0.5px;
margin: 0 8px 0 2px;
z-index: 1;
display: inline-flex;
align-items: center;
}
}
.ant-form-item-control {
flex: 16;
}

// .ant-form-item-label {
// // 仅在相邻元素不是 .ant-form-item-control 时应用样式
// &:not(:has(+ .ant-form-item-control)) {
// display: none;
// width: 100%;
// padding: 0;
// margin-bottom: 20px;
// text-align: left;
// border: 0;
// border-bottom: 1px solid #e5e5e5;
// label{
// font-size: 21px !important;
// color: #333;
// }
// label::after {
// content: "";
// position: relative;
// top: -0.5px;
// margin: 0 8px 0 2px;
// z-index: 1;
// display: inline-flex;
// align-items: center;
// }
// }
// }
.ant-form-item-label {
// 仅在相邻元素不是 .ant-form-item-control 时应用样式
&:not(:has(+ .ant-form-item-control)) {
display: none;
width: 100%;
padding: 0;
margin-bottom: 20px;
text-align: left;
border: 0;
border-bottom: 1px solid #e5e5e5;
label {
font-size: 21px !important;
color: #333;
}
label::after {
content: "";
position: relative;
top: -0.5px;
margin: 0 8px 0 2px;
z-index: 1;
display: inline-flex;
align-items: center;
}
}
}
}
}
}
}
}
Loading

0 comments on commit 5367825

Please sign in to comment.