• Stars
    star
    131
  • Rank 266,199 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Controls and monitors organization permissions across GitHub, Slack and GSuite. Built with ❤️ by The Electron Team

Sheriff: Permissions Bot

This bot, when deployed as a Heroku app and configured correctly, is capable of controlling permissions across GitHub, Slack and GSuite. It also actively monitors and alerts you to suspicious or unexpected activity on GitHub.

How It Works

Using a combination of webhooks and a YAML configuration file, Sheriff will automatically control your permissions and access controls across GitHub, Slack and GSuite. (Slack and GSuite plugins are optional and disabled by default).

It will post to a designated Slack channel every time it updates any permission setting or any time it detects potentially suspect actions including new deploy keys with write access, tag deletion or release branch deletion.

If you have an organization with a lot of repositories and/or org members using Sheriff can help ensure your organization remains secure and transparent.

Deployment

We recommend deploying this as a Heroku app (this is how Electron has deployed it), although you can use another deployment strategy if you want. There are three core components to Sheriff, all of which need to be configured for it to work:

The Webhook

Deploy the webhook to Heroku with this button ➡️ Deploy

To the run the webhook server, you need to start the main Sheriff entry point.

npm start

You then need to create a webhook for your entire organization; you can do this on your organization's GitHub webhooks page:

https://github.com/organizations/{orgname}/settings/hooks/new

You want to specify the following options:

  • Payload URL - The deployed URL of your webhook server, e.g. https://my-sheriff.mysite.com
  • Content type - application/json
  • Secret - Generate a random and secure secret here and save it for later in the configuration
  • Which events? - Choose "Send me everything"

Finally, click "Add webhook".

The GitHub App

To manage GitHub instances, Sheriff requires you to create a GitHub App that gets installed in the desired Org.

The app needs the following OAuth scopes permitted:

Org:
administration:write
contents:read
metadata:read

Repo:
members:write

Once created, you can generate and download a Private Key for the app, and supply it to Sheriff.

Before setting it as SHERIFF_GITHUB_APP_CREDS, you must pass it through a utility to change the format to what Octokit is expecting:

npx @electron/github-app-auth --creds={path-to-downloaded-private-key} --app-id={id-from-created-github-app}

The Cron Job

The actual permissions controller should be triggered every 10 minutes as a cron job. You can run this job with:

node lib/permissions/run.js --do-it-for-real-this-time

If you leave off the --do-it-for-real-this-time Sheriff will "dry run" and tell you what it would have done if you had let it run.

On Heroku you use the "Heroku Scheduler" addon to configure this cron job.

The Slack App

In order to provide realtime information on the actions Sheriff takes, we use a Slack app that sends messages to a channel. You'll need to create your own Slack App by following the instructions below.

  1. Create a new Slack app on https://api.slack.com/apps - Name it whatever you like and choose your workspace as the development workspace
  2. Go to "Incoming Webhooks" and enable it
  3. Click "Add New Webhook to Workspace" and choose the channel you want Sheriff to post in to
  4. Keep a note of the newly created Webhook URL as you'll need it later for configuration purposes.
  5. Go to "OAuth & Permissions" and add the following OAuth scopes. usergroups:read, usergroups:write, users:read and users:read:email.
  6. Follow the prompt to reinstall your app for the new OAuth scopes to take effect
  7. Keep a note of the OAuth Access Token at the top of the page as you'll need it later for configuration purposes.

Configuration

Service Config

The following environment variables represent the configuration of the actual Sheriff deployment. For the permissions.yaml reference see the Permissions File section.

Name Required Value For Plugin
PERMISSIONS_FILE_ORG ✔️ The name of the GitHub org where you put the .permissions repository
PERMISSIONS_FILE_REPO Override the default repo to look for config.yaml .permissions
PERMISSIONS_FILE_PATH Override the default filepath to look for the Sheriff config config.yaml
PERMISSIONS_FILE_REF Override the default repo branch to look for the Sheriff config main
GITHUB_WEBHOOK_SECRET ✔️ The secret for the org-wide webhook you configured earlier
SLACK_TOKEN ✔️ The token for your Slack App you created earlier
SLACK_WEBHOOK_URL ✔️ The webhook URL for your Slack App you created earlier
SHERIFF_HOST_URL ✔️ The fully qualified URL for your deployed webhook
SHERIFF_PLUGINS A comma separated list of plugins to enable. Possible plugins are gsuite and slack
SHERIFF_IMPORTANT_BRANCH A regular expression to match important branches you want to monitor for deletion
SHERIFF_GITHUB_APP_CREDS ✔️ Private key credentials generated for a GitHub App.
GSUITE_CREDENTIALS GSuite credentials gsuite
GSUITE_TOKEN GSuite authentication token gsuite
SHERIFF_GSUITE_DOMAIN The primary domain of your GSuite account gsuite slack
SHERIFF_SLACK_DOMAIN The "domain" part of {domain}.slack.com for your Slack instance gsuite if you add slack email addresses to your google groups for notifications

Permissions File

Your organization permissions are controlled through a config.yaml file stored in a .permissions repository in your GitHub organization. We keep that .permissions repository private but you can choose to keep it public if you wish. That repository needs a config.yaml file at the top level that is in the following format:

organization: <name of github org>
repository_defaults:
  # Whether repositories should have wikis enabled by default or not
  # For security reasons, you should consider defaulting this to false
  has_wiki: <boolean>
# Teams are not specific to a single platform; they are shared across GitHub, Slack and GSuite
teams:
  - name: <team name>
    # A list of members / maintainers of this GitHub team
    # Maintainer in GitHub conveys some extra permissions over the team (set description, avatar, etc.)
    members:
      - list
      - of
      - gh_usernames
    maintainers:
      - list
      - of
      - gh_usernames
    # Or don't provide members/maintainers and instead provide a list of other
    # teams to draw users from.  This doesn't set any parent/child relationship
    # rather it simply says:
    # for team of formation:
    #   self.members += team.members
    #   self.maintainers += team.maintainers
    # i.e. doing a union of members/maintainers of the formation teams to create
    # a new member list
    formation:
      - list
      - of
      - other
      - teams
    # Optional team properties
    # Human friendly display name for GSuite and Slack groups
    displayName: <string>
    # Hidden GitHub team? true=yes, false=no
    secret: <boolean>
    # Create a slack user group for this team
    # false=no, true=use name of team, string=custom_name
    # Used by the `slack` plugin
    slack: <boolean> | <string>
    # Create a GSuite group for this team
    # Leave undefined for "no"
    # Used by the `gsuite` plugin
    gsuite:
      # internal = only visible to other GSuite members
      # external = public facing group email address
      privacy: internal | external
repositories:
  - name: <repo name>
    teams:
      <team_name>: read | triage | write | maintain | admin
    external_collaborators:
      <gh_username>: read | triage | write | maintain | admin
    # Optional repository settings
    settings:
      # Wiki enabled? true=yes, false=no
      has_wiki: <boolean>
    # Public vs Private repository, no value is assumed to mean public
    visibility: public | private

Generating your initial configuration

You can generate a permissions file for the current state of your org using the generate helper script.

node lib/permissions/generate.js

Please note you may want to edit this generated YAML file:

  • All org owners are considered maintainers of the teams they are in, this may be semantically incorrect
  • No GSuite or slack configuration is included in the generated file
  • You may want to use the formation property to declare larger teams instead of listing all members individually

However in theory running Sheriff immediately on this generated file should result in a no-op run.

Deployment Recommendations

You should have alerting set up in case the cron job fails. Occasionally, it will fail due to an unexpected state on GitHub or an incorrect/incomplete permissions file.

Known Limitations

  • Sheriff is not currently capable of inviting people to your org
    • Before adding them to the permissions file, ensure you've added them to the org.
  • Sheriff will not remove people from your org, if your has "default member permissions" you should ensure users are manually removed when appropriate

More Repositories

1

electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
C++
111,759
star
2

electron-quick-start

Clone to try a simple Electron app
JavaScript
10,851
star
3

electron-api-demos

Explore the Electron APIs
HTML
10,236
star
4

fiddle

:electron: 🚀 The easiest way to get started with Electron
TypeScript
7,312
star
5

forge

:electron: A complete tool for building and publishing Electron applications
TypeScript
6,117
star
6

asar

Simple extensive tar-like archive format with indexing
JavaScript
2,426
star
7

apps

A collection of apps built on Electron
JavaScript
1,655
star
8

electronjs.org-old

Electron website
Handlebars
1,588
star
9

windows-installer

Build Windows Installers for Electron apps
TypeScript
1,529
star
10

rcedit

Command line tool to edit resources of exe
C++
1,502
star
11

electron-quick-start-typescript

Clone to try a simple Electron app (in TypeScript)
TypeScript
1,176
star
12

rebuild

Package to rebuild native Node.js modules against the currently installed Electron version
TypeScript
980
star
13

update-electron-app

🌲 A drop-in module that adds autoUpdating capabilities to Electron apps
TypeScript
682
star
14

i18n

🌍 The home of Electron's translated documentation
TypeScript
623
star
15

simple-samples

Minimal Electron applications with ideas for taking them further
JavaScript
610
star
16

update.electronjs.org

📡 A free service that makes it easy for open-source Electron apps to update themselves.
JavaScript
556
star
17

osx-sign

Codesign Electron macOS apps
TypeScript
538
star
18

libchromiumcontent

Shared library build of Chromium’s Content module
Python
484
star
19

remote

Bridge JavaScript objects from the main process to the renderer process in Electron.
TypeScript
351
star
20

get

Download Electron release artifacts
TypeScript
325
star
21

releases

📦 Complete and up-to-date info about every release of Electron
JavaScript
245
star
22

build-tools

The GN scripts to use for Electron dev-flows
JavaScript
244
star
23

mini-breakpad-server

Minimum breakpad crash reports collecting server
CoffeeScript
237
star
24

node

Node fork to make it suitable for embedding in Electron
231
star
25

node-rcedit

Node module to edit resources of exe
JavaScript
183
star
26

node-abi

🐢 🚀 Get the Node.js and Electron ABI for a given target and runtime
JavaScript
154
star
27

governance

Public repository for governance issues and documents
Shell
136
star
28

chromedriver

Download ChromeDriver for Electron
JavaScript
128
star
29

typescript-definitions

Convert the Electron API JSON file to electron.d.ts
TypeScript
120
star
30

mksnapshot

Electron mksnapshot binaries
JavaScript
102
star
31

universal

Create Universal macOS applications from two x64 and arm64 Electron applications
TypeScript
102
star
32

notarize

Notarize your macOS Electron Apps
TypeScript
95
star
33

website

:electron: The Electron website
TypeScript
89
star
34

packager

Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI
TypeScript
75
star
35

trop

automate the backporting process
TypeScript
70
star
36

node-minidump

Node module to process minidump files
JavaScript
68
star
37

pdf-viewer

Fork of Chrome pdf extension to work as webui page in Electron
JavaScript
51
star
38

clerk

Verify PRs have release notes
TypeScript
48
star
39

hubdown

Convert markdown to GitHub-style HTML using a common set of remark plugins
JavaScript
39
star
40

native-mate

Fork of Chromium's gin library that makes it easier to marshal types between C++ and JavaScript.
C++
38
star
41

download-stats

⬇️ Download stats for Electron. Updated daily.
JavaScript
34
star
42

fuses

TypeScript
32
star
43

crashpad

Electron fork of crashpad
C++
31
star
44

symbolicate-mac

Symbolicate macOS Electron crash reports
JavaScript
30
star
45

onboarding-guide

or, "So You Want to Be an Electron Hacker"
30
star
46

chromium-breakpad

GitHub clone of the breakpad used by Chromium
C++
29
star
47

node-chromium-pickle-js

