sparklemotion/mechanize
59.8
Adequate · 14 November 2026
7.1k
lines of production code
Ruby
primary language
6
measurements over time
What this system is
Features
Add new example scripts for user agent fetching, spidering, and Wikipedia traversal
The examples directory now includes several new scripts: \latest\_user\_agents.rb\ fetches current user agents from WhatIsMyBrowser.com; \spider.rb\ demonstrates web crawling with unlimited history; \wikipedia\_links\_to\_philosophy.rb\ implements the XKCD 903 algorithm to traverse Wikipedia links to the Philosophy article; \flickr\_upload.rb\ shows how to log in and upload to Flickr; \rubygems.rb\ demonstrates logging into RubyGems; \mech-dump.rb\ dumps a page's inspection output; and \proxy\_req.rb\ shows how to use a proxy.
examples · high confidence
Security
Security fixes for credential leakage on cross-origin redirects and meta refreshes
Mechanize now strips sensitive headers (Proxy-Authorization, Cookie2, and headers set via request\_headers=) when following a redirect or meta refresh to a different origin (scheme, host, or port). This prevents credential leakage to unintended sites, addressing security advisories [GHSA redacted], [GHSA redacted], and [GHSA redacted].
(repo-wide) · high confidence
Behavioural changes
Redesigned HTTP agent with secure credential handling and robust authentication parsing
The HTTP agent implementation has been restructured into dedicated classes (Agent, AuthStore, AuthChallenge, WWWAuthenticateParser) to improve security and reliability. A key behavioral change is that credentials and sensitive headers (Authorization, Proxy-Authorization, Cookie, Cookie2) are now automatically withheld when a redirect crosses an origin (scheme or port change), preventing accidental password disclosure to third-party servers. The agent now features a robust WWW-Authenticate parser that correctly handles multiple authentication schemes (e.g., 'Negotiate, NTLM') and whitespace delimiters, preventing infinite loops on malformed headers. Additionally, it supports NTLM authentication with domain arguments, parses Content-Disposition headers more strictly (supporting ISO 8601 dates), and introduces configurable timeouts and error code handling for better control over HTTP interactions. Also in this area: Refactor error hierarchy and introduce streaming downloads; Refactored form field classes into specific types.
lib/mechanize/http, mechanize · high confidence
Refactor error hierarchy and introduce streaming downloads
Mechanize now uses a dedicated error class hierarchy under Mechanize::Error (such as ResponseReadError, ContentTypeError, and ChunkedTerminationError) instead of raising generic RuntimeErrors, providing more specific exception types for error handling. Additionally, a new Mechanize::Download class enables streaming large file responses directly to disk, reducing memory usage compared to the previous in-memory Mechanize::File approach, and a Mechanize::DirectorySaver is introduced to save downloaded files into a flat directory structure.
lib/mechanize · high confidence
Refactored form field classes into specific types
The generic form field handling has been split into specialized classes (such as Text, Hidden, TextArea, CheckBox, RadioButton, SelectList, and FileUpload) that inherit from a common base. This change improves how different input types are represented and processed, including specific support for keygen tags, image buttons, and multi-select lists, while ensuring fields are sorted by their page appearance before submission.
lib/mechanize/form · high confidence
Refactored page element classes and improved meta-refresh handling
The page parsing logic has been restructured into dedicated classes (Link, Image, Frame, Label, MetaRefresh, Base) with improved attribute access and resolution. Links now support DOM ID/class queries and lazy text population, while images expose MIME types, captions, and download methods. Meta-refresh parsing now correctly handles decimal delays and escapes special URI characters to prevent errors, and frames can be accessed directly via their content.
lib/mechanize/page · high confidence
Updated user-agent aliases to reflect modern browsers
The default user-agent strings for Linux Firefox, Mac Firefox, Windows Chrome, Windows Edge, Android, iPad, and iPhone have been updated to current versions (e.g., Firefox 121, Chrome 120, Edge 120, Safari 17.2). This ensures that websites receiving requests from Mechanize will see realistic, up-to-date browser identifiers, which can affect content delivery, caching, and compatibility checks.
lib · high confidence
Test coverage
Added test document for relative link resolution scenarios; Added test fixture for file URLs with embedded spaces; Added test fixtures for HTML parsing and form handling; Expanded test coverage for Mechanize core components; Refactored test infrastructure into modular WEBrick servlets.
Dependencies
Migrate to Bundler and update dependency specifications
The project has switched from the Hoe build system to Bundler, introducing a Gemfile for development dependencies (minitest, rake, rdoc, rubocop, and optional compression gems brotli and zstd-ruby) while moving runtime dependencies into the mechanize.gemspec. This change updates runtime requirements to addressable \~\> 2.8, mime-types \~\> 3.3, net-http-persistent (\>= 2.5.2, \< 5.0.dev), nokogiri (\>= 1.11.2, \~\> 1.11), and webrick \~\> 1.7, and enforces a minimum Ruby version of 2.6.0.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 61 → 60 (-0.9)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 62 → 59 (-3.2)
- Architecture 90 → 89 (-0.3)
- Maturity 50 → 50 (+0.1)
- Readiness 70 → 70 (+0.0)
- Security 86 → 85 (-1.3)
Resolved (2)
- Off-boarding risk: anonymized user #1
- Orphaned file (lib/mechanize/parser.rb)
New (6)
- Edited copy of a member (28 corresponding lines) (lib/mechanize/test_case/many_cookies_as_string_servlet.rb)
- Edited copy of a member (4 corresponding lines) (lib/mechanize/form/check_box.rb)
- Edited copy of a member (4 corresponding lines) (lib/mechanize/test_case/infinite_refresh_servlet.rb)
- Edited copy of a member (8 corresponding lines) (lib/mechanize/test_case/refresh_with_empty_url.rb)
- Edited copy of a member (9 corresponding lines) (lib/mechanize/download.rb)
- Off-boarding risk: anonymized user #1
Changes since last survey
- 4 commits — 2 feature/other, 2 fixes
By area
- lib/mechanize — 2 commits
- (repo) — 1 commit
- (root) — 1 commit
Notable commits
- fix: fix: FileSaver requires its host directory under the current directory
- fix: fix: savers write only inside their save directory
- change: Merge pull request #678 from sparklemotion/card-857-saver-path-traversal
- change: version bump to v2.14.2
Architecture
- Unchanged — 0 containers · 1 contexts · 0 edges
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
sparklemotion/mechanize was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 14 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 464a5f4ff42c0f55d0c02d8cbfdbd3d18c174727 — the exact code this score is about.
- Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-36d4cd83012f.