Skip to content

Commit

Permalink
fix:修改插件执行编辑器输入问题 (#1903)
Browse files Browse the repository at this point in the history
  • Loading branch information
luoluoTH authored Aug 13, 2024
1 parent 7da17bd commit d0080df
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ export const EditorCode: React.FC<EditorCodeProps> = memo(
requestParams.HTTPRequestTemplate = {
...value,
IsRawHTTPRequest: value.requestType === "original",
RawHTTPRequest: value.RawHTTPRequest
? Buffer.from(value.RawHTTPRequest, "utf8")
RawHTTPRequest: value.rawHTTPRequest
? Buffer.from(value.rawHTTPRequest, "utf8")
: Buffer.from("", "utf8")
}
break
Expand All @@ -385,8 +385,8 @@ export const EditorCode: React.FC<EditorCodeProps> = memo(
requestParams.HTTPRequestTemplate = {
...value,
IsRawHTTPRequest: value.requestType === "original",
RawHTTPRequest: value.RawHTTPRequest
? Buffer.from(value.RawHTTPRequest, "utf8")
RawHTTPRequest: value.rawHTTPRequest
? Buffer.from(value.rawHTTPRequest, "utf8")
: Buffer.from("", "utf8")
}
break
Expand Down
4 changes: 0 additions & 4 deletions app/renderer/src/main/src/pages/plugins/editDetails/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ export const getValueByType = (defaultValue, type: string): number | string | bo
case "boolean":
value = defaultValue === "true" || defaultValue === true
break
case "http-packet":
case "yak":
value = Buffer.from((defaultValue || "") as string, "utf8")
break
case "select":
// 考虑(defaultValue)的数据可能本身就是一个数组
if (Array.isArray(defaultValue)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ export const LocalPluginExecuteDetailHeard: React.FC<PluginExecuteDetailHeardPro
IsRawHTTPRequest: value.requestType === "original",
IsHttpFlowId: false,
HTTPFlowId: [],
RawHTTPRequest: value.RawHTTPRequest
? Buffer.from(value.RawHTTPRequest, "utf8")
RawHTTPRequest: value.rawHTTPRequest
? Buffer.from(value.rawHTTPRequest, "utf8")
: Buffer.from("", "utf8")
},
ExecParams: yakExecutorParams,
Expand Down Expand Up @@ -649,6 +649,7 @@ export const OutputFormComponentsByType: React.FC<OutputFormComponentsByTypeProp
</Form.Item>
)
case "http-packet":
const defaultValue = item.DefaultValue || ""
return (
<Form.Item
{...formProps}
Expand All @@ -665,21 +666,16 @@ export const OutputFormComponentsByType: React.FC<OutputFormComponentsByTypeProp
}
}
]}
valuePropName='originValue'
className={classNames(formProps.className, styles["code-wrapper"], {
[styles["code-error-wrapper"]]: validateStatus === "error"
})}
initialValue={item.DefaultValue || ""}
initialValue={defaultValue}
trigger='setValue'
validateTrigger='setValue'
validateStatus={validateStatus}
help={validateStatus === "error" ? `${formProps.label} 是必填字段` : ""}
>
<HTTPPacketYakitEditor
originValue={item.DefaultValue}
value={item.DefaultValue || ""}
readOnly={disabled}
/>
<HTTPPacketYakitEditor originValue={defaultValue} readOnly={disabled} />
</Form.Item>
)
case "yak":
Expand All @@ -706,7 +702,6 @@ export const OutputFormComponentsByType: React.FC<OutputFormComponentsByTypeProp
}
}
]}
valuePropName='originValue'
className={classNames(formProps.className, styles["code-wrapper"], {
[styles["code-error-wrapper"]]: validateStatus === "error"
})}
Expand All @@ -716,7 +711,7 @@ export const OutputFormComponentsByType: React.FC<OutputFormComponentsByTypeProp
validateStatus={validateStatus}
help={validateStatus === "error" ? `${formProps.label} 是必填字段` : ""}
>
<YakitEditor type={language} value={item.DefaultValue || ""} readOnly={disabled} />
<YakitEditor type={language} readOnly={disabled} />
</Form.Item>
)
default:
Expand Down Expand Up @@ -747,7 +742,7 @@ export const PluginFixFormParams: React.FC<PluginFixFormParamsProps> = React.mem
const requestType: RequestType = Form.useWatch("requestType", form)
const rawItem = useMemo(() => {
const codeItem: YakParamProps = {
Field: "RawHTTPRequest",
Field: "rawHTTPRequest",
FieldVerbose: "数据包",
Required: true,
TypeVerbose: "http-packet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export interface PluginExecuteProgressProps {
export interface PluginExecuteExtraFormValue extends HTTPRequestBuilderParams {
/**前端使用,请求类型的选择 */
requestType: RequestType
/**前端使用,请求类型》原始请求:数据包 */
rawHTTPRequest:string
}
/**表单的key value类型 */
export interface CustomPluginExecuteFormValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ export const defPluginExecuteFormValue: PluginExecuteExtraFormValue = {
MultipartFileParams: [],
IsHttpFlowId: false,
HTTPFlowId: [],
requestType: "original"
requestType: "original",
rawHTTPRequest:''
}
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ export const HybridScanExecuteContent: React.FC<HybridScanExecuteContentProps> =
const onSetScanData = useMemoizedFn(() => {
if (!dataScanParams) return
const {https, httpFlowIds, request} = dataScanParams
const initRawHTTPRequestString = Uint8ArrayToString(isEmpty(request) ? new Uint8Array() : request)
const formValue = {
IsHttps: https,
httpFlowId: httpFlowIds.length > 0 ? httpFlowIds.join(",") : "",
Expand All @@ -641,15 +642,15 @@ export const HybridScanExecuteContent: React.FC<HybridScanExecuteContentProps> =
? "input"
: "original") as RequestType,
IsRawHTTPRequest: isEmpty(request),
RawHTTPRequest: isEmpty(request) ? new Uint8Array() : request
rawHTTPRequest: initRawHTTPRequestString
}
const initRawHTTPRequestString = Uint8ArrayToString(formValue.RawHTTPRequest)

setExtraParamsValue((v) => ({...v, ...formValue}))
/**目前只有webfuzzer带数据包的参数进入poc */
setInitRawHTTPRequest(initRawHTTPRequestString)
form.setFieldsValue({
...formValue,
RawHTTPRequest: initRawHTTPRequestString
rawHTTPRequest: initRawHTTPRequestString
})
})

Expand Down Expand Up @@ -706,19 +707,21 @@ export const HybridScanExecuteContent: React.FC<HybridScanExecuteContentProps> =
httpFlowId,
requestType: (isHttpFlowId ? "httpFlowId" : isRawHTTPRequest ? "original" : "input") as RequestType
}
const initRawHTTPRequestString = Uint8ArrayToString(params.HTTPRequestTemplate.RawHTTPRequest)
// form表单数据
const extraForm = {
...params.HTTPRequestTemplate,
...requestType,
Proxy: params.Proxy,
Concurrent: params.Concurrent,
TotalTimeoutSecond: params.TotalTimeoutSecond
TotalTimeoutSecond: params.TotalTimeoutSecond,
rawHTTPRequest: initRawHTTPRequestString
}
const initRawHTTPRequestString = Uint8ArrayToString(params.HTTPRequestTemplate.RawHTTPRequest)

const formValue = {
Input: params.Input,
IsHttps: params.HTTPRequestTemplate.IsHttps,
RawHTTPRequest: initRawHTTPRequestString,
rawHTTPRequest: initRawHTTPRequestString,
...requestType
}
form.setFieldsValue({...formValue})
Expand Down Expand Up @@ -748,8 +751,8 @@ export const HybridScanExecuteContent: React.FC<HybridScanExecuteContentProps> =
IsRawHTTPRequest: value.requestType === "original",
IsHttpFlowId: value.requestType === "httpFlowId",
HTTPFlowId: hTTPFlowId.map((ele) => Number(ele)).filter((ele) => !!ele),
RawHTTPRequest: value.RawHTTPRequest
? Buffer.from(value.RawHTTPRequest, "utf8")
RawHTTPRequest: value.rawHTTPRequest
? Buffer.from(value.rawHTTPRequest, "utf8")
: Buffer.from("", "utf8")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ export const PluginDebugBody: React.FC<PluginDebugBodyProps> = memo((props) => {
requestParams.HTTPRequestTemplate = {
...value,
IsRawHTTPRequest: value.requestType === "original",
RawHTTPRequest: value.RawHTTPRequest
? Buffer.from(value.RawHTTPRequest, "utf8")
RawHTTPRequest: value.rawHTTPRequest
? Buffer.from(value.rawHTTPRequest, "utf8")
: Buffer.from("", "utf8")
}
break
Expand All @@ -469,8 +469,8 @@ export const PluginDebugBody: React.FC<PluginDebugBodyProps> = memo((props) => {
requestParams.HTTPRequestTemplate = {
...value,
IsRawHTTPRequest: value.requestType === "original",
RawHTTPRequest: value.RawHTTPRequest
? Buffer.from(value.RawHTTPRequest, "utf8")
RawHTTPRequest: value.rawHTTPRequest
? Buffer.from(value.rawHTTPRequest, "utf8")
: Buffer.from("", "utf8")
}
break
Expand Down

0 comments on commit d0080df

Please sign in to comment.