StackStorm/st2

PowerShell Script Runner not passing parameters to script

Open

#4.730 aberto em 28 de jun. de 2019

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)Python (740 forks)batch import
buggood first issue

Métricas do repositório

Stars
 (5.794 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

SUMMARY

When a script is larger than the WINRM_MAX_CMD_LENGTH = 8192 the arguments are not being passed.

ISSUE TYPE
  • Bug Report
STACKSTORM VERSION

st2 3.0.1, on Python 2.7.5

OS / ENVIRONMENT / INSTALL METHOD

CENTOS7 per stackstorm install guide

STEPS TO REPRODUCE

winrm_windump.yaml

---
name: "winrm_windump"
description: "Action that runs arg dump"
enabled: true
entry_point: "windows/dump.ps1"
runner_type: "winrm-ps-script"
parameters:
  one:
    type: string
    default: "SOMEVALUE"
    required: true
    position: 0
    description: the first arguments

dump.ps1

param($one="notset")

write-host "one: $one"

### Enough content of script comments and code to get past the 8192 byte boundary
### ...
### ...

EXPECTED RESULTS
one: SOMEVALUE
ACTUAL RESULTS
one: notset

I could not get positional or named parameters to successfully make it to the PS script. The issue appears to be in the _run_ps_script function in winrm_base.py:

            ps = "& {%s}" % (tmp_script)  ###the ampersand and braces should be removed here
            if params:
                ps += " " + params
            return self._run_ps(ps)

Wrapping the braces around the script path is unnecessary and causes the arguments to be lost.

Quick workaround:

ps = "%s" % (tmp_script)

or simply:

ps = tmp_script

Guia do colaborador