MCPcopy Create free account
hub / github.com/Xenov-X/csbot / executeConsoleCommand

Method executeConsoleCommand

workflow/executor_config.go:232–256  ·  view source on GitHub ↗

executeConsoleCommand executes a console command on the beacon

(ctx context.Context, client *csclient.Client, beaconID string, action Action)

Source from the content-addressed store, hash-verified

230
231// executeConsoleCommand executes a console command on the beacon
232func (e *Executor) executeConsoleCommand(ctx context.Context, client *csclient.Client, beaconID string, action Action) (string, error) {
233 command, ok := action.Parameters["command"].(string)
234 if !ok {
235 return "", fmt.Errorf("command parameter required for console_command")
236 }
237
238 arguments, _ := action.Parameters["arguments"].(string) // optional
239
240 // Files parameter is optional, parse if present
241 var files map[string]string
242 if filesInterface, ok := action.Parameters["files"].(map[string]interface{}); ok {
243 files = make(map[string]string)
244 for k, v := range filesInterface {
245 if strVal, ok := v.(string); ok {
246 files[k] = strVal
247 }
248 }
249 }
250
251 resp, err := client.ConsoleCommand(ctx, beaconID, command, arguments, files)
252 if err != nil {
253 return "", err
254 }
255 return e.waitForOutput(ctx, client, resp.TaskID)
256}
257
258// executeListJobs lists all active jobs for the specified beacon
259func (e *Executor) executeListJobs(ctx context.Context, client *csclient.Client, beaconID string) (string, error) {

Callers 1

executeActionMethod · 0.95

Calls 1

waitForOutputMethod · 0.95

Tested by

no test coverage detected