Skip to content

Commit

Permalink
删除无效代码文件 (yaklang#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rdfree authored Mar 27, 2024
1 parent 35eee15 commit 5eeeb1d
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 3,966 deletions.
4 changes: 0 additions & 4 deletions app/main/handlers/communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ module.exports = (win, getClient) => {
ipcMain.handle("send-to-tab", async (e, params) => {
win.webContents.send("fetch-send-to-tab", params)
})
// 发送专项漏洞页面目标和类型参数
ipcMain.handle("send-to-bug-test", async (e, params) => {
win.webContents.send("fetch-send-to-bug-test", params)
})
// 请求包通过通信打开一个数据包插件执行弹窗
ipcMain.handle("send-to-packet-hack", async (e, params) => {
win.webContents.send("fetch-send-to-packet-hack", params)
Expand Down
1 change: 1 addition & 0 deletions app/main/handlers/manageYakScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ module.exports = (win, getClient) => {
stream && stream.cancel()
streamMap.delete(token)
})
// 老版插件批量
ipcMain.handle("exec-batch-yak-script", async (e, params, token) => {
let stream = getClient().ExecBatchYakScript(params)
streamMap.set(token, stream)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,111 +52,6 @@ export const onLocalScriptToOnlinePlugin = (params: YakScript, type?: number) =>
return onlineParams
}

interface SyncCopyCloudButtonProps {
params: YakScript
setParams: (s: YakScript) => void
children: ReactNode
}
export const SyncCopyCloudButton: React.FC<SyncCopyCloudButtonProps> = (props) => {
const {params, setParams, children} = props
const {userInfo} = useStore()
// 登录框状态
const [loginshow, setLoginShow] = useState<boolean>(false)
const modalRef = useRef<any>()
const upOnlinePlugin = useMemoizedFn((formParams?: YakScript) => {
const newParams = formParams || params
// 1 私密:个人账号 复制至云端仅能为私密插件
const onlineParams: API.NewYakitPlugin = onLocalScriptToOnlinePlugin(newParams, 1)
if (newParams.OnlineId) {
onlineParams.base_plugin_id = parseInt(`${newParams.OnlineId}`)
}
NetWorkApi<API.NewYakitPlugin, API.YakitPluginResponse>({
method: "post",
url: "yakit/plugin",
data: onlineParams
})
.then((res) => {
ipcRenderer
.invoke("DownloadOnlinePluginById", {
OnlineID: res.id,
UUID: res.uuid
} as DownloadOnlinePluginProps)
.then(() => {
setTimeout(() => ipcRenderer.invoke("change-main-menu"), 100)
ipcRenderer
.invoke("GetYakScriptByOnlineID", {
OnlineID: res.id,
UUID: res.uuid
} as GetYakScriptByOnlineIDRequest)
.then((newSrcipt: YakScript) => {
setParams(newSrcipt)
success("同步成功")
formParams && modalRef.current.destroy()
})
.catch((e) => {
failed(`查询本地插件错误:${e}`)
})
.finally(() => {})
})
.catch((err) => {
failed("插件下载本地失败:" + err)
})
})
.catch((err) => {
failed("插件上传失败:" + err)
})
.finally(() => {})
})

const onSyncCloud = useMemoizedFn(() => {
if (!userInfo.isLogin) {
Modal.confirm({
title: "未登录",
icon: <ExclamationCircleOutlined />,
content: "登录后才可同步至云端",
cancelText: "取消",
okText: "登录",
onOk() {
setLoginShow(true)
},
onCancel() {}
})
return
}
if (params.ScriptName !== params.OnlineScriptName) {
upOnlinePlugin()
return
}

modalRef.current = showModal({
title: "复制至云端",
width: 520,
content: (
<CopyCloudForm
params={params}
onClose={() => {
modalRef.current.destroy()
}}
onSubmit={upOnlinePlugin}
/>
)
})
})
return (
<>
<div
onClick={(e) => {
e.stopPropagation()
onSyncCloud()
}}
>
{children}
</div>
{loginshow && <Login visible={loginshow} onCancel={() => setLoginShow(false)}></Login>}
</>
)
}

interface SyncCloudButtonProps {
params: YakScript
setParams: (s: YakScript) => void
Expand Down Expand Up @@ -338,45 +233,6 @@ export const ModalSyncSelect: React.FC<ModalSyncSelect> = (props) => {
)
}

interface CopyCloudFormProps {
params: YakScript
onSubmit: (v: YakScript) => void
onClose: () => void
}
const layout = {
labelCol: {span: 5},
wrapperCol: {span: 16}
}
export const CopyCloudForm: React.FC<CopyCloudFormProps> = (props) => {
const {onClose, params, onSubmit} = props
const [form] = Form.useForm()
const [loading, setLoading] = useState<boolean>(false)
const [newParams, setNewParams, getNewParams] = useGetState(params)

const onFinish = useMemoizedFn((values) => {
// setLoading(true)
setNewParams((value) => ({...value, ScriptName: values.name}))
onSubmit(getNewParams())
})
return (
<div>
<Form {...layout} form={form} onFinish={onFinish}>
<div style={{padding: "0 30px", marginBottom: 18}}>
复制插件并同步到自己的私密插件,无需作者同意,即可保存修改内容至云端
</div>
<Form.Item name='name' label='插件名称' rules={[{required: true, message: "该项为必填"}]}>
<Input placeholder='请输入插件名称' allowClear />
</Form.Item>
<div style={{display: "flex", justifyContent: "space-evenly"}}>
<Button onClick={() => onClose()}>取消</Button>
<Button type='primary' htmlType='submit' loading={loading}>
确认
</Button>
</div>
</Form>
</div>
)
}
export interface SyncCloudProgressProps{
visible: boolean
onCancle:()=>void
Expand Down
82 changes: 2 additions & 80 deletions app/renderer/src/main/src/pages/invoker/ExecYakScript.tsx
Original file line number Diff line number Diff line change
@@ -1,72 +1,7 @@
import React, {useEffect, useState} from "react"
import React from "react"
import {YakScript} from "./schema"
import {YakExecutorParam} from "./YakExecutorParams"
import {showDrawer} from "../../utils/showModal"
import {randomString} from "../../utils/randomUtil"
import {Space} from "antd"
import {PluginResultUI} from "../yakitStore/viewers/base"
import {useCreation} from "ahooks"

import useHoldingIPCRStream, {InfoState} from "../../hook/useHoldingIPCRStream"
import {getReleaseEditionName} from "@/utils/envfile"

const {ipcRenderer} = window.require("electron")

export interface YakScriptRunnerProp {
script: YakScript
params: YakExecutorParam[]
debugMode?: boolean
consoleHeight?: string
}

export const YakScriptRunner: React.FC<YakScriptRunnerProp> = (props) => {
const token = useCreation(() => randomString(40), [])
const [infoState, {reset, setXtermRef}] = useHoldingIPCRStream(
"exec-script-immediately",
"exec-yak-script",
token,
() => {
setFinished(true)
},
() => {
ipcRenderer.invoke(
"exec-yak-script",
{
Params: props.params.filter((param: YakExecutorParam) => {
return param.Value !== 'false'
}),
YakScriptId: props.script.Id
},
token
)
}
)

const [finished, setFinished] = useState(false)

useEffect(() => {
return () => reset()
}, [])

return (
<div style={{width: "100%", height: "100%"}}>
<PluginResultUI
script={props.script}
debugMode={props.debugMode}
results={infoState.messageState}
statusCards={infoState.statusState}
risks={infoState.riskState}
featureType={infoState.featureTypeState}
progress={infoState.processState}
feature={infoState.featureMessageState}
loading={!finished}
onXtermRef={(ref) => setXtermRef(ref)}
cardStyleType={1}
consoleHeight={props.consoleHeight}
/>
</div>
)
}
import {InfoState} from "../../hook/useHoldingIPCRStream"

export interface DefaultPluginResultUIProp {
infoState: InfoState
Expand All @@ -91,16 +26,3 @@ export const DefaultPluginResultUI: React.FC<DefaultPluginResultUIProp> = (props
/>
</div>
};

export const startExecuteYakScript = (script: YakScript, params: YakExecutorParam[]) => {
showDrawer({
title: `正在执行的 ${getReleaseEditionName()} 模块:${script.ScriptName}`,
width: "85%",
mask: false,
content: (
<>
<YakScriptRunner {...{script, params}} />
</>
)
})
}
47 changes: 1 addition & 46 deletions app/renderer/src/main/src/pages/invoker/YakExecutor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ import {
FolderOpenOutlined,
FullscreenExitOutlined,
FullscreenOutlined,
PoweroffOutlined,
EditOutlined,
SaveOutlined
PoweroffOutlined
} from "@ant-design/icons"
import {YakScriptManagerPage} from "./YakScriptManager"
import {getRandomInt} from "../../utils/randomUtil"
import {showDrawer} from "../../utils/showModal"
import {failed, info, success} from "../../utils/notification"
import {ExecResult} from "./schema"
import {SelectOne} from "../../utils/inputUtil"
Expand Down Expand Up @@ -762,47 +758,6 @@ export const YakExecutor: React.FC<YakExecutorProp> = (props) => {
{isInteractive ? "常规编辑" : "交互式编辑"}
</Button>

{/* <Button
style={{height: 25}}
type={"link"}
size={"small"}
disabled={
tabList[+activeTab] && tabList[+activeTab].suffix !== "yak"
}
onClick={(e) => {
let m = showDrawer({
width: "60%",
placement: "left",
title: "选择你的 Yak 模块执行特定功能",
content: (
<>
<YakScriptManagerPage
type={"yak"}
onLoadYakScript={(s) => {
const tab: tabCodeProps = {
tab: `Untitle-${unTitleCount}.yak`,
code: s.Content,
suffix: "yak",
isFile: false
}
info(`加载 Yak 模块:${s.ScriptName}`)
isInteractive
? xtermClear(xtermRef)
: xtermClear(interactiveXtermRef)
setActiveTab(`${tabList.length}`)
setTabList(tabList.concat([tab]))
setUnTitleCount(unTitleCount + 1)
m.destroy()
}}
/>
</>
)
})
}}
>
Yak脚本模板
</Button> */}
<Button
icon={
fullScreen ? (
Expand Down
Loading

0 comments on commit 5eeeb1d

Please sign in to comment.