MCPcopy
hub / github.com/deepfence/SecretScanner / main

Function main

main.go:78–135  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76}
77
78func main() {
79 zerolog.CallerMarshalFunc = func(pc uintptr, file string, line int) string {
80 return filepath.Base(file) + ":" + strconv.Itoa(line)
81 }
82 log.Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: "2006-01-02T15:04:05Z07:00"}).
83 With().Timestamp().Caller().Logger()
84
85 log.Info().Str("version", version).Msg("starting")
86
87 flag.Parse()
88
89 if *core.GetSession().Options.Debug {
90 zerolog.SetGlobalLevel(zerolog.DebugLevel)
91 } else {
92 zerolog.SetGlobalLevel(zerolog.InfoLevel)
93 }
94
95 ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)
96
97 out.ScanStatusFilename = jobs.GetDfInstallDir() + "/var/log/fenced/secret-scan-log/secret_scan_log.log"
98 out.ScanFilename = jobs.GetDfInstallDir() + "/var/log/fenced/secret-scan/secret_scan.log"
99
100 runnerOpts := runner.RunnerOptions{
101 SocketPath: *socketPath,
102 RulesPath: *core.GetSession().Options.RulesPath,
103 HostMountPath: *core.GetSession().Options.HostMountPath,
104 FailOnCompileWarning: *core.GetSession().Options.FailOnCompileWarning,
105 Local: *core.GetSession().Options.Local,
106 ImageName: *core.GetSession().Options.ImageName,
107 ContainerID: *core.GetSession().Options.ContainerID,
108 ConsoleURL: *core.GetSession().Options.ConsoleURL,
109 ConsolePort: *core.GetSession().Options.ConsolePort,
110 DeepfenceKey: *core.GetSession().Options.DeepfenceKey,
111 OutFormat: *core.GetSession().Options.OutFormat,
112 FailOnHighCount: *core.GetSession().Options.FailOnHighCount,
113 FailOnMediumCount: *core.GetSession().Options.FailOnMediumCount,
114 FailOnLowCount: *core.GetSession().Options.FailOnLowCount,
115 FailOnCount: *core.GetSession().Options.FailOnCount,
116 InactiveThreshold: *core.GetSession().Options.InactiveThreshold,
117 }
118
119 // Download rules if updater is enabled and in CLI mode
120 if *socketPath == "" && *core.GetSession().Options.EnableUpdater {
121 downloadRules(ctx, core.GetSession().Options)
122 }
123
124 runner.StartYaraHunter(ctx, runnerOpts, core.GetSession().ExtractorConfig,
125
126 func(base *yaraserver.GRPCScannerServer) server.SecretGRPCServer {
127 return server.SecretGRPCServer{
128 GRPCScannerServer: base,
129 UnimplementedSecretScannerServer: pb.UnimplementedSecretScannerServer{},
130 }
131 },
132 func(s grpc.ServiceRegistrar, impl any) {
133 pb.RegisterSecretScannerServer(s, impl.(pb.SecretScannerServer))
134 })
135}

Callers

nothing calls this directly

Calls 3

GetSessionFunction · 0.92
GetDfInstallDirFunction · 0.92
downloadRulesFunction · 0.85

Tested by

no test coverage detected