Source files for
git clone git://
Log | Files | Refs

20210421_web_shapshot.rst (11826B)

      1 Proving what you link to
      2 ########################
      4 :date: 2021-05-03 14:22
      5 :modified: 2024-06-19 16:21
      6 :category: Archiving
      7 :author: Louis Holbrook
      8 :tags: web,hash,chromium
      9 :slug: web-snapshot
     10 :summary: Generating proof of a web resource when you read and share
     11 :lang: en
     12 :status: published
     15 When we send a link to someone, we are trusting that whoever is behind that link will serve that someone the content we actually saw. Give or take an ad or two.
     17 Also, when we bookmark the link for later retrieval. We are trusting that the entity will be serving that content at any time in the future that you may want it.
     19 This may not be a huge problem if the page is merely a list of `dead baby jokes`_ [6]_. They are objectively funny, of course. But you can also get along without them.
     21 But what of the case of formal, scientific texts we may depend on, and that use citations from the web as part of their source material? Usually, they refer to a source by *link* and *date of retrieval*. This is not of much use unless the actual source and/or render they saw at that time also is available.
     23 That may not always be the case.
     26 Take care of your shelf
     27 =======================
     29         "No worries, the `Wayback Machine`_ has me covered."
     31 Yes. But no. The Wayback Machine is a (thus far) centralized entity that depend on a few idealists and donations to keep going. If they stop to keep going, they depend on passing the buck to someone else. If that someone is evil, they may take it and rewrite history to suit themselves. If that someone else cannot be found, it becomes a garbage collection blip on Bezos' `infrastructure monopoly`_ dashboard. [1]_ 
     33 That aside, sources like Wayback Machine are like libraries. Libraries are, of course, essential. Not only because they serve as one of the pillars of democracy, providing free access to knowledge for everyone. They are also essential because it's simply not very practical for you to pre-emptively own all the books that you may at some point want to read. Let alone ask around in your neighborhood if they happen to have a copy (although a crowd-sourced library app sounds like a fun decentralization project to explore).
     35 You may however want to keep a copy of the books you *depend* on, and the ones you *really like*. Just to make really sure you have it available when you want it. Then, if some New Public Management clowns get the chance to gut public infrastructure where you live, or someone starts a good old-fashioned fascist book burning, you have yourself covered.
     38 A lack of friction
     39 ==================
     41 Yes, stuff may disappear on the web. Just as books may.
     43 On the web that stuff can get *rewritten*. Books may be rewritten, too. [2]_ The previous editions of the books will still exist as independent physical objects until they degrade, as long as something is not actively done to them. But so too with data on storage media. If it is not renewed or copied during that lifetime it may degrade until it becomes illegible. And of course, it may also simply be deleted. And without the smell of smoke at that.
     45 That's the difference that seems to leap out when using this imagery. How  *easy* it is to change and destroy stuff at scale on the web compared with the real world of books. And how inconspicuously it can happen, without *anyone* noticing. And for those who notice, it is very hard to prove what has changed, unless you have a copy. [5]_
     47 So what can we do? Copies and proofs are definitely keywords here. Fortunately, copying is what computers are all about. And making a cryptographical proof of what you see is easy enough these days, too. The tricky bit is to build *credibility* around that proof. But let's stick our head in the sand and start with the easy part and see where it takes us.
     50 Look, no head
     51 =============
     53 ..
     54         .. WARNING::
     56                 Nerdy zone ahead
     58 A good start is to dump the document source to disk, then calculating and storing the sum of it.
     60 In many cases this will be insufficient, though, as many sites populates the DOM through scripts, either in part or in full. As the use-case here is humans voting on what they see is what they get, human aids will be needed. In other words, we need to render the page to store what we actually see.
     62 Printing to PDF from the browser is an option, but that is really difficult to automate. Fortunately, modern browser engines provide command line access to rendering. Since I mostly use `Brave Browser`_ these days, we'll use *headless Chromium* here.
     64 In addition to source, sum and rendering, we should also include a copy of the request headers for good measure.
     66 Thus, we end up with something like this.
     68 .. include:: code/web-snapshot/
     69    :code: bash
     72 What does this mean
     73 ===================
     75 Let's sum up what information we've managed to store with this operation.
     77 - We have a copy of the unrendered source. It may or may not include all the information we want to store.
     78 - We have a fingerprint of that source.
     79 - We have a copy of the headers we were served when retrieving the document. [3]_
     80 - We have a image copy of what we actually saw when visiting the page.
     81 - We have a date and time for retrieval (file attributes).
     83 To link the headers together with the visual copy, we could sum the header file and image file aswell, put those sums together with the content sum in a deterministic order, and calculate the sum of those sums. E.g. [4]_
     85 .. code-block:: bash
     87         $ cp contents.txt.sha256 sums.txt
     88         $ sha256sum headers.txt | awk '{ print $1; }' >> sums.txt
     89         $ sha256sum <pdf file> | awk '{ print $1; }' >> sums.txt
     90         $ sha256sum sums.txt | awk '{ print $1; }' > topsum.txt
     92 If we now sign *this* sum, we are confirming that for this particuar resource:
     94         "This was the source. These were the headers for that source. This is how that source served in that manner looked for **ME** at the time" 
     97 Proving links in this post
     98 ==========================
    100 This post makes use of several external links to articles. So as a final step, let's eat our own dogfood and add proofs for them.
    102 .. list-table:: Article retrieval proofs
    103         :widths: 34 22 22 22 
    104         :header-rows: 1
    106         * - Link
    107           - Content
    108           - Header
    109           - Image
    111         * -
    112           - `0c657ec2 <{filename}misc/web_snapshot/0c657ec25e55e72702b0473f62e6d632dece992485f67c407ed1f748b3f40bc2.txt>`_
    113           - `360125fa <{filename}misc/web_snapshot/360125fa513b8db8380eb2b62c4479164baa5b48d8544b2242bcc7305bad0de4.txt>`_
    114           - `a2584ca0 <{filename}misc/web_snapshot/a2584ca07ba16b15b9fad315a767cbb0c4b7124abdfd578cab2afb4dce9d1971.pdf>`_
    116         * -
    117           - `be8741ff <{filename}misc/web_snapshot/be8741ff91c6e3eac760a3a4652b57f47bce92fa9b617662296c2ab5b3c5fe31.txt>`_ 
    118           - `6c20e767 <{filename}misc/web_snapshot/6c20e7678a0235467687425b9818718ab143fd477afee2087d7f79c933abdc75.txt>`_
    119           - `f1c557b9 <{filename}misc/web_snapshot/f1c557b9555149dde570976ed956ffb17d17b99cea5f2651020f66408dacf301.pdf>`_
    121         * -
    122           - `595a07b8 <{filename}misc/web_snapshot/595a07b85e6b75a41fe0880c8538f15c4b6da5770db230d986efa2e080ca479a.txt>`_
    123           - `f2aa95b4 <{filename}misc/web_snapshot/f2aa95b42c5420cb11ccbf1cb084d5e5ccc3fc6cd575c51e9ee473b9df19c890.txt>`_
    124           - `6a610fa6 <{filename}misc/web_snapshot/6a610fa69d4909cc9aa1dcb7105203cc50c1bcf26733411964f95cbcbdf37eb5.pdf>`_
    126         * -
    127           - `5a806be4 <{filename}misc/web_snapshot/5a806be410da82986a85f68658279234c1a5cf3bb6dc55da137d5274dc722f26.txt>`_
    128           - `078d9fe6 <{filename}misc/web_snapshot/078d9fe6be070de0d378a6e903f8558a7da4917cba5c95ca453ae1936541e4f6.txt>`_
    129           - `2d0f0e69 <{filename}misc/web_snapshot/2d0f0e69e7c8b6ffe9ff8ffc8702a78d6a2d46ab1edd4123e84eb211171d6cde.pdf>`_
    131         * -
    132           - `a8c6b61c <{filename}misc/web_snapshot/a8c6b61cec2cce1a58bcf7a65091a6c2e8510ca5fa17f2d242d286f087d95cd5.txt>`_
    133           - `3ba9094b <{filename}misc/web_snapshot/3ba9094b295a898cfe8cba256f4ebf65ef98ff05bb3034e048e517d52fc13d33.txt>`_
    134           - `eb76a87f <{filename}misc/web_snapshot/eb76a87f224b0e4f4e5d1673b1505aaeee28d8ad03ce544656b6f5ac7c4d9983.pdf>`_
    136 Clicking on the "image" links, we see that thanks to the recent ubiquity of cookie nag boxes screaming "accept all" at you, those very boxes are now blocking the content we want to get at. So we will need more work to get to where we want by automation. But it's s start.
    139 .. _dead baby jokes:
    141 .. _Wayback Machine:
    143 .. _Brave Browser:
    145 .. _headless Chromium:
    147 .. _infrastructure monopoly:
    149 ..
    151         .. [1] Early 2021 survey puts Amazon at one-third of the global market share.
    153 ..
    155         .. [2] 2011 sparked a controversy_ around Astrid Lindgren's Pippi Longstockings. Echoing those viewpoints, the books were edited in 2015 during which some alleged "racist" content was altered. The rabid rightwing media later spun a `false tale of mass purges`_ of Pippi books around one single swedish library's decision to throw out copies of the originial "racist" versions. Case-in-point, a public statement in which the library tries to justify its actions is no longer available on their website, and has to be retrieved by the Wayback Machine. (in swedish)
    157 ..
    159         .. [3] Well actually, not quite. We did the same request twice, but they were two separate requests. Using a single request would improve the script.
    161 ..
    163         .. [4] We use the hex representation for clarity here. A proper tool would convert the hex values to bytes before calculating sum on them.
    165 ..
    167         .. [5] Another important difference is that the book does not need to be *interpreted* by a *machine* in order to make sense for a human. Availability of tooling is definitely an equally important topic in this discussion. However this post limits focus to the actual data itself.
    169 ..
    171         .. [6] How ironic; that site is gone. And I don't have a snapshot. What a shame. I've changed the link to some different baby jokes. The original url was
    173 ..
    174         .. _data availability:
    176 .. _controversy:
    178 ..
    179 <- not available on link, no result on search
    181 .. _false tale of mass purges: