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

ci: use git submodules for (securely) using third party Github Actions #12709

Merged
merged 4 commits into from
Jan 24, 2021

Conversation

TobKed
Copy link
Contributor

@TobKed TobKed commented Jan 23, 2021

SUMMARY

The idea was to improve GitHub Actions after ASF changed the rules and only allow
actions hosted in-organization.

IMHO using git submodules is more clean way to use external github actions.
I based my opinion this on the discussion:
https://lists.apache.org/x/thread.html/r435c45dfc28ec74e28314aa9db8a216a2b45ff7f27b15932035d3f65@%3Cbuilds.apache.org%3E

and how it was solved in:

List of repositories added as git submodules with their revisions:

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

Tobiasz Kędzierski added 2 commits January 23, 2021 11:21
…ions

List of repositories added as submodules:

EndBug/latest-tag@latest
morrisoncole/pr-lint-action@v1.4.1
trilom/file-changes-action@v1.2.4
styfle/cancel-workflow-action@0.6.0
apache-superset/cached-dependencies@b90713b
unsplash/comment-on-pr@v1.2.0
@TobKed TobKed marked this pull request as draft January 23, 2021 10:33
@TobKed TobKed changed the title Use git submodules for gh actions Use git submodules for (securely) using third party Github Actions Jan 23, 2021
@TobKed
Copy link
Contributor Author

TobKed commented Jan 23, 2021

I need to add proper git checkout

@TobKed TobKed changed the title Use git submodules for (securely) using third party Github Actions ci: use git submodules for (securely) using third party Github Actions Jan 23, 2021
@TobKed TobKed marked this pull request as ready for review January 23, 2021 10:59
@TobKed
Copy link
Contributor Author

TobKed commented Jan 23, 2021

cc @ktmud @potiuk @ashb

@codecov-io
Copy link

codecov-io commented Jan 23, 2021

Codecov Report

Merging #12709 (1e133cb) into master (0143a98) will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #12709      +/-   ##
==========================================
+ Coverage   66.89%   66.90%   +0.01%     
==========================================
  Files        1020     1020              
  Lines       49905    49905              
  Branches     4888     4888              
==========================================
+ Hits        33384    33390       +6     
+ Misses      16396    16390       -6     
  Partials      125      125              
Flag Coverage Δ
cypress 50.93% <ø> (+0.03%) ⬆️
javascript 60.91% <ø> (ø)
python 64.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...perset-frontend/src/messageToasts/actions/index.ts 88.46% <0.00%> (+7.69%) ⬆️
superset-frontend/src/components/FlashProvider.tsx 71.42% <0.00%> (+28.57%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0143a98...1e133cb. Read the comment docs.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Nice! This is the recommended way which I think all Apache Projects should adopt. It has only benefits and no drawbacks:

  • inner working of submodules is such actions are automatically linked via their long hash commit -- recommended security practice
  • no change to the current workflow of people (submodules are only needed for CI - you only need submodules if you want to update to newer version of the actions
  • GitHub has full support for review for submodules. When action is updated, reviewer will see diff of incoming changes that can be reviewed as usual (also part of security guidelines to review changes to actions rigorously)
  • no 3rd-party code in superset repo

There are no drawbacks that I am aware of.

Copy link
Member

@mik-laj mik-laj left a comment

Choose a reason for hiding this comment

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

@amitmiran137 @ktmud Can you look at it?

@ktmud
Copy link
Member

ktmud commented Jan 24, 2021

This is great. Thanks for making this change!

@ktmud ktmud merged commit 1f27b62 into apache:master Jan 24, 2021
@ktmud
Copy link
Member

ktmud commented Jan 24, 2021

We actually used @potiuk 's potius/cancel-workflow-runs for the cancel_duplciates.yml job. But I can make the updates in another PR.

@potiuk
Copy link
Member

potiuk commented Jan 24, 2021

FYI. I do recommend to migrate it to submodule as well, however my action was allow-listed by INFRA so you can use it directly ;)

@TobKed TobKed deleted the use-git-submodules-for-gh-actions branch January 25, 2021 12:10
morningman pushed a commit to apache/doris that referenced this pull request Jul 25, 2021
My change is the fix and improvement for github action which labels approved PRs (introduced in this [PR](#6239)).

It is inspired by solution introduced and tested in [Apache Airflow](https://github.com/apache/airflow) (thanks @potiuk @ashb 🚀 )

Corresponding Apache Airflow workflows on which I based this PR:
 - https://github.com/apache/airflow/blob/main/.github/workflows/label_when_reviewed.yml
 - https://github.com/apache/airflow/blob/main/.github/workflows/label_when_reviewed_workflow_run.yml

Problems which were solved in this PR:

 - **Permissions**.
  @morningman opened a related bug: [[Help] Error: Resource not accessible by integration](TobKed/label-when-approved-action#7). It is related to limited permissions of workflows being triggered by `pull_request_review` (`GITHUB_TOKEN` has read-only permissions). More information about it you can find in the article:  [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
   TL;DR:  On pull request review event (`on: pull_request_review` ) "dummy" workflow `Label when reviewed` triggers another workflow `Label when approved workflow run` which has sufficient permissions (`on:  workflow_run:  workflows: ["Label when reviewed"]`).

 - **Safe use of 3rd-party Github Actions by using submodules pattern.**  It is decribed in:    
 https://cwiki.apache.org/confluence/display/BUILDS/GitHub+Actions+status

    >  NEVER use 3rd-party actions directly in your workflows - use the "submodule" pattern.
    
    This pattern is successfully used by projects like:
     - [Apache Airflow](https://github.com/apache/airflow) ([PR](apache/airflow#13514))
     - [Apache Beam](https://github.com/apache/beam) ([PR](apache/beam#13736))
     - [Apache Superset](https://github.com/apache/superset) ([PR](apache/superset#12709))
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants