Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加分支机构和子公司名称过滤功能 #141

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type ENOptions struct {
OutPutType string // 导出文件类型
IsApiMode bool
ENConfig *ENConfig
BranchFilter string
}

// EnsGo EnScan 接口请求通用格式接口
Expand Down
1 change: 1 addition & 0 deletions common/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -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详细信息")
Expand Down
15 changes: 15 additions & 0 deletions runner/enscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package runner

import (
"fmt"
"regexp"

"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
"github.com/wgpsec/ENScan/common"
Expand Down Expand Up @@ -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]
Expand All @@ -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())
Expand Down Expand Up @@ -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 {
Expand Down
Loading