mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-29 12:44:22 +01:00
feat(git): disable link generation (#1748)
Add an option to disable link creation. If there are any weird edge cases, it shouldn't block scanning
This commit is contained in:
1 parent
c6424a6fc3
commit
ae26eff464
6 files changed
+27
-26
No files matched your search
+1
-4
@@ -99,7 +99,7 @@ func runDetect(cmd *cobra.Command, args []string) {
|
||||
logOpts = mustGetStringFlag(cmd, "log-opts")
|
||||
gitCmd *sources.GitCmd
|
||||
scmPlatform scm.Platform
|
||||
remote *detect.RemoteInfo
|
||||
remote = detect.NewRemoteInfo(scmPlatform, source)
|
||||
)
|
||||
if gitCmd, err = sources.NewGitLogCmd(source, logOpts); err != nil {
|
||||
logging.Fatal().Err(err).Msg("could not create Git cmd")
|
||||
@@ -107,9 +107,6 @@ func runDetect(cmd *cobra.Command, args []string) {
|
||||
if scmPlatform, err = scm.PlatformFromString(mustGetStringFlag(cmd, "platform")); err != nil {
|
||||
logging.Fatal().Err(err).Send()
|
||||
}
|
||||
if remote, err = detect.NewRemoteInfo(scmPlatform, source); err != nil {
|
||||
logging.Fatal().Err(err).Msg("failed to scan Git repository")
|
||||
}
|
||||
|
||||
if findings, err = detector.DetectGit(gitCmd, remote); err != nil {
|
||||
// don't exit on error, just log it
|
||||
|
||||
+1
-3
@@ -74,9 +74,7 @@ func runGit(cmd *cobra.Command, args []string) {
|
||||
if scmPlatform, err = scm.PlatformFromString(mustGetStringFlag(cmd, "platform")); err != nil {
|
||||
logging.Fatal().Err(err).Send()
|
||||
}
|
||||
if remote, err = detect.NewRemoteInfo(scmPlatform, source); err != nil {
|
||||
logging.Fatal().Err(err).Msg("failed to scan Git repository")
|
||||
}
|
||||
remote = detect.NewRemoteInfo(scmPlatform, source)
|
||||
}
|
||||
|
||||
findings, err = detector.DetectGit(gitCmd, remote)
|
||||
|
||||
+7
-3
@@ -8,7 +8,8 @@ import (
|
||||
type Platform int
|
||||
|
||||
const (
|
||||
NoPlatform Platform = iota
|
||||
UnknownPlatform Platform = iota
|
||||
NoPlatform // Explicitly disable the feature
|
||||
GitHubPlatform
|
||||
GitLabPlatform
|
||||
// TODO: Add others.
|
||||
@@ -16,6 +17,7 @@ const (
|
||||
|
||||
func (p Platform) String() string {
|
||||
return [...]string{
|
||||
"unknown",
|
||||
"none",
|
||||
"github",
|
||||
"gitlab",
|
||||
@@ -24,13 +26,15 @@ func (p Platform) String() string {
|
||||
|
||||
func PlatformFromString(s string) (Platform, error) {
|
||||
switch strings.ToLower(s) {
|
||||
case "", "none":
|
||||
case "", "unknown":
|
||||
return UnknownPlatform, nil
|
||||
case "none":
|
||||
return NoPlatform, nil
|
||||
case "github":
|
||||
return GitHubPlatform, nil
|
||||
case "gitlab":
|
||||
return GitLabPlatform, nil
|
||||
default:
|
||||
return NoPlatform, fmt.Errorf("invalid scm platform value: %s", s)
|
||||
return UnknownPlatform, fmt.Errorf("invalid scm platform value: %s", s)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user