manbytesgnu_site

Source files for manbytesgnu.org
git clone git://holbrook.no/manbytesgnu_site.git
Info | Log | Files | Refs

20210421_web_shapshot.rst (11826B)


      1 Proving what you link to
      2 ########################
      3 
      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
     13 
     14 
     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.
     16 
     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.
     18 
     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.
     20 
     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.
     22 
     23 That may not always be the case.
     24 
     25 
     26 Take care of your shelf
     27 =======================
     28 
     29         "No worries, the `Wayback Machine`_ has me covered."
     30 
     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]_ 
     32 
     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).
     34 
     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.
     36 
     37 
     38 A lack of friction
     39 ==================
     40 
     41 Yes, stuff may disappear on the web. Just as books may.
     42 
     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.
     44 
     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]_
     46 
     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.
     48 
     49 
     50 Look, no head
     51 =============
     52 
     53 ..
     54         .. WARNING::
     55                 
     56                 Nerdy zone ahead
     57 
     58 A good start is to dump the document source to disk, then calculating and storing the sum of it.
     59 
     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.
     61 
     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.
     63 
     64 In addition to source, sum and rendering, we should also include a copy of the request headers for good measure.
     65 
     66 Thus, we end up with something like this.
     67 
     68 .. include:: code/web-snapshot/webshot.sh
     69    :code: bash
     70 
     71 
     72 What does this mean
     73 ===================
     74 
     75 Let's sum up what information we've managed to store with this operation.
     76 
     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).
     82 
     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]_
     84 
     85 .. code-block:: bash
     86 
     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
     91 
     92 If we now sign *this* sum, we are confirming that for this particuar resource:
     93 
     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" 
     95         
     96 
     97 Proving links in this post
     98 ==========================
     99 
    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.
    101 
    102 .. list-table:: Article retrieval proofs
    103         :widths: 34 22 22 22 
    104         :header-rows: 1
    105 
    106         * - Link
    107           - Content
    108           - Header
    109           - Image
    110 
    111         * - https://gizmodo.com/i-tried-to-block-amazon-from-my-life-it-was-impossible-1830565336
    112           - `0c657ec2 <{filename}misc/web_snapshot/0c657ec25e55e72702b0473f62e6d632dece992485f67c407ed1f748b3f40bc2.txt>`_
    113           - `360125fa <{filename}misc/web_snapshot/360125fa513b8db8380eb2b62c4479164baa5b48d8544b2242bcc7305bad0de4.txt>`_
    114           - `a2584ca0 <{filename}misc/web_snapshot/a2584ca07ba16b15b9fad315a767cbb0c4b7124abdfd578cab2afb4dce9d1971.pdf>`_
    115         
    116         * - https://www.thelocal.se/20111109/37244/
    117           - `be8741ff <{filename}misc/web_snapshot/be8741ff91c6e3eac760a3a4652b57f47bce92fa9b617662296c2ab5b3c5fe31.txt>`_ 
    118           - `6c20e767 <{filename}misc/web_snapshot/6c20e7678a0235467687425b9818718ab143fd477afee2087d7f79c933abdc75.txt>`_
    119           - `f1c557b9 <{filename}misc/web_snapshot/f1c557b9555149dde570976ed956ffb17d17b99cea5f2651020f66408dacf301.pdf>`_
    120 
    121         * - https://www.statista.com/chart/18819/worldwide-market-share-of-leading-cloud-infrastructure-service-providers/
    122           - `595a07b8 <{filename}misc/web_snapshot/595a07b85e6b75a41fe0880c8538f15c4b6da5770db230d986efa2e080ca479a.txt>`_
    123           - `f2aa95b4 <{filename}misc/web_snapshot/f2aa95b42c5420cb11ccbf1cb084d5e5ccc3fc6cd575c51e9ee473b9df19c890.txt>`_
    124           - `6a610fa6 <{filename}misc/web_snapshot/6a610fa69d4909cc9aa1dcb7105203cc50c1bcf26733411964f95cbcbdf37eb5.pdf>`_
    125 
    126         * - https://web.archive.org/web/20170710185409/https://www.botkyrka.se/arkiv/nyhetsarkiv/nyheter-startsida/2017-07-10-angaende-uttalanden-av-journalisten-janne-josefsson-om-bibliotek-botkyrka.html
    127           - `5a806be4 <{filename}misc/web_snapshot/5a806be410da82986a85f68658279234c1a5cf3bb6dc55da137d5274dc722f26.txt>`_
    128           - `078d9fe6 <{filename}misc/web_snapshot/078d9fe6be070de0d378a6e903f8558a7da4917cba5c95ca453ae1936541e4f6.txt>`_
    129           - `2d0f0e69 <{filename}misc/web_snapshot/2d0f0e69e7c8b6ffe9ff8ffc8702a78d6a2d46ab1edd4123e84eb211171d6cde.pdf>`_
    130 
    131         * - https://www.breitbart.com/europe/2017/07/19/swedens-libraries-pulp-traditional-children-books-racist-phrases/
    132           - `a8c6b61c <{filename}misc/web_snapshot/a8c6b61cec2cce1a58bcf7a65091a6c2e8510ca5fa17f2d242d286f087d95cd5.txt>`_
    133           - `3ba9094b <{filename}misc/web_snapshot/3ba9094b295a898cfe8cba256f4ebf65ef98ff05bb3034e048e517d52fc13d33.txt>`_
    134           - `eb76a87f <{filename}misc/web_snapshot/eb76a87f224b0e4f4e5d1673b1505aaeee28d8ad03ce544656b6f5ac7c4d9983.pdf>`_
    135 
    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.
    137 
    138 
    139 .. _dead baby jokes: https://thoughtcatalog.com/clint-conway/2016/08/50-of-the-funniest-dead-baby-jokes-of-all-time/
    140 
    141 .. _Wayback Machine: https://archive.org
    142 
    143 .. _Brave Browser: https://brave.com/
    144 
    145 .. _headless Chromium: https://developers.google.com/web/updates/2017/04/headless-chrome
    146 
    147 .. _infrastructure monopoly: https://gizmodo.com/i-tried-to-block-amazon-from-my-life-it-was-impossible-1830565336
    148 
    149 ..
    150 
    151         .. [1] Early 2021 survey puts Amazon at one-third of the global market share. https://www.statista.com/chart/18819/worldwide-market-share-of-leading-cloud-infrastructure-service-providers/
    152 
    153 ..
    154 
    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. https://web.archive.org/web/20170710185409/https://www.botkyrka.se/arkiv/nyhetsarkiv/nyheter-startsida/2017-07-10-angaende-uttalanden-av-journalisten-janne-josefsson-om-bibliotek-botkyrka.html (in swedish)
    156 
    157 ..
    158 
    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.
    160 
    161 ..
    162 
    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.
    164 
    165 ..
    166 
    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.
    168 
    169 ..
    170 
    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 https://dead-baby-joke.com.
    172 
    173 ..
    174         .. _data availability:  https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.433.3480
    175 
    176 .. _controversy: https://www.thelocal.se/20111109/37244/
    177 
    178 ..
    179         https://web.archive.org/web/20170710185409/https://www.botkyrka.se/arkiv/nyhetsarkiv/nyheter-startsida/2017-07-10-angaende-uttalanden-av-journalisten-janne-josefsson-om-bibliotek-botkyrka.html <- not available on link, no result on search https://www.mhpbooks.com/the-trouble-with-pippi/
    180 
    181 .. _false tale of mass purges: https://www.breitbart.com/europe/2017/07/19/swedens-libraries-pulp-traditional-children-books-racist-phrases/