Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase timeout for powershell wlanapi execution #720

Merged
merged 3 commits into from
Mar 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/osquery/tables/wifi_networks/wifi_networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/kolide/launcher/pkg/dataflatten"
"github.com/kolide/launcher/pkg/osquery/tables/dataflattentable"
"github.com/kolide/launcher/pkg/osquery/tables/wifi_networks/internal"
Expand Down Expand Up @@ -43,7 +44,7 @@ func TablePlugin(client *osquery.ExtensionManagerClient, logger log.Logger) *tab
}

func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) ([]map[string]string, error) {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
var results []map[string]string
var output bytes.Buffer
Expand All @@ -61,9 +62,9 @@ func (t *Table) generate(ctx context.Context, queryContext table.QueryContext) (

func execPwsh(logger log.Logger) execer {
return func(ctx context.Context, buf *bytes.Buffer) error {
// MS requires interfaces to complete network scans in <4 seconds
// give a bit more time for everything else to run.
ctx, cancel := context.WithTimeout(ctx, 4500*time.Millisecond)
// MS requires interfaces to complete network scans in <4 seconds, but
// that appears not to be consistent
ctx, cancel := context.WithTimeout(ctx, 45*time.Second)
defer cancel()

// write the c# code to a file, so the powershell script can load it
Expand Down Expand Up @@ -119,6 +120,9 @@ func execPwsh(logger log.Logger) execer {
// sometimes the powershell script logs errors to stderr, but returns a
// successful execution code.
if err != nil || errOutput != "" {
// if there is an error, inspect the contents of stdout
level.Debug(logger).Log("msg", "error execing, inspecting stdout contents", "stdout", buf.String())

if err == nil {
err = errors.Errorf("exec succeeded, but emitted to stderr")
}
Expand Down