-
Notifications
You must be signed in to change notification settings - Fork 26
Add Telegram bot with private linking, notification delivery, and commands #930
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
base: dev
Are you sure you want to change the base?
Changes from all commits
0b69ce6
6c7a492
4d56707
96bee7f
6bc2f50
542e498
be5f844
b301a7b
74cbcf9
ed31eba
06be31b
edfbf50
493c3e3
82ba3ef
0030d5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Deliver Telegram Notifications (dev) | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: telegram-deliver-dev | ||
| cancel-in-progress: false | ||
|
|
||
| on: | ||
| schedule: | ||
| # GitHub Actions schedules are best-effort; avoid crowded :00/:15/:30/:45 slots. | ||
| # Start at :01 so the last slot (:56) rolls to :01 with no hourly gap. | ||
| - cron: '1-59/5 * * * *' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| deliver: | ||
| runs-on: ubuntu-latest | ||
| environment: cron-job | ||
|
coderabbitai[bot] marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
fd 'deploy-apprunner' backend --exec cat {}
fd '.env.example' backend --exec grep -n -i 'CRON_SYNC_TOKEN' {}Repository: genlayer-foundation/points Length of output: 37287 🏁 Script executed: #!/bin/bash
set -euo pipefail
for f in .github/workflows/telegram-deliver-dev.yml .github/workflows/telegram-deliver.yml; do
echo "===== $f ====="
cat -n "$f" | sed -n '1,200p'
echo
done
echo "===== CRON_SYNC_TOKEN references ====="
rg -n "CRON_SYNC_TOKEN|environment:" .github/workflows -SRepository: genlayer-foundation/points Length of output: 4579 Split cron delivery into separate environments Both workflows use 📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| steps: | ||
| - name: Drain Telegram outbox (dev) | ||
| run: | | ||
| response=$(curl -s -w "\n%{http_code}" -X POST \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "X-Cron-Token: ${{ secrets.CRON_SYNC_TOKEN }}" \ | ||
| "${{ secrets.DEV_API_BASE_URL }}/api/v1/notifications/telegram/deliver/") | ||
|
|
||
| http_code=$(echo "$response" | tail -n1) | ||
| body=$(echo "$response" | sed '$d') | ||
|
|
||
| echo "Response: $body" | ||
| echo "HTTP Code: $http_code" | ||
|
|
||
| if [ "$http_code" = "200" ]; then | ||
| echo "Telegram delivery run completed" | ||
| else | ||
| echo "Telegram delivery failed with status $http_code" | ||
| exit 1 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Deliver Telegram Notifications | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: telegram-deliver-prod | ||
| cancel-in-progress: false | ||
|
|
||
| on: | ||
| schedule: | ||
| # GitHub Actions schedules are best-effort; avoid crowded :00/:15/:30/:45 slots. | ||
| - cron: '4-59/5 * * * *' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| deliver: | ||
| runs-on: ubuntu-latest | ||
| environment: cron-job | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| steps: | ||
| - name: Drain Telegram outbox | ||
| run: | | ||
| response=$(curl -s -w "\n%{http_code}" -X POST \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "X-Cron-Token: ${{ secrets.CRON_SYNC_TOKEN }}" \ | ||
| "${{ secrets.API_BASE_URL }}/api/v1/notifications/telegram/deliver/") | ||
|
|
||
| http_code=$(echo "$response" | tail -n1) | ||
| body=$(echo "$response" | sed '$d') | ||
|
|
||
| echo "Response: $body" | ||
| echo "HTTP Code: $http_code" | ||
|
|
||
| if [ "$http_code" = "200" ]; then | ||
| echo "Telegram delivery run completed" | ||
| else | ||
| echo "Telegram delivery failed with status $http_code" | ||
| exit 1 | ||
| fi | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win
Both Telegram delivery workflows lack explicit
permissions:andconcurrency:blocks. Root cause: neither workflow was scaffolded with a hardening block, so both default to broad token permissions and allow overlapping scheduled runs..github/workflows/telegram-deliver-dev.yml#L3-13: add a top-levelpermissions: contents: readand aconcurrency: {group: telegram-deliver-dev, cancel-in-progress: false}block..github/workflows/telegram-deliver.yml#L3-12: add a top-levelpermissions: contents: readand aconcurrency: {group: telegram-deliver-prod, cancel-in-progress: false}block.🧰 Tools
🪛 zizmor (1.26.1)
[warning] 1-34: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents
Source: Linters/SAST tools