Commit graph

38 commits

Author SHA1 Message Date
cae3dbb985 feat: KI-gestützte Inhaltsanalyse via OpenRouter (hash-gegated)
Optionale semantische Prüfung von Text und Bildern (inkl. OCR) auf
problematische Inhalte ohne Link-Signal: Pornografie, Propaganda,
diffamierende/strafbare Texte, versteckter Spam, themenfremde Werbung,
widersprüchliche Aussagen. Bewertet die thematische Passung zum
deklarierten site_context — eingestreute Heimat-Begriffe täuschen die
Erkennung nicht.

Kern:
- scanner/ai_analyzer.py: run_ai_analysis + score_ai_findings.
  Hash-Gate über data/ai_ledger.json → unveränderte Inhalte = Cache-
  Treffer = kein API-Call. Nur neue/geänderte Inhalte kosten etwas.
- Modell-Kette mit zweifacher Eskalation (Stufe 1+2 free, Stufe 3
  günstig bezahlt); eskaliert bei Fehler ODER Timeout (attempt_timeout).
  Erfolgreiches Modell wird im Ledger vermerkt.
- KI-Funde sind auf GELB gedeckelt — ROT bleibt harten Integritäts-
  Signalen vorbehalten. Graceful degradation: ohne Key/bei Fehler wird
  übersprungen, Scan läuft unverändert weiter.

Integration:
- baseline.py: load/save_ai_ledger, dismiss_ai_entries.
- config.py: ai_analysis-Block + ai_* Scoring-Schlüssel.
- __main__.py: Einhängung in cmd_scan/cmd_check, ai-dismiss-Subcommand,
  approve quittiert zugehörige Funde, status-Anzeige, diff-only + report.
- alerter.py + __main__.py: beanstandete Dateien erscheinen mit URL,
  Begründung und Quittier-Fingerprint in E-Mail UND Markdown-Report.
- plain.py: laienverständliche KI-Sätze.

API-Key nur aus Umgebungsvariable (OPENROUTER_API_KEY). Audio/Video als
abschaltbare Hooks vorbereitet (default aus).

Modelle live gegen OpenRouter verifiziert; Demo auf bredelar.info zeigte
korrekte Erkennung (echter Inhalt clean, eingeschleuster Casino-Spam mit
Heimat-Begriffen als hidden_spam erkannt).

Tests: 227 grün (+26 für ai_analyzer, +1 für E-Mail-KI-Abschnitt).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-13 00:04:33 +02:00
0aaf53135a docs: comprehensive documentation update
README.md:
- Workflow examples updated to URL-first syntax throughout
- report --diff-only added to Incident and Legitimate-Change workflows
- scanner.sh symlink hint added to installation section
- Directory structure overhauled: per-site layout, scanner.sh, template dir
- Removed report --diff-only from "not implemented" extensions list

BEDIENUNGSANLEITUNG.md:
- Section 2: scanner.sh wrapper usage added
- Section 4: manual scan uses URL-first syntax
- Section 9 (alarm): report --diff-only as first investigation step,
  updated all commands to URL-first syntax
