MSO4SC / cloudify-hpc-plugin

Plugin to allow Cloudify to deploy and orchestrate HPC resources
Apache License 2.0
8 stars 8 forks source link

Bug bootstrap fails because of unescape special char #12

Closed gdolle closed 6 years ago

gdolle commented 6 years ago

This error is related to #10.

https://github.com/MSO4SC/cloudify-hpc-plugin/blob/6b74506f882798348186a9d5bd678387b9d3cd91/hpc_plugin/tasks.py#L233 All special char need to be escaped when doing echo "$file_data" for the variable $file_data.

Maybe you rather should use regex python module, it would be safer. https://docs.python.org/3.6/library/re.html?highlight=escape#re.escape This way:

import re;
script_data = ctx.get_resource(script) # string
scrpt_data = re.escape( script_data )
gdolle commented 6 years ago

Hum you might get exactly the same problem here https://github.com/MSO4SC/cloudify-hpc-plugin/blob/master/hpc_plugin/slurm.py#L47 I'll update the PR

emepetres commented 6 years ago

Such "special char" set doesn't exits, what needs to be done is to escape characters that echo consider not to be simple characters when inside ""

re.escape does not work because it is meant to escape regular expression pattern characters (https://docs.python.org/2/library/re.html#re.escape), which is not the case.

I've tested all shell metacharacters and I've identified the four that need to be escaped programmatically (those which echo does not understand as regular char when using double quotes): \, ", `, $

Is there any other you think it might be necessary?