omnirank 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- omnirank/__init__.py +14 -0
- omnirank/__main__.py +6 -0
- omnirank/adapters/__init__.py +202 -0
- omnirank/adapters/astro.py +338 -0
- omnirank/adapters/base.py +372 -0
- omnirank/adapters/html.py +561 -0
- omnirank/adapters/jsx.py +340 -0
- omnirank/adapters/nextjs.py +692 -0
- omnirank/aeo/__init__.py +9 -0
- omnirank/aeo/extract.py +383 -0
- omnirank/aeo/propose.py +84 -0
- omnirank/aeo/rules.py +964 -0
- omnirank/aeo/runner.py +148 -0
- omnirank/applicability.py +98 -0
- omnirank/apply/__init__.py +23 -0
- omnirank/apply/engine.py +1254 -0
- omnirank/apply/journal.py +139 -0
- omnirank/apply/patch.py +144 -0
- omnirank/audit.py +185 -0
- omnirank/bands.py +106 -0
- omnirank/brief/__init__.py +0 -0
- omnirank/brief/analyze.py +197 -0
- omnirank/brief/constants.py +89 -0
- omnirank/brief/cost.py +62 -0
- omnirank/brief/egress.py +23 -0
- omnirank/brief/fetchpages.py +239 -0
- omnirank/brief/render.py +151 -0
- omnirank/brief/runner.py +369 -0
- omnirank/brief/serp.py +274 -0
- omnirank/brief/text.py +181 -0
- omnirank/cli.py +844 -0
- omnirank/clock.py +22 -0
- omnirank/cms/__init__.py +1 -0
- omnirank/cms/runner.py +170 -0
- omnirank/cms/wordpress.py +495 -0
- omnirank/cms/wordpress_apply.py +508 -0
- omnirank/cms/wordpress_plan.py +280 -0
- omnirank/config.py +81 -0
- omnirank/connect/__init__.py +4 -0
- omnirank/connect/bing.py +284 -0
- omnirank/connect/cloud_setup.py +43 -0
- omnirank/connect/confirm.py +242 -0
- omnirank/connect/constants.py +226 -0
- omnirank/connect/doctor.py +270 -0
- omnirank/connect/ga4.py +749 -0
- omnirank/connect/ga4_ai.py +123 -0
- omnirank/connect/google_auth.py +657 -0
- omnirank/connect/gsc.py +630 -0
- omnirank/connect/gsc_reports.py +169 -0
- omnirank/connect/http.py +310 -0
- omnirank/connect/indexnow.py +373 -0
- omnirank/connect/naver.py +536 -0
- omnirank/connect/runner.py +515 -0
- omnirank/connect/runner_ga4_ai.py +59 -0
- omnirank/connect/runner_more.py +489 -0
- omnirank/connect/runner_regional.py +260 -0
- omnirank/connect/secrets.py +190 -0
- omnirank/connect/urlcheck.py +41 -0
- omnirank/connect/yandex.py +350 -0
- omnirank/crawl/__init__.py +11 -0
- omnirank/crawl/analyze.py +493 -0
- omnirank/crawl/crawler.py +491 -0
- omnirank/crawl/custom.py +175 -0
- omnirank/crawl/export.py +67 -0
- omnirank/crawl/fetcher.py +212 -0
- omnirank/crawl/parse.py +102 -0
- omnirank/crawl/render.py +148 -0
- omnirank/crawl/robotsgate.py +198 -0
- omnirank/crawl/runner.py +295 -0
- omnirank/crawl/sitemap.py +99 -0
- omnirank/crawl/text.py +20 -0
- omnirank/crawl/urls.py +100 -0
- omnirank/crawlers.py +564 -0
- omnirank/data/ai_crawlers.json +269 -0
- omnirank/data/ai_referrers.json +42 -0
- omnirank/fetch.py +107 -0
- omnirank/fixes/__init__.py +92 -0
- omnirank/fixes/base.py +232 -0
- omnirank/fixes/canonical.py +243 -0
- omnirank/fixes/schema.py +126 -0
- omnirank/formats.py +134 -0
- omnirank/framework.py +223 -0
- omnirank/gates/__init__.py +48 -0
- omnirank/gates/aeo.py +114 -0
- omnirank/gates/contradictions.py +280 -0
- omnirank/gates/crawler_policy.py +85 -0
- omnirank/gates/geo.py +152 -0
- omnirank/gates/hygiene.py +81 -0
- omnirank/gates/jsonld.py +282 -0
- omnirank/gates/onpage.py +177 -0
- omnirank/gates/perf.py +115 -0
- omnirank/gates/security.py +264 -0
- omnirank/gates/seo.py +118 -0
- omnirank/gates/site.py +248 -0
- omnirank/geo_artifacts.py +199 -0
- omnirank/html.py +79 -0
- omnirank/keywords/__init__.py +5 -0
- omnirank/keywords/constants.py +69 -0
- omnirank/keywords/engine.py +384 -0
- omnirank/keywords/report.py +143 -0
- omnirank/keywords/runner.py +160 -0
- omnirank/keywords/source.py +60 -0
- omnirank/keywords/text.py +45 -0
- omnirank/locator.py +480 -0
- omnirank/logs/__init__.py +0 -0
- omnirank/logs/analyze.py +127 -0
- omnirank/logs/bots.py +69 -0
- omnirank/logs/ipranges.py +191 -0
- omnirank/logs/parse.py +452 -0
- omnirank/logs/paths.py +22 -0
- omnirank/logs/privacy.py +105 -0
- omnirank/logs/runner.py +179 -0
- omnirank/mcp_server.py +1480 -0
- omnirank/netguard.py +525 -0
- omnirank/packs/__init__.py +6 -0
- omnirank/packs/backlinks.py +535 -0
- omnirank/packs/blog.py +544 -0
- omnirank/packs/blog_cross.py +468 -0
- omnirank/packs/crawlers.py +23 -0
- omnirank/packs/entity.py +492 -0
- omnirank/packs/feeds.py +150 -0
- omnirank/packs/frontmatter.py +59 -0
- omnirank/packs/gsc.py +421 -0
- omnirank/packs/local.py +879 -0
- omnirank/packs/mdscan.py +326 -0
- omnirank/packs/miniyaml.py +378 -0
- omnirank/packs/model.py +46 -0
- omnirank/packs/product.py +979 -0
- omnirank/packs/refresh.py +165 -0
- omnirank/packs/runner.py +277 -0
- omnirank/packs/sitescan.py +294 -0
- omnirank/packs/textsafe.py +79 -0
- omnirank/packs/xmlsafe.py +92 -0
- omnirank/page.py +42 -0
- omnirank/registry.py +302 -0
- omnirank/report.py +251 -0
- omnirank/report_cmd/__init__.py +7 -0
- omnirank/report_cmd/delta.py +58 -0
- omnirank/report_cmd/files.py +64 -0
- omnirank/report_cmd/model.py +208 -0
- omnirank/report_cmd/notify.py +195 -0
- omnirank/report_cmd/pdf.py +83 -0
- omnirank/report_cmd/portfolio.py +342 -0
- omnirank/report_cmd/render.py +379 -0
- omnirank/report_cmd/runner.py +267 -0
- omnirank/robots.py +172 -0
- omnirank/scanner/__init__.py +10 -0
- omnirank/scanner/badge.py +90 -0
- omnirank/scanner/cache.py +69 -0
- omnirank/scanner/cli.py +96 -0
- omnirank/scanner/engine.py +289 -0
- omnirank/scanner/limits.py +98 -0
- omnirank/scanner/server.py +143 -0
- omnirank/scanner/service.py +328 -0
- omnirank/schema/__init__.py +13 -0
- omnirank/schema/catalog.py +679 -0
- omnirank/schema/catalog_specs.py +350 -0
- omnirank/schema/core.py +306 -0
- omnirank/schema/extract.py +396 -0
- omnirank/schema/gate.py +121 -0
- omnirank/schema/runner.py +213 -0
- omnirank/schema/validate.py +504 -0
- omnirank/schema/vocab.py +305 -0
- omnirank/schemas/omnirank.config.schema.json +268 -0
- omnirank/track/__init__.py +0 -0
- omnirank/track/ai_prompts.py +207 -0
- omnirank/track/analysis.py +197 -0
- omnirank/track/constants.py +155 -0
- omnirank/track/cost.py +229 -0
- omnirank/track/discover.py +277 -0
- omnirank/track/discover_cli.py +309 -0
- omnirank/track/discover_constants.py +95 -0
- omnirank/track/engines.py +216 -0
- omnirank/track/estimate_view.py +212 -0
- omnirank/track/history.py +261 -0
- omnirank/track/runner.py +586 -0
- omnirank/track/stats.py +138 -0
- omnirank/track/storage.py +128 -0
- omnirank-0.5.0.dist-info/METADATA +47 -0
- omnirank-0.5.0.dist-info/RECORD +183 -0
- omnirank-0.5.0.dist-info/WHEEL +5 -0
- omnirank-0.5.0.dist-info/entry_points.txt +2 -0
- omnirank-0.5.0.dist-info/top_level.txt +1 -0
omnirank/logs/privacy.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""What a log report may show of a requested URL.
|
|
2
|
+
|
|
3
|
+
* the query string is dropped unless ``keep_query`` (whether there WAS one is still known,
|
|
4
|
+
for the "parameter URL" waste count); a fragment is always dropped;
|
|
5
|
+
* an absolute or protocol-relative (``//host/...``) URL is reduced to its path (the host is
|
|
6
|
+
not shown);
|
|
7
|
+
* e-mail addresses (also ``%40``-encoded) become ``[email]``; path segments that look like
|
|
8
|
+
secrets (32+ hex characters, or 32+ base64url-ish characters mixing upper case, lower
|
|
9
|
+
case and digits -- a heuristic) become ``[token]``; path parameters with credential-like
|
|
10
|
+
names (``;jsessionid=...``) and, with ``keep_query``, query parameters with such names
|
|
11
|
+
(``api-key``, ``apiKey``, ``access_token``, ``X-Amz-Signature`` ...) become ``[redacted]``;
|
|
12
|
+
* control, line-separator (U+2028/U+2029/U+0085), zero-width and bidirectional characters
|
|
13
|
+
become ``?`` so a hostile path cannot
|
|
14
|
+
drive the terminal; the result is capped at MAX_SHOWN characters.
|
|
15
|
+
|
|
16
|
+
IP addresses are never shown by the report at all.
|
|
17
|
+
"""
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import re
|
|
21
|
+
|
|
22
|
+
MAX_SHOWN = 300
|
|
23
|
+
MAX_INPUT = 8192
|
|
24
|
+
_EMAIL = re.compile(r"[A-Za-z0-9._%+-]{1,64}(?:@|%40)[A-Za-z0-9.-]{1,253}\.[A-Za-z]{2,24}")
|
|
25
|
+
_SEGMENT_TOKEN = re.compile(r"[A-Za-z0-9_\-.=~+]{32,}")
|
|
26
|
+
_HEX = re.compile(r"[A-Fa-f0-9]{32,}")
|
|
27
|
+
_CONTROL = re.compile("[\\x00-\\x1f\\x7f-\\x9f\\u061c\\u200b-\\u200f\\u2028-\\u202e"
|
|
28
|
+
"\\u2060-\\u2069\\ufeff]")
|
|
29
|
+
_ABSOLUTE = re.compile(r"[A-Za-z][A-Za-z0-9+.-]{0,20}://[^/?#]{0,300}")
|
|
30
|
+
_SENSITIVE_NAMES = frozenset({
|
|
31
|
+
"token", "key", "secret", "password", "passwd", "pwd", "pass", "auth", "authorization",
|
|
32
|
+
"sig", "signature", "session", "sid", "jwt", "code", "otp", "email", "mail", "apikey",
|
|
33
|
+
"credential", "credentials"})
|
|
34
|
+
_SENSITIVE_SUFFIXES = ("token", "secret", "password", "passwd", "apikey", "signature",
|
|
35
|
+
"sessionid", "sessid", "credential")
|
|
36
|
+
_NAME_SEPARATORS = re.compile(r"[-_.]")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def sensitive_name(name: str) -> bool:
|
|
40
|
+
"""``api-key``, ``x-api-key``, ``apiKey``, ``api_key``, ``access-token``, ``authToken``,
|
|
41
|
+
``X-Amz-Signature``, ``jsessionid`` ... (case, hyphens, underscores and dots ignored)."""
|
|
42
|
+
norm = _NAME_SEPARATORS.sub("", name.lower())
|
|
43
|
+
return norm in _SENSITIVE_NAMES or norm.endswith(_SENSITIVE_SUFFIXES)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def strip_controls(text: str) -> str:
|
|
47
|
+
return _CONTROL.sub("?", text)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _looks_secret(segment: str) -> bool:
|
|
51
|
+
if not _SEGMENT_TOKEN.fullmatch(segment):
|
|
52
|
+
return False
|
|
53
|
+
if _HEX.fullmatch(segment):
|
|
54
|
+
return True
|
|
55
|
+
return (any(c.isupper() for c in segment) and any(c.islower() for c in segment)
|
|
56
|
+
and any(c.isdigit() for c in segment))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _scrub_value(value: str) -> str:
|
|
60
|
+
value = _EMAIL.sub("[email]", value)
|
|
61
|
+
return "[token]" if _looks_secret(value) else value
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _scrub_segment(segment: str) -> str:
|
|
65
|
+
"""A path segment and its ``;name=value`` path parameters."""
|
|
66
|
+
head, *params = segment.split(";")
|
|
67
|
+
out = [_scrub_value(head)]
|
|
68
|
+
for param in params:
|
|
69
|
+
name, eq, value = param.partition("=")
|
|
70
|
+
if eq and sensitive_name(name):
|
|
71
|
+
out.append(f"{_scrub_value(name)}=[redacted]")
|
|
72
|
+
else:
|
|
73
|
+
out.append(_scrub_value(name) + (eq + _scrub_value(value) if eq else ""))
|
|
74
|
+
return ";".join(out)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def clean_target(target: str, *, keep_query: bool) -> tuple[str, bool]:
|
|
78
|
+
"""``(what to show, whether the request had a query string)``."""
|
|
79
|
+
target = target[:MAX_INPUT]
|
|
80
|
+
m = _ABSOLUTE.match(target)
|
|
81
|
+
if m:
|
|
82
|
+
target = target[m.end():] or "/"
|
|
83
|
+
elif target.startswith("//"):
|
|
84
|
+
end = re.search(r"[/?#]", target[2:])
|
|
85
|
+
target = target[2 + end.start():] if end else "/"
|
|
86
|
+
if not target.startswith("/"):
|
|
87
|
+
target = "/" + target
|
|
88
|
+
target = target.split("#", 1)[0]
|
|
89
|
+
path, sep, query = target.partition("?")
|
|
90
|
+
had_query = bool(sep)
|
|
91
|
+
path = "/".join(_scrub_segment(seg) for seg in path.split("/"))
|
|
92
|
+
shown = path
|
|
93
|
+
if keep_query and had_query:
|
|
94
|
+
pairs = []
|
|
95
|
+
for pair in query.split("&"):
|
|
96
|
+
name, eq, value = pair.partition("=")
|
|
97
|
+
if eq and sensitive_name(name):
|
|
98
|
+
pairs.append(f"{_scrub_value(name)}=[redacted]")
|
|
99
|
+
else:
|
|
100
|
+
pairs.append(_scrub_value(name) + (eq + _scrub_value(value) if eq else ""))
|
|
101
|
+
shown = f"{path}?{'&'.join(pairs)}"
|
|
102
|
+
shown = _CONTROL.sub("?", shown)
|
|
103
|
+
if len(shown) > MAX_SHOWN:
|
|
104
|
+
shown = shown[:MAX_SHOWN] + "…"
|
|
105
|
+
return shown, had_query
|
omnirank/logs/runner.py
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"""`omnirank logs FILE...`: which AI crawlers fetched what, from your own access logs.
|
|
2
|
+
|
|
3
|
+
Exit codes: 0 report produced; 1 report produced but at least one file hit a budget and was
|
|
4
|
+
not read to the end (TRUNCATED); 2 usage error (unreadable or out-of-root file, undetectable
|
|
5
|
+
format, bad ranges file, bad number). Read-only: nothing is written and nothing is sent.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import json
|
|
11
|
+
import sys
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from .. import __version__
|
|
15
|
+
from . import analyze, bots, parse
|
|
16
|
+
from .ipranges import IpRanges, RangesError
|
|
17
|
+
from .paths import PathError, confined
|
|
18
|
+
from .privacy import strip_controls as privacy_safe
|
|
19
|
+
|
|
20
|
+
NO_UA_NOTE = ("{path}: the {fmt} format has no user-agent field, so no crawler can be "
|
|
21
|
+
"identified from it (its requests are counted as other hits)")
|
|
22
|
+
UA_CAVEAT = ("Every crawler count is CLAIMED BY USER-AGENT: anyone can send a crawler's "
|
|
23
|
+
"user-agent, so these numbers are unverified unless an --ip-ranges check says "
|
|
24
|
+
"'verified' (reverse DNS verification is not built).")
|
|
25
|
+
PRIVACY_NOTE = ("IP addresses are not printed. Query strings are dropped (use --keep-query "
|
|
26
|
+
"to keep them; credential-like values are still redacted), e-mail "
|
|
27
|
+
"addresses and token-like path segments are masked.")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _taxonomy_block() -> dict:
|
|
31
|
+
checked = bots.taxonomy_checked_on()
|
|
32
|
+
table = bots.taxonomy()
|
|
33
|
+
unverified = sorted(b.token for b in table if not b.verified)
|
|
34
|
+
if not table:
|
|
35
|
+
note = "no crawler tokens loaded"
|
|
36
|
+
elif unverified:
|
|
37
|
+
note = (f"table dated {checked}; {len(table) - len(unverified)} of {len(table)} "
|
|
38
|
+
f"tokens verified on vendor pages, UNVERIFIED: {', '.join(unverified)}")
|
|
39
|
+
else:
|
|
40
|
+
note = f"table dated {checked}; all {len(table)} tokens verified on vendor pages"
|
|
41
|
+
return {"source": "omnirank/data/ai_crawlers.json", "checked_on": checked,
|
|
42
|
+
"unverified": unverified, "note": note}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _format_sources(formats: set[str | None]) -> dict:
|
|
46
|
+
out = {}
|
|
47
|
+
if formats & {"cloudflare", "json"}:
|
|
48
|
+
out["cloudflare"] = {"source": parse.CLOUDFLARE_FIELDS_SOURCE,
|
|
49
|
+
"checked_on": parse.FIELDS_CHECKED_ON}
|
|
50
|
+
if formats & {"vercel", "json"}:
|
|
51
|
+
out["vercel"] = {"source": parse.VERCEL_FIELDS_SOURCE,
|
|
52
|
+
"checked_on": parse.FIELDS_CHECKED_ON}
|
|
53
|
+
return out
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def run_logs(args: argparse.Namespace) -> int:
|
|
57
|
+
try:
|
|
58
|
+
if args.top < 0:
|
|
59
|
+
raise ValueError("--top must be 0 or more")
|
|
60
|
+
if args.max_lines < 1 or args.max_bytes < 1:
|
|
61
|
+
raise ValueError("--max-lines and --max-bytes must be 1 or more")
|
|
62
|
+
if not args.max_seconds > 0:
|
|
63
|
+
raise ValueError("--max-seconds must be more than 0")
|
|
64
|
+
except ValueError as exc:
|
|
65
|
+
print(f"omnirank logs: {exc}", file=sys.stderr)
|
|
66
|
+
return 2
|
|
67
|
+
root = Path(args.root)
|
|
68
|
+
budget = parse.Budget(max_bytes=args.max_bytes, max_lines=args.max_lines,
|
|
69
|
+
max_seconds=args.max_seconds)
|
|
70
|
+
try:
|
|
71
|
+
ranges = None
|
|
72
|
+
if args.ip_ranges:
|
|
73
|
+
ranges = IpRanges()
|
|
74
|
+
for spec in args.ip_ranges:
|
|
75
|
+
ranges.load(spec, root=root)
|
|
76
|
+
paths = [confined(name, root) for name in args.files]
|
|
77
|
+
agg = analyze.Aggregator(ranges=ranges, keep_query=args.keep_query, top=args.top)
|
|
78
|
+
all_stats: list[parse.FileStats] = []
|
|
79
|
+
for name, path in zip(args.files, paths, strict=True):
|
|
80
|
+
stats = parse.FileStats(name)
|
|
81
|
+
for rec in parse.iter_records(path, args.format, budget, stats):
|
|
82
|
+
agg.add(rec)
|
|
83
|
+
all_stats.append(stats)
|
|
84
|
+
except (PathError, RangesError, parse.LogFormatError) as exc:
|
|
85
|
+
print(f"omnirank logs: {privacy_safe(str(exc))}", file=sys.stderr)
|
|
86
|
+
return 2
|
|
87
|
+
except OSError as exc:
|
|
88
|
+
print(f"omnirank logs: cannot read: {exc.strerror or exc}", file=sys.stderr)
|
|
89
|
+
return 2
|
|
90
|
+
report = agg.report(all_stats)
|
|
91
|
+
notes = [NO_UA_NOTE.format(path=s.path, fmt=s.format) for s in all_stats
|
|
92
|
+
if s.format == "common"]
|
|
93
|
+
notes += [f"{s.path}: more than {parse.MAX_DEDUPE_KEYS} distinct request ids; later "
|
|
94
|
+
"repeats of a request may be counted again" for s in all_stats
|
|
95
|
+
if s.dedupe_capped]
|
|
96
|
+
data = {"tool": f"OmniRank {__version__}", "files": [s.as_dict() for s in all_stats],
|
|
97
|
+
**report, "taxonomy": _taxonomy_block(),
|
|
98
|
+
"format_sources": _format_sources({s.format for s in all_stats}), "notes": notes,
|
|
99
|
+
"caveats": [UA_CAVEAT, PRIVACY_NOTE]}
|
|
100
|
+
truncated = any(s.truncated for s in all_stats)
|
|
101
|
+
if args.json:
|
|
102
|
+
print(json.dumps(data, indent=2, ensure_ascii=False))
|
|
103
|
+
else:
|
|
104
|
+
_print_text(data)
|
|
105
|
+
return 1 if truncated else 0
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def _print_text(data: dict) -> None:
|
|
109
|
+
print(f"{data['tool']} — AI crawler log analysis (read-only; nothing is sent)")
|
|
110
|
+
for f in data["files"]:
|
|
111
|
+
bad = sum(f["malformed"].values())
|
|
112
|
+
line = (f" {privacy_safe(f['path'])}: {f['format']}"
|
|
113
|
+
+ (" (gzip)" if f["compressed"] else "")
|
|
114
|
+
+ f", {f['lines']} line(s), {f['records']} request(s)")
|
|
115
|
+
if bad:
|
|
116
|
+
line += f", {bad} malformed (" + ", ".join(
|
|
117
|
+
f"{k} {v}" for k, v in f["malformed"].items()) + ")"
|
|
118
|
+
if f["non_request"]:
|
|
119
|
+
line += f", {f['non_request']} non-request line(s)"
|
|
120
|
+
if f["duplicates"]:
|
|
121
|
+
line += f", {f['duplicates']} repeated line(s) of a request already counted"
|
|
122
|
+
print(line)
|
|
123
|
+
if f["truncated"]:
|
|
124
|
+
print(f" TRUNCATED: {f['truncated']}")
|
|
125
|
+
for name, src in data["format_sources"].items():
|
|
126
|
+
print(f" {name} field names per {src['source']} (checked {src['checked_on']})")
|
|
127
|
+
for note in data["notes"]:
|
|
128
|
+
print(f" NOTE: {privacy_safe(note)}")
|
|
129
|
+
t = data["totals"]
|
|
130
|
+
print(f"\n AI crawler hits: {t['ai_hits']} (claimed by user-agent); other requests: "
|
|
131
|
+
f"{t['other_hits']}")
|
|
132
|
+
print(" By purpose: " + ", ".join(f"{k} {v}" for k, v in data["by_purpose"].items()))
|
|
133
|
+
for b in data["bots"]:
|
|
134
|
+
v = b["ip_verification"]
|
|
135
|
+
w = b["wasted"]
|
|
136
|
+
print(f"\n {b['token']} ({b['vendor']}, {b['purpose']}): {b['hits']} hit(s) claimed "
|
|
137
|
+
f"by user-agent; IP check: {v['verified']} verified, {v['mismatch']} "
|
|
138
|
+
f"mismatch, {v['unverifiable']} unverifiable, {v['not_checked']} not checked")
|
|
139
|
+
urls = (f">= {b['unique_urls']} unique URL(s) (capped), "
|
|
140
|
+
f"{b['untracked_path_hits']} hit(s) on untracked paths"
|
|
141
|
+
if b["unique_urls_capped"]
|
|
142
|
+
else f"{b['unique_urls']} unique URL(s)")
|
|
143
|
+
print(f" {urls}; {b['active_days']} active day(s) "
|
|
144
|
+
f"{b['first_day']}..{b['last_day']}, {b['avg_hits_per_active_day']:g} hit(s) "
|
|
145
|
+
"per active day")
|
|
146
|
+
print(" status: " + ", ".join(f"{k} {n}" for k, n in b["status_codes"].items()))
|
|
147
|
+
print(f" wasted crawl: {w['total']} ({w['share']:.0%}) — redirect "
|
|
148
|
+
f"{w['redirect']}, 4xx {w['client_error']}, 5xx {w['server_error']}, "
|
|
149
|
+
f"parameter URL {w['parameter']}")
|
|
150
|
+
for p in b["top_paths"]:
|
|
151
|
+
print(f" {p['hits']:>6} {privacy_safe(p['path'])}")
|
|
152
|
+
tax = data["taxonomy"]
|
|
153
|
+
print(f"\n Crawler table: {tax['source']} — {tax['note']}.")
|
|
154
|
+
for c in data["caveats"]:
|
|
155
|
+
print(f" {c}")
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def add_parser(sub) -> None:
|
|
159
|
+
p = sub.add_parser("logs", help="AI-crawler activity from your own access logs "
|
|
160
|
+
"(nginx/Apache, Cloudflare, Vercel; read-only)")
|
|
161
|
+
p.add_argument("files", nargs="+", metavar="FILE",
|
|
162
|
+
help="Log file(s) inside --root; gzip is detected automatically")
|
|
163
|
+
p.add_argument("--bots", choices=["ai"], default="ai",
|
|
164
|
+
help="Which crawlers to report (only 'ai' for now)")
|
|
165
|
+
p.add_argument("--format", choices=list(parse.FORMATS), default="auto",
|
|
166
|
+
help="Log format (default: detect from the first lines, conservatively)")
|
|
167
|
+
p.add_argument("--root", default=".",
|
|
168
|
+
help="Files (and --ip-ranges files) must be inside this directory "
|
|
169
|
+
"(default: .)")
|
|
170
|
+
p.add_argument("--ip-ranges", action="append", metavar="[TOKEN=]FILE",
|
|
171
|
+
help="Operator-published IP ranges to check user-agent claims against "
|
|
172
|
+
"(repeatable; see docs/logs.md)")
|
|
173
|
+
p.add_argument("--keep-query", action="store_true",
|
|
174
|
+
help="Keep query strings in paths (credential-like values are redacted)")
|
|
175
|
+
p.add_argument("--top", type=int, default=10, help="Most-crawled paths per bot")
|
|
176
|
+
p.add_argument("--max-lines", type=int, default=parse.Budget.max_lines)
|
|
177
|
+
p.add_argument("--max-bytes", type=int, default=parse.Budget.max_bytes)
|
|
178
|
+
p.add_argument("--max-seconds", type=float, default=parse.Budget.max_seconds)
|
|
179
|
+
p.add_argument("--json", action="store_true", help="Emit the report as JSON")
|