From e3d839251cd6c8c6451a2518ff3eff2c332b3a96 Mon Sep 17 00:00:00 2001 From: Lars Karlslund Date: Sat, 15 Jan 2022 15:39:28 +0100 Subject: [PATCH] Add warning for GPO collection if no files are actualy collected (hints to maybe running collection as Domain Admin) --- modules/integrations/activedirectory/collect/cli.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/integrations/activedirectory/collect/cli.go b/modules/integrations/activedirectory/collect/cli.go index 8c94159..b33fddc 100644 --- a/modules/integrations/activedirectory/collect/cli.go +++ b/modules/integrations/activedirectory/collect/cli.go @@ -383,6 +383,7 @@ func Execute(cmd *cobra.Command, args []string) error { gpoinfo.GPOinfo.Path = originalpath // The original path is kept, we don't care offset := len(gppath) + var filescollected int filepath.WalkDir(gppath, func(curpath string, d fs.DirEntry, err error) error { if !d.IsDir() && (strings.HasSuffix(strings.ToLower(curpath), ".adm") || strings.HasSuffix(strings.ToLower(curpath), ".admx")) { @@ -405,6 +406,8 @@ func Execute(cmd *cobra.Command, args []string) error { } } if !d.IsDir() { + filescollected++ + rawfile, err := ioutil.ReadFile(curpath) if err == nil { fileinfo.Contents = rawfile @@ -416,6 +419,10 @@ func Execute(cmd *cobra.Command, args []string) error { return nil }) + if filescollected == 0 { + log.Warn().Msgf("No files found/accessible in %v", gppath) + } + gpodatafile := filepath.Join(datapath, gpoguid[0]+".gpodata.json") f, err := os.Create(gpodatafile) if err != nil {