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

Protects against spaces in env vars and avoid quoting of all env vars as single entity #1008

Closed
wants to merge 3 commits into from

Conversation

pcm32
Copy link

@pcm32 pcm32 commented May 21, 2021

Addresses #1007

@pcm32 pcm32 requested a review from johanneskoester as a code owner May 21, 2021
@sonarcloud
Copy link

sonarcloud bot commented Jun 14, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@@ -792,13 +792,15 @@ def write_jobscript(self, job, jobscript, **kwargs):
use_threads = "--force-use-threads" if not job.is_group() else ""

envvars = " ".join(
"{}={}".format(var, os.environ[var]) for var in self.workflow.envvars
# quotes values, as envvars values could have spaces
"{}='{}'".format(var, os.environ[var])
Copy link
Contributor

@johanneskoester johanneskoester Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the env var itself contains single quotes? Python provides escape mechanisms that should be used instead: use repr(os.environ[var]).

)

exec_job = self.format_job(
self.exec_job,
job,
_quote_all=True,
_quote_all=False,
Copy link
Contributor

@johanneskoester johanneskoester Jun 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this has to be deactivated? It is also needed for other things in the exec job template.

@johanneskoester
Copy link
Contributor

johanneskoester commented Mar 16, 2022

Closing in favor of a global solution in #1491. Nevertheless, thanks a lot for taking a first stab at this!

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.

None yet

2 participants