Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/actions/setup-repo-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Set up Repo Environment'
description: 'Sets up Python and its deps'
runs:
using: "composite"
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
shell: bash
working-directory: ./email-rotation
46 changes: 46 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Run Tests

on:
pull_request:
paths:
- '**/*.py'
- '**/*.yaml'
- '.github/**'

jobs:
run_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up repo environment
uses: ./.github/actions/setup-repo-env

- name: Run email script tests
run: python3 email_about_issues_test.py
working-directory: ./email-rotation

- name: Run rotation extension tests
run: python3 extend_rotation_test.py
working-directory: ./email-rotation

- name: Run yaml verification test
run: python3 verify_yaml_files_test.py
working-directory: ./email-rotation

- name: Run pyright
run: pyright *.py
working-directory: ./email-rotation

- name: Run mypy
run: mypy . --explicit-package-bases --strict
working-directory: ./email-rotation

- name: Run isort
run: isort . --check-only
working-directory: ./email-rotation

- name: Run black
run: black . --check
working-directory: ./email-rotation
4 changes: 4 additions & 0 deletions email-rotation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/__pycache__
github-token
secrets
state.json
28 changes: 28 additions & 0 deletions email-rotation/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM debian:stable-slim
LABEL maintainer="George Burgess <[email protected]>"

# Grab the packages
RUN apt-get update
RUN apt-get install -y python3 python3-requests python3-yaml

ENV LANG=C.UTF-8

# Rootn't
RUN \
useradd email-bot && \
mkdir /home/email-bot && \
chown email-bot:email-bot /home/email-bot

USER email-bot
WORKDIR /home/email-bot

# Example build'n'run invocation:
# docker build -t llvm-security-group-emails . && docker run --rm -it -v $PWD:/home/email-bot/llvm-security-repo/email-rotation llvm-security-group-emails
#
# Example `secrets` file:
# export [email protected]
# export GITHUB_REPOSITORY=llvm/llvm-security-repo
# export GITHUB_TOKEN=[redacted]
# export GMAIL_PASSWORD=[redacted]
# export [email protected]
CMD ["bash", "-c", "cd llvm-security-repo && . secrets && exec ./email_about_issues.py --state-file=state.json --debug"]
20 changes: 20 additions & 0 deletions email-rotation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
This directory implements an oncall rotation for security issues, essentially.

Relevant files (ignoring tests) are:

- `rotation-members.yaml`, which is the set of all members currently on the
security group who are eligible for this rotation.

- `rotation.yaml`, which specifies the rotation. This is generally extended by
`rotation-members.yaml`, though can be edited by humans (e.g., to remove
people from rotations, swap with others, etc.)

- `email_about_issues.py` actually emails about the issues; it's run on
a machine through a Docker image produced by the `Dockerfile`.
The `docker run` invocation looks like:
```
docker run --rm -it -v $PWD:/home/email-bot/llvm-security-repo llvm-security-group-emails
```
- `extend_rotation.py` extends the `rotation.yaml` file automatically. This
script only appends to the rotation, and takes into account who's already been
in the rotation recently when creating new rotation instances.
Empty file added email-rotation/__init__.py
Empty file.
Loading