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

Retrieve exclusion list from environment variable #1164

Merged
merged 3 commits into from
Oct 11, 2022

Conversation

0x2b3bfa0
Copy link
Member

@0x2b3bfa0 0x2b3bfa0 commented Sep 12, 2022

Suggested solution for #802, along with iterative/terraform-provider-iterative#665

@dacbd
Copy link
Contributor

dacbd commented Sep 12, 2022

I haven't tested this yet. And I don't think this should be the permanent solution. I am in favor of setting up the CI agents as their own service that the runner monitors so that their parent is systemd and not cml, thus avoiding the env leaks.

⚠️

This should have a blog post for some migration information on how to use the --cloud-permission-set for all three providers as the leaking (in the case of AWS) is slightly displayed as a feature example:
Screen Shot 2022-09-12 at 15 37 21

src/cml.js Outdated
return await this.getDriver().startRunner(opts);
const env = {};
const sensitive =
['CML_RUNNER_SENSITIVE_ENV'] +
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a whitelist of environment variables to propagate be a more robust solution here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, that's what I originally proposed:

Although that would require launching the runner process from a shell, to provide the bare minimum variables like e.g. PATH and any custom NVIDIA values.

Copy link
Contributor

Choose a reason for hiding this comment

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

Again

I am in favor of setting up the CI agents as their own service that the runner monitors so that their parent is systemd and not cml, thus avoiding the env leaks.

would also solve it, would it not?

Copy link
Member Author

Choose a reason for hiding this comment

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

would also solve it, would it not?

Except for Kubernetes

Copy link
Contributor

Choose a reason for hiding this comment

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

would also solve it, would it not?

It depends how you would like to solve this. Cloud agnostic should be the way that way CML is secure in every environment. I might want to just launch CML on my own

Copy link
Contributor

@DavidGOrtega DavidGOrtega Sep 21, 2022

Choose a reason for hiding this comment

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

const sensitive = ['CML_RUNNER_SENSITIVE_ENV'] + process.env.CML_RUNNER_SENSITIVE_ENV.split(':');
for (const variable in process.env)
      if (!sensitive.includes(variable)) env[variable]

This does not sound to me correct. Have you tried this?

in JS + concatenates strings so I think that this is calling the toSting() incarnation of them giving you

CML_RUNNER_SENSITIVE_ENVone,two,three 

for process.env.CML_RUNNER_SENSITIVE_ENV = ['one:two:three'] ?

Copy link
Contributor

Choose a reason for hiding this comment

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

this does indeed not concat correctly, though using string.includes negates whether it really matters

Copy link
Member Author

Choose a reason for hiding this comment

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

It works, but it's definitely not correct. 🤦🏼 Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

JavaScript blunder fixed with e29b8aa (commit comment worth watching)

Copy link
Member Author

@0x2b3bfa0 0x2b3bfa0 Oct 10, 2022

Choose a reason for hiding this comment

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

Would a whitelist of environment variables to propagate be a more robust solution here?

Better solutions are possible, but also more complicated.

@dacbd dacbd self-requested a review September 14, 2022 18:29
Copy link
Contributor

@dacbd dacbd left a comment

Choose a reason for hiding this comment

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

yargs collides with your naming choice CML_RUNNER_*

Sep 14 18:07:44 ip-172-31-21-33 systemd[1]: Started cml.service.
Sep 14 18:07:44 ip-172-31-21-33 cml.sh[2632]:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Sep 14 18:07:44 ip-172-31-21-33 cml.sh[2632]:                                  Dload  Upload   Total   Spent    Left  Speed
Sep 14 18:07:44 ip-172-31-21-33 cml.sh[2632]: [158B blob data]
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]: cml runner
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]: Manage self-hosted (cloud & on-premise) CI runners
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]: Commands:
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:   cml runner launch  Launch and register a self-hosted runner
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]: Global Options:
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:   --log     Logging verbosity
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:           [string] [choices: "error", "warn", "info", "debug"] [default: "info"]
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:   --driver  Git provider where the repository is hosted
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:     [string] [choices: "github", "gitlab", "bitbucket"] [default: infer from the
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:                                                                     environment]
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:   --repo    Repository URL or slug[string] [default: infer from the environment]
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:   --token   Personal access token [string] [default: infer from the environment]
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]:   --help    Show help                                                  [boolean]
Sep 14 18:07:45 ip-172-31-21-33 cml.sh[2632]: Unknown argument: sensitiveEnv
Sep 14 18:07:45 ip-172-31-21-33 systemd[1]: cml.service: Main process exited, code=exited, status=1/FAILURE
Sep 14 18:07:45 ip-172-31-21-33 systemd[1]: cml.service: Failed with result 'exit-code'.

@DavidGOrtega
Copy link
Contributor

DavidGOrtega commented Sep 21, 2022

Would be awesome if in the description PR you could explain how this is set or used.

Maybe I would prefer ; as a separator

src/cml.js Outdated
return await this.getDriver().startRunner(opts);
const env = {};
const sensitive =
['CML_RUNNER_SENSITIVE_ENV'] +
Copy link
Contributor

@DavidGOrtega DavidGOrtega Sep 21, 2022

Choose a reason for hiding this comment

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

const sensitive = ['CML_RUNNER_SENSITIVE_ENV'] + process.env.CML_RUNNER_SENSITIVE_ENV.split(':');
for (const variable in process.env)
      if (!sensitive.includes(variable)) env[variable]

This does not sound to me correct. Have you tried this?

in JS + concatenates strings so I think that this is calling the toSting() incarnation of them giving you

CML_RUNNER_SENSITIVE_ENVone,two,three 

for process.env.CML_RUNNER_SENSITIVE_ENV = ['one:two:three'] ?

@dacbd
Copy link
Contributor

dacbd commented Sep 21, 2022

Would be awesome if in the description PR you could explain how this is set or used.

Maybe I would prefer ; as a separator

it is set in the linked PR for tpi: iterative/terraform-provider-iterative#665

@DavidGOrtega
Copy link
Contributor

it is set in the linked PR for tpi: iterative/terraform-provider-iterative#665

This PR assumes :

@dacbd
Copy link
Contributor

dacbd commented Sep 21, 2022

it is set in the linked PR for tpi: iterative/terraform-provider-iterative#665

This PR assumes :

sorry for only for the first part of your question, how it is set/used

@0x2b3bfa0
Copy link
Member Author

Maybe I would prefer ; as a separator
This PR assumes :

I'd rather prefer the ⚔️ emoji as a separator, but there is a clear reason to choose : over ; to separate items: VALUES=ONE;TWO would produce sh: command not found: TWO because ; is used by the shell to separate command lists. Of course, quoting is always an option. 🤷🏼‍♂️

src/cml.js Outdated Show resolved Hide resolved
src/cml.js Outdated Show resolved Hide resolved
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal October 10, 2022 04:00 Inactive
src/drivers/gitlab.js Show resolved Hide resolved
src/cml.js Outdated Show resolved Hide resolved
@0x2b3bfa0 0x2b3bfa0 temporarily deployed to internal October 10, 2022 04:05 Inactive
@0x2b3bfa0
Copy link
Member Author

0x2b3bfa0 commented Oct 10, 2022

Reply to #1164 (comment)

I don't think this should be the permanent solution

Neither do I 👍🏼

I am in favor of setting up the CI agents as their own service that the runner monitors so that their parent is systemd and not cml, thus avoiding the env leaks.

Sounds worth considering, although would effectively separate cml runner --cloud from cml runner 👍🏼

This should have a blog post for some migration information on how to use the --cloud-permission-set for all three providers as the leaking (in the case of AWS) is slightly displayed as a feature

Looks like the HCL snippet at iterative/terraform-provider-iterative#602 (comment) could be a good starting point

@0x2b3bfa0 0x2b3bfa0 requested review from a team, tasdomas and dacbd and removed request for DavidGOrtega and dacbd October 11, 2022 23:11
@0x2b3bfa0
Copy link
Member Author

0x2b3bfa0 commented Oct 11, 2022

@iterative/cml, cascading to #802

@0x2b3bfa0 0x2b3bfa0 merged commit daa7cde into no-envars Oct 11, 2022
@0x2b3bfa0 0x2b3bfa0 deleted the suggestion/no-envvars branch October 11, 2022 23:14
@casperdcl
Copy link
Contributor

as the leaking (in the case of AWS) is slightly displayed as a feature example:

That's poor wording on the cml.dev/doc pages. The intention was to say "users only need to go through the nightmare of obtaining cloud auth tokens once for both cloud storage AND provisioning." It was NOT meant to imply "we inject your provisioning-auth-tokens into the provisioned machine just in case you want to use them for something else."

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.

5 participants