718 Commits

Author SHA1 Message Date
Adam Miller 558727ac37 fix handle more bdb shutdown interrupts 2025-10-03 17:17:46 -07:00
Adam Miller 38e7156ef6 fix: don't restore crawlEndTime when resuming from checkpoint. 2025-09-25 10:50:47 -07:00
Adam Miller fd2aed89fb feat: strip invalid chars from xml rest api output 2025-09-11 17:42:07 -07:00
Alex Osborne 2388db4229 Bump commons-lang from 2.6 to 3.18.0 2025-07-21 16:55:31 +09:00
Alex Osborne 85ceab905c BrowserProcessor: create scratchDir on start
This fixes an exception on first launch.
2025-07-21 11:55:37 +09:00
Alex Osborne db63c7ec85 Seeds report: record redirect URI for statuses 303, 307 and 308
These can also redirect, not just 301 and 302.

Fixes #564
2025-06-30 22:24:29 +09:00
Alex Osborne 9b5900b528 FetchHTTP2: Avoid silently decoding gzip
Fixes `Recorder getContentReplayInputStream
WARNING: gzip problem; using raw entity instead`.
2025-06-12 21:36:14 +09:00
Adam Miller 0494d63ea2 fix: Avoid a NullPointerException when terminate is called again during shutdown 2025-06-11 17:44:52 -07:00
Alex Osborne 61af1d83c4 MitmProxy: Handle URLs generated by browsers but disallowed by java.net.URI 2025-06-11 20:38:54 +09:00
Alex Osborne 8a15156fa1 BrowserProcessor: Catch WebDriver timeouts and exceptions 2025-06-11 17:17:02 +09:00
Alex Osborne c3f9afe64b BrowserProcessor: use FetchHTTP2's configured proxy as an upstream proxy 2025-06-10 09:01:02 +09:00
Alex Osborne e68e4975c9 Rename to BrowserProcessor and -Behavior
After I added them to the Bean reference they seemed out of place with the DecideRules and RecordBuilders.

We had two classes called 'Browser' which is potentially confusing. It's also probably good to more clearly differentiate the ExtractLinks browser behavior from the Extractor processors.
2025-06-09 15:35:25 +09:00
Alex Osborne cf447f3bd9 Add Browser processor and behaviors to bean reference 2025-06-09 15:19:09 +09:00
Alex Osborne 1161d87217 Browser: Add processor report 2025-06-05 10:48:15 +09:00
Alex Osborne 2210cb7262 Browser: Handle navigation abort from downloads starting 2025-06-04 17:44:42 +09:00
Alex Osborne 5131ea4a80 Browser: Disable downloads in Firefox and Chrome
This hopefully will stop us filling up ~/Downloads with random junk.
2025-06-04 17:44:42 +09:00
Alex Osborne 722552feef Add Browser processor using WebDriver BiDi
The Browser processor can load a fetched page in a local web browser, record any requests the browser makes and run behaviors that interact with the page such as scrolling down and extracting links.

This differs from my previous attempt (ExtractorChrome) in a few ways:

- Uses the new WebDriver BiDi standard instead of the Chrome Devtools Protocol. The new protocol is mostly browser-agnostic, more consistent and hopefully more stable.

- Uses a MITM proxy instead of CDP request interception for recording sub-resources. That's partly because BiDi is still missing some key interception APIs. Even so in practice I found the proxy method loads pages faster and more reliably, likely because responses can be streamed incrementally, which helps a lot for large resources or server-sent events.

- Even when HTTP/2 is unavailable, the new FetchHTTP2 module does connection pooling which makes loading browser requests a lot faster. The original FetchHTTP opened a new connection for every request.

- The Browser processor can be configured with a list of behavior beans making it more customizable and extensible.

Obvious areas for future development:

- More Behavior beans: take screenshots, saveg the rendered DOM, run Browsertrix-compatible behavior scripts