Binary value packing and unpacking library compatible with Chromium's Pickle class
JavaScript
22
star
48

electron-docs-linter

Parse and validate Electron's API documentation
JavaScript
21
star
49

nightlies

Nightly release store
19
star
50

docs-parser

Parse Electron docs in a lossless way into a JSON file
TypeScript
19
star
51

cation

Electron's PR monitoring bot
TypeScript
18
star
52

be

Scripts to help building Electron
JavaScript
18
star
53

season-of-docs-2020

📖 Project repository for Electron's possible participation in Google's Season of Docs
18
star
54

debian-sysroot-image-creator

Scripts to create debian sysroot image for building electron
Shell
18
star
55

dependent-repos

Public GitHub repos that depend on Electron. spiritual successor to https://github.com/electron/repos-using-electron
JavaScript
18
star
56

asar-require

Enable "require" scripts in asar archives
CoffeeScript
18
star
57

packages

A collection of all npm packages that mention `electron` in their package.json
JavaScript
17
star
58

symbol-server

Electron symbol server
TypeScript
14
star
59

unreleased

Checks for and reports commits unreleased for a specific release branch.
JavaScript
13
star
60

windows-sign

Codesign Electron apps for Windows
TypeScript
13
star
61

archaeologist

Digging up your artifacts since 2018
TypeScript
13
star
62

algolia-indices

Algolia search index data for Electron APIs, Tutorials, Packages, and Repos
JavaScript
13
star
63

fiddle-core

Run fiddles from anywhere, on any Electron release
TypeScript
13
star
64

electron-frameworks

Frameworks used by Electron
11
star
65

search-with-your-keyboard

Add keyboard navigation to your existing client-side search interface.
JavaScript
10
star
66

electron-api-historian

Find the birthday of every Electron API
JavaScript
9
star
67

gyp

Python
9
star
68

electron-api-docs

📝 Electron's API documentation in a structured JSON format [ARCHIVED]
JavaScript
9
star
69

build-tools-installer

Installer for Electron's wrapper toolkit for working with Electron.js source code
JavaScript
9
star
70

build-images

Base docker image used to build Electron on CI
Shell
9
star
71

github-app-auth

Gets an auth token for a repo via a GitHub app installation
TypeScript
8
star
72

electron-docs

Fetch Electron documentation as raw markdown strings
JavaScript
8
star
73

.github

organization-wide defaults for all electron/* repos
7
star
74

bugbot

Making life easier for people who report or triage Electron issues.
TypeScript
6
star
75

node-is-valid-window

Validates if a pointer to window is valid.
C++
5
star
76

circleci-oidc-secret-exchange

Provides dynamic access to secrets in exchange for a valid OIDC token
TypeScript
5
star
77

electron-translators

Everyone who has helped translate Electron's documentation into different languages.
JavaScript
5
star
78

electron-userland-reports

Slices of data about packages, repos, and users in Electron userland. Collected from the GitHub API, npm registry, and libraries.io
JavaScript
5
star
79

rfcs

5
star
80

roller

🎵rollin on upstream 🎵
TypeScript
4
star
81

eslint-config

ESLint config used by Electron and Electron maintained modules
JavaScript
4
star
82

tweets

3
star
83

electron-website-updater

JavaScript
3
star
84

zoilist

Nag @electron/api-wg to do API reviews
TypeScript
3
star
85

lint-roller

JavaScript
2
star
86

github-app-auth-action

TypeScript
2
star
87

libcc-check

A little tool for checking up on libchromiumcontent builds.
JavaScript
2
star
88

slack-chromium-helper

Slack bot to unfurl Chromium development URLs
TypeScript
2
star
89

electron-issues

An experiment to better understand the issues filed on the electron/electron repo
JavaScript
2
star
90

hippo

TypeScript
2
star
91

ventifact

TypeScript
2
star
92

node-orb

Shell
1
star
93

electron-notarize

Notarize your macOS Electron Apps
TypeScript
1
star
94

docs-reviewer

TypeScript
1
star