- Section 16: directory structure reflects per-site layout + scanner.sh
- Section 19: asset baseline setup now correctly described as automatic

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 22:34:25 +02:00
1dd51809b7 docs: document report --diff-only in README and Bedienungsanleitung
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 22:28:52 +02:00
2c3aa60d97 feat: report --diff-only — colored terminal diff view
Shows only the changed parts of the latest report: text diffs with
ANSI colors (+green/-red/@cyan), new/missing URLs, link diffs,
hidden content, meta-refresh and inline script findings.
Colors are suppressed when stdout is not a terminal (pipes, log files).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 22:27:19 +02:00
fe61b18906 test: add test_alerter.py — 25 tests for send_alert, email and webhook dispatch
Covers: level filtering, email enabled/disabled, TLS, login with/without
password, no recipients, SMTP exception handling, webhook payload,
webhook exception handling.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 22:21:33 +02:00
beb7f274a3 docs: update README + Bedienungsanleitung; fix config.py SMTP defaults
- test-alert subcommand documented in both files
- Cron examples extended with www.bergbauspuren-bredelar.de (03:30)
- "Neue Website hinzufügen" updated to URL-first syntax
- Bedienungsanleitung: sitemap option, CF7 ignore_pattern example, generic header
- config.py: SMTP defaults corrected (smtp_host, smtp_user, from, to)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 22:17:34 +02:00
b6838bb346 chore: remove Keller/ from repo and add to .gitignore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 21:42:15 +02:00
235cef6b85 chore: remove site directories from repo, gitignore completely
bredelar.info/ and jamulix.de/ contain local credentials and crawl data
that must not be version-controlled. Files are kept on disk.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 21:40:43 +02:00
aa2b1ebf5c feat: test-alert subcommand + enable email for bredelar.info
- Add `test-alert [--level yellow|red]` to verify SMTP without a real scan
- Enable email alerting in bredelar.info/config.yaml (uses DEFAULT_CONFIG
  for host/user/from/to, only smtp_password_env kept explicit)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 19:50:24 +02:00
a8563cb821 chore: add www.bergbauspuren-bredelar.de to .gitignore
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 19:28:28 +02:00
9801ce6fc4 feat: sitemap seeding — discover orphan pages not reachable via links
Reads robots.txt Sitemap directive and fetches sitemap.xml / sitemap_index.xml
before crawling. All listed URLs are added to the crawl queue so pages
without any inbound links are still scanned. Configurable via crawl.sitemap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 17:58:52 +02:00
792ca67c08 feat: single-line progress indicator during crawl and ext-link check
Uses \r to overwrite the same terminal line — no scrolling.
Crawler exposes on_progress callback; checker.check_external_links
gets an optional on_progress parameter.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 17:17:37 +02:00
fcbccce422 feat: URL-first CLI + auto-setup for new targets
- python -m scanner https://domain.de scan  (URL as first positional arg)
- On first use, the domain directory is auto-created from the
  meine-seite.de template with all paths and target URL substituted
- scanner.sh wrapper script for convenient ./scanner.sh usage
- --config syntax fully preserved (cron jobs unchanged)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 16:29:43 +02:00
08566c7807 docs: explain why cron jobs should be staggered (network/CPU load)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 15:48:30 +02:00
6e9e2c3240 fix: complete example.com → meine-seite.de rename in config.yaml
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 15:44:49 +02:00
c6e72dad9c refactor: rename example.com template to meine-seite.de
Replaces the placeholder domain example.com with meine-seite.de
throughout the template directory and config. Tests and scanner defaults
retain example.com as a generic RFC 2606 placeholder.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 15:43:44 +02:00
e6dbab3ebf docs: add example.com template for new target websites
Heavily commented config.yaml and config/ directory serve as a
copy-paste starting point for any new site to monitor.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 15:38:13 +02:00
c9bfba1701 Name und Email-Adresse korrigiert. 2026-06-12 15:31:18 +02:00
Your Name
2f985c8d59 docs: update cron setup for multi-site structure
Both README.md and BEDIENUNGSANLEITUNG.md now show the correct
cron entries using --config <site>/config.yaml, one entry per site
with staggered start times (03:00 / 03:15).

Added "Neue Website hinzufügen" step-by-step guide and updated
log-rotation path to */logs/*.log (covers all sites).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 15:12:25 +02:00
Your Name
ab882f912e refactor: multi-site structure — one directory per target website
Each monitored website now lives in its own named subdirectory
(bredelar.info/, jamulix.de/) with a dedicated config.yaml using
absolute paths. This makes adding new sites trivial:
  mkdir newsite.de && cp bredelar.info/config.yaml newsite.de/
  # adjust target + paths, then: python -m scanner --config newsite.de/config.yaml init

Changes:
- bredelar.info/: moved data/, reports/, logs/, config/ from project root
- bredelar.info/config.yaml: new, with absolute paths
- jamulix.de/: moved from ~/Python_Programs/jamulix_check/
- jamulix.de/config.yaml: updated paths to new location
- .gitignore: replaced old data/*/reports/logs entries with per-site entries
- config.yaml (root): removed (replaced by site-specific configs)
- CLAUDE.md: updated CLI examples to --config <site>/config.yaml

Usage:
  python -m scanner --config bredelar.info/config.yaml scan
  python -m scanner --config jamulix.de/config.yaml scan

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 15:01:14 +02:00
Your Name
f964e41201 fix: retry crawler with browser UA on 403 (bot-blocking)
Some servers return 403 for the scanner's bot user-agent but serve
the page normally to browsers. On a 403 response, the crawler now
retries with a browser-like UA; if the server then returns 2xx, the
page is crawled normally (HTML extracted, status recorded as 2xx).

Mirrors the same fix already applied to check_external_links.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 14:46:06 +02:00
Your Name
3a44cfb515 feat: exclude_paths — skip dynamic areas (RSS feeds, news archives) from scan
Adds crawl.exclude_paths config option (list of URL path prefixes).
Matching URLs are excluded at two levels:
- Crawler: not fetched at all (saves HTTP requests)
- Differ: filtered from both baseline and current before comparison,
  so legacy baseline entries under excluded paths don't appear as
  "missing URLs" after the option is added retroactively

Example config:
  crawl:
    exclude_paths: ["/rss/", "/feed/", "/news/archiv/"]

8 new tests (176 total).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 13:14:06 +02:00
Your Name
b01344dcd8 fix: always report broken internal links + show source pages
Previously, broken links that were part of the baseline ("known broken")
disappeared from the terminal output (score=0, no Klartext mention).

- differ.py: build reverse link index to record which pages link to
  each broken URL; "pages" field added to new_broken/known_broken entries
- plain.py: klartext_befunde() now includes known_broken_urls alongside
  new_broken_urls — broken links are always reported until fixed
- __main__.py: report shows "gefunden auf: <page>" for every broken entry,
  known entries labelled "[bekannt, noch nicht behoben]"
- 3 new tests (169 total)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 12:18:38 +02:00
Your Name
30ac95a5cf fix: show source pages for broken/unreachable external links in report
The broken_links entries already contained a pages[] list, but
_render_markdown didn't display it. Now each broken link shows up to
3 pages where it was found ("gefunden auf: …").
Also adds error_links (connection errors) to the main scan report
with the same source-page annotation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 12:02:44 +02:00
Your Name
4bae633a41 perf: reuse browser-UA crawl result in cloak-check during scan
When cmd_scan triggers the weekly cloak-check, the browser-UA crawl
has already just been completed. Pass those pages directly to
_run_cloak_core() so only the Googlebot-UA crawl is needed,
reducing weekly scans from 3 full crawls to 2.

Standalone `cloak-check` command is unaffected (pages_normal=None).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 11:55:24 +02:00
Your Name
22ed1570a4 fix: retry external link check with browser UA on 403
Servers that block bot user-agents return 403 even for live URLs.
On a 403 response, the checker now retries with a browser-like UA;
if the server then responds with 2xx/3xx, the link is counted as OK.
This eliminates false positives from bot-blocking (e.g. bergbauspuren-bredelar.de).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 11:40:27 +02:00
Your Name
bed20db8bd feat: Laientauglichkeit — Auto-Modus, Klartext-Ausgabe, einfachere Doku
Ziel: ein einziger täglicher Befehl genügt, jede Meldung ist auch ohne
IT-Wissen verständlich.

Auto-Modus (ein Cron-Job genügt für alles):
- data/state.json merkt sich, wann die Wochen-Prüfungen zuletzt liefen
  (baseline.py: load_state/save_state/is_check_due/mark_check_run)
- `scan` führt fällige Zusatzprüfungen (Tarnung/externe Links/Dateien)
  automatisch mit aus; Gesamt-Ampel = schlechtestes Teilergebnis;
  EIN kombinierter Report + EIN Alert
- neuer Config-Abschnitt periodic_checks (Default: wöchentlich, an)

Klartext (scanner/plain.py):
- Ampel 🟢/🟡/🔴 + Sätze ohne Fachbegriffe, aus den strukturierten Befunden
- Report: Klartext oben, "Technische Details (für Ihren Dienstleister)" unten
- Terminal-Ausgabe und E-Mail (alerter.py) ebenso umgestellt

Komfort:
- approve --all/--rebuild legt die Datei-Überwachung automatisch mit an
  (Opt-out: --skip-assets); approve-assets bleibt für den Sonderfall
- status zeigt Ampel zuoberst + wann die Wochen-Prüfungen zuletzt liefen
- Onboarding-Text in einfacher Sprache, wenn noch kein Vergleichsstand existiert

Doku: README + BEDIENUNGSANLEITUNG mit "In 3 Schritten"-Einstieg.

Tests: test_state.py, test_plain.py (Fachbegriff-Assertion), Auto-Asset-
Baseline-Test. 165 Tests grün.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 11:14:05 +02:00
Your Name
54ff1a6060 docs: Bedienungsanleitung um cloak-check, check-ext-links und check-assets ergänzen
Neue Abschnitte 17–19 für Cloaking-Erkennung, externe Link-Prüfung und
Asset-Hashing. Befehlstabelle, Scoring-Tabelle, Erkennungsübersicht und
Verzeichnisstruktur aktualisiert.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 09:32:30 +02:00
Your Name
d803f79efe feat: Binärdateien auf Änderungen prüfen (check-assets / approve-assets)
Neue Befehle:
- `python -m scanner check-assets`    — SHA-256-Hashes aller JS/CSS/Bild-Assets
  aus dem letzten Snapshot fetchen und mit Baseline vergleichen
- `python -m scanner approve-assets`  — aktuelle Hashes als neue Baseline setzen

Scoring: geändertes JS 40 Pkt, CSS 30 Pkt, Bild/PDF 20 Pkt.
Asset-Baseline liegt in data/baseline/asset_hashes.json.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 09:26:59 +02:00
Your Name
ecd01abf98 feat: externe Links auf Erreichbarkeit prüfen (check-ext-links)
Neuer Befehl `python -m scanner check-ext-links`:
- Liest alle externen <a>-Links aus dem letzten Snapshot
- Prüft jeden per HEAD-Request (Fallback auf GET bei HTTP 405)
- Meldet 4xx/5xx und Verbindungsfehler mit Quelladressen
- Report unter reports/<ts>_ext-links/
- Exit-Code 1 bei kaputten Links, 0 wenn alle erreichbar

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 04:14:50 +02:00
Your Name
0302d469b1 feat: Cloaking-Erkennung per Doppel-Crawl (Browser-UA vs. Googlebot-UA)
Neuer Befehl `python -m scanner cloak-check`:
- Crawlt die Website zweimal: einmal mit Browser-UA, einmal als Googlebot
- Vergleicht Text, Links und Response-Header (Vary: User-Agent)
- Scoring: Bot-Only-Link 60 Pkt (RED), extra Text >100 Zeichen 40 Pkt,
  Vary: User-Agent ohne Inhaltsdiff 25 Pkt
- Eigener Report unter reports/<ts>_cloak/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 04:02:24 +02:00
Your Name
ad939f3a31 chore: CLAUDE.md aus Repo entfernen, in .gitignore aufnehmen
CLAUDE.md enthält lokale Claude-Code-Anweisungen und gehört nicht ins
öffentliche Repository.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 03:51:03 +02:00
Your Name
5769f3fc88 docs: Bedienungsanleitung hinzufügen
Vollständige Bedienungsanleitung für den täglichen Betrieb, Erstinbetriebnahme,
Alarm-Workflows, Cron-Setup, E-Mail-Konfiguration und Konfigurationsreferenz.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 03:28:36 +02:00
Your Name
68243a97b9 fix: Bugfixes, toten Code entfernt, Cache-Normalisierung & Session
Echte Bugs:
- extractor: JSON-LD-Crash bei Nicht-Dict-Items (isinstance-Guard)
- baseline/__main__: Crawl-Fehler ins Snapshot-Manifest -> erscheinen im Report
- __main__: Whitelist-/Header-/Webshell-Checks nur noch auf status==200
- crawler: Noise-Param-Regex auf Voll-Key (view=/value= nicht mehr verworfen)
- differ/__main__: unerwartetes JSON-LD via eigenem Kanal, auch auf
  unveraenderten Seiten erkannt, kein Re-Alert auf bereits genehmigte Typen