- Support for remote WebDrivers (e.g. Selenium Server or cloud services)
2025-06-04 17:44:42 +09:00
Alex Osborne eaf72b5ce2 Add --web-auth basic command-line option
This option enables HTTP Basic authentication for the web interface instead of the default Digest authentication. This is useful when running Heritrix behind a reverse proxy that adds external authentication as typically they don't support Digest auth for the upstream server.

#641
2025-05-25 00:29:14 +09:00
Alex Osborne 0f0db370ee UI: Disable Jetty graceful shutdown for faster restarts
Graceful shutdown would be useful if you could deploy the UI in a high-availability configuration and direct new requests to a different instance while the current instance finished its outstanding ones. But as you can't, it's just making restarting Heritrix slow for little benefit.
2025-05-24 22:46:42 +09:00
Alex Osborne 679fde42c6 SelfTestBase: Use a dynamic port (port 0) for Heritrix web port
This stops the tests from failing when you happen to be running Heritrix or something else on port 8443.
2025-05-22 15:38:45 +09:00
Alex Osborne 567e27181d Upgrade webarchive-commons from 1.3.0 to 2.0.1 (removes httpclient 3) 2025-05-21 17:39:21 +09:00
Alex Osborne 33446c7a2b Upgrade to CodeMirror 6
This resolves some browser incompatibilities, allowing CodeMirror’s own find function to be re-enabled for reliable text search of content far outside the viewport.
2025-05-16 18:34:30 +09:00
Alex Osborne eb1205f6d5 Upgrade all tests to junit 5 2025-05-09 00:07:18 +09:00
Alex Osborne db16b60960 Fix 'anypath' URL generation and avoid unnecessary usages of it
Restlet 2.6 refuses paths with double slash in the static path and we
were inadvertently generating them.
2025-04-28 17:09:33 +09:00
Alex Osborne bc259728a0 Update to Jetty 12.0.16 and Restlet 2.6.0-M2
The Jetty API has changed, which mostly affects test code.

Jetty now does a strict SNI host check which unfortunately causes it to
return "SNI error" for our existing ad-hoc certificates. For now, I've
disabled it to avoid breaking existing deployments but added a
--sni-host-check command-line option so you can re-enable it if
you've configured your own certificate appropriately.
2025-04-24 17:40:20 +09:00
Adam Miller 02c4c8ee09 feat: add unit test for HighestUriPrecedenceProvider Kryo serialization 2025-04-23 16:25:58 -07:00
Adam Miller fdada4c5ec chore: formatting 2025-04-23 15:20:40 -07:00
Adam Miller cb98bfc522 chore: fix line endings 2025-04-22 17:33:32 -07:00
Adam Miller e7fe566919 fix: autoregister Histotable and HighestUriPrecedenceProvider 2025-04-22 17:29:52 -07:00
Alex Osborne 575a2653b9 Fix warning: assert statement with side effects 2025-04-01 16:27:13 +09:00
Alex Osborne b8dbe8bb2d Remove unused utility class LogUtils 2025-04-01 16:25:44 +09:00
Alex Osborne ed72112d9c Fix missing try-with-resources warning 2025-04-01 16:19:58 +09:00
Alex Osborne f956b2ec1f Fix broken references in javadoc 2025-04-01 15:59:38 +09:00
Alex Osborne 7ff1078d21 Fix warning about implicit narrowing conversion for contentSinceCheck 2025-03-31 15:31:04 +09:00
Alex Osborne f6b083ecfb Remove usages of deprecated Integer and Long constructors 2025-03-31 15:04:00 +09:00
Alex Osborne 4e8bda1a07 ExtractorHTML: Add obeyRelNofollow option
When enabled this option causes regular links annotated with rel=nofollow to not be extracted. This is useful for sites that use rel=nofollow to hint crawler traps.
2025-01-13 15:34:38 +09:00
Alex Osborne 4c4510a364 Merge pull request #632 from internetarchive/groovy-config
Add Groovy crawl configs
2024-12-24 12:11:41 +09:00
Alex Osborne d13acddfc4 Remove usages of fastutil
fastutil is our largest dependency, consuming about a third of the
total Heritrix distribution size but we only use a couple of trivial
classes from it.

FPMergeUriUniqFilter (which I'm not sure anyone uses anyway), uses
LongArrayList so this change replaces it with a basic version that does
just enough.

The unsynchronized FastBufferedOutputStream usages are likely
unnecessary these days thanks to the JVM's lock optimisations and for
the one in CrawlerJournal, the GZIPOutputStream is still going to
be synchronizing anyway.
2024-12-20 14:37:20 +09:00
Alex Osborne 19c24b9006 Add Groovy crawl configs
This enables crawl configuration files to use Spring's [Groovy Bean Definition DSL] as an optional alternative to Spring XML. It uses the same bean configuration model but the syntax is more terse and human-readable. No more need for `&` in seed URLs. :-)

```groovy
   checkpointService(CheckpointService) {
        checkpointIntervalMinutes = 15
        checkpointsDir = 'checkpoints'
        forgetAllButLatest = true
   }
```

It also enables some powerful scripting capabilities. For example, defining a custom DecideRule directly in the crawl scope:

```groovy
scope(DecideRuleSequence) {
    rules = [
        new RejectDecideRule(),
        // ACCEPT everything linked from a .pdf file
        new PredicatedDecideRule() {
             boolean evaluate(CrawlURI uri) {
                 return uri.via?.path?.endsWith(".pdf")
             }
        },
        // ...
    ]
}
```

The main downsides are defining nested inner beans can be a bit awkward, some of the errors can be cryptic, and you can't just manipulate the config files with an XML parser.

This commit includes a Groovy version of the default crawl profile for reference, but doesn't expose a way to use it in the UI yet. For now, you need to manually create a `crawler-beans.groovy` file in your job directory.

[Groovy Bean Definition DSL]: https://docs.spring.io/spring-framework/reference/core/beans/basics.html#beans-factory-groovy
2024-12-01 00:14:42 +09:00
Alex Osborne 3fbf1bc8c0 Merge pull request #631 from internetarchive/update-deps
Update dependencies for 3.6.0 release
2024-11-29 19:24:28 +09:00
Alex Osborne 0a215f6467 Bump jaxb-runtime from 2.3.1 to 4.0.5 2024-11-29 17:12:43 +09:00
Alex Osborne 405b2efc6d Bump restlet from 2.4.0 to 2.5.0-rc1 2024-11-29 10:34:35 +09:00
Alex Osborne 4093871de1 Merge pull request #626 from internetarchive/checkpoint-on-shutdown
Add checkpoint on shutdown and --checkpoint CLI option
2024-11-28 16:43:45 +09:00
Alex Osborne a02a339830 Fix StackOverflowError and map exceptions in Browse Beans 2024-11-24 20:30:16 +09:00
Alex Osborne 585fed8575 Add --checkpoint command-line option
This makes it possible to select a checkpoint from the command-line when using the --run-job option.
2024-11-24 13:40:33 +09:00
Alex Osborne 18c69def9a CheckpointService: Add checkpointOnShutdown option
This enables a checkpoint to be automatically created during a graceful termination. This makes it easier to stop and restart Heritrix without having to manually checkpoint each running job.
2024-11-24 13:08:11 +09:00
Alex Osborne dd210c8e70 Replace Spring's removed @Required annotation with our own
Spring 6 removed @Required and they suggest using constructor injection instead. If we switched our beans to that we'd break existing Heritrix crawl configs. So this change implements our own basic version so we still get errors when a @Required property is null.
2024-11-20 16:30:15 +09:00
Alex Osborne 3d1b7e37ca Remove log4j 2024-10-17 19:25:53 +09:00
Alex Osborne 1d37cbc237 StatisticsSelfTest: Update for new jetty version
Jetty error messages are included in the selftest crawl and now have
slightly different lengths.
2024-10-17 11:58:13 +09:00
Alex Osborne 3c80dacabe CrawlJob: Replace joda-time with java.time (JSR-310) 2024-09-13 13:47:00 +09:00