@@ -20,7 +20,7 @@ func GenAQLForGolang(packageName, version string) string {
2020}
2121
2222// 获取包
23- func GetMod () []request.Component {
23+ func GetMod () ( []request.Component , string ) {
2424 //fmt.Println(getCurrentPath())
2525 path , _ := os .Executable ()
2626 return scanFile (path , true )
@@ -35,7 +35,7 @@ func isExe(file string, info fs.FileInfo) bool {
3535}
3636
3737// 从二进制文件读取包信息
38- func scanFile (file string , mustPrint bool ) (packages []request.Component ) {
38+ func scanFile (file string , mustPrint bool ) (packages []request.Component , agentVersion string ) {
3939 bi , err := buildinfo .ReadFile (file )
4040 if err != nil {
4141 if mustPrint {
@@ -45,7 +45,7 @@ func scanFile(file string, mustPrint bool) (packages []request.Component) {
4545 fmt .Fprintf (os .Stderr , "%s: %v\n " , file , err )
4646 }
4747 }
48- return packages
48+ return packages , agentVersion
4949 }
5050 fmt .Printf ("%s: %s\n " , file , bi .GoVersion )
5151 bi .GoVersion = "" // suppress printing go version again
@@ -57,16 +57,21 @@ func scanFile(file string, mustPrint bool) (packages []request.Component) {
5757 if licl [0 ] == "dep" {
5858 fmt .Printf ("依赖:%s\t 版本:%s\n " , licl [1 ], licl [2 ])
5959 aql := GenAQLForGolang (licl [1 ], licl [2 ])
60+ if licl [1 ] == "github.com/HXSecurity/DongTai-agent-go" {
61+ fmt .Println ("当前探针版本为:" + licl [2 ])
62+ agentVersion = licl [2 ]
63+ }
6064 packages = append (packages , request.Component {
6165 PackageName : aql ,
6266 PackageAlgorithm : "SHA-1" ,
6367 PackagePath : file ,
68+ PackageVersion : licl [2 ],
6469 PackageSignature : utils .SHA1 (aql ),
6570 },
6671 )
6772 }
6873 }
69- return
74+ return packages , agentVersion
7075}
7176
7277// 获取服务信息
0 commit comments