diff --git a/internal/commands/process/filelist/filelist.go b/internal/commands/process/filelist/filelist.go index 559a49889..0ade9ca16 100644 --- a/internal/commands/process/filelist/filelist.go +++ b/internal/commands/process/filelist/filelist.go @@ -19,21 +19,23 @@ import ( func Discover(repository *gitrepository.Repository, targetPath string, goclocResult *gocloc.Result, config settings.Config) (*flfiles.List, error) { ignore := ignore.New(targetPath, config) - fileList, err := repository.ListFiles(ignore, goclocResult) - if err != nil { - log.Error().Msg("Git discovery failed") - return nil, err - } + if !config.IgnoreGit { + fileList, err := repository.ListFiles(ignore, goclocResult) + if err != nil { + log.Error().Msg("Git discovery failed") + return nil, err + } - if fileList != nil { - log.Debug().Msg("Files found from Git") - return fileList, nil - } + if fileList != nil { + log.Debug().Msg("Files found from Git") + return fileList, nil + } - log.Debug().Msg("No files found from Git") + log.Debug().Msg("No files found from Git") + } var files []flfiles.File - err = filepath.WalkDir(targetPath, func(filePath string, d fs.DirEntry, err error) error { + err := filepath.WalkDir(targetPath, func(filePath string, d fs.DirEntry, err error) error { if err != nil { return err } diff --git a/internal/commands/process/settings/settings.go b/internal/commands/process/settings/settings.go index b20732f2a..d9fc4c475 100644 --- a/internal/commands/process/settings/settings.go +++ b/internal/commands/process/settings/settings.go @@ -62,8 +62,9 @@ type Config struct { BearerRulesVersion string `mapstructure:"bearer_rules_version" json:"bearer_rules_version" yaml:"bearer_rules_version"` NoColor bool `mapstructure:"no_color" json:"no_color" yaml:"no_color"` Debug bool `mapstructure:"debug" json:"debug" yaml:"debug"` - LogLevel string `mapstructure:"string" json:"string" yaml:"string"` + LogLevel string `mapstructure:"log_level" json:"log_level" yaml:"log_level"` DebugProfile bool `mapstructure:"debug_profile" json:"debug_profile" yaml:"debug_profile"` + IgnoreGit bool `mapstructure:"ignore_git" json:"ignore_git" yaml:"ignore_git"` } type Modules []*PolicyModule @@ -354,6 +355,7 @@ func FromOptions(opts flag.Options, versionMeta *version_check.VersionMeta) (Con Debug: opts.GeneralOptions.Debug, LogLevel: opts.GeneralOptions.LogLevel, IgnoreFile: opts.GeneralOptions.IgnoreFile, + IgnoreGit: opts.GeneralOptions.IgnoreGit, Policies: policies, Rules: result.Rules, BuiltInRules: result.BuiltInRules, diff --git a/internal/flag/general_flags.go b/internal/flag/general_flags.go index 13f60e23b..adaa677a7 100644 --- a/internal/flag/general_flags.go +++ b/internal/flag/general_flags.go @@ -79,6 +79,14 @@ var ( Hide: true, DisableInConfig: true, } + IgnoreGitFlag = Flag{ + Name: "ignore-git", + ConfigName: "ignore-git", + Value: false, + Usage: "Ignore Git listing", + Hide: true, + DisableInConfig: true, + } ) type GeneralFlagGroup struct { @@ -91,6 +99,7 @@ type GeneralFlagGroup struct { DebugFlag *Flag LogLevelFlag *Flag DebugProfile *Flag + IgnoreGit *Flag } // GlobalOptions defines flags and other configuration parameters for all the subcommands @@ -103,6 +112,7 @@ type GeneralOptions struct { Debug bool `mapstructure:"debug" json:"debug" yaml:"debug"` LogLevel string `mapstructure:"log-level" json:"log-level" yaml:"log-level"` DebugProfile bool + IgnoreGit bool `mapstructure:"ignore-git" json:"ignore-git" yaml:"ignore-git"` } func NewGeneralFlagGroup() *GeneralFlagGroup { @@ -116,6 +126,7 @@ func NewGeneralFlagGroup() *GeneralFlagGroup { DebugFlag: &DebugFlag, LogLevelFlag: &LogLevelFlag, DebugProfile: &DebugProfileFlag, + IgnoreGit: &IgnoreGitFlag, } } @@ -134,6 +145,7 @@ func (f *GeneralFlagGroup) Flags() []*Flag { f.DebugFlag, f.LogLevelFlag, f.DebugProfile, + f.IgnoreGit, } } @@ -169,6 +181,7 @@ func (f *GeneralFlagGroup) ToOptions() GeneralOptions { IgnoreFile: getString(f.IgnoreFile), Debug: debug, LogLevel: logLevel, + IgnoreGit: getBool(f.IgnoreGit), DebugProfile: getBool(f.DebugProfile), } }