Aufgeraeumt:
- checker: check_internal_paths, find_broken_pages, canonical_is_hijacked,
  check_jsonld_types entfernt (nicht verdrahtet)
- allowed_paths.yaml-Logik und tote Scoring-Keys entfernt
- tote Imports entfernt

Neuer aktiver Schutz:
- Webshell-/Backdoor-Dateinamen-Check verdrahtet (suspicious_filename: 60).
  Regex wortgrenzen-verankert gegen Fehlalarm auf PSEMailerAntispam.js

Effizienz/Struktur:
- crawler nutzt requests.Session (keep-alive)
- Cache-Buster-Normalisierung an einer Stelle (Extraktion) -> stabile
  Snapshots, differ wieder reiner Set-Diff

Tests: 111 gruen (neu: test_checker.py + Regressionstests)
CLAUDE.md aktualisiert

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 03:20:32 +02:00
Your Name
b3ef3a90d4 feat: report broken links (4xx/5xx) in every scan
Neue 4xx/5xx-Seiten (nicht in Baseline) werden bewertet (+20 Pkt) und
lösen ab Schwelle einen Alert aus. Bekannte kaputte Links (in Baseline
vorhanden) erscheinen im Report als [bekannt] ohne Score-Beitrag.

Motivation: erster Crawl fand bredelar.info/www.stadtmarketing-marsberg.de
(404) — CMS-Fehler durch Schema-losen href. Soll dauerhaft sichtbar sein.

Änderungen: checker.find_broken_pages(), differ.compare_snapshots() mit
new_broken_urls/known_broken_urls, score_diff(), Report-Abschnitt,
config-Default new_broken_link:20, 4 neue Tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 01:55:19 +02:00
Your Name
5d52db6eed fix: exclude internal comment-links; add initial external domain whitelist
- extractor.py: _find_comment_links() liefert nur noch externe Links.
  Interne Links in Kommentaren sind CMS-Artefakte (auskommentierte
  Navigations-Fragmente), keine SEO-Spam-Indikatoren.
- allowed_external.yaml: 36 legitime externe Domains nach initialem
  Crawl von bredelar.info manuell geprüft und eingetragen.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 01:15:58 +02:00
Your Name
de90dbc19c fix: handle YAML null values for list config fields
PyYAML parst auskommentierte Listen als None statt []. Da der Key
vorhanden ist, greift .get(key, []) nicht. Drei Fixes:
- extractor.py, differ.py: `or []` statt Default-Argument
- config.py: _deep_update überspringt None-Override auf List-Defaults

Tritt auf bei `ignore_selectors` und `ignore_patterns` in config.yaml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 01:12:09 +02:00
Your Name
98e8d11eb5 feat: initial implementation of website integrity scanner
Python-Package zur unabhängigen Überwachung statischer Websites gegen
SEO-Spam und unbefugte Manipulationen. Läuft außerhalb des Hosters.

Kernfunktionen:
- Reiner Python-Crawler (bs4+lxml), kein wget
- Baseline-Management mit manuellem Freigabe-Workflow (niemals automatisch)
- Text-/Link-/Meta-Diff mit Risiko-Scoring (grün/gelb/rot)
- Hidden-Content-Erkennung (CSS inline, noscript, Kommentar-Links)
- Whitelist für externe Domains und interne Pfade
- E-Mail + Webhook Alarmierung
- CLI: init, crawl, check, scan, approve, report, status
- 79 Unit-Tests (pytest), alle grün

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 00:51:41 +02:00