44 "context"
55 "path/filepath"
66
7+ "github.com/murphysecurity/murphysec/env"
78 "github.com/murphysecurity/murphysec/infra/logctx"
89 "github.com/murphysecurity/murphysec/infra/ui"
910 "github.com/murphysecurity/murphysec/model"
@@ -28,24 +29,30 @@ func (Inspector) CheckDir(ctx context.Context, dir string) bool {
2829func (Inspector ) InspectProject (ctx context.Context ) error {
2930 logger := logctx .Use (ctx )
3031 task := model .UseInspectionTask (ctx )
31- var doOld = false
32+ allowFallback := ! env .ScannerScan
33+ doOld := false
34+
3235 var e error
3336 if ! task .IsNoBuild () {
3437 if multipleBuilds (ctx , task ) != nil {
3538 logger .Warn ("multipleBuilds no build" )
3639 ui .Use (ctx ).Display (ui .MsgWarn , "通过 Nuget获取依赖信息失败,可能会导致检测结果不完整或失败,访问 https://murphysec.com/docs/faqs/quick-start-for-beginners/programming-language-supported.html 了解详情" )
37- e = noBuildEntrance (ctx , task , & doOld )
38- } else {
40+ if allowFallback {
41+ e = noBuildEntrance (ctx , task , & doOld )
42+ }
43+ } else if allowFallback {
3944 e = noBuildEntrance (ctx , task , & doOld )
4045 }
4146 } else {
4247 logger .Warn ("multipleBuilds no build" )
43- e = noBuildEntrance (ctx , task , & doOld )
48+ if allowFallback {
49+ e = noBuildEntrance (ctx , task , & doOld )
50+ }
4451 }
4552 if e != nil {
4653 logger .Sugar ().Error (e )
4754 }
48- if doOld {
55+ if doOld && allowFallback {
4956 packagesFilePath := filepath .Join (task .Dir (), "packages.config" )
5057 if checkPackagesIsExistence (packagesFilePath ) {
5158 return scanPackage (task , packagesFilePath )
0 commit comments