Masataka Pocke Kuwabara
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Design Doc: Community-driven RBS repository ## Glossaries * PR author * Who opens a pull request. * Administrator (Admin) * The administrator of ruby/gem_rbs_collection GitHub repository * Including me (@pocke) * Gem Reviewer * A reviewer in charge of a gem * It's specified in `gems/GEM_NAME/_reviewers.yaml` * BOT * The bot sends announcements, and merges pull requests. * GHA * GitHub Actions ## Requirements ### Minimize reviewing by admin (@pocke) Currently @pocke reviews every PRs on gem_rbs_collection GitHub repository. I'd like to avoid this situation because @pocke is the bottleneck of this repository. ### Security The following two requirements are guaranteed by this PR. https://github.com/ruby/gem_rbs_collection/pull/502 * The PR author MUST NOT execute arbitrary code on CI of the `main` branch. * Therefore we need to give up executing RBS testing on runtime. * The PR author MUST NOT execute arbitrary code on PC of RBS users. * RBS related tools do not execute any program, therefore we do not need to care about it. The following requirement is NOT guaranteed by the system. We just put a security policy and accept security reports. * The PR author SHOULD NOT put malicious executable files * The CI only executes limited files. Even if a malicious PR author puts an executable file, it does not affect anything if anyone execute it. * But our GitHub repository should not provides malicious files. Therefore we should remove malicious files asap if they contamitate. ### First time contributors friendly This repository should be friendly for the first time contributors too. This change make contribution easier because the contributor can do everything to merge the PR by themselves. ## Auto reviewing flow The PR will be reviewed with the following flows. If multiple flows match, the PR must satisfy the all flow. The admin can bypass the reviewing flow. ### Update an existing gem 1. The PR author opens a PR 2. If 1. The gem reviewers exist for the gem, and they do not include the PR author 1. The BOT requests reviewing to the gem reviewers 2. The gem reviewers review the PR until they approve it. 3. If the gem reviewers do not respond the request, the PR author can request to become a gem reviewer to the admin. * See the Gem Reviewer Promotion section for more information * After the request is accepted, it continues to the second flow. 4. After the gem reviewers approve it, the gem reviewer or the PR author can request merging the PR to the BOT. 5. The bot merges the PR. 2. The gem reviewers exist for the gem, and they include the PR author 1. The BOT requests reviewing to the gem reviewers 2. OPTIONAL: The gem reviewers review the PR until they approve it. 3. The gem reviewers can request merging the PR to the BOT. 4. The BOT merges the PR. 3. The gem reviewers do not exist for the tem 1. OPTIONAL: The PR author adds themselves to the gem reviewers. 2. If they adds, it continues to the second flow. 3. The PR author can request merging the PR to the BOT. 4. The BOT merges the PR. ### Add a new gem 1. The PR author opens a PR. 2. OPTIONAL: The PR author adds themselves to the gem reviewers. 3. The PR author can request merging the PR to the BOT. 4. The BOT merges the PR. ### Update / add non-gem files 1. The PR author opens a PR. 2. The BOT requets reviewing to the admin. 3. The admin reviews the PR until they approve it. 4. The admin or the BOT merges the PR. ## Gem Reviewer Promotion (This section is under TODO. ) Basically, to become a gem reviewer requires approval from another gem reviewer of the gem or the admin. It is necessary to avoid adding incorrect RBS files by a malicious PR author. * If a PR author want to add a new gem, the PR author can become the gem reviewer of the gem without permission. * If a PR author want to become a gem reviewer of an existing gem * If the gem does not have any gem reviewers, the PR author can become a gem reviewer without permission. * If the gem has gem reviewers, an approval is required from the gem reviewer. * If the gem has reviewers but they are not active, the PR author can request the promotion to the admin. * Admin can promote the PR author to the gem reviewer if the gem reviewer is absent TODO days. If a gem reviewer does something malicious, the admin can ban them. ## How to implement We use GHA for this purpose. We need the following workflows. ### Testing https://github.com/ruby/gem_rbs_collection/blob/main/.github/workflows/test.yml We already have worflows for testing. It works on the pull_request event. We can use them continuously. ### Merge PR by a comment When the PR author requests merging the PR on a PR comment, the BOT merges the PR. This GHA workflow checks the PR is ready to be merged. * The PR has necessary approvals. * The user sending the comment has permission to the PR This workflow also checks the following things inplicitly. * The PR passes all tests * It is checked by protected branch feature of GitHub * The PR does not change `.github` directory * It is checked CODEONWERS file * This check is necessary to avoid falsification of GHA workflow files. If an attacker tries to falsificate GHA workflow, the PR needs to review by the admins. This command uses the squash merge feature to avoid that a commit in the middle of the history contains malicious code. It is important to guarantee safety of `git bisect` and so on. ### Check that the PR has appropriate approval It updates the commit status. The commit status becomes green if the PR satisfies the all following conditions: * If the PR changes files under `gems/` * If `_reviewers.yaml` exists, it needs an approval from one of the Gem Reviewer or Admin. * If `_reviewers.yaml` does not exists, it's satisfied. * If the PR changes files under other directories * It needs an approval from the Admin ### Request reviewing when PR opens and updated It also needs to describe the role of the BOT. ## Migration process This section describes how to migrate from the current system (using CODEOWNERS file). We need to avoid attack on all phases during the migration. 1. Remove the users who are previously code owners from GitHub's outside collaborators. * By this change, they lose code owner bit. 3. Configure code owner permission? * Before merge the PR, we need to configure restriction on the GitHub UI (if we need) * The protected branch is already configured. We do not need any action. 5. Merge https://github.com/ruby/gem_rbs_collection/pull/520 * The migration has been completed. ## Alternative Solutions ### Construct a server for the Bot I decided to use GHA, but we can also use a server for the purpose. For example, we can build the bot as a Sinatra app and host it on Heroku. Or we can use serverless function service such as AWS Lambda. But I have not decided using a server. * I do not want to manage a server for this purpose. * A server increases dependencies. * Cost problem * Heroku server or AWS Lambda can increases infrastructure cost. ## References ### GitHub Actions * [Security hardening for GitHub Actions - docs.github.com](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions) * [Automatic token authentication - docs.github.com](https://docs.github.com/en/actions/security-guides/automatic-token-authentication) * https://blog.gitguardian.com/github-actions-security-cheat-sheet/ * It well describe security risks * [Workflow syntax for GitHub Actions - docs.github.com](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions) ### Related tools * https://github.com/rubygems/bundlerbot * Bundler previously used this script to merge PRs, but currently they are not used it. * It uses GitHub app * https://github.com/DefinitelyTyped/dt-mergebot * DefinitelyTyped uses this bot.

Import from clipboard

Paste your webpage below. It will be converted to Markdown.

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

How to use Slide mode

API Docs

Edit in VSCode

Install browser extension

Get in Touch

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully