Skip to content

Conversation

@jokasimr
Copy link
Contributor

@jokasimr jokasimr commented Jul 9, 2024

This change adds environment variables containing credentials that can be used to read files in the protected folder on the file server.

The environment variables are only added to workflows that run on the main branch that is assumed to be trusted.
If the environment variables would be added to typical CI workflows then the credentials could be extracted by someone without write permission to the main branch.

With this change workflows can look for the environment variables and read protected files if they find them.

@jokasimr jokasimr requested a review from jl-wynen July 9, 2024 07:38
@jl-wynen
Copy link
Member

jl-wynen commented Jul 9, 2024

Can you add a comment to each file that explains your security considerations? The idea is that when someone finds the code in the future, they can see why the env vars are not available in PRs.

@jokasimr jokasimr merged commit 1e81db5 into main Jul 9, 2024
@jokasimr jokasimr deleted the protected-files branch July 9, 2024 11:04
Comment on lines +23 to +26
env:
# Security note! The secrets are only added to workflows that run on trusted branches (main). If secrets are accessible in workflows that run on untrusted branches they can be extracted, see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#exfiltrating-data-from-a-runner.
ESS_PROTECTED_FILESTORE_USERNAME: ${{ secrets.ESS_PROTECTED_FILESTORE_USERNAME }}
ESS_PROTECTED_FILESTORE_PASSWORD: ${{ secrets.ESS_PROTECTED_FILESTORE_PASSWORD }}
Copy link
Member

Choose a reason for hiding this comment

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

We were recently trying to remove Scipp and ESS-specifics from the copier-template. This seems to counter that effort?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it does 🤔 how do we fix that?

Copy link
Member

Choose a reason for hiding this comment

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

You could move it into the ess template. But then it could not be used in ScippNeutron and ScippNexus.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can I move it to ess_template when the actions using the variables are defined here in copier_template?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. The templates will be merged into the same repo. GH CI won't care where the files ultimately come from.

Copy link
Contributor Author

@jokasimr jokasimr Jul 10, 2024

Choose a reason for hiding this comment

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

But then I have to move the entire workflow files (nightly.yaml for example) to ess_template. Or can I just move the part that concerns the environment variables?

Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to move the env section to a custom file that gets included in the workflow, and write the custom file content only if the template is rendered for our projects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, is there an example of a similar mechanism somewhere else in the copier template?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@jokasimr jokasimr Jul 10, 2024

Choose a reason for hiding this comment

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

Still unsure what you have in mind. The file you mentioned is just a jinja template with a parameter from the copier answers file, and it doesn't involve the other ess copier template. Not sure what I'm supposed to take from that. Let's talk about it tomorrow.

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.

4 participants