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

Further steps for CI functions with GH actions #15608

Open
2 of 4 tasks
bekuno opened this issue Apr 15, 2024 · 22 comments
Open
2 of 4 tasks

Further steps for CI functions with GH actions #15608

bekuno opened this issue Apr 15, 2024 · 22 comments
Assignees
Labels
CI server / Build tools Issues with our CI server or other build/dev tools Feedback required Issue requires feedback of the author or another user

Comments

@bekuno
Copy link
Member

bekuno commented Apr 15, 2024

After merging PR #15529 the configuration needs some tuning.

  • configure secrets for normal workflow
  • configure secrets for workflows from dependabot (if necessary)
  • clarify, if workflow(s) should not run from cloned repositories - and if yes, configure it
  • create documentation to configure secrets for cloned repositories

(Feel free to extend the list)

@bekuno bekuno added Feedback required Issue requires feedback of the author or another user CI server / Build tools Issues with our CI server or other build/dev tools labels Apr 15, 2024
@bekuno
Copy link
Member Author

bekuno commented Apr 15, 2024

@Lineflyer
Copy link
Member

AFAICS the secrets are already stored in our repo key/secrests storage.
If this problem only comes up for builds on forks (looks a bit like that) we should disable this feature. We do not need that and it blocks resources.

@bekuno
Copy link
Member Author

bekuno commented Apr 15, 2024

AFAICS the secrets are already stored in our repo key/secrests storage. If this problem only comes up for builds on forks (looks a bit like that) we should disable this feature. We do not need that and it blocks resources.

The failing test above links to a PR in the c:geo repo for master against the source in a cloned repo (typically for a normal PR).

@Lineflyer
Copy link
Member

Lineflyer commented Apr 15, 2024

mmh...thats indeed a pretty normal case.
I would have thought, that it uses the secret of the target repo rather than requiring the secrets to be located in the source/fork repo.

@fm-sys
Copy link
Member

fm-sys commented Apr 15, 2024

Might be a security feature. Otherwise developers might introduce malicious code to retrieve the secrets... Still problematic for our workflow.

@bekuno
Copy link
Member Author

bekuno commented Apr 15, 2024

@fm-sys
Copy link
Member

fm-sys commented Apr 15, 2024

The relevant part out of it:

workflows from forks do not have access to sensitive data such as secrets

@kumy
Copy link
Member

kumy commented Apr 16, 2024

Yes this is our issue, a security issue.
@bekuno From our mails, you wanted to disable such jobs for PR from external repositories, am I right?

I did a small POC to test the expression required in such case

It allows:

The expression I came to:

github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id)

We should add some well placed one to our workflows.
We should also check if the secret is empty and provide a better way of failing

@kumy
Copy link
Member

kumy commented Apr 16, 2024

(I didn't remembered I had set the action cgeo-preferences on all jobs.)

Does someone know if graddle tasks below really require the app to be fully configured? Is it something that we can skip?

  • :main:countBasicDebugDexMethods
  • :main:checkstyle
  • :main:lintBasicDebug

@kumy
Copy link
Member

kumy commented Apr 16, 2024

That would give PR #15626

@Lineflyer
Copy link
Member

Lineflyer commented Apr 16, 2024

I am not sure if skipping part of tests is meaningful.
The remaining problem is, that secrets are not shared, which will prevent a full test of PRs from forked repositories.

From what I read here https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ (not sure if outdated but sounds logical from security perspective) we could also make use of pull_request_target in combination with a simple approval workflow e.g. by setting a label Safe to test or OK to test.

As this trigger allows to use secrets of the target repo we should be able to fully test the PRs.
The safety measure is, that labels can only be set by people with write access to the target repo.

@kumy
Copy link
Member

kumy commented Apr 16, 2024

I will read the article soon. I agree we should have way to test incoming PRs.

On PR #15625 was afraid you'll activate pull_request_target blindly. As long as each PR is reviewed before the WF can run, we should be safe.

@Lineflyer
Copy link
Member

On PR #15625 was afraid you'll activate pull_request_target blindly. As long as each PR is reviewed before the WF can run, we should be safe.

That part (label trigger) was not yet included as I did not (out of the box) know how to do this...but its mentioned in the article.
Help appreciated if you think this method is meaningful to achieve our goal.

@Lineflyer
Copy link
Member

Regarding:

configure secrets for workflows from dependabot (if necessary)

Further reading:
https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#accessing-secrets

@kumy
Copy link
Member

kumy commented Apr 16, 2024

If you accept the security risk you can redefine them all in the dependabot secret section

image

its mentioned in the article.

I'll read it and see how we can implement their proposal

(heading to bed now)

@Lineflyer
Copy link
Member

If you accept the security risk you can redefine them all in the dependabot secret section

That brings me to the point, that I do not have any of the secrets. They have ever only been stored on the CI and in the hands of @mucek4
@kumy If there is no objection form others, please kindly forward the whole set to me in a safe way.

@kumy
Copy link
Member

kumy commented Apr 16, 2024

I didn't stored them. I will need to extract them from Jenkins again 😉🫣

@Lineflyer
Copy link
Member

clarify, if workflow(s) should not run from cloned repositories - and if yes, configure it

IMHO they should not run in cloned repositories.
For PR and pushes:
We want to have this quality gate for PRs and pushes to our repo. Developers usually have their SDK and emulator to run the tests they need (with own keys and credentials).
For watchdog:
It makes no sense if watchdog tests run scheduled in all forks.

The short cut-off method is to disable actions in your forks using the repository settings.
but (@kumy) I guess it would be possible by adding a condition to the workflows to only run if triggered in or for our main repo.

@kumy
Copy link
Member

kumy commented Apr 17, 2024

That brings me to the point, that I do not have any of the secrets. They have ever only been stored on the CI and in the hands of @mucek4
@kumy If there is no objection form others, please kindly forward the whole set to me in a safe way.

@Lineflyer I've sent you a mail

@kumy
Copy link
Member

kumy commented Apr 17, 2024

secrets added for dependabot ✔️
That job is un-stuck, but it may also encounter the same issue as in #15630 (comment)

@kumy
Copy link
Member

kumy commented Apr 17, 2024

@Lineflyer please see PR #15631 to

  • Only run watchdog from cgeo repo
  • Check for secret presence and fail is missing

@kumy
Copy link
Member

kumy commented Apr 17, 2024

@Lineflyer here is what I understood from the link you sent earlier (untested)
#15632

Also note from the document

Warning

Note that this kind of label based verification is still prone to a race condition in which the attacker may push new changes after the workflow was approved (labeled), but has not started yet.

(Heading to bed now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI server / Build tools Issues with our CI server or other build/dev tools Feedback required Issue requires feedback of the author or another user
Projects
None yet
Development

No branches or pull requests

4 participants