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

Quote variables for well defined behavior #527

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

ailox
Copy link

@ailox ailox commented Nov 20, 2024

By quoting variables we can improve stability of this script. $HOME and $password are both user supplied variables, that may contain spaces.

We need to quote them, or they may be expanded into extra arguments. This means this scripit will no longer break, if a space is supplied inside the password.

What

In tests it was discovered that setup sometime fails. This turned out due to passwords that contain spaces, breaking the setup script.

This PR tries to fix this problem, and mitigates a couple of other potential issues.

Currently the problem still persists. I suspect that the same problem also happens inside the container entrypoint, and needs to be quoted there as well. Until then this PR will remain a draft.

Why

Variables should be quoted if they may contain spaces ($password, $DOWNLOAD_DIR).

read treats backslashes differently, which can be annoying when entering a random password. with the -r flag we can disable this behavior.

$@ will return an array of all arguments, which will then be translated into a string. When using $* we will get a sting which is safe to use, as its behavior is defined.

References

DEVOPS-1304
Test run failing in test-community-containers

Checklist

By quoting variables we can improve stability of this script. $HOME and
$password are both user supplied variables, that may contain spaces.

We need to quote them, or they may be expanded into extra arguments.
This means this scripit will no longer break, if a space is supplied
inside the password.

`read` treats backslashes differently, which can be annoying when
entering a random password. with the `-r` flag we can disable this
behavior.

`$@` will return an array of all arguments, which will then be
translated into a string. When using `$*` we will get a sting which is
safe to use, as its behavior is defined.
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA b91166a.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

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

Successfully merging this pull request may close these issues.

1 participant