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
29 changes: 29 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,35 @@ These are deliberate and **should not be reported** as bugs:
so the worst case is old genuine error reports getting rotated out faster under abuse, not
unbounded disk growth.

## Dependabot alerts

GitHub reported 8 alerts (1 critical, 2 high, 5 moderate) the first time
`pnpm-lock.yaml` was committed — Dependabot can only scan a lockfile once it's
tracked in git, so this was a first-visibility event, not a new regression.

- **7 of 8 (`request`, `form-data` ×2 including the critical one, `qs` ×2,
`uuid`, `tough-cookie`)** all traced to the same chain: the deprecated
`request`/`@cypress/request` HTTP client pulled in transitively by
`node-telegram-bot-api@0.66.0` (an `optionalDependency`, used only by the
standalone `telegram-bot.js`). That library's only actual use in this repo
was `new TelegramBot(token, {polling:false})` + `bot.sendMessage(...)` — a
single Telegram Bot API call. **Fixed**: `telegram-bot.js` was rewritten to
POST to `api.telegram.org` directly via `https` (same pattern as
`sendDiscord()` in `server.js`), and `node-telegram-bot-api` was dropped
from `package.json` entirely. This removes the whole vulnerable chain and
needs no `npm install` step anymore.
- **1 of 8 (`js-yaml`, high, quadratic-CPU DoS in `!!omap` parsing)** comes
from `eslint@9.39.5` → `@eslint/eslintrc` (a `devDependency`, only runs
locally/in CI, never in the deployed server). The project never parses
untrusted YAML anywhere in `server.js`/`index.html`/`lib.js` — the only YAML
file is the static, developer-authored `openapi.yaml`, which is served as-is
and never fed through `js-yaml`. **Accepted, not fixed**: eslint only drops
this dependency in its v10 line, which requires migrating `.eslintrc.json`
to flat config (`eslint.config.js`) and raising the supported Node version
to `^20.19 || ^22.13 || >=24` (the project currently declares
`engines.node: >=18`) — out of proportion to a lint-only, non-exploitable
advisory. Revisit if/when the project bumps its minimum Node version.

## Data & privacy

- The server stores only alert data (city, type, timestamp) — **no user accounts, no PII**.
Expand Down
10 changes: 7 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## מה הפרויקט

**צפיר** (Tzafir; חבילת npm: `tzafir`, לשעבר `israel-alert-map`, v1.6.1) — שרת Node.js + קליינט HTML עצמאי שמציג בזמן אמת את אזעקות פיקוד העורף על מפת Leaflet. תלות בליבה: אפס (רק `node` ≥ 18). תלויות אופציונליות: `web-push`, `node-telegram-bot-api`. שם ה-repo ב-GitHub נשאר `RedAlert` במכוון (המיתוג שונה, ה-repo לא שונה).
**צפיר** (Tzafir; חבילת npm: `tzafir`, לשעבר `israel-alert-map`, v1.6.1) — שרת Node.js + קליינט HTML עצמאי שמציג בזמן אמת את אזעקות פיקוד העורף על מפת Leaflet. תלות בליבה: אפס (רק `node` ≥ 18). תלות אופציונלית יחידה: `web-push` (ל-server.js). `telegram-bot.js` ללא תלויות בכלל — קורא ל-Telegram Bot API דרך `https` גולמי. שם ה-repo ב-GitHub נשאר `RedAlert` במכוון (המיתוג שונה, ה-repo לא שונה).

מקור הנתונים: `https://www.oref.org.il/WarningMessages/alert/alerts.json` (polling כל 2 שניות). אין מפתחות, אין הרשמה.

