Skip to content

Commit

Permalink
Add warning for GPO collection if no files are actualy collected (hin…
Browse files Browse the repository at this point in the history
…ts to maybe running collection as Domain Admin)
  • Loading branch information
lkarlslund committed Jan 15, 2022
1 parent e508d8e commit e3d8392
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/integrations/activedirectory/collect/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit e3d8392

Please sign in to comment.