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.
Files changed (183) hide show
  1. omnirank/__init__.py +14 -0
  2. omnirank/__main__.py +6 -0
  3. omnirank/adapters/__init__.py +202 -0
  4. omnirank/adapters/astro.py +338 -0
  5. omnirank/adapters/base.py +372 -0
  6. omnirank/adapters/html.py +561 -0
  7. omnirank/adapters/jsx.py +340 -0
  8. omnirank/adapters/nextjs.py +692 -0
  9. omnirank/aeo/__init__.py +9 -0
  10. omnirank/aeo/extract.py +383 -0
  11. omnirank/aeo/propose.py +84 -0
  12. omnirank/aeo/rules.py +964 -0
  13. omnirank/aeo/runner.py +148 -0
  14. omnirank/applicability.py +98 -0
  15. omnirank/apply/__init__.py +23 -0
  16. omnirank/apply/engine.py +1254 -0
  17. omnirank/apply/journal.py +139 -0
  18. omnirank/apply/patch.py +144 -0
  19. omnirank/audit.py +185 -0
  20. omnirank/bands.py +106 -0
  21. omnirank/brief/__init__.py +0 -0
  22. omnirank/brief/analyze.py +197 -0
  23. omnirank/brief/constants.py +89 -0
  24. omnirank/brief/cost.py +62 -0
  25. omnirank/brief/egress.py +23 -0
  26. omnirank/brief/fetchpages.py +239 -0
  27. omnirank/brief/render.py +151 -0
  28. omnirank/brief/runner.py +369 -0
  29. omnirank/brief/serp.py +274 -0
  30. omnirank/brief/text.py +181 -0
  31. omnirank/cli.py +844 -0
  32. omnirank/clock.py +22 -0
  33. omnirank/cms/__init__.py +1 -0
  34. omnirank/cms/runner.py +170 -0
  35. omnirank/cms/wordpress.py +495 -0
  36. omnirank/cms/wordpress_apply.py +508 -0
  37. omnirank/cms/wordpress_plan.py +280 -0
  38. omnirank/config.py +81 -0
  39. omnirank/connect/__init__.py +4 -0
  40. omnirank/connect/bing.py +284 -0
  41. omnirank/connect/cloud_setup.py +43 -0
  42. omnirank/connect/confirm.py +242 -0
  43. omnirank/connect/constants.py +226 -0
  44. omnirank/connect/doctor.py +270 -0
  45. omnirank/connect/ga4.py +749 -0
  46. omnirank/connect/ga4_ai.py +123 -0
  47. omnirank/connect/google_auth.py +657 -0
  48. omnirank/connect/gsc.py +630 -0
  49. omnirank/connect/gsc_reports.py +169 -0
  50. omnirank/connect/http.py +310 -0
  51. omnirank/connect/indexnow.py +373 -0
  52. omnirank/connect/naver.py +536 -0
  53. omnirank/connect/runner.py +515 -0
  54. omnirank/connect/runner_ga4_ai.py +59 -0
  55. omnirank/connect/runner_more.py +489 -0
  56. omnirank/connect/runner_regional.py +260 -0
  57. omnirank/connect/secrets.py +190 -0
  58. omnirank/connect/urlcheck.py +41 -0
  59. omnirank/connect/yandex.py +350 -0
  60. omnirank/crawl/__init__.py +11 -0
  61. omnirank/crawl/analyze.py +493 -0
  62. omnirank/crawl/crawler.py +491 -0
  63. omnirank/crawl/custom.py +175 -0
  64. omnirank/crawl/export.py +67 -0
  65. omnirank/crawl/fetcher.py +212 -0
  66. omnirank/crawl/parse.py +102 -0
  67. omnirank/crawl/render.py +148 -0
  68. omnirank/crawl/robotsgate.py +198 -0
  69. omnirank/crawl/runner.py +295 -0
  70. omnirank/crawl/sitemap.py +99 -0
  71. omnirank/crawl/text.py +20 -0
  72. omnirank/crawl/urls.py +100 -0
  73. omnirank/crawlers.py +564 -0
  74. omnirank/data/ai_crawlers.json +269 -0
  75. omnirank/data/ai_referrers.json +42 -0
  76. omnirank/fetch.py +107 -0
  77. omnirank/fixes/__init__.py +92 -0
  78. omnirank/fixes/base.py +232 -0
  79. omnirank/fixes/canonical.py +243 -0
  80. omnirank/fixes/schema.py +126 -0
  81. omnirank/formats.py +134 -0
  82. omnirank/framework.py +223 -0
  83. omnirank/gates/__init__.py +48 -0
  84. omnirank/gates/aeo.py +114 -0
  85. omnirank/gates/contradictions.py +280 -0
  86. omnirank/gates/crawler_policy.py +85 -0
  87. omnirank/gates/geo.py +152 -0
  88. omnirank/gates/hygiene.py +81 -0
  89. omnirank/gates/jsonld.py +282 -0
  90. omnirank/gates/onpage.py +177 -0
  91. omnirank/gates/perf.py +115 -0
  92. omnirank/gates/security.py +264 -0
  93. omnirank/gates/seo.py +118 -0
  94. omnirank/gates/site.py +248 -0
  95. omnirank/geo_artifacts.py +199 -0
  96. omnirank/html.py +79 -0
  97. omnirank/keywords/__init__.py +5 -0
  98. omnirank/keywords/constants.py +69 -0
  99. omnirank/keywords/engine.py +384 -0
  100. omnirank/keywords/report.py +143 -0
  101. omnirank/keywords/runner.py +160 -0
  102. omnirank/keywords/source.py +60 -0
  103. omnirank/keywords/text.py +45 -0
  104. omnirank/locator.py +480 -0
  105. omnirank/logs/__init__.py +0 -0
  106. omnirank/logs/analyze.py +127 -0
  107. omnirank/logs/bots.py +69 -0
  108. omnirank/logs/ipranges.py +191 -0
  109. omnirank/logs/parse.py +452 -0
  110. omnirank/logs/paths.py +22 -0
  111. omnirank/logs/privacy.py +105 -0
  112. omnirank/logs/runner.py +179 -0
  113. omnirank/mcp_server.py +1480 -0
  114. omnirank/netguard.py +525 -0
  115. omnirank/packs/__init__.py +6 -0
  116. omnirank/packs/backlinks.py +535 -0
  117. omnirank/packs/blog.py +544 -0
  118. omnirank/packs/blog_cross.py +468 -0
  119. omnirank/packs/crawlers.py +23 -0
  120. omnirank/packs/entity.py +492 -0
  121. omnirank/packs/feeds.py +150 -0
  122. omnirank/packs/frontmatter.py +59 -0
  123. omnirank/packs/gsc.py +421 -0
  124. omnirank/packs/local.py +879 -0
  125. omnirank/packs/mdscan.py +326 -0
  126. omnirank/packs/miniyaml.py +378 -0
  127. omnirank/packs/model.py +46 -0
  128. omnirank/packs/product.py +979 -0
  129. omnirank/packs/refresh.py +165 -0
  130. omnirank/packs/runner.py +277 -0
  131. omnirank/packs/sitescan.py +294 -0
  132. omnirank/packs/textsafe.py +79 -0
  133. omnirank/packs/xmlsafe.py +92 -0
  134. omnirank/page.py +42 -0
  135. omnirank/registry.py +302 -0
  136. omnirank/report.py +251 -0
  137. omnirank/report_cmd/__init__.py +7 -0
  138. omnirank/report_cmd/delta.py +58 -0
  139. omnirank/report_cmd/files.py +64 -0
  140. omnirank/report_cmd/model.py +208 -0
  141. omnirank/report_cmd/notify.py +195 -0
  142. omnirank/report_cmd/pdf.py +83 -0
  143. omnirank/report_cmd/portfolio.py +342 -0
  144. omnirank/report_cmd/render.py +379 -0
  145. omnirank/report_cmd/runner.py +267 -0
  146. omnirank/robots.py +172 -0
  147. omnirank/scanner/__init__.py +10 -0
  148. omnirank/scanner/badge.py +90 -0
  149. omnirank/scanner/cache.py +69 -0
  150. omnirank/scanner/cli.py +96 -0
  151. omnirank/scanner/engine.py +289 -0
  152. omnirank/scanner/limits.py +98 -0
  153. omnirank/scanner/server.py +143 -0
  154. omnirank/scanner/service.py +328 -0
  155. omnirank/schema/__init__.py +13 -0
  156. omnirank/schema/catalog.py +679 -0
  157. omnirank/schema/catalog_specs.py +350 -0
  158. omnirank/schema/core.py +306 -0
  159. omnirank/schema/extract.py +396 -0
  160. omnirank/schema/gate.py +121 -0
  161. omnirank/schema/runner.py +213 -0
  162. omnirank/schema/validate.py +504 -0
  163. omnirank/schema/vocab.py +305 -0
  164. omnirank/schemas/omnirank.config.schema.json +268 -0
  165. omnirank/track/__init__.py +0 -0
  166. omnirank/track/ai_prompts.py +207 -0
  167. omnirank/track/analysis.py +197 -0
  168. omnirank/track/constants.py +155 -0
  169. omnirank/track/cost.py +229 -0
  170. omnirank/track/discover.py +277 -0
  171. omnirank/track/discover_cli.py +309 -0
  172. omnirank/track/discover_constants.py +95 -0
  173. omnirank/track/engines.py +216 -0
  174. omnirank/track/estimate_view.py +212 -0
  175. omnirank/track/history.py +261 -0
  176. omnirank/track/runner.py +586 -0
  177. omnirank/track/stats.py +138 -0
  178. omnirank/track/storage.py +128 -0
  179. omnirank-0.5.0.dist-info/METADATA +47 -0
  180. omnirank-0.5.0.dist-info/RECORD +183 -0
  181. omnirank-0.5.0.dist-info/WHEEL +5 -0
  182. omnirank-0.5.0.dist-info/entry_points.txt +2 -0
  183. omnirank-0.5.0.dist-info/top_level.txt +1 -0
@@ -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
@@ -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")