Expand Down Expand Up @@ -38,7 +38,7 @@ flowchart LR
| [test/unit.js](test/unit.js) | בדיקות יחידה ל-`lib.js` דרך `node:test`. ללא תלויות. |
| [test/integration.js](test/integration.js) | בדיקת אינטגרציה ברמת ה-API — מקים mock OREF + spawned server, מאמת אזעקה זורמת ל-`/api/alerts` + SSE + `/api/health`. ללא דפדפן. |
| [test/e2e.js](test/e2e.js) | E2E בדפדפן אמיתי (Playwright, `channel:'chrome'` — משתמש ב-Chrome המותקן מקומית, בלי הורדת דפדפן bundled). מריץ spawned server + בודק רגרסיות UI אמיתיות שנתפסו בעבר (פוקוס בחיפוש, שימור טאב, רוחב ניווט מובייל, תוויות מקלטים, צבעי option במצב כהה, תוויות טאב חסרות, קריסת טאב היסטוריה) — כל טסט מקושר לבאג ספציפי מה-CHANGELOG. `playwright` הוא `devDependency` בלבד. |
| [telegram-bot.js](telegram-bot.js) | בוט עצמאי — polling ל-`/api/alerts` ושליחה לערוץ טלגרם. |
| [telegram-bot.js](telegram-bot.js) | בוט עצמאי — polling ל-`/api/alerts` ושליחה לערוץ טלגרם. **ללא תלויות** — `sendMessage` ל-Telegram Bot API דרך `https` גולמי (אותו סגנון כמו `sendDiscord()` ב-server.js), לא `node-telegram-bot-api`. |
| [Dockerfile](Dockerfile) + [docker-compose.yml](docker-compose.yml) | בנייה ל-`node:20-alpine` עם healthcheck. |
| [package.json](package.json) | scripts בלבד; ללא `dependencies` רגילים, רק `optionalDependencies`. |

Expand All @@ -58,7 +58,7 @@ node test/unit.js # 90+ בדיקות (כולל smoke test לשרת)
node test/integration.js # אינטגרציה ברמת API — mock OREF → server → SSE
node test/e2e.js # E2E בדפדפן אמיתי — דורש Chrome/Edge מקומי + playwright (devDependency)
node telegram-bot.js # בוט טלגרם (דורש משתני סביבה)
npm install # התקנת web-push + telegram-bot-api (אופציונלי)
npm install # התקנת web-push (אופציונלי; telegram-bot.js ללא תלויות)
docker-compose up -d # פריסה ב-Docker

npm start # = node server.js
Expand Down Expand Up @@ -217,3 +217,7 @@ npm run docker:run # docker run -p 3000:3000 ...
- **CORS פתוח (`*`)** — מכוון; ה-API נועד לצריכה ציבורית.
- **CSP מתיר `unsafe-inline`** — מכוון; הקליינט הוא HTML+JS מונוליטי.
- **המערכת אינה חליפה להנחיות פיקוד העורף**. הדגש את זה בכל UI חדש.

## Dependabot / תלויות פגיעות — היסטוריה

