20210421_web_shapshot.rst (11530B)
1 Proving what you link to 2 ######################## 3 4 :date: 2021-05-03 14:22 5 :category: Archiving 6 :author: Louis Holbrook 7 :tags: web,hash,chromium 8 :slug: web-snapshot 9 :summary: Generating proof of a web resource when you read and share 10 :lang: en 11 :status: published 12 13 14 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. 15 16 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. 17 18 This may not be a huge problem if the page is merely a list of `dead baby jokes`_. They are objectively funny, of course. But you can also get along without them. 19 20 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. 21 22 That may not always be the case. 23 24 25 Take care of your shelf 26 ======================= 27 28 "No worries, the `Wayback Machine`_ has me covered." 29 30 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]_ 31 32 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). 33 34 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. 35 36 37 A lack of friction 38 ================== 39 40 Yes, stuff may disappear on the web. Just as books may. 41 42 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. 43 44 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]_ 45 46 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. 47 48 49 Look, no head 50 ============= 51 52 .. 53 .. WARNING:: 54 55 Nerdy zone ahead 56 57 A good start is to dump the document source to disk, then calculating and storing the sum of it. 58 59 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. 60 61 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. 62 63 In addition to source, sum and rendering, we should also include a copy of the request headers for good measure. 64 65 Thus, we end up with something like this. 66 67 .. include:: code/web-snapshot/webshot.sh 68 :code: bash 69 70 71 What does this mean 72 =================== 73 74 Let's sum up what information we've managed to store with this operation. 75 76 - We have a copy of the unrendered source. It may or may not include all the information we want to store. 77 - We have a fingerprint of that source. 78 - We have a copy of the headers we were served when retrieving the document. [3]_ 79 - We have a image copy of what we actually saw when visiting the page. 80 - We have a date and time for retrieval (file attributes). 81 82 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]_ 83 84 .. code-block:: bash 85 86 $ cp contents.txt.sha256 sums.txt 87 $ sha256sum headers.txt | awk '{ print $1; }' >> sums.txt 88 $ sha256sum <pdf file> | awk '{ print $1; }' >> sums.txt 89 $ sha256sum sums.txt | awk '{ print $1; }' > topsum.txt 90 91 If we now sign *this* sum, we are confirming that for this particuar resource: 92 93 "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" 94 95 96 Proving links in this post 97 ========================== 98 99 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. 100 101 .. list-table:: Article retrieval proofs 102 :widths: 34 22 22 22 103 :header-rows: 1 104 105 * - Link 106 - Content 107 - Header 108 - Image 109 110 * - https://gizmodo.com/i-tried-to-block-amazon-from-my-life-it-was-impossible-1830565336 111 - `0c657ec2 <{filename}misc/web_snapshot/0c657ec25e55e72702b0473f62e6d632dece992485f67c407ed1f748b3f40bc2.txt>`_ 112 - `360125fa <{filename}misc/web_snapshot/360125fa513b8db8380eb2b62c4479164baa5b48d8544b2242bcc7305bad0de4.txt>`_ 113 - `a2584ca0 <{filename}misc/web_snapshot/a2584ca07ba16b15b9fad315a767cbb0c4b7124abdfd578cab2afb4dce9d1971.pdf>`_ 114 115 * - https://www.thelocal.se/20111109/37244/ 116 - `be8741ff <{filename}misc/web_snapshot/be8741ff91c6e3eac760a3a4652b57f47bce92fa9b617662296c2ab5b3c5fe31.txt>`_ 117 - `6c20e767 <{filename}misc/web_snapshot/6c20e7678a0235467687425b9818718ab143fd477afee2087d7f79c933abdc75.txt>`_ 118 - `f1c557b9 <{filename}misc/web_snapshot/f1c557b9555149dde570976ed956ffb17d17b99cea5f2651020f66408dacf301.pdf>`_ 119 120 * - https://www.statista.com/chart/18819/worldwide-market-share-of-leading-cloud-infrastructure-service-providers/ 121 - `595a07b8 <{filename}misc/web_snapshot/595a07b85e6b75a41fe0880c8538f15c4b6da5770db230d986efa2e080ca479a.txt>`_ 122 - `f2aa95b4 <{filename}misc/web_snapshot/f2aa95b42c5420cb11ccbf1cb084d5e5ccc3fc6cd575c51e9ee473b9df19c890.txt>`_ 123 - `6a610fa6 <{filename}misc/web_snapshot/6a610fa69d4909cc9aa1dcb7105203cc50c1bcf26733411964f95cbcbdf37eb5.pdf>`_ 124 125 * - 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 126 - `5a806be4 <{filename}misc/web_snapshot/5a806be410da82986a85f68658279234c1a5cf3bb6dc55da137d5274dc722f26.txt>`_ 127 - `078d9fe6 <{filename}misc/web_snapshot/078d9fe6be070de0d378a6e903f8558a7da4917cba5c95ca453ae1936541e4f6.txt>`_ 128 - `2d0f0e69 <{filename}misc/web_snapshot/2d0f0e69e7c8b6ffe9ff8ffc8702a78d6a2d46ab1edd4123e84eb211171d6cde.pdf>`_ 129 130 * - https://www.breitbart.com/europe/2017/07/19/swedens-libraries-pulp-traditional-children-books-racist-phrases/ 131 - `a8c6b61c <{filename}misc/web_snapshot/a8c6b61cec2cce1a58bcf7a65091a6c2e8510ca5fa17f2d242d286f087d95cd5.txt>`_ 132 - `3ba9094b <{filename}misc/web_snapshot/3ba9094b295a898cfe8cba256f4ebf65ef98ff05bb3034e048e517d52fc13d33.txt>`_ 133 - `eb76a87f <{filename}misc/web_snapshot/eb76a87f224b0e4f4e5d1673b1505aaeee28d8ad03ce544656b6f5ac7c4d9983.pdf>`_ 134 135 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. 136 137 138 .. _dead baby jokes: https://dead-baby-joke.com/ 139 140 .. _Wayback Machine: https://archive.org 141 142 .. _Brave Browser: https://brave.com/ 143 144 .. _headless Chromium: https://developers.google.com/web/updates/2017/04/headless-chrome 145 146 .. _infrastructure monopoly: https://gizmodo.com/i-tried-to-block-amazon-from-my-life-it-was-impossible-1830565336 147 148 .. 149 150 .. [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/ 151 152 .. 153 154 .. [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) 155 156 .. 157 158 .. [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. 159 160 .. 161 162 .. [4] We use the hex representation for clarity here. A proper tool would convert the hex values to bytes before calculating sum on them. 163 164 .. 165 166 .. [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. 167 168 .. 169 .. _data availability: https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.433.3480 170 171 .. _controversy: https://www.thelocal.se/20111109/37244/ 172 173 .. 174 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/ 175 176 .. _false tale of mass purges: https://www.breitbart.com/europe/2017/07/19/swedens-libraries-pulp-traditional-children-books-racist-phrases/