Skip to content

Commit 62d3f50

Browse files
committed
Change path package to filepath, and ignore errors on powershell
1 parent e4d16dc commit 62d3f50

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

ee/tables/ntfs_ads_zone_id/zone_identifier.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"context"
99
"fmt"
1010
"log/slog"
11-
"path"
11+
"path/filepath"
1212
"strings"
1313

1414
"github.com/kolide/launcher/ee/allowedcmd"
@@ -42,11 +42,11 @@ func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) (
4242
return nil, fmt.Errorf("kolide_ntfs_ads_zone_id requires at least one path to be specified")
4343
}
4444

45-
for _, p := range paths {
45+
for _, path := range paths {
4646
for _, dataQuery := range tablehelpers.GetConstraints(queryContext, "query", tablehelpers.WithDefaults("*")) {
4747
var output bytes.Buffer
48-
if err := tablehelpers.Run(ctx, t.slogger, 30, allowedcmd.Powershell, []string{"Get-Content", "-Path", path.Clean(p), "-Stream", "Zone.Identifier"}, &output, &output); err != nil {
49-
t.slogger.Log(ctx, slog.LevelInfo, "failure running powershell get-content command", "err", err, "path", p)
48+
if err := tablehelpers.Run(ctx, t.slogger, 30, allowedcmd.Powershell, []string{"Get-Content", "-Path", filepath.Clean(path), "-Stream", "Zone.Identifier", "-ErrorAction", "Ignore"}, &output, &output); err != nil {
49+
t.slogger.Log(ctx, slog.LevelInfo, "failure running powershell get-content command", "err", err, "path", path)
5050
continue
5151
}
5252

@@ -62,7 +62,7 @@ func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) (
6262
}
6363

6464
rowData := map[string]string{
65-
"path": p,
65+
"path": path,
6666
}
6767

6868
results = append(results, dataflattentable.ToMap(flattened, dataQuery, rowData)...)

0 commit comments

Comments
 (0)