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

eval is evil. #53

Open
vStone opened this issue Mar 21, 2019 · 3 comments
Open

eval is evil. #53

vStone opened this issue Mar 21, 2019 · 3 comments

Comments

@vStone
Copy link

vStone commented Mar 21, 2019

If somebody would use quotes (or backticks) in some kind of message, using eval would allow them to execute malicious code on purpose or by accident.

IE: If any backticks are used, you would be able to reboot a server.

@aswen
Copy link
Owner

aswen commented Mar 21, 2019

@vStone Thanks for your comment. Which eval do you mean? And more important: how would you advise me to work around it?

@vStone
Copy link
Author

vStone commented Apr 25, 2019

@aswen sorry about the late reply.

I think it would be this eval $(parse_yaml $lastrunfile $yaml_prefix) line.

Our catalog version uses the last commit message, whenever there is a quote in there, the check borks out with:
1: eval: Syntax error: Unterminated quoted string

@bitcrush
Copy link

bitcrush commented Jan 3, 2020

We use a custom catalog version string as well. The following change parses the yaml data properly. I can send in a PR if you like me to.

@@ -128,8 +128,7 @@ usage () {
 parse_yaml () {
    local prefix=$2
    local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
-   sed -ne "s|^\($s\):|\1|" \
+   sed -ne "s|\(\ *config:\) \"\([0-9]\{10,\}\).*|\1 \2|" \
+        -e "s|^\($s\):|\1|" \
         -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
         -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p"  $1 |
    awk -F$fs '{

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

3 participants