ב-2026-08-29 GitHub דיווח 8 alerts (1 critical, 2 high, 5 moderate) בפעם הראשונה ש-`pnpm-lock.yaml` הוכנס ל-git (זה first-visibility — Dependabot סורק רק lockfile שכבר ב-repo, לא regression חדש). נבדק ישירות מול `gh api repos/.../dependabot/alerts`: **7 מתוך 8** (`request`, `form-data` פעמיים כולל ה-critical, `qs` פעמיים, `uuid`, `tough-cookie`) חזרו לאותה שרשרת אחת — הלקוח הישן `request`/`@cypress/request` שנמשך טרנזיטיבית ע״י `node-telegram-bot-api@0.66.0` (שהיה `optionalDependency`). השימוש היחיד בספרייה הזו בקוד היה `new TelegramBot(token,{polling:false})` + `bot.sendMessage(...)` — קריאת API בודדת. **תוקן**: `telegram-bot.js` נכתב מחדש לקרוא ל-`api.telegram.org` ישירות דרך `https` גולמי (אותו סגנון כמו `sendDiscord()`), ו-`node-telegram-bot-api` הוסר לגמרי מ-`package.json` — מסיר את כל השרשרת, בלי `npm install` בכלל. **1 מתוך 8** (`js-yaml`, high, DoS ב-`!!omap`) מגיע מ-`eslint@9.39.5`→`@eslint/eslintrc`, `devDependency` בלבד שרץ רק לוקאלית/ב-CI. הפרויקט לא מפרסר YAML לא-מהימן באף מקום (openapi.yaml הוא סטטי ומוגש כמו שהוא, לא עובר `js-yaml`). **התקבל כסיכון, לא תוקן** — הסרתו דורשת מעבר `.eslintrc.json`→flat config (`eslint.config.js`) והעלאת `engines.node` ל-`^20.19||^22.13||>=24` (הפרויקט מצהיר `>=18`), לא פרופורציונלי לאזהרת lint-only שאינה ניתנת לניצול. פירוט מלא ב-[.github/SECURITY.md](.github/SECURITY.md#dependabot-alerts).
10 changes: 7 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## מה הפרויקט

**צפיר** (Tzafir; חבילת npm: `tzafir`, לשעבר `israel-alert-map`, v1.6.1) — שרת Node.js + קליינט HTML עצמאי שמציג בזמן אמת את אזעקות פיקוד העורף על מפת Leaflet. תלות בליבה: אפס (רק `node` ≥ 18). תלויות אופציונליות: `web-push`, `node-telegram-bot-api`. שם ה-repo ב-GitHub נשאר `RedAlert` במכוון (המיתוג שונה, ה-repo לא שונה).
**צפיר** (Tzafir; חבילת npm: `tzafir`, לשעבר `israel-alert-map`, v1.6.1) — שרת Node.js + קליינט HTML עצמאי שמציג בזמן אמת את אזעקות פיקוד העורף על מפת Leaflet. תלות בליבה: אפס (רק `node` ≥ 18). תלות אופציונלית יחידה: `web-push` (ל-server.js). `telegram-bot.js` ללא תלויות בכלל — קורא ל-Telegram Bot API דרך `https` גולמי. שם ה-repo ב-GitHub נשאר `RedAlert` במכוון (המיתוג שונה, ה-repo לא שונה).

מקור הנתונים: `https://www.oref.org.il/WarningMessages/alert/alerts.json` (polling כל 2 שניות). אין מפתחות, אין הרשמה.

Expand Down Expand Up @@ -38,7 +38,7 @@ flowchart LR
| [test/unit.js](test/unit.js) | בדיקות יחידה ל-`lib.js` דרך `node:test`. ללא תלויות. |
| [test/integration.js](test/integration.js) | בדיקת אינטגרציה ברמת ה-API — מקים mock OREF + spawned server, מאמת אזעקה זורמת ל-`/api/alerts` + SSE + `/api/health`. ללא דפדפן. |
| [test/e2e.js](test/e2e.js) | E2E בדפדפן אמיתי (Playwright, `channel:'chrome'` — משתמש ב-Chrome המותקן מקומית, בלי הורדת דפדפן bundled). מריץ spawned server + בודק רגרסיות UI אמיתיות שנתפסו בעבר (פוקוס בחיפוש, שימור טאב, רוחב ניווט מובייל, תוויות מקלטים, צבעי option במצב כהה, תוויות טאב חסרות, קריסת טאב היסטוריה) — כל טסט מקושר לבאג ספציפי מה-CHANGELOG. `playwright` הוא `devDependency` בלבד. |
| [telegram-bot.js](telegram-bot.js) | בוט עצמאי — polling ל-`/api/alerts` ושליחה לערוץ טלגרם. |
| [telegram-bot.js](telegram-bot.js) | בוט עצמאי — polling ל-`/api/alerts` ושליחה לערוץ טלגרם. **ללא תלויות** — `sendMessage` ל-Telegram Bot API דרך `https` גולמי (אותו סגנון כמו `sendDiscord()` ב-server.js), לא `node-telegram-bot-api`. |
| [Dockerfile](Dockerfile) + [docker-compose.yml](docker-compose.yml) | בנייה ל-`node:20-alpine` עם healthcheck. |
| [package.json](package.json) | scripts בלבד; ללא `dependencies` רגילים, רק `optionalDependencies`. |

Expand All @@ -58,7 +58,7 @@ node test/unit.js # 90+ בדיקות (כולל smoke test לשרת)
node test/integration.js # אינטגרציה ברמת API — mock OREF → server → SSE
node test/e2e.js # E2E בדפדפן אמיתי — דורש Chrome/Edge מקומי + playwright (devDependency)
node telegram-bot.js # בוט טלגרם (דורש משתני סביבה)
npm install # התקנת web-push + telegram-bot-api (אופציונלי)
npm install # התקנת web-push (אופציונלי; telegram-bot.js ללא תלויות)
docker-compose up -d # פריסה ב-Docker

npm start # = node server.js
Expand Down Expand Up @@ -217,3 +217,7 @@ npm run docker:run # docker run -p 3000:3000 ...
- **CORS פתוח (`*`)** — מכוון; ה-API נועד לצריכה ציבורית.
- **CSP מתיר `unsafe-inline`** — מכוון; הקליינט הוא HTML+JS מונוליטי.
- **המערכת אינה חליפה להנחיות פיקוד העורף**. הדגש את זה בכל UI חדש.

## Dependabot / תלויות פגיעות — היסטוריה

ב-2026-08-29 GitHub דיווח 8 alerts (1 critical, 2 high, 5 moderate) בפעם הראשונה ש-`pnpm-lock.yaml` הוכנס ל-git (זה first-visibility — Dependabot סורק רק lockfile שכבר ב-repo, לא regression חדש). נבדק ישירות מול `gh api repos/.../dependabot/alerts`: **7 מתוך 8** (`request`, `form-data` פעמיים כולל ה-critical, `qs` פעמיים, `uuid`, `tough-cookie`) חזרו לאותה שרשרת אחת — הלקוח הישן `request`/`@cypress/request` שנמשך טרנזיטיבית ע״י `node-telegram-bot-api@0.66.0` (שהיה `optionalDependency`). השימוש היחיד בספרייה הזו בקוד היה `new TelegramBot(token,{polling:false})` + `bot.sendMessage(...)` — קריאת API בודדת. **תוקן**: `telegram-bot.js` נכתב מחדש לקרוא ל-`api.telegram.org` ישירות דרך `https` גולמי (אותו סגנון כמו `sendDiscord()`), ו-`node-telegram-bot-api` הוסר לגמרי מ-`package.json` — מסיר את כל השרשרת, בלי `npm install` בכלל. **1 מתוך 8** (`js-yaml`, high, DoS ב-`!!omap`) מגיע מ-`eslint@9.39.5`→`@eslint/eslintrc`, `devDependency` בלבד שרץ רק לוקאלית/ב-CI. הפרויקט לא מפרסר YAML לא-מהימן באף מקום (openapi.yaml הוא סטטי ומוגש כמו שהוא, לא עובר `js-yaml`). **התקבל כסיכון, לא תוקן** — הסרתו דורשת מעבר `.eslintrc.json`→flat config (`eslint.config.js`) והעלאת `engines.node` ל-`^20.19||^22.13||>=24` (הפרויקט מצהיר `>=18`), לא פרופורציונלי לאזהרת lint-only שאינה ניתנת לניצול. פירוט מלא ב-[.github/SECURITY.md](.github/SECURITY.md#dependabot-alerts).
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ docker-compose up -d
### עם תוספות אופציונליות

```bash
npm install # web-push + telegram bot
npm install # web-push (Telegram bot אין לו תלויות — ראו למטה)
ADMIN_PASS=secret node server.js
```

Expand Down Expand Up @@ -391,10 +391,11 @@ cloudflared tunnel --url http://localhost:3000
## 🤖 Telegram Bot

```bash
npm install node-telegram-bot-api
TELEGRAM_TOKEN=123:ABC TELEGRAM_CHANNEL=@my_channel node telegram-bot.js
```

ללא תלויות — קריאה ל-Telegram Bot API (`sendMessage`) דרך `https` גולמי, אין יותר `npm install`.

---

## 🧪 בדיקות + CI
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"author": "",
"license": "MIT",
"optionalDependencies": {
"node-telegram-bot-api": "^0.66.0",
"web-push": "^3.6.0"
},
"devDependencies": {
Expand Down
Loading
Loading