Commit Graph
804 Commits
Author SHA1 Message Date
Alex Osborne dbb779f899 Add a commented-out CaptureIndex to the default profiles
BrowserProcessor and the WARC writer pick up a CaptureIndex only if the
job declares one. Show how to declare it in both default profiles.
2026-11-26 17:39:10 +09:00
Alex Osborne 12a02b883b BrowserProcessor: replay subresources from a CaptureIndex
When a GET subresource was captured within replayMaxAgeSeconds, serve it
from the WARC file instead of fetching it again, so that pages sharing
resources don't refetch them once the browser has evicted them from its
cache or the page loads in another browser. Redirects back to the same
canonical URL aren't replayed as they would loop. Part of #831.
2026-11-26 17:39:10 +09:00
Alex Osborne 2fbf9d19fe GridBrowser: let browserName choose between Chrome, Firefox and Edge
By default the Grid picks Chrome or Firefox, whichever it has a free
slot for, which on a node that detects every browser on its machine
could be either.
2026-11-20 18:42:15 +09:00
Alex Osborne 1fde99a24d BrowserProcessor: check that a launched browser can reach the recording proxy
A browser that can't reach the proxy, through a firewall, a wrong
proxyHost or an allowlist missing its address, would otherwise count as
up and fail every page. As the last step of a launch, load an https page
through the proxy with a page ID, which the proxy answers itself, so that
CONNECT and its TLS interception are checked too. A browser that fails
to load it, or doesn't reach the proxy within 10 seconds, fails to
launch.
2026-11-20 18:42:15 +09:00
Alex Osborne 44ee73c301 BrowserProcessor: open browser sessions on a Selenium Grid
http:// and https:// entries in browsers, or GridBrowser beans with
credentials, each create one session on a Grid. Grid nodes reach the
recording proxy at proxyHost, which defaults to loopback for a Grid
that shares this machine's loopback; otherwise the proxy needs to listen
off loopback and allow the nodes' addresses.
2026-11-20 18:42:15 +09:00
Alex Osborne 8c34f4723a BrowserProcessor: separate launching a browser from setting up its session
So that a browser can come from somewhere other than a launch.
2026-11-20 18:42:15 +09:00
Alex Osborne 6ff26a0743 BrowserProcessor: make the proxy's address, port and allowed sources configurable 2026-11-20 18:42:15 +09:00
Alex Osborne 17c5dac361 BrowserProcessor: keep the Firefox prefs as a map and generate user.js from it
So they can also be sent as capabilities to browsers we don't launch.
2026-11-20 18:42:15 +09:00
Alex Osborne 7eedafddc7 Merge pull request #825 from internetarchive/link-rel-preload
Fix navlink/embed classification of link rel types and duplicate outlinks
2026-11-18 17:46:35 +09:00
Alex Osborne aa746df854 Schedule outlinks as embeds when a page also embeds them
When a page links to the same URL both as an embed and via another hop
type, only schedule the embed. Previously whichever came first in the page
was scheduled and the rest dropped as duplicates by the frontier, so e.g. in

    <a href=image.jpg><img src=image.jpg></a>

the image was queued as a navlink. Likewise, until rel=preload was treated
as an embed, the stylesheet in

    <link rel=preload href=style.css as=style>
    <link rel=stylesheet href=style.css>

