Skip to content

Commit 9917a07

Browse files
added feature flag
1 parent 162ccc8 commit 9917a07

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ func run(state overseer.State) {
450450
// OSS Default APK handling on
451451
feature.EnableAPKHandler.Store(true)
452452

453+
// OSS Default simplified gitlab enumeration
454+
feature.UseSimplifiedGitlabEnumeration.Store(true)
455+
453456
conf := &config.Config{}
454457
if *configFilename != "" {
455458
var err error

pkg/feature/feature.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package feature
33
import "sync/atomic"
44

55
var (
6-
ForceSkipBinaries atomic.Bool
7-
ForceSkipArchives atomic.Bool
8-
SkipAdditionalRefs atomic.Bool
9-
EnableAPKHandler atomic.Bool
10-
UserAgentSuffix AtomicString
6+
ForceSkipBinaries atomic.Bool
7+
ForceSkipArchives atomic.Bool
8+
SkipAdditionalRefs atomic.Bool
9+
EnableAPKHandler atomic.Bool
10+
UserAgentSuffix AtomicString
11+
UseSimplifiedGitlabEnumeration atomic.Bool
1112
)
1213

1314
type AtomicString struct {

pkg/sources/gitlab/gitlab.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/trufflesecurity/trufflehog/v3/pkg/common"
1212
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
13+
"github.com/trufflesecurity/trufflehog/v3/pkg/feature"
1314
"github.com/trufflesecurity/trufflehog/v3/pkg/giturl"
1415
"github.com/trufflesecurity/trufflehog/v3/pkg/log"
1516
"github.com/trufflesecurity/trufflehog/v3/pkg/pb/source_metadatapb"
@@ -31,9 +32,6 @@ const SourceType = sourcespb.SourceType_SOURCE_TYPE_GITLAB
3132
// This is the URL for gitlab hosted at gitlab.com
3233
const gitlabBaseURL = "https://gitlab.com/"
3334

34-
// useSimplifiedGitlabEnumeration if set to true use simplified list-all-projects API to enumerate
35-
var useSimplifiedGitlabEnumeration = true
36-
3735
type Source struct {
3836
name string
3937
sourceID sources.SourceID
@@ -268,7 +266,7 @@ func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, tar
268266
return ctx.Err()
269267
},
270268
}
271-
if useSimplifiedGitlabEnumeration {
269+
if feature.UseSimplifiedGitlabEnumeration.Load() {
272270
if err := s.getAllProjectReposV2(ctx, apiClient, ignoreRepo, reporter); err != nil {
273271
return err
274272
}
@@ -403,7 +401,7 @@ func (s *Source) Validate(ctx context.Context) []error {
403401
},
404402
}
405403

406-
if useSimplifiedGitlabEnumeration {
404+
if feature.UseSimplifiedGitlabEnumeration.Load() {
407405
if err := s.getAllProjectReposV2(ctx, apiClient, ignoreProject, visitor); err != nil {
408406
errs = append(errs, err)
409407
return errs
@@ -943,7 +941,7 @@ func (s *Source) Enumerate(ctx context.Context, reporter sources.UnitReporter) e
943941
_ = reporter.UnitErr(ctx, fmt.Errorf("could not compile include/exclude repo glob: %w", err))
944942
})
945943

946-
if useSimplifiedGitlabEnumeration {
944+
if feature.UseSimplifiedGitlabEnumeration.Load() {
947945
return s.getAllProjectReposV2(ctx, apiClient, ignoreRepo, reporter)
948946
} else {
949947
return s.getAllProjectRepos(ctx, apiClient, ignoreRepo, reporter)

0 commit comments

Comments
 (0)