Skip to content

Commit b6f95c2

Browse files
committed
fix(conan): skip fallback logic when ScannerScan is enabled in Conan and Nuget modules
1 parent 32e14e1 commit b6f95c2

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

module/conan/conan.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ func (Inspector) InspectProject(ctx context.Context) error {
4242

4343
var conanErr conanError
4444
if errors.As(e, &conanErr) {
45-
badConanView(ctx)
46-
printConanError(ctx, &conanErr)
45+
if !env.ScannerScan {
46+
badConanView(ctx)
47+
printConanError(ctx, &conanErr)
48+
}
4749
return e
4850
}
4951
if e != nil {

module/nuget/nuget.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
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 {
2829
func (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

Comments
 (0)