was queued as a navlink (#824).
2026-11-18 17:32:40 +09:00
Alex Osborne 30b88543e8 Add @codemirror/streamparser to import maps
@codemirror/language 6.13 and @codemirror/legacy-modes 6.5.5 now import
@codemirror/streamparser, so the editors failed to load with an
unmapped bare specifier error.
2026-11-18 17:02:28 +09:00
Alex Osborne aa4dd213df Merge pull request #814 from internetarchive/soft404-detector
Soft404Detector: detect soft 404s and optionally skip extraction
2026-11-18 16:35:14 +09:00
Alex Osborne 6f8201cc60 Comment out Soft404Detector in the default profiles
It's still new, so leave it opt-in until it has seen more real-world use.
2026-11-17 15:03:33 +09:00
Leslie Bellony 13c6572ad6 Merge pull request #821 from bnfleb/statisticstracker
ToeThread dies on `http://0.0.0.0/` (IllegalStateException "got suspicious value 0.0.0.0"), job stuck in EMPTY forever
2026-11-15 07:48:03 +09:00
Alex Osborne db156f3427 Write browser behaviors inline in the Groovy profile and docs 2026-11-13 16:08:42 +09:00
Alex Osborne fb3452a6af Behaviors: log unparseable links through the Page instead of a constructor argument
ExtractLinksBehavior and PaginationBehavior took the UriErrorLoggerModule as a
constructor argument, so they had to be Spring beans to get it. That meant the
Groovy config couldn't create them inline in the behaviors list, as Spring's
Groovy reader doesn't turn inner beans in a list into beans, and had to declare
each one as a named bean and refer to it. BrowserProcessor already has the
logger module, so it now passes it to behaviors through the page and they can
be plain objects.
2026-11-13 16:08:36 +09:00
Alex Osborne 27ba6ba850 Add a commented-out BrowserProcessor bean to the Groovy default profile 2026-11-13 16:01:35 +09:00
Alex Osborne 336d0d6c52 BrowserProcessor: turn off Firefox site isolation 2026-11-13 10:12:38 +09:00
Alex Osborne 7b2a485091 BrowserProcessor: don't mistake a crashed Firefox tab for a download 2026-11-13 10:12:38 +09:00
Alex Osborne 486dffbedf BrowserProcessor: allow per-browser concurrency, executable and options 2026-11-13 10:12:38 +09:00
Alex Osborne d7c9a5581e BrowserProcessor: launch browsers on other machines over ssh 2026-11-13 10:12:38 +09:00
Alex Osborne dc070b4af1 BrowserProcessor: close idle browsers and relaunch them when a page needs one
Many small jobs in one JVM would otherwise each hold browsers open for as long as the job runs or sits paused.
2026-11-12 15:47:09 +09:00
Alex Osborne 51668638b0 BrowserProcessor: track each browser's state with an enum instead of a flag 2026-11-12 15:29:43 +09:00
Alex Osborne 0f8644fd65 LocalWebDriverBiDi: make the command timeout configurable 2026-11-12 13:50:20 +09:00
Alex Osborne 9cefc32df0 LocalWebDriverBiDi: kill the browser if it stops answering 2026-11-12 13:50:20 +09:00
Alex Osborne d7f82bce4d BrowserProcessor: launch browsers in parallel and retry failed launches with backoff 2026-11-12 13:44:03 +09:00
Alex Osborne ad8e3fb51b BrowserProcessor: support several browsers 2026-11-12 13:44:03 +09:00
Alex Osborne 7369ec2980 BrowserProcessor: move per-browser state into a nested Browser class 2026-11-12 13:43:55 +09:00
Alex Osborne ec320998c2 CI: run the browser tests in their own job against Firefox and Chrome 2026-11-12 13:19:14 +09:00
Alex Osborne 74d236ee57 BrowserProcessor: reject proxy requests that don't belong to an open page 2026-11-11 22:21:44 +09:00
Alex Osborne 832279989d Add ExtractorSVG to the Groovy default profile 2026-11-06 13:56:11 +09:00
Alex Osborne 9d79ef7372 Add ExtractorSVG and extract links from inline SVG
ExtractorSVG parses SVG with the JDK's StAX parser and extracts hrefs
from elements like <image>, <use> and <script> as embeds and from <a>
as links, along with <?xml-stylesheet?>, url() in presentation
attributes, <style>, <script>, animated hrefs and HTML in
<foreignObject>. Like browsers it requires the SVG namespace, decides
by the root element whether text/xml and application/xml responses
are SVG, and keeps the links found before any XML error. It's added
to the default profile before extractorHtml.

ExtractorHTML and JerichoExtractorHTML now treat hrefs on those inline
SVG elements as embeds rather than links, and extract url() from
presentation attributes like fill. ExtractorCSS now ignores
same-document references like url(#gradient).

Fixes #796
2026-11-05 16:17:28 +09:00
Alex Osborne d614ea3b34 Soft404Detector: detect soft 404s and optionally skip extraction
Sites that return 200 for nonexistent URLs, combined with relative
links, can generate an endless series of fake URLs (#729).

The first time a server returns a successful response, a probe for a
random two-segment path on it is scheduled. If the probe gets a 200,
its content is fingerprinted, and later 200 responses from that server
with the same fingerprint are annotated "soft404". The fingerprint is a
hash of the content after removing echoes of the requested path and
replacing tokens that contain digits, so nonces and timestamps don't
prevent a match. Seeds and the root path are exempt, and a probe
redirect that keeps the probe path is treated as the probe.

With skipExtraction (the default) the rest of the fetch chain is
skipped for matching pages, so neither the extractors nor the browser
processor see them. The default profiles enable the detector with
skipExtraction=false for now, so it only annotates and counts soft
404s until it has seen more real-world use.

Per-server probe state is stored on CrawlServer.
2026-11-05 16:12:17 +09:00
Alex Osborne 7a9e2689b4 Use CrawlURI.hasContentType() for exact media type checks
Replaces startsWith() prefix checks, which also matched longer subtypes,
e.g. "application/vnd.wap.wml" matched the binary
"application/vnd.wap.wmlc". The truncated "application/xhtml" and
"application/vnd.wap.xhtml" checks now name the full "+xml" types. Also
fixes case-sensitive comparisons in ExtractorPDF and ExtractorPDFContent,
and drops BotBlockDetector's private equivalent.

Substring heuristics like ExtractorJS's indexOf("javascript") and
ExtractorXML's indexOf("xml") are intentionally left as they are.
2026-11-05 09:58:58 +09:00
Alex Osborne 5b1f492cc2 CrawlURI: add hasContentType() for media type comparison
Compares the content type's type/subtype with the given media type,
ignoring case and any parameters, so "Text/HTML; charset=utf-8" matches
"text/html" but "text/htmlfoo" doesn't. This replaces ad hoc checks like
toLowerCase().startsWith(...), which also match longer subtypes.
2026-11-05 09:53:25 +09:00
Matt Van Horn a769651bf5 fix: give midfetch aborts their own fetch status code
Add S_MIDFETCH_ABORTED (-5005) and set it in FetchHTTP when
shouldFetchBodyRule rejects a response, in place of S_OUT_OF_SCOPE.
The code means something distinct from a scope rejection, so crawl logs
and reports can now tell the two apart. AbstractFrontier.isDisregarded()
treats it as disregarded, CrawlURI gives it a readable string and the
glossary lists it.
2026-11-02 06:01:06 -08:00
Leslie Bellony 91a869bd4b sourcetags: dispose of the sorted map after use (#788) 2026-10-12 18:34:12 +09:00
Alex Osborne 94a6761a17 BrowserProcessorTest: make tempDir static (#785)
We're seeing occasional random test failures. I think it may be because we're changing the CrawlController scratchDir before each test, which means the profile of a running browser can get wiped out.
2026-10-08 18:36:09 +09:00
Alex Osborne 8bb0a65349 Merge pull request #783 from internetarchive/toethread-always-end-disposition
Always release the disposition lock when a ToeThread exits
2026-10-07 12:42:19 +09:00
Alex Osborne d6747686e3 Don't let browsers cache job directory files for 10 minutes (#782)
Restlet's Directory gives every file an Expires header 10 minutes in the
future. Job files (logs, reports, crawler-beans.cxml) change constantly, so
browsers could show stale copies. Worst case, the config editor loads a
cached crawler-beans.cxml and saving it silently reverts newer changes.

Clear the expiration date and send Cache-Control: no-cache instead, so
browsers revalidate against Last-Modified on each use.
2026-10-07 12:42:02 +09:00
Alex Osborne 7939d0d7e1 Reject cross-site requests to the web UI
Add CrossSiteRequestFilter in front of the web UI's router to protect
against cross-site request forgery. POST, PUT and DELETE requests are
rejected with 403 when the browser's Sec-Fetch-Site header says they
came from another site.

Sec-Fetch-Site is set by the browser from its own view of the page and
target URL, so unlike comparing Origin with Host it isn't affected by
reverse proxies rewriting the host or scheme. Requests without the
header, such as from curl and other API clients, are allowed.

Origins listed in the heritrix.trustedOrigins system property (comma
separated) are allowed to send cross-site requests.
2026-10-06 12:21:40 +09:00
Alex Osborne 55bef0aa32 Merge pull request #780 from internetarchive/paged-log-viewer-search
Crawl log search
2026-10-06 12:09:09 +09:00
Alex Osborne 6f9a82c8fb Fix HTML escaping in templates
Enables autoescaping in Freemarker and adds some missing escaping
where we generate HTML in Java methods.
2026-10-06 12:04:23 +09:00
Alex Osborne a09f38570d Only write heritrix_dmesg.log when requested (#779)
Only write heritrix_dmesg.log when requested

Heritrix.java always created heritrix_dmesg.log in $HERITRIX_HOME, even
though only the bin/heritrix script reads it, and only when it starts
Heritrix in the background. This got in the way of making
$HERITRIX_HOME read-only for Docker and systemd setups.

The startup log is now written only when the heritrix.dmesg system
property gives its path. bin/heritrix sets this property in background
mode and keeps the file in the same place as before.

Also fix a typo in bin/heritrix ($startmessage) that stopped it
removing a heritrix_dmesg.log left over from a previous start.

Set -Dheritrix.dmesg in heritrix.cmd too.
2026-10-06 11:29:51 +09:00
Alex OsborneandClaude Opus 5.5 f5070f6203 Paged log viewer: search and filter with a small query language
The paged log viewer gains a search box taking a search-engine style
query, passed as the q parameter:

  status:4xx host:example.com -type:image size>1MB duration>10s

- Terms are ANDed; '-' negates; double quotes allow spaces.
- 'field:value' is a case-insensitive substring match with '*'
  wildcards, 'field=value' is exact and 'field~regex' is a Java regex.
  Numeric fields take the same values with ':' or '=', and no regex;
  a comparison needs no operator, as in size>1MB.
- Bare words and the 'line' field search the whole line in any log.
  crawl.log also supports status (404, 4xx, <0, 500..599, 404,410),
  size (>1MB, 100KB..10MB; units are powers of 1024), duration (>10s,
  500..2000 in ms), depth (hops from the seed: 0, >5), hops (the hop
  path, e.g. hops:*E), url, host (includes subdomains), via and viahost
  (the URI it was discovered from, and its host), type and annot.
- Bare words and line terms are highlighted in the results.

Filtering keeps the viewer's stateless, byte-position paging and works
across checkpoint logs: each request scans forward or backward from pos
until it has enough matches or reaches the start or end, streaming a
progress bar to the browser. A scan stops after 5 minutes, offering a
link to continue from where it stopped, or as soon as the client
disconnects. Regex matching is aborted at the same deadline to guard against
catastrophic backtracking. The query is carried through all navigation links.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 16:54:19 +09:00
Alex OsborneandClaude Opus 5.5 b1a36159ae Paged log viewer: view a log together with its checkpoint generations
Checkpointing renames each log in place (crawl.log becomes
crawl.log.cp00001-<timestamp>) and starts a new one, so earlier entries
could only be viewed one file at a time. The paged viewer now offers an
"include N checkpoint logs" link (all=y) that shows the log and its
rotated generations in the current launch as one virtual file, oldest
first, with each run of lines labelled with its file.

Positions in the virtual file stay valid across checkpoints, since a
rotated file keeps its place and the new log continues after it, and
they are converted when toggling so the view stays where it was.
Gzipped generations can't be read at arbitrary positions and are
left out.

LogSeries opens the files and fixes their lengths up front, so a
rotation mid-request doesn't change what is read. Paging uses a new
FilteredLineScanner over a LogSeries instead of FileUtils.pagedLines,
which can only read a single file. Results are the same for every
position the navigation links generate; a hand-edited pos in the
middle of a line now starts at that line rather than the next one.
Lines are capped at 256 KiB so a file with few or no newlines can't
exhaust the heap.

Also fixes in the crawl.log rendering: a rotated crawl.log gets the
same status highlighting, status codes unknown to Jetty (e.g. 999) and
numbers too long to be a status no longer fail the page, and the file
name, status titles and navigation links are HTML escaped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 16:46:36 +09:00
Alex Osborne 838523d33a BotBlockDetector: enable in default profiles 2026-10-02 09:24:44 +09:00
Alex Osborne f6a14ac1f6 Implement invoker commands for older browsers like Firefox ESR
Fixes #773
2026-10-01 19:05:53 +09:00
Leslie Bellony b0beb39518 Call tallySourceStats only if the URI is effectively crawled 2026-09-09 17:12:29 +02:00
Leslie Bellony 7b43a91e38 Include Heritrix status code in extended SourceTags report 2026-09-08 11:13:33 +02:00