Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions tools/benchmark/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type attestWorker struct {
workerConfig
useSyscallMonitor bool
useNetworkProxy bool
overwriteMode schema.OverwriteMode
}

var _ packageWorker = &attestWorker{}
Expand All @@ -136,6 +137,7 @@ func (w *attestWorker) ProcessOne(ctx context.Context, p benchmark.Package, out
ID: w.runID,
UseSyscallMonitor: w.useSyscallMonitor,
UseNetworkProxy: w.useNetworkProxy,
OverwriteMode: w.overwriteMode,
}
var verdict *schema.Verdict
var err error
Expand Down Expand Up @@ -229,6 +231,7 @@ type RunBenchOpts struct {
MaxConcurrency int
UseSyscallMonitor bool
UseNetworkProxy bool
OverwriteMode schema.OverwriteMode
ExecService ExecutionService
}

Expand Down Expand Up @@ -258,6 +261,7 @@ func RunBench(ctx context.Context, set benchmark.PackageSet, opts RunBenchOpts)
workerConfig: conf,
useSyscallMonitor: opts.UseSyscallMonitor,
useNetworkProxy: opts.UseNetworkProxy,
overwriteMode: opts.OverwriteMode,
}
default:
return nil, fmt.Errorf("invalid mode: %s", string(opts.Mode))
Expand Down
4 changes: 4 additions & 0 deletions tools/ctl/command/runbenchmark/runbenchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func (c Config) Validate() error {
if c.Format != "" && c.Format != "summary" && c.Format != "csv" {
return errors.Errorf("invalid format: %s. Expected one of 'summary' or 'csv'", c.Format)
}
if c.OverwriteMode != "" && c.OverwriteMode != string(schema.OverwriteServiceUpdate) && c.OverwriteMode != string(schema.OverwriteForce) {
return errors.Errorf("invalid overwrite-mode: %s. Expected one of 'SERVICE_UPDATE' or 'FORCE'", c.OverwriteMode)
}
return nil
}

Expand Down Expand Up @@ -190,6 +193,7 @@ func Handler(ctx context.Context, cfg Config, deps *Deps) (*act.NoOutput, error)
MaxConcurrency: cfg.MaxConcurrency,
UseSyscallMonitor: cfg.UseSyscallMonitor,
UseNetworkProxy: cfg.UseNetworkProxy,
OverwriteMode: schema.OverwriteMode(cfg.OverwriteMode),
})
if err != nil {
return nil, errors.Wrap(err, "running benchmark")
Expand Down
6 changes: 6 additions & 0 deletions tools/ctl/command/runone/runone.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Config struct {
Strategy string
UseNetworkProxy bool
UseSyscallMonitor bool
OverwriteMode string
Mode string
}

Expand All @@ -61,6 +62,9 @@ func (c Config) Validate() error {
if mode != schema.SmoketestMode && mode != schema.AttestMode && mode != analyzeMode {
return errors.Errorf("unknown mode: %s. Expected one of 'smoketest', 'attest', or 'analyze'", c.Mode)
}
if c.OverwriteMode != "" && c.OverwriteMode != string(schema.OverwriteServiceUpdate) && c.OverwriteMode != string(schema.OverwriteForce) {
return errors.Errorf("invalid overwrite-mode: %s. Expected one of 'SERVICE_UPDATE' or 'FORCE'", c.OverwriteMode)
}
return nil
}

Expand Down Expand Up @@ -165,6 +169,7 @@ func Handler(ctx context.Context, cfg Config, deps *Deps) (*act.NoOutput, error)
Artifact: cfg.Artifact,
UseNetworkProxy: cfg.UseNetworkProxy,
UseSyscallMonitor: cfg.UseSyscallMonitor,
OverwriteMode: schema.OverwriteMode(cfg.OverwriteMode),
ID: time.Now().UTC().Format(time.RFC3339),
})
if err != nil {
Expand Down Expand Up @@ -206,5 +211,6 @@ func flagSet(name string, cfg *Config) *flag.FlagSet {
set.StringVar(&cfg.Strategy, "strategy", "", "the strategy file to use")
set.BoolVar(&cfg.UseNetworkProxy, "use-network-proxy", false, "request the newtwork proxy")
set.BoolVar(&cfg.UseSyscallMonitor, "use-syscall-monitor", false, "request syscall monitoring")
set.StringVar(&cfg.OverwriteMode, "overwrite-mode", "", "reason to overwrite existing attestation (SERVICE_UPDATE or FORCE)")
return set
}
12 changes: 12 additions & 0 deletions tools/ctl/command/runone/runone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ func TestValidation(t *testing.T) {
},
wantErr: true,
},
{
name: "invalid overwrite mode",
cfg: Config{
API: "http://test",
Ecosystem: "npm",
Package: "test",
Version: "1.0.0",
Mode: "attest",
OverwriteMode: "INVALID",
},
wantErr: true,
},
{
name: "valid config smoketest",
cfg: Config{
Expand Down