diff --git a/common/config.go b/common/config.go index 0ff918b..6e82290 100644 --- a/common/config.go +++ b/common/config.go @@ -49,6 +49,7 @@ type ENOptions struct { OutPutType string // 导出文件类型 IsApiMode bool ENConfig *ENConfig + BranchFilter string } // EnsGo EnScan 接口请求通用格式接口 diff --git a/common/flag.go b/common/flag.go index 587cf5e..5058137 100644 --- a/common/flag.go +++ b/common/flag.go @@ -41,6 +41,7 @@ func Flag(Info *ENOptions) { flag.BoolVar(&Info.IsSearchBranch, "is-branch", false, "深度查询分支机构信息(数量巨大)") flag.BoolVar(&Info.IsJsonOutput, "json", false, "json导出") flag.StringVar(&Info.Output, "out-dir", "", "结果输出的文件夹位置(默认为outs)") + flag.StringVar(&Info.BranchFilter, "branch-filter", "", "提供一个正则表达式,名称匹配该正则的分支机构和子公司会被跳过") flag.StringVar(&Info.UPOutFile, "out-update", "", "导出指定范围文件,自更新") flag.StringVar(&Info.OutPutType, "out-type", "xlsx", "导出的文件后缀 默认xlsx") flag.BoolVar(&Info.IsDebug, "debug", false, "是否显示debug详细信息") diff --git a/runner/enscan.go b/runner/enscan.go index 3a7c908..13437cc 100644 --- a/runner/enscan.go +++ b/runner/enscan.go @@ -2,6 +2,8 @@ package runner import ( "fmt" + "regexp" + "github.com/tidwall/gjson" "github.com/tidwall/sjson" "github.com/wgpsec/ENScan/common" @@ -49,6 +51,10 @@ func getInfoById(pid string, searchList []string, job _interface.ENScan) (enInfo if len(ds) > 0 { gologger.Info().Msgf("深度搜索列表:%v", ds) } + var etNameFilter *regexp.Regexp + if options.BranchFilter != "" { + etNameFilter = regexp.MustCompile(options.BranchFilter) + } for _, sk := range ds { enSk := enMap[sk].Field pidName := enSk[len(enSk)-2] @@ -73,6 +79,10 @@ func getInfoById(pid string, searchList []string, job _interface.ENScan) (enInfo for _, r := range iEnData[i] { tPid := r.Get(pidName).String() tName := r.Get(etNameJ).String() + if etNameFilter != nil && etNameFilter.MatchString(tName) { + gologger.Info().Msgf("根据过滤器跳过 [%s]", tName) + continue + } gologger.Debug().Str("PID", tPid).Str("Name", tName).Str("PID NAME", pidName).Msgf("查询PID") // 计算投资比例判断是否符合 investNum := utils.FormatInvest(r.Get(scaleName).String()) @@ -100,6 +110,11 @@ func getInfoById(pid string, searchList []string, job _interface.ENScan) (enInfo for i, r := range enInfo[sk] { gologger.Info().Msgf("[%d/%d]", i, enLen) tPid := r.Get(pidName).String() + tName := r.Get(etNameJ).String() + if etNameFilter != nil && etNameFilter.MatchString(tName) { + gologger.Info().Msgf("根据过滤器跳过 [%s]", tName) + continue + } dEnData := getCompanyInfoById(tPid, association, searchList, job) // 把查询完的一个企业按类别存起来 for dk, dr := range dEnData {