Commit Graph

528 Commits

Author SHA1 Message Date
21586f6b91 fix(chat): Rozszerzone słowa kluczowe ZOPK - polskie odmiany przypadków
Dodano:
- Odmiany 'jądrowa/jądrowej/jądrowe/jądrowy'
- 'atomowa' i odmiany
- Konkretne nazwy: westinghouse, bechtel, arabelle, turbiny
- Więcej form offshore wind
- Rozszerzono infrastructure i energy keywords

Dzięki temu pytania jak 'turbiny dla elektrowni jądrowej'
będą poprawnie rozpoznawane jako ZOPK

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:48:02 +01:00
1136e9d40b fix(gemini): Przekazywanie safety_settings z BLOCK_NONE
Problem: Gemini blokował treści o energetyce jako 'dangerous content'
Rozwiązanie: Przekazywanie safety_settings do API z BLOCK_NONE

Uwaga: FREE tier może nadal mieć ograniczenia

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:43:33 +01:00
27b03eb051 fix(zopk): Neutralne prompty ekstrakcji - unikanie safety filters
Problem: Gemini blokował ekstrakcję z artykułów o energetyce
Rozwiązanie: Bardziej neutralne sformułowania promptów
- Podkreślono że to analiza PUBLICZNYCH artykułów prasowych
- Usunięto wrażliwe słowa kluczowe (nuclear, defense)
- Zmieniono 'extract' na 'identify'

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:42:05 +01:00
cd2db86a95 fix(zopk): Naprawiono błąd system_prompt w AI extraction
Problem: GeminiService.generate_text() nie obsługuje parametru system_prompt
Rozwiązanie: Połączono system_prompt z user_prompt w jeden full_prompt

Dotyczy: ekstrakcji faktów, encji i relacji z artykułów ZOPK

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:37:09 +01:00
a20d94883e feat(admin): Konfigurowalne limity dla operacji ZOPK
- Scraping: domyślnie 1, max 100
- Ekstrakcja: domyślnie 1, max 100
- Embeddingi: domyślnie 1, max 500
- Usunięto stałe liczby z etykiet przycisków

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:30:54 +01:00
0797afe162 fix(admin): Poprawiono czytelność wyświetlania statystyk ZOPK
- Dodano white-space: pre-line do modala
- Wyrównano kolumny wartości
- Dodano separatory sekcji
- Usunięto zbędne emoji w nagłówkach

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:29:26 +01:00
498f273aba fix(admin): Naprawiono strukturę danych w przyciskach ZOPK
- Naprawiono showKnowledgeStats - używa prawidłowej zagnieżdżonej struktury
- Naprawiono endpoint embeddings - renamed 'success' count to 'generated'
- Naprawiono endpoint extract - renamed 'success' count to 'processed'
- Unikamy nadpisywania flagi 'success: True' przez spread operator

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:27:02 +01:00
8b065d84d0 feat(admin): Przyciski do scrapingu i ekstrakcji wiedzy ZOPK
- Dodano przyciski: Scrapuj treść, Ekstraktuj wiedzę, Generuj embeddingi
- Dodano przycisk Statystyki z podglądem bazy wiedzy
- Przyciski widoczne w panelu /admin/zopk/news

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:21:55 +01:00
1b4cd31c41 feat(zopk): Knowledge Base + NordaGPT integration (FAZY 0-3)
FAZA 0 - Web Scraping:
- Migracja 015: pola full_content, scrape_status w zopk_news
- zopk_content_scraper.py: scraper z rate limiting i selektorami

FAZA 1 - Knowledge Extraction:
- zopk_knowledge_service.py: chunking, facts, entities extraction
- Endpointy /admin/zopk/knowledge/extract

FAZA 2 - Embeddings:
- gemini_service.py: generate_embedding(), generate_embeddings_batch()
- Model text-embedding-004 (768 dimensions)

FAZA 3 - NordaGPT Integration:
- nordabiz_chat.py: _is_zopk_query(), _get_zopk_knowledge_context()
- System prompt z bazą wiedzy ZOPK
- Semantic search w kontekście chatu

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 20:15:30 +01:00
0f1cf6176a fix(health): Usunięcie nieistniejącego endpointu /admin/news
Endpoint /admin/news był planowany (dokumentacja CLAUDE.md) ale nigdy
nie zaimplementowany. Tylko /admin/zopk/news istnieje.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 21:31:10 +01:00
0a5f40879b fix(admin): Naprawa błędu 500 na /admin/fees + rozszerzenie health check
1. Context processor bug: datetime.now → datetime.now()
   - Szablon fees.html używa now.strftime(), potrzebuje wartości nie metody
   - Powodowało jinja2.UndefinedError na /admin/fees

2. Health check: dodano brakujące endpointy admina
   - /admin/fees (Składki/FIS)
   - /admin/news (News moderacja)
   - /admin/zopk/news (ZOPK News)
   - /admin/recommendations (Rekomendacje)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 21:27:18 +01:00
c13ad09e3a feat(zopk): Skrypt do naprawy źródeł newsów z Google News
Problem: Newsy z Google News RSS miały source_domain='news.google.com'
i favicon Google zamiast prawdziwego źródła.

Rozwiązanie: Nowy skrypt fix_google_news_sources.py który:
- Wyciąga nazwę źródła z tytułu (po " - ")
- Mapuje 59 źródeł na ich prawdziwe domeny
- Aktualizuje source_domain i image_url (favicon)

Wynik: 143/143 newsów zaktualizowanych z poprawnymi źródłami.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 08:06:40 +01:00
8055589a08 fix: Usunięto Session z decode_google_news_url, dodano max_depth
- Zamieniono requests.Session() na bezpośredni requests.get()
- Dodano max_depth=3 jako zabezpieczenie przed nieskończoną rekurencją
- Jawne zamykanie response.close() po każdym request

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 07:45:02 +01:00
af4c0d157a fix: Naprawiono wyciek połączeń HTTP w fix_google_news_images.py
- Dodano context manager (with) dla sesji requests
- Jawne zamykanie odpowiedzi HTTP (response.close())
- Dodano flush=True do print dla natychmiastowego outputu
- Rozwiązuje problem 725+ otwartych połączeń

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 07:40:00 +01:00
07171b46b7 docs: Raport incydentu CPU + ostrzeżenia o uruchamianiu skryptów
- Dodano INCIDENT_REPORT_20260115.md dokumentujący incydent
  wysokiego CPU spowodowany wielokrotnym uruchomieniem skryptu
- Dodano ostrzeżenia do CLAUDE.md o uruchamianiu skryptów:
  - SSH timeout NIE oznacza nieudanego wykonania
  - Sprawdzaj procesy przed ponownym uruchomieniem
  - Używaj QEMU guest agent jako alternatywy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 07:35:05 +01:00
637ec2fc75 feat: Skrypt do naprawy obrazków newsów z Google News 2026-01-15 06:19:53 +01:00
c2205b0815 fix: Poprawione dekodowanie URL Google News + użycie source_domain 2026-01-15 06:10:59 +01:00
8ead7798df fix: Ładowanie DATABASE_URL z .env w skrypcie obrazków 2026-01-15 06:08:59 +01:00
cf56fe7d8a feat(zopk): Skrypt do pobierania obrazków dla newsów
Strategia pobierania obrazków:
1. Rozwiń URL Google News do oryginalnego źródła
2. Pobierz og:image z meta tagów strony
3. Fallback: logo domeny (Clearbit API)
4. Fallback: favicon (Google Favicon API)

Użycie: python scripts/fetch_news_images.py [--dry-run] [--limit N]

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:08:10 +01:00
82d4c870a0 style(zopk): Ujednolicenie stylu kart newsów z /zopk/aktualnosci
- Obrazki newsów (lub zielony placeholder z ikoną)
- Większy padding i promień zaokrąglenia kart
- Dłuższe opisy (250 znaków zamiast 200)
- Data w formacie DD.MM.YYYY w jednej linii ze źródłem
- Hover z efektem podniesienia (translateY)
- Responsive: obrazki na pełną szerokość na mobile

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 06:00:10 +01:00
819192bdad feat(zopk): Rozszerzony widok aktualności ze statystykami czasowymi
- Dodano pasek statystyk newsów (łącznie, dzień, tydzień, miesiąc)
- Zwiększono limit wyświetlanych newsów z 10 do 25
- Usunięto przycisk "Zobacz wszystkie" - pełny widok od razu
- Przycisk "Starsze aktualności" pojawia się gdy jest więcej niż 25

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:56:00 +01:00
489f04d04d fix(zopk): Newsy auto_approved teraz widoczne na stronie publicznej
BUG: Strona publiczna pokazywała tylko status='approved',
     ale AI ustawia status='auto_approved' dla newsów 3+★.

Wynik: Newsy zatwierdzone przez AI NIE pojawiały się publicznie!

Naprawione miejsca:
- /zopk (strona główna ZOPK)
- /zopk/projekt/<slug> (szczegóły projektu)
- /zopk/aktualnosci (lista newsów)

Teraz wszystkie 3 miejsca pokazują obie wartości:
status IN ('approved', 'auto_approved')

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:50:35 +01:00
3beacd8806 fix(zopk): Naprawa duplikatu ID aiEvalResult w modalu
Były dwa elementy z tym samym ID - JavaScript znajdował pierwszy
(poza modalem) zamiast właściwego wewnątrz modala.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:46:39 +01:00
1193a2bf48 feat(zopk): Re-ewaluacja newsów z niską oceną zawierających kluczowe tematy
- Nowa funkcja reevaluate_low_score_news() szuka newsów z 1-2★
  zawierających Via Pomerania, NORDA, S6, Droga Czerwona, etc.
- Nowy endpoint POST /admin/zopk/news/reevaluate-low-scores
- Przycisk w UI "Re-ewaluuj niskie oceny" z szczegółowym raportem
- Automatyczne auto-approve jeśli nowa ocena >= 3★

Problem: Artykuły o Via Pomerania miały 1★ bo były ocenione
         przed dodaniem tego tematu do promptu AI.
Rozwiązanie: Re-ewaluacja nowym promptem podniesie ich oceny.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:38:20 +01:00
0cbdcaaad6 feat(zopk): Szczegółowe statystyki wyników wyszukiwania newsów
- Zamiana auto-odświeżania na przycisk OK
- Dodanie sekcji szczegółowych statystyk (12 metryk)
- Dodanie listy artykułów odrzuconych przez AI
- Śledzenie czasu przetwarzania
- API zwraca nowe pola: sent_to_ai, ai_rejected_articles, processing_time

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:28:10 +01:00
61b8a8e797 feat(zopk): Add AI model info banner to dashboard
Shows:
- Current model: gemini-2.5-flash-lite
- Prompt version: v2 (2026-01-15)
- New topics: +7 infrastructure projects

Tooltip lists: Via Pomerania, S6, Droga Czerwona, etc.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:19:12 +01:00
e96d579350 feat(zopk): Expand AI evaluation prompt with key infrastructure projects
Added missing topics to ZOPK AI evaluation prompt:
- Via Pomerania (highway Ustka-Bydgoszcz)
- S6 (Koszalin-Słupsk)
- Droga Czerwona (Port Gdynia)
- Pakt Bezpieczeństwa Pomorze Środkowe
- Deklaracja Bałtycka
- Izba Przedsiębiorców NORDA / Akademia Biznesu NORDA

These topics were incorrectly scored 1-2★ instead of 4-5★.
Updated examples to guide AI better.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:17:13 +01:00
223bc91cfa fix: Rename reserved 'metadata' attribute in ZOPKKnowledgeEntity
SQLAlchemy reserves 'metadata' attribute name. Changed to 'entity_metadata'.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:08:34 +01:00
db02d3660f feat(zopk): Improve AI scoring and auto-approve threshold
Changes:
- Lower auto-approve threshold from 4★ to 3★ (verified 2026-01-15)
- Add detailed progress bar for ZOPK search process
- Add auto-approved articles list with star ratings
- Document ZOPK topics (ZOP Kaszubia) in CLAUDE.md
- Add 8-second countdown before auto-refresh

Technical:
- zopk_news_service.py: Changed score threshold from >=4 to >=3
- Templates: New CSS for progress phases and results display
- CLAUDE.md: Added "ZOP Kaszubia News" section with topic guidelines

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 05:05:41 +01:00
90da6b9c64 fix: Treat HTTP 429 as OK in health check
429 (Too Many Requests) means the endpoint is working correctly
and is protected by rate limiting - this is expected behavior
for /register endpoint.

- Add 429 to acceptable status codes (200, 302, 304, 429)
- Update legend to explain 429 means protection is working
- Apply to all health check endpoints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 04:15:39 +01:00
3acbc53b87 fix: Health check - INPI, Waterm + 3 random companies
- Always check INPI and Waterm profiles (fixed)
- Add 3 random company profiles each refresh
- Total 5 company profiles tested for better coverage

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 04:12:22 +01:00
54b3b94482 feat: Add graphical Health Check dashboard
- Add /admin/health route with visual status indicators
- Create health_dashboard.html with category-based endpoint cards
- Color-coded status: green (OK), yellow (warning), red (error)
- Show response times with color indicators (fast/medium/slow)
- Add HTTP status code legend
- Auto-refresh every 2 minutes
- Add link in admin navigation menu
- Categories: public pages, auth, API, admin panel, company profiles

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:56:43 +01:00
23f109db2c fix: Update technology stack with verified versions only
- Verify all software versions via SSH (NORDABIZ-01, R11-REVPROXY-01, Proxmox)
- Remove Redis (not used), Gunicorn (app runs directly via python)
- Add PostgreSQL version dynamic fetch from database
- Add Docker version for R11-REVPROXY-01
- Update all package versions to verified values
- Handle unknown versions (Fortigate) with yellow "nieznana" badge
- Add comment with verification date (2026-01-14)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:48:21 +01:00
38682bf808 fix: Correct admin calendar path in health check (/admin/kalendarz)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:39:03 +01:00
03bd90f33b feat: Add system status dashboard with tech stack visualization
- Add /admin/status route with real-time system metrics (CPU, RAM, disk)
- Add /api/admin/status API endpoint for auto-refresh
- Add technology stack section showing all platform technologies
- Add auto-refresh (5 min) to GeoIP stats in security dashboard
- Add "Status systemu" link to admin navigation menu
- Fix /health/full endpoint list (remove non-existent endpoints)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:35:25 +01:00
8ed3724970 feat: Add extended health check endpoint /health/full
- Checks 14 critical endpoints (public + admin pages)
- Returns JSON with pass/fail status for each endpoint
- HTTP 200 if all OK, HTTP 503 if any failures
- Useful for deployment verification and monitoring

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:25:13 +01:00
9fdcee35d0 fix: Fix alert_breakdown sum in security dashboard template
Changed from sum(attribute='value') to values()|sum for dict type

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:23:02 +01:00
6402ff7f0e docs: Update release notes and CLAUDE.md with security features
- Add GeoIP blocking, security panel, and stats to v1.16.0 release notes
- Add comprehensive security mechanisms table to CLAUDE.md
- Document GeoIP configuration and MaxMind setup
- List all 12 security mechanisms with star ratings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:20:32 +01:00
e9e37796c7 feat: Add security mechanisms list and GeoIP stats to admin dashboard
- New 'Mechanisms' tab listing all security features with star ratings (5★=critical)
- New 'GeoIP' tab with blocking statistics (daily/monthly/yearly/total)
- Country breakdown with flags for blocked connections
- Status indicators for each security mechanism

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:16:33 +01:00
341ce29aa9 fix: Use lazy loading for GeoIP config to respect load_dotenv timing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:13:49 +01:00
cb574851cf feat: Add GeoIP blocking for high-risk countries (RU, CN, KP, IR, BY, SY, VE, CU)
- Update security_service.py with BLOCKED_COUNTRIES list
- Add check_geoip() middleware in app.py
- Log blocked attempts with security alerts
- Uses MaxMind GeoLite2-Country database

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 22:11:53 +01:00
1a06b6ab29 feat: Add security dashboard link to admin menu 2026-01-14 21:45:05 +01:00
cfdcfea093 fix: Remove duplicate CSRF input in 2fa_settings.html
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 21:41:01 +01:00
6ec830fabc fix: CSRF token in 2FA templates
Changed {{ csrf_token() }} to proper hidden input field.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 21:35:19 +01:00
0dba52e9c4 feat: Add security features - 2FA, audit log, alerting
Security enhancements:
- Two-Factor Authentication (TOTP) for all users
  - Enable/disable 2FA in settings
  - Backup codes for recovery
  - Login flow with 2FA verification
- Audit log for admin actions
  - Track all sensitive operations
  - IP address and user agent logging
- Security alerts system
  - Alert types: brute_force, honeypot_hit, account_locked, geo_blocked
  - Email notifications for high/critical alerts
  - Dashboard for alert management
- Admin security dashboard (/admin/security)
  - View/acknowledge/resolve alerts
  - Unlock locked accounts
  - 2FA status overview

New files:
- security_service.py: Security utilities
- templates/auth/verify_2fa.html
- templates/auth/2fa_settings.html
- templates/auth/2fa_setup.html
- templates/auth/2fa_backup_codes.html
- templates/admin/security_dashboard.html

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 21:23:27 +01:00
7226e098f6 feat: Honeypot endpoints for malicious bot detection
- Trap URLs: /wp-admin, /phpmyadmin, /.env, /.git/config, etc.
- Log to security.log for fail2ban integration
- Instant 24h ban via fail2ban after 1 hit
2026-01-14 21:13:05 +01:00
10dcbde7a8 feat: Account lockout after 5 failed login attempts
- Lock account for 30 minutes after 5 failed attempts
- Reset counter on successful login
- Log ACCOUNT_LOCKED events to security log
2026-01-14 21:11:33 +01:00
2efad9ba82 feat: Use Redis for rate limiter storage (persistent limits) 2026-01-14 21:08:48 +01:00
b6c58c9312 feat: Add security logger for fail2ban integration
- Security events logged to /var/log/nordabiznes/security.log
- Failed login attempts include IP address
- Format compatible with fail2ban filter
2026-01-14 21:07:09 +01:00
af3ba43c89 feat: Dynamic stats in release notes (companies, categories from DB) 2026-01-14 17:31:10 +01:00