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

Parameters in "params:" value with blank spaces in quotes are interpreted as multiple parameters #32

Open
cx-scord opened this issue Sep 27, 2021 · 2 comments

Comments

@cx-scord
Copy link

cx-scord commented Sep 27, 2021

Description

Parameters added to params: value that have spaces inside quotes are being interpreted as multiple arguments instead of a single argument inside the parameter when executing CxFlow inside the container.

Expected Behavior

When adding parameters to params: section that have a space inside, like for example --jira.open-transition="In Progress" or even when using a split comma list inside like this --jira.open-status="Backlog,Selected for Development,In Progress", the quoted values should be seen as one value, meaning that the CxFlow's JIRA open-status value in the previous example here should be unique "Backlog,Selected for Development,In Progress".

Actual Behavior

Currently and picking on the previous example, the quoted (single or double) strings are being split as multiple arguments to the CxFlow's java command running inside the container, meaning that --jira.open-status="Backlog,Selected for Development,In Progress" is actually interpreted as multiple arguments (4 in total for this example):

  1. --jira.open-status="Backlog,Selected
  2. for
  3. Development,In
  4. Progress"

The problem is in the ${CXFLOW_PARAMS} environment variable.
The ${CXFLOW_PARAMS} environment variable is resolved/expanded inside the docker_entrypoint.sh script on CxFlow's GitHub Action Docker container without being parsed first, making the whole command not properly evaluated or that environment variable and all the blank space split strings inside it matching 1 argument each instead of 1 argument for each enclosed string.

Reproduction

Adding a params: section to the GitHub Action with some parameters with quoted strings with spaces like above will trigger the issue.
In the example below, the issues will be in the parameter set as an example above and in the --jira.open-transition="In Progress" parameter:

  • params: --namespace=${{ github.repository_owner }} --repo-name=${{ github.event.repository.name }} --branch=${{ github.ref }} --cx-flow.filter-severity=High --cx-flow.filter-category="SQL_Injection,SQL_Injection_via_Service" --jira.url=${{secrets.JIRA_URL}} --jira.username=${{secrets.JIRA_USER}} --jira.token=${{secrets.JIRA_TOKEN}} --jira.project=${{secrets.JIRA_PROJECT}} --jira.issue-type=Bug --jira.priorities.High=High --jira.priorities.Medium=Medium --jira.priorities.Low=Low --jira.priorities.Informational=Lowest --jira.open-transition="In Progress" --jira.close-transition=Done --jira.open-status="Backlog,Selected for Development,In Progress" --jira.closed-status=Done

Environment Details

CxFlow 1.6.24 in CLI mode, Windows 10.

Solution

A possible solution is to wrap the java command inside an environment variable and then execute it with the eval command.
The eval command below will parse the whole string first, making sure the quoted strings inside are read as 1 argument and not multiple ones.

This is an example of shell script code that might fix this inside the docker_entrypoint.sh file, using eval with the $EXEC_COMMAND executable string within single quotes allows for sanitizing possible command injections coming through any of the GitHub action parameter variables:

#!/bin/sh
EXEC_COMMAND='java -jar /app/cx-flow.jar --spring.profiles.active="${CX_FLOW_ENABLED_VULNERABILITY_SCANNERS}" --scan --github.api-url="${GITHUB_API_URL}/repos/" --cx-team="${TEAM}" --cx-project="${PROJECT}" --app="${APP}" --f=. ${CXFLOW_PARAMS}'
eval "$EXEC_COMMAND"
@cx-scord
Copy link
Author

cx-scord commented Feb 8, 2022

Hi, is there an ETA for this? @DhavalPatelPersistent is this being looked that?

@jbrotsos
Copy link
Contributor

jbrotsos commented Feb 9, 2022

There is not an ETA.

Also, can the user use config as code instead?

DhavalPatelPersistent added a commit that referenced this issue Mar 18, 2022
…in quotes are interpreted as multiple parameters

Parameters in "params:" value with blank spaces in quotes are interpreted as multiple parameters.
--jira.open-status="Backlog,Selected for Development,In Progress" is actually interpreted as multiple arguments (4 in total for this example):
1. --jira.open-status="Backlog,Selected
2. for
3. Development,In
4. Progress"
DhavalPatelPersistent added a commit to checkmarx-ltd/cx-flow that referenced this issue Mar 21, 2022
Update document for GH 32 Issue. checkmarx-ts/checkmarx-cxflow-github-action#32

Parameters in "params:" value with blank spaces in quotes are interpreted as multiple parameters #32
DhavalPatelPersistent added a commit that referenced this issue Mar 21, 2022
…in quotes are interpreted as multiple parameters

Documentation Update
DhavalPatelPersistent added a commit to checkmarx-ltd/cx-flow that referenced this issue Mar 22, 2022
Update document for GH 32 Issue. checkmarx-ts/checkmarx-cxflow-github-action#32

Parameters in "params:" value with blank spaces in quotes are interpreted as multiple parameters #32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants