mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00

移除了36个静态分析工具识别的未使用函数,减少代码体积534行: 核心模块: - core/PluginAdapter.go: 移除7个未使用的插件适配器方法 - core/Registry.go: 移除5个未使用的注册器方法 - core/Scanner.go: 移除1个未使用的扫描方法 - core/WebDetection.go: 移除4个未使用的Web检测方法 通用模块: - common/ConcurrencyMonitor.go: 移除3个未使用的并发监控方法 - common/common.go: 移除1个未使用的插件注册方法 - common/base/Plugin.go: 移除4个未使用的插件管理方法 - common/parsers/Simple.go: 移除1个未使用的端口解析方法 - common/utils/memmonitor.go: 移除9个未使用的内存监控方法 - common/utils/slicepool.go: 移除1个未使用的切片去重方法 插件模块: - plugins/services/vnc/plugin.go: 移除1个未使用的服务识别方法 所有移除的函数均替换为中文注释标记,保持代码可读性。
78 lines
2.0 KiB
Go
78 lines
2.0 KiB
Go
package core
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/shadow1ng/fscan/common"
|
|
"github.com/shadow1ng/fscan/plugins/base"
|
|
)
|
|
|
|
// PluginAdapter 插件适配器
|
|
// 提供从新插件系统到旧扫描接口的适配
|
|
type PluginAdapter struct {
|
|
registry *base.PluginRegistry
|
|
}
|
|
|
|
// NewPluginAdapter 创建插件适配器
|
|
func NewPluginAdapter() *PluginAdapter {
|
|
return &PluginAdapter{
|
|
registry: base.GlobalPluginRegistry,
|
|
}
|
|
}
|
|
|
|
// 全局插件适配器实例
|
|
var GlobalPluginAdapter = NewPluginAdapter()
|
|
|
|
// GetAllPluginNames 获取所有插件名称
|
|
func (pa *PluginAdapter) GetAllPluginNames() []string {
|
|
return pa.registry.GetAll()
|
|
}
|
|
|
|
// PluginExists 检查插件是否存在
|
|
func (pa *PluginAdapter) PluginExists(name string) bool {
|
|
metadata := pa.registry.GetMetadata(name)
|
|
return metadata != nil
|
|
}
|
|
|
|
// 已移除未使用的 GetPluginPorts 方法
|
|
|
|
// 已移除未使用的 GetPluginsByPort 方法
|
|
|
|
// 已移除未使用的 GetPluginsByType 方法
|
|
|
|
// ScanWithPlugin 使用插件进行扫描
|
|
func (pa *PluginAdapter) ScanWithPlugin(pluginName string, info *common.HostInfo) error {
|
|
common.LogDebug(fmt.Sprintf("使用新插件架构扫描: %s", pluginName))
|
|
|
|
// 创建插件实例
|
|
plugin, err := pa.registry.Create(pluginName)
|
|
if err != nil {
|
|
return fmt.Errorf("创建插件 %s 失败: %v", pluginName, err)
|
|
}
|
|
|
|
// 执行扫描
|
|
result, err := plugin.Scan(context.Background(), info)
|
|
if err != nil {
|
|
return fmt.Errorf("插件 %s 扫描失败: %v", pluginName, err)
|
|
}
|
|
|
|
// 处理扫描结果
|
|
if result == nil {
|
|
common.LogDebug(fmt.Sprintf("插件 %s 返回了空结果", pluginName))
|
|
} else if result.Success {
|
|
common.LogDebug(fmt.Sprintf("插件 %s 扫描成功", pluginName))
|
|
// TODO: 输出扫描结果
|
|
} else {
|
|
common.LogDebug(fmt.Sprintf("插件 %s 扫描失败: %v", pluginName, result.Error))
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// 已移除未使用的 FilterPluginsByType 方法
|
|
|
|
// 已移除未使用的 GetServicePlugins 方法
|
|
|
|
// 已移除未使用的 GetWebPlugins 方法
|
|
|
|
// 已移除未使用的 GetLocalPlugins 方法
|