Overview
This video automates adding newly published vulnerabilities from the GitHub Security Advisory API to a Notion database, with no server to manage. naoyashiga studies security by reading OSS vulnerability reports and used to search the advisories by hand and paste links into Notion; automating that frees up time for learning.
It uses the Notion Developer Platform: the Notion CLI (ntn) to create and deploy the project, and Notion Workers to run the TypeScript code on Notion’s side. Claude Code writes the code.
Key Points
- A scheduled script usually needs a server someone must maintain. Notion Workers host and run the code instead, which suits short jobs on a fixed interval.
- Workers offer Syncs (pull external data into Notion on a schedule), Tools (functions Notion agents can call) and Webhooks (receive events from external services). This project uses Syncs.
ntn workers newcreates a ready-to-deploy project, and one deploy command bundles, builds (on the server) and uploads it. A failed deploy of the sync code was traced to a date-filter bug.- The sync runs every six hours to respect GitHub API rate limits. Upserts keyed on the GitHub Advisory ID update existing rows and add only new ones.
- Later steps add categories by vulnerability type (such as XSS, SSRF and RCE), widen the window from 12 hours to 3 days, and add Japanese summaries with the cheap, OpenAI-compatible DeepSeek V4 Flash, with its API key pushed from
.envviantn workers env push.
Chapters
- 0:00 Introduction
- 0:23 The problem with doing it by hand
- 0:47 Why automate it serverlessly
- 1:29 Using the Notion CLI
- 1:57 What Notion Workers are
- 2:22 The three Worker features (Syncs/Tools/Webhooks)
- 2:54 Creating the project
- 3:39 Deploying
- 4:37 Implementation (built with Claude Code)
- 5:30 Deploying and checking that it works
- 6:23 Walking through the sync code
- 6:46 Adding categories
- 7:35 Updating safely with upsert
- 7:56 Adjusting how many items are fetched
- 9:46 Adding Japanese summaries
概要
この動画では、GitHub Security Advisory APIで新しく公開された脆弱性情報を、サーバーを管理することなくNotionのデータベースへ自動で追加します。筆者はOSSの脆弱性報告を読んでセキュリティを学んでおり、これまではアドバイザリーを手作業で検索し、リンクをNotionに貼っていました。この作業を自動化することで、学習に使える時間が増えます。
使うのはNotion Developer Platformで、プロジェクトの作成とデプロイにはNotion CLI(ntn)を、TypeScriptのコードをNotion側で動かす場所としてNotion Workersを使います。コードはClaude Codeに書かせます。
ポイント
- 定期実行するスクリプトには、ふつう誰かが面倒を見続けるサーバーが必要です。Notion Workersならコードを預けるだけで実行してくれるため、短時間で終わる処理を決まった間隔で回す用途に向いています。
- Workersには、外部のデータを定期的にNotionへ取り込むSyncs、Notionのエージェントから呼び出せる関数のTools、外部サービスからのイベントを受け取るWebhooksがあります。今回はSyncsを使います。
ntn workers newでそのままデプロイできるプロジェクトが作られ、デプロイコマンド1つでバンドル、ビルド(サーバー側で実行)、アップロードまで済みます。同期のコードをデプロイして失敗した原因は、日付フィルターのバグでした。- 同期はGitHub APIのレートリミットを考えて6時間ごとに実行します。GitHub Advisory IDを主キーにupsertし、既存の行は更新、新しいものだけを追加します。
- その後、脆弱性の種類によるカテゴリー(XSS、SSRF、RCEなど)を追加し、取得範囲を12時間から3日間に広げ、安くてOpenAI互換のAPIを持つDeepSeek V4 Flashによる日本語要約も加えます。APIキーは
.envからntn workers env pushで環境変数として送ります。