<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[plapadoo - Medium]]></title>
        <description><![CDATA[Posting about our journey as a German software company. - Medium]]></description>
        <link>https://medium.com/plapadoo?source=rss----b0b47b46d8ff---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>plapadoo - Medium</title>
            <link>https://medium.com/plapadoo?source=rss----b0b47b46d8ff---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 06:14:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/plapadoo" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automatic Deployment of Docker Containers to AWS EC2 Using GitLab]]></title>
            <link>https://medium.com/plapadoo/automatic-deployment-of-docker-containers-to-aws-ec2-using-gitlab-aaccb824cd08?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/aaccb824cd08</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[game-development]]></category>
            <dc:creator><![CDATA[Kim Rinnewitz]]></dc:creator>
            <pubDate>Mon, 16 Dec 2019 18:01:01 GMT</pubDate>
            <atom:updated>2019-12-16T18:01:01.298Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJqipPSLNW6m0flE2GuzkQ.jpeg" /></figure><p>For our game <a href="https://reaktron.com/"><em>reaktron</em></a>, we are running a <a href="https://medium.com/plapadoo/spawning-game-servers-on-aws-a391ca78e4ee">server infrastructure on AWS</a>. While the actual server for a each match is started on demand, one of the servers, the so-called “Matchmaking Server”, has to be up and running 24/7.</p><p>We decided to use AWS Fargate for the short-lived game servers, but to operate an “always-on” EC2 instance for the matchmaking server, which is much cheaper than just running a Fargate container 24/7.</p><p>This article explains how we utilize GitLab and EC2 to automatically deploy the Matchmaking Server.</p><h4>What the EC2 instance does</h4><p>Since the Matchmaking Server is wrapped in a Docker image, the EC2 instance needs a Docker daemon to run the container. Also, we want to have the latest system updates applied to the EC2 instance. To achieve all of this, we are using the following cloud config which defines what the EC2 instance should do when started:</p><pre>#cloud-config<br>cloud_final_modules:<br>- [scripts-user, always]<br>repo_update: true<br>repo_upgrade: all<br>package_upgrade: true</pre><pre>packages:<br> - docker</pre><p>When the EC2 instance starts up, it will apply the latest system updates and install Docker. The cloud config continues with:</p><pre>runcmd:<br> - sudo mkdir /root/.aws<br> - echo -e &quot;$HOST_MATCHMAKING_CREDENTIALS&quot; | sudo tee /root/.aws/credentials<br> - sudo chown 400 /root/.aws/credentials<br> - sudo systemctl start docker<br> - sudo sh -c &#39;$(aws ecr get-login --no-include-email --region $MATCHMAKING_REGION)&#39;<br> - sudo docker rm -f reaktron-matchmaking-prod || true<br> - sudo docker rmi -f  $HOST_REGISTRY_AWS/reaktron-matchmaking:prod || true<br> - sudo docker run --publish $PORT_PROD:$PORT_PROD/tcp -name=reaktron-matchmaking-prod --env REAKTRON_MATCHMAKING_BIND_PORT=$PORT_PROD --env REAKTRON_STACK=prod --restart=always --detach $HOST_REGISTRY_AWS/reaktron-matchmaking:prod</pre><p>This script performs the main part of the actual deployment. First, it writes AWS credentials into /root. These are necessary to access the Amazon ECR Docker registry which contains the image with the Matchmaking Server. After starting the Docker daemon and logging in to the ECR registry, any old containers and images are removed. Finally, the new container is started.</p><h4>What GitLab does</h4><p>In GitLab, we use GitLab CI to build the Matchmaking Server’s Docker image and push it to the ECR registry. Once this is done, the GitLab CI job restarts the EC2 instance by running the following script:</p><pre>#!/usr/bin/env bash</pre><pre>INSTANCE_ID=`AWS_SHARED_CREDENTIALS_FILE=$CREDENTIALS_RUNNER aws ec2 describe-instances --region $MATCHMAKING_REGION | jq --raw-output &quot;.Reservations[0].Instances[0].InstanceId&quot;`<br>echo &quot;Restarting ec2 instance $INSTANCE_ID&quot;<br>AWS_SHARED_CREDENTIALS_FILE=$CREDENTIALS_RUNNER aws ec2 reboot-instances --instance-ids $INSTANCE_ID --region $MATCHMAKING_REGION</pre><p>As soon as the EC2 instance is fully started, the latest version of the Matchmaking Server is live.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaccb824cd08" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/automatic-deployment-of-docker-containers-to-aws-ec2-using-gitlab-aaccb824cd08">Automatic Deployment of Docker Containers to AWS EC2 Using GitLab</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dispatching using query parameters in react-router]]></title>
            <link>https://medium.com/plapadoo/dispatching-using-query-parameters-in-react-router-b1eabbd2d831?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/b1eabbd2d831</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[plapadoo]]></dc:creator>
            <pubDate>Wed, 25 Sep 2019 17:41:01 GMT</pubDate>
            <atom:updated>2019-10-10T08:56:45.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A2is85DmPRDTogRegCzwVg.jpeg" /></figure><p><a href="https://reacttraining.com/react-router">react-router</a> is the de-facto standard for <em>routing</em> in react.js-based applications. It’s easy to use, has multiple backends and can be used with react native, too. We found one feature lacking, however: you cannot easily route based on a query parameter. For example, this code is easily read and understood¹:</p><pre>function About() {<br>  return &lt;h2&gt;About&lt;/h2&gt;;<br>}</pre><pre>function Users() {<br>  return &lt;h2&gt;Users&lt;/h2&gt;;<br>}</pre><pre>function AppRouter() {<br>  return (<br>    &lt;Router&gt;<br>      &lt;Route path=&quot;/about&quot; component={About} /&gt;<br>      &lt;Route path=&quot;/users&quot; component={Users} /&gt;<br>    &lt;/Router&gt;<br>  );<br>}</pre><p>This way, you can openhttp://localhost:3000/about and get the “About” headline. However, what if your URL looks like http://localhost:3000/index.html?page=about ? You’re out of luck, because the path parameter doesn’t know how to parse query strings.</p><p>Luckily, the solution is pretty simple. You wrap your routes in a route that transforms the location property of the render props. Our AppRouter function then looks like this:</p><pre>function AppRouter() {<br>  return (<br>    &lt;Router&gt;<br>      &lt;Route render={(routeProps) =&gt; (<br>        &lt;Switch location={transformLocation(routeProps.location)}&gt;<br>          &lt;Route path=&quot;/about&quot; component={About} /&gt;<br>          &lt;Route path=&quot;/users&quot; component={Users} /&gt;<br>        &lt;/Switch&gt;)<br>      /&gt;<br>    &lt;/Router&gt;<br>  );<br>}</pre><p>Note that we’re using &lt;Switch&gt; here to have no (accidentally) overlapping routes.</p><p>The transformLocation function might look like this:</p><pre>function transformLocation(inputLocation: Location): Location {<br>  const queryStringParsed = parseQuery(inputLocation.search);<br>  if (queryStringParsed.page === undefined) {<br>    return inputLocation;<br>  }<br>  return {<br>    ...inputLocation,<br>    pathname: &quot;/&quot; + queryStringParsed.page,<br>  };<br>}</pre><p>Here, we are using thequery-string package to parse the query string and extract the page parameter and transform it into a path parameter.</p><p>This solution “works for us”, and allows other query string transformations. If you know of a better, more “native” solution to this problem, please let us know.</p><p>¹ We are omitting imports and exports here for brevity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1eabbd2d831" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/dispatching-using-query-parameters-in-react-router-b1eabbd2d831">Dispatching using query parameters in react-router</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Custom Pylint Check For i18n Keys]]></title>
            <link>https://medium.com/plapadoo/a-custom-pylint-check-for-i18n-keys-1364561a8675?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/1364561a8675</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pylint]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[plapadoo]]></dc:creator>
            <pubDate>Wed, 18 Sep 2019 18:21:01 GMT</pubDate>
            <atom:updated>2019-09-18T18:21:01.365Z</atom:updated>
            <content:encoded><![CDATA[<p>Using a programming language with a dynamic type system is convenient. But convenience comes at a price. As there is no compiler to detect typos and other trivial mistakes, bigger programs written in dynamic languages like Python often suffer from bugs which could be avoided easily by using a strong type system. <a href="https://medium.com/plapadoo/tools-to-manage-large-scale-python-projects-e56b726d775e">To avoid these problems, we are using Python type hints, mypy, Pylint and other tools.</a> This tooling catches most typos and other programming mistakes. However, typos in translation keys won’t get caught.</p><h4>Translate All The Texts</h4><p>For python, <em>gettext</em> seems to be a popular choice when doing translations. gettext is a great choice when managing a lot of translated text. However, since we don’t have a lot of text in <a href="https://reaktron.com/">our small video game <em>reaktron</em></a>, we decided to use a lightweight lib called <a href="https://pypi.org/project/python-i18n/"><em>python-i18n</em></a> there. As most i18n solutions, it works by specifying a key-value-pair in a file which maps from translation keys to translations:</p><pre>{<br>...<br> “quit”: “Terminar”,<br>...<br>}</pre><p>Whenever a text should be loaded in a program, the translation key is specified and the library loads the correct translation for the current language:</p><pre>i18n.t(&quot;ui.quit&quot;)</pre><h4>Typos Screw it up</h4><p>This works perfectly as long as the translation keys you specify in your program are correct. python-i18n can be configured to raise an exception when a translation key does not exist. However, it will only raise at runtime which doesn’t help much since we like to detect our bugs before the user does. Python type hints and the tooling mentioned above don’t catch typos in translations keys because these keys look like regular strings to any tool unaware of python-i18n.</p><h4>Custom Pylint Checks</h4><p>Fortunately, Pylint can easily be extended by custom checks. Here is a check to detect typos in translations keys:</p><p><a href="https://gist.github.com/krinnewitz/8d4581ca32989e20771c300ab07d88f1">https://gist.github.com/krinnewitz/8d4581ca32989e20771c300ab07d88f1</a></p><p>This check can be loaded by adding load-plugins=checks.i18n_check to the .pylintrc file, given the i18n_check.pyfile is placed in a folder called checks. If this check is used, Pylint will validate all occurrences of i18n.t(&quot;my.translationskey&quot;)and show a warning if a translation key does not exist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*EFhYu2t04SxhOzbI945ECg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1364561a8675" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/a-custom-pylint-check-for-i18n-keys-1364561a8675">A Custom Pylint Check For i18n Keys</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tools to manage large-scale Python projects]]></title>
            <link>https://medium.com/plapadoo/tools-to-manage-large-scale-python-projects-e56b726d775e?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/e56b726d775e</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[plapadoo]]></dc:creator>
            <pubDate>Wed, 11 Sep 2019 18:01:03 GMT</pubDate>
            <atom:updated>2019-09-11T18:01:03.089Z</atom:updated>
            <content:encoded><![CDATA[<p>Python is a perfect language for small scripts. In our experience writing <a href="https://reaktron.com/">reaktron</a>, it doesn’t scale that well to bigger programs. In this article, we present the tools we use to ensure your Python code is…</p><ul><li>refactoring-safe: a method rename shouldn’t cause you to manually revisit the whole code base</li><li>easier to understand: in large code-bases, what a method does isn’t always apparent from its name</li><li>easier to maintain with git. We’ll explain that one below.</li></ul><h3>mypy</h3><p>Everyone knows Python is a dynamically typed programming language. Not everyone knows Python actually has the ability to specify and enforce types! <a href="https://mypy-lang.org/">mypy</a> does just that. How does that help? Well, consider:</p><pre>class Foo:<br>  def get_id(self):<br>    return &quot;foo&quot;</pre><pre>foo = Foo()<br>print(foo.get_d() + 3)</pre><p>Note that we have a typo in get_d and we cannot add a string to a number.</p><p>To use mypy, for best results, you have to add types. In the case above, we just have to add a type for the get_id function:</p><pre>class Foo:<br>  def get_id(self) -&gt; str: # note the new type<br>    return &quot;foo&quot;</pre><pre>foo = Foo()<br>foo.get_d() + 3</pre><p>Running mypy on the file gives:</p><pre>&quot;Foo&quot; has no attribute &quot;get_d&quot;; maybe &quot;get_id&quot;?</pre><p>And if we correct the code to</p><pre>foo.get_id() + 3</pre><p>we get:</p><pre>Unsupported operand types for + (&quot;str&quot; and &quot;int&quot;)</pre><p>So there’s lots of trivial bugs to be found this way.</p><h3>pylint</h3><p><a href="https://pylint.org/">pylint</a> is a tool that helps validate your Python code against a myriad of known sources of bugs. For example, say that you forgot to add self to your method:</p><pre>class Foo:<br>  def get_id():<br>    return self.id</pre><p>pylint complains:</p><pre>Method has no argument<br>Method could be a function</pre><p>Or if you misspell the file mode when opening a file:</p><pre>f = open(&quot;test.txt&quot;, &quot;x&quot;)</pre><p>pylint tells you:</p><pre>&quot;x&quot; is not a valid mode for open</pre><h3>black</h3><p>Python uses whitespace for indentation, so the “where do I put the angle brackets” war that other languages fight is not a problem. However, there is still more than one way to format Python. Do you put spaces around operators, as in 1 + 2 + 3 or do you prefer 1+2+3? Where do you break function calls with lots of arguments? Like this?</p><pre>f(1,2,3<br>  4,5)</pre><p>…or like this:</p><pre>f(1,<br>  2,<br>  3,<br>  4<br>  5)</pre><p>To mitigate commits that inadvertently introduce (just?) stylistic changes, we format our source code using <a href="https://github.com/psf/black">black</a> before committing. black isn’t configurable with respect to code style, it just enforces one specific style. This way, we ensure the same style choices everywhere and mitigate commits that inadvertently bring in just stylistic changes.</p><h3>reorder-python-imports</h3><p>There’s an aspect of code style that black doesn’t cover: import statements. And when you have a Python project with more than one git branch, these statements are a nightmare. Consider a statement like:</p><pre>from typing import Optional</pre><p>If two people on different branches add something to that, say:</p><pre># branch a<br>from typing import Optional, List<br># branch b<br>from typing import List, Optional</pre><p>That’s a completely unnecessary merge conflict coming up!</p><p><a href="https://github.com/asottile/reorder_python_imports">reorder-python-imports</a> solves this with a few tricks:</p><ul><li>expanding imports so there is one import for each class/function/… (in other words, there are no commas in an import line)</li><li>sorting imports</li><li>removing duplicates</li></ul><p>This has the disadvantage of adding more lines of code at the top of the file, but it solves many of the problems you encounter using imports on many branches.</p><h3>Miscellaneous</h3><p>Besides that, we have a few helper scripts which alleviate some minor problems, notably:</p><ul><li>a script to check if somebody used breakpoint or ipdb.set_trace()</li><li>a script to check if every directory has an __init__ file</li></ul><h3>Conclusion</h3><p>When starting the project, we actually had <em>none</em> of these tools installed. We added them one by one because we noticed certain problems (like said merge conflicts in import statements). Writing this, we hope to give you a better starting point than we had with Python and large projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e56b726d775e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/tools-to-manage-large-scale-python-projects-e56b726d775e">Tools to manage large-scale Python projects</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What it Takes to Release Your Game on Steam]]></title>
            <link>https://medium.com/plapadoo/what-it-takes-to-release-your-game-on-steam-adb32a1bd6fc?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/adb32a1bd6fc</guid>
            <category><![CDATA[indie-game]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[steam]]></category>
            <category><![CDATA[videogames]]></category>
            <dc:creator><![CDATA[Michael Stypa]]></dc:creator>
            <pubDate>Wed, 04 Sep 2019 18:21:02 GMT</pubDate>
            <atom:updated>2019-09-04T18:21:02.732Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*othyclrLKQhroGBKfDQmfw.png" /></figure><p>While creating reaktron (<a href="https://reaktron.com/">https://reaktron.com</a> — a snaker game on powerups), we not only had to think about how to implement the game, but also where to publish it. In the end, we decided to go with Steam. This article is about the steps we had to take until we could sell our game on Steam.</p><h3>Signing up</h3><p>The first thing we did was creating a Steam partner account (<a href="https://partner.steamgames.com/">https://partner.steamgames.com/</a>). This involves some paper work because US authorities require you to provide a lot of information. Also, some NDAs with Valve have to be accepted. Once this is done, you get access to the Steam partner portal which provides four important functionalities:</p><ol><li>Steam SDK releases</li><li>Steam SDK documentation</li><li>A portal to configure your app</li><li>A portal to create your shop site</li></ol><h3>Integrating The Steam SDK</h3><p>The Steam SDK is a well-documented C++ library. It comes with an example game and there are (unofficial) bindings for many programming languages. Since our game is written in Python, we tried out unofficial Python bindings. Since we didn’t like these, we created our own Python bindings which we may release as open source at some point in the future. It is important to note, that the Steam SDK provides a lot of general purpose functionality that you can use instead of creating your own solutions. E.g. you can use the Steam SDK to send and receive network packages instead of utilizing low-level socket networking yourself. Also, there are solutions for matchmaking, lobby communication and much more. Therefore you should start integrating the Steam SDK at an early stage of your development to avoid writing code which may be provided by the SDK.</p><blockquote>Hint for Linux users: for the Steam Overlay to work with your app, you have to set LD_PRELOAD=”$HOME/.local/share/Steam/ubuntu12_64/gameoverlayrenderer.so” when launching from outside Steam. However, you should <strong>not</strong> export this variable since it will break various applications in your terminal in a very subtly way.</blockquote><h3>Configuring Your Steam App</h3><p>To actually run your app after you have integrated the Steam SDK, you need a Steam “app id”. An app id will be assigned once you have created and configured a new app using the Steam partner portal. You will have to provide some graphical assets, texts, paths to executables, and more. After uploading your game, it will be available on Steam (only to your developers) and can be tested. Read about how to automate the deployment to Steam. A pitfall can be that you have to edit various places in the Steam partner portal when adding a new platform. If you encounter problems like your game being zero bytes of download size in the Steam Library or Steam not being able to launch your game, you most likely missed one of the places to configure inside the Steam partner portal.</p><h3>Creating The Store Page</h3><p>For your store page, you have to provide numerous graphical assets and texts. Also, to us it looked like a trailer video is mandatory. We also marked our game as “Early Access” which required us to write additional explanations about what to expect in the “Early Access” version of the game and for how long the Early Access phase should roughly last. You should also think about which price label to put on your game and whether you want to grant a release discount or not. We also noticed, that it is not possible to include external links within your store page texts as these get stripped out.</p><h3>Publishing The Game</h3><p>Before your app can be released to the public, it has to pass an official review by Valve. Also, your shop site will be reviewed before it can go live. To us, the review process was valuable. Not only did the reviewer bring up important issues, but he also gave some recommendations for improvements. The review was started quickly, seemed to be done thoroughly, and findings were well-documented (thanks, Tony!). After a few iterations, our app passed the review and we could put the game into the “coming soon” state and set a release date. This release date has to be at least two weeks in the future, so the “coming soon” state has to last at least two weeks. Once, these two weeks have passed, you can release your game at any time. During the two “coming soon” weeks, you can edit your store page and deploy new versions of your game without any problem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adb32a1bd6fc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/what-it-takes-to-release-your-game-on-steam-adb32a1bd6fc">What it Takes to Release Your Game on Steam</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying to Steam using GitLab]]></title>
            <link>https://medium.com/plapadoo/deploying-to-steam-using-gitlab-2fea0149fdaf?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/2fea0149fdaf</guid>
            <category><![CDATA[videogames]]></category>
            <category><![CDATA[ci]]></category>
            <category><![CDATA[steam]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Michael Stypa]]></dc:creator>
            <pubDate>Wed, 28 Aug 2019 18:26:14 GMT</pubDate>
            <atom:updated>2019-08-28T18:26:13.940Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_X-yF-TyrXEOAHao-JwYRg.png" /></figure><p>While developing reaktron (<a href="https://reaktron.com/">https://reaktron.com</a> — a snaker game on powerups) <a href="https://plapadoo.com/">we </a>made use of a git branching model with master, develop and feature branches. This way, all team members can work collaboratively and in parallel. Additionally we wanted to be able to test fixes and new features against the production infrastructure (you can read more about how we run reaktron game servers <a href="https://link.medium.com/ZFoCtERVsZ">here</a>). Steam gives you the ability to run multiple “betas” of your software. Let’s call them steam branches for now. Inside the steam client, you can select which steam branch you want to install from. This allows us to map our git branches to steam branches. Within <em>GitLab CI</em> we automated the deployment of different versions (master, develop) to steam.</p><figure><img alt="reaktron Gitlab CI pipeline" src="https://cdn-images-1.medium.com/max/1024/1*g1lL6q7aFDGzUVw3BmxIQg.png" /><figcaption>reaktron GitLab CI pipeline for branch develop</figcaption></figure><h3>A multiplatform video game</h3><p>As reaktron is available on Windows, macOS and Linux we need to build a steam package for each platform. Luckily <em>GitLab Runner</em> is available on all three. You will have to invest a good amount of time setting up the necessary dependencies on each platform. We suggest you write all helper scripts in bash. This way you can reuse the scripts and keep things consistent.</p><p>To publish a steam package you need to upload it to the <em>SteamPipe Content System</em>. There is a <a href="https://www.youtube.com/watch?v=SoNH-v6aU9Q">basic tutorial video</a> created by Valve on how to do this. We wrote a script to configure a template depot config for each package of the game. This way we can adjust the package configuration via <em>GitLab CI</em> <a href="https://docs.gitlab.com/ce/ci/variables/">environment variables</a>. When you upload your steam package you can tell steam to publish the new package immediately (as long as its not the steam default branch).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08Oy78NmhfeBdVZd8OqE4Q.png" /><figcaption>reaktron stem content builder config</figcaption></figure><blockquote>Tip: If you test a newly rolled out version make sure to select the wanted steam branch and restart your steam client. Restarting the steam client forces it to fetch the newest package versions. Otherwise you have to wait for the client to run into its timeout to fetch the new package information.</blockquote><p>Automating this process saves a lot of time as packaging and uploading by hand is a mundane and time consuming process. By using CI/CD we can deploy a new development version by merging into the git develop branch. Using scripts we can automatically configure the builds to use different servers and start the game with or without debug parameters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fea0149fdaf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/deploying-to-steam-using-gitlab-2fea0149fdaf">Deploying to Steam using GitLab</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spawning Game Servers on AWS]]></title>
            <link>https://medium.com/plapadoo/spawning-game-servers-on-aws-a391ca78e4ee?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/a391ca78e4ee</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[aws-fargate]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[aws-ecs]]></category>
            <dc:creator><![CDATA[Kim Rinnewitz]]></dc:creator>
            <pubDate>Thu, 15 Aug 2019 18:21:07 GMT</pubDate>
            <atom:updated>2019-08-15T18:21:05.814Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7XhWb1mN-4Y3224DmV7yEQ.jpeg" /></figure><p>To us, the most interesting thing about game development is that you have to master many different disciplines of software engineering. E.g. when developing a multiplayer online game, you not only have to think about how you write your net code, but also how to match your players and how to make your servers available all over the world at low latency. <strong>We used AWS to create a global on-demand server infrastructure for our game</strong> called <a href="https://reaktron.com/"><em>reaktron</em></a>.</p><h3>Matching Slow - Playing Fast</h3><p>For reaktron, we are running a matchmaking server which is queried by players to find adversaries to play against. When this server receives a request, it matches players to form a group of regionally close players and starts an instance of the actual game server which is then used by the matched group to play on. This is illustrated in the following picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6uB7WXmWRadScwRCJiPdCg.png" /><figcaption>Matchmaking</figcaption></figure><ol><li>Players contact the matchmaking server to find them a game.</li><li>The matchmaking server matches the players to groups and spawns a game server for each group in their region.</li><li>The matchmaking server waits for the game server to be started and returns the IP and port to the players.</li><li>The groups connect to their servers.</li></ol><p>So, while the matchmaking server needs to be running 24 hours a day, 7 days a week, the game server instances are only started on demand. When a game ends, the game server instance shuts itself down. Also, latency with the game server instances is critical for the in-game experience while high latency during matchmaking won’t be noticed. This means game servers have to run regional, matchmaking servers can run anywhere.</p><h3>Cloud Hosted Game Servers</h3><p>By hosting our game servers with AWS, we achieve three things:</p><ol><li>Deploy a world-wide, scalable, low-latency infrastructure without renting servers from different providers all over the world</li><li>Don’t administer hundreds of servers</li><li>Only pay when someone plays our game</li></ol><p>Since the <em>matchmaking</em> server can run anywhere, we will focus on how to get the <em>game</em> server running on AWS.</p><p>To run the game server Docker images, we opted in for <em>AWS Elastic Compute Cloud (ECS)</em> using <em>Fargate</em>. ECS is Amazon’s solution to run Docker containers. Fargate is a special agent to start and stop the containers, which comes with some pros and cons:</p><ul><li>Fargate is not available in every AWS region (but in many)</li><li>With Fargate, you avoid running your own Docker daemon on an AWS EC2 instance (this is a big advantage since the EC2 instance would have to run 24/7)</li><li>You cannot use <em>AWS Elastic Block Storage (EBS)</em> when running your containers using Fargate</li></ul><p>Our idea was to use the AWS SDK within the matchmaking server to dynamically start instances of the game server with ECS/Fargate. To be able to do this, we first had to set some things up:</p><ul><li>For each region, we created an ECS cluster to run the containers</li><li>We wrote an ECS task definition for Fargate to know how to start the containers</li><li>We built the Docker image of our game server and pushed it into an <em>AWS Elastic Container Registry (ECR)</em></li></ul><p><em>Hint: It is advisable to use AWS Cloud Formation to set these things up. This way, you can automate creating uniform stacks in different regions.</em></p><p>After implementing and running our first version of the container-spawning matchmaking server, we noticed that starting the game servers took too long. We could not let our players wait two minutes for their match to start. Looking into it, we found two main reasons:</p><ol><li>Since our game is Steam-based, the game server instances had to run a Steam update on startup which took about 40 seconds. Updating Steam on each launch is necessary because the game server instances don’t get re-used.</li><li>It took Fargate a long time to receive our Docker Image from the registry before it could go ahead and start the container.</li></ol><h3>Optimizing Fargate Container Starting Times</h3><p>To address the latter, we first stripped down our game server Docker image as much as possible. Second, we decided to use <em>regional</em> ECRs instead of just one ECR. So when the matchmaking server starts a game server in London, Fargate now also pulls the docker image from a London-based ECR instead of the central international one which speeds up things quite a bit.</p><p>To solve the problem with the slow steam update, we created <em>AWS Simple Storage Service (S3)</em> Buckets in all regions and built a simple service which, when started, updates steam, pushes the updated files to all of the S3 buckets and then shuts itself down. We dockerized this service as well and configured Fargate to run it once a day. We then updated the game servers to download the steam files from the S3 bucket in their region instead of running a steam update themselves. This brought the actual game server starting time down from 40 to about 3 seconds. However, there will be some Fargate overhead you cannot get rid of.</p><p>We ended up with Fargate taking about 30 seconds to start our game servers, which is acceptable. This time varies a bit, depending on whether the cluster is “hot” or “cold” when starting a container.</p><h3>Saving Data From Short-Lived Container Instances</h3><p>As our game servers store the played levels, we created another S3 bucket to which the game servers upload their data when a match has ended. Since this is not time-critical anymore, a shared global S3 bucket can be used, as opposed to the regional buckets which have to be used to download the steam files when the game server starts up. It would be preferable to use an EBS volume instead of all these S3 buckets, but since that is not supported by Fargate at the time of writing, we have to fall back to S3.</p><h3>Low Latency, Low Cost, Low Maintenance</h3><p>Our takeaway is that you can dynamically spawn game server instances using AWS ECS Fargate as long as your game server is not too large. Our game server docker image is about 70 MB in size. One can and should use AWS Cloud Formation to describe and roll-out the server landscape in different regions. We are happy with the latency of the game servers and we only pay for the time users play our game. Also, we don’t have to maintain our own docker daemons or clusters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a391ca78e4ee" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/spawning-game-servers-on-aws-a391ca78e4ee">Spawning Game Servers on AWS</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Nix and CI for great good!]]></title>
            <link>https://medium.com/plapadoo/using-nix-and-ci-for-great-good-8a9162fed313?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/8a9162fed313</guid>
            <category><![CDATA[nix]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nixos]]></category>
            <dc:creator><![CDATA[plapadoo]]></dc:creator>
            <pubDate>Sat, 14 Jul 2018 19:01:02 GMT</pubDate>
            <atom:updated>2018-07-14T19:01:01.978Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z0frf_CS7ZROmA7l9qnbRw.jpeg" /></figure><p>Like most modern software companies, we use continuous integration (CI) to build, test and deploy our software after we make changes to our code base. Naturally, this requires a build server that has all the build and test dependencies instOalled. The problem: there are vastly different requirements for building and testing software. C/C++ needs a compiler like gcc, Java needs at least a JDK, but more often than not a build tool like <a href="https://maven.apache.org/">Maven</a>. LaTeX needs something like <a href="https://www.tug.org/texlive/">Texlive</a>, and so on.</p><p>Moreover, what you should strive for are <em>reproducible builds</em>. No matter what date, server setup or, say, internet availability, your build should always produce the same results.</p><h3>Possible solutions</h3><h4>Use your distribution</h4><p>If your CI system provides this, you can trigger the CI build process directly on your build server as a normal user (for example, by registering a shell runner in Gitlab CI). This way, you install all the build dependencies using the package manager (e.g. apt-get, dnf, pacman) of your distribution. This solution has a few pros and cons.</p><p><strong>Pro</strong>: You know what you’re doing. The distribution on your server is something you’re familiar with. Don’t underestimate this.</p><p><strong>Pro</strong>: Building and installing packages for your server distribution is simple, as the tools are readily available (for instance, makepkg on Arch).</p><p><strong>Pro</strong>: Deploying software might be simple, as you can scp to other servers or even copy results on the machine you’re running on without further adjustment.</p><p><strong>Con</strong>: Unless you’re giving the CI user root privileges, you’re not able to install the necessary dependencies inside your source code repository. You have to take care of installing the right software before the CI server starts building it (and you have to uninstall software that’s no longer needed by any project).</p><p><strong>Con</strong>: Keeping the build reproducible is harder to achieve, since you’re a good administrator and keep on updating the software on your servers. Different versions of your build tools might change the outcome of your build.</p><p><strong>Con</strong>: In the same vein, reproducing the CI build locally requires that you install the exact same software packages on your developer machine. If you have a different distribution on your local machine than your server has, this is pretty difficult. Also, it might be difficult to install multiple versions of the same package on the same machine. Think about a project that needs an older version of the build system, and a different project that needs the latest one. Not all distributions/packages support parallel installs.</p><h4>Use Docker</h4><p>Some CI systems like Gitlab CI or Travis support specifying a Docker image that’s used for building and testing your software. Again, here are the pros/cons of doing that.</p><p><strong>Pro</strong>: The build and test dependencies are all installed in the Docker image and thus have a version that’s independent of the server environment you’re running Docker from. Also, Docker provides network and file-system isolation. This is helpful towards reproducible builds.</p><p><strong>Pro</strong>: Building the software on your local machine is also relatively easy, as you can use the same Docker image locally.</p><p><strong>Pro</strong>: Multiple versions of the same package are possible.</p><p><strong>Con</strong>: You need a Docker file that has all the necessary dependencies preinstalled. For some build environments, a Docker image is available on Docker Hub. For others, it’s not, and you have to write the Dockerfile yourself and possibly create a local Docker repository to store the finished image. This is something you have to learn.</p><p><strong>Con</strong>: Deploying software might be harder from inside Docker. For this, you have to either setup an SSH user inside the container (which you might not have created yourself), or mount a directory (or volume) on the host to the container. This might depend on the CI software in use, of course.</p><h3>Enter Nix</h3><p>There is a third solution: <a href="https://nixos.org/nix">Nix</a>¹. Before we get to the pros and cons, let me explain what it is.</p><p>Nix is a package manager, just like dnf, pacman, or apt-get. Unlike those, it’s not bound to a specific distribution². You can install Nix on your machine right now and have two package managers installed! But why would you?</p><p>Nix has a lot of cools things in store, but for the sake of this article, I’m going to focus on one feature: with Nix, you can install packages as a normal, unprivileged user. Usually, this would be dangerous. What if a malicious user installs a malicious version of Firefox on your system which sniffs all the passwords you enter? But when you install software with Nix, it’s more like you download the Firefox sources, compile it yourself, and then add your compiled Firefox to PATH. In other words, other users don’t see “your” Firefox version. And actually, that’s close to what really happens³.</p><p>Before we get to actually using it, let’s look at configuring Nix in Gitlab CI and Travis.</p><h4>Nix in Gitlab CI</h4><p>There are two ways to use Nix from Gitlab CI.</p><ol><li>You configure a Docker runner for your project and can then specify a Docker image to use for the CI build using the image directive in your .gitlab-ci.yml file.</li><li>You configure a shell runner. This will execute the build commands in a normal shell on the machine where you installed gitlab-runner.</li></ol><p>If you opt for Docker to build your project (or you’re using Gitlab hosted at gitlab.com), you have to tell it to use a Docker image containing Nix. There an official image available at <a href="https://hub.docker.com/r/nixos/nix/">Docker Hub</a>, so this suffices:</p><pre>image: nixos/nix:latest</pre><p>If you opt for a shell runner, you have to install Nix either globally, or just for the gitlab-runner user. A multi-user install is best done with the corresponding distribution package. A single-user install consists of executing a one-liner and following the instructions. Follow “Get Nix” <a href="https://nixos.org/nix/">here</a>.</p><h4>Nix in Travis</h4><p>With Travis, it’s even simpler, since Travis has Nix support out of the box. All you have to do is add the following to your .travis.yml:</p><pre>language: nix</pre><h4>Using Nix</h4><p>Let’s say the instructions to build your software are contained in a small bash script build.shin your source repository. To start build.sh with the necessary dependencies installed, you can use nix-shell. If you’re building a Java project, for example, you can request a shell with a JDK and Maven installed using⁴: nix-shell -p jdk maven. If you execute this, you get an interactive shell with those two packages in your PATH. Using…</p><pre>nix-shell -p jdk maven --run ./build.sh</pre><p>…you can execute build.sh directly.</p><p>Ok, but what about reproducible builds? Isn’t this just as susceptible to updates breaking the build as the previous approaches? If you’re doing just what I just described, that’s true. But with a little extra effort, we can do better.</p><p>When you install Nix, you typically set a “channel” to take packages from. You can think of a channel as a specific commit in package repository. When you run nix-shell -p jdk, Nix will (hypothetically)…</p><ul><li>clone the repository defined in the currently active channel,</li><li>checkout the commit defined by the current channel,</li><li>find the build instructions for jdk in the cloned repository,</li><li>build jdk and all its dependencies transitively⁵.</li></ul><p>So if you <em>pin</em> (or <em>freeze</em>) the channel in your CI script, your build does not depend on any external library that might get updated or changed. To do that, you can, for example, set the environment variable NIX_PATH to a specific commit, as such:</p><pre>export NIX_PATH=&quot;nixpkgs=<a href="https://github.com/NixOS/nixpkgs/archive/ab593d46dc38b9f0f23964120912138c77fa9af4.tar.gz">https://github.com/NixOS/nixpkgs/archive/ab593d46dc38b9f0f23964120912138c77fa9af4.tar.gz</a>&quot; <br>nix-shell -p jdk maven --run build.sh</pre><p>This not only pins the version of jdk and maven, but of all their dependencies, too. At our company, we’ve set up a <a href="https://docs.gitlab.com/ee/ci/variables/">CI Variable</a> in Gitlab CI set to the contents of NIX_PATH, so we can easily update the software needed for the build.</p><h3>The verdict</h3><p>So, just as before, what are the pros and cons of Nix:</p><p><strong>Pro</strong>: You can encode the dependencies your software needs inside your source repository and thus tie them together more tightly.</p><p><strong>Pro</strong>: Reproducible builds are as easy as with Docker.</p><p><strong>Pro</strong>: You can build your software the exact same way your CI does by installing Nix on your local machine and just running the build commands yourself.</p><p><strong>Pro</strong>: Nix’s “nixpkgs” software repository is plentiful. You can check if your build and tests tools are available <a href="https://nixos.org/nixos/packages.html">here</a>, but probably, they are. There’s around 42,000 packages in there at the time of writing.</p><p><strong>Pro</strong>: Nix is easily integrated with at least two major CI systems, as we’ve shown.</p><p><strong>Con</strong>: Nix is, just as Docker, something you have to learn.</p><p><strong>Con</strong>: nix-shell will download and provide the software you ask from it. But it will not clean up after you’re done. This is nice, because using nix-shell with the same packages again will not re-download anything. But it also means you hold a cache somewhere that gets bigger over time. You have to take care of that (for example, by regularly calling nix-collect-garbage).</p><p>I hope I could convince you to at least give Nix a try. We’ve been using it with Gitlab CI for a year now, and we’re really happy so far. And I hope the hardcore Nixers aren’t disappointed to find no mention of nix-build and the Nix language here. This is the topic of another article.</p><p>If you’re interested in learning Nix, I recommend the excellent <a href="https://nixos.org/nixos/nix-pills">Nix Pills</a> series, as well as the <a href="https://nixos.org/nix/manual/">Nix manual</a> (describing the package manager) and the <a href="https://nixos.org/nixpkgs/manual/">nixpkgs manual</a> (describing the package infrastructure).</p><p>¹ Since we’re German, you usually get a light chuckle when you mention it since “nix” colloquially means “nothing”.</p><p>² Although a distribution, <a href="https://nixos.org/">NixOS</a>, exists.</p><p>³ Though luckily, Nix has caching mechanisms mostly preventing the tedious manual compilation.</p><p>⁴ In case you’re wondering, this will install OpenJDK. You can request oraclejdk if you want Oracle’s JDK.</p><p>⁵ Again, there are caches involved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a9162fed313" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/using-nix-and-ci-for-great-good-8a9162fed313">Using Nix and CI for great good!</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Syncing JIRA work logs with ledger]]></title>
            <link>https://medium.com/plapadoo/syncing-jira-work-logs-with-ledger-5f0708211b52?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/5f0708211b52</guid>
            <category><![CDATA[jira]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[ledger]]></category>
            <dc:creator><![CDATA[plapadoo]]></dc:creator>
            <pubDate>Sun, 20 May 2018 20:42:41 GMT</pubDate>
            <atom:updated>2018-05-20T20:42:40.758Z</atom:updated>
            <content:encoded><![CDATA[<h4>And yes, you can create work logs with ledger, too!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4zPp7tSoMSnucAGjCHmoKA.jpeg" /></figure><p>When doing contract work, it’s important to properly clock your work (which is the act of measuring how much time you spend and on what). This might be important for your own projects, too, if you want to track where time is wasted, for example. At plapadoo, we strive for solutions that involve open, plain-text (electronic) formats. You know, stuff you can put into a git repository and do diffs, blame people, use your Linux tools on, etc.…</p><p>If you’re into the aforementioned open, libre evangelism, you might know ledger, which is usually mentioned when talking about plain text accounting and book-keeping. And we’re using ledger for that as well. But really, if you replace “$” or “€” with “hours”, you can do “time-accounting” in ledger, too. In that sense, time is (semantically equivalent to) money. And ledger fulfills the criteria mentioned above: it’s an open plain-text format, and it’s pretty easy to read by humans, too:</p><pre>2018-04-29 socialmedia  ; Medium article about ledger clocking<br> NonProgramming:usage:SocialMedia:Medium  2.0h  ; :Philipp:<br> NonProgramming:quota:SocialMedia</pre><p>However, your customer might use different tools, and might expect different work logs from you. In our case, we have a customer using JIRA. The experience with JIRA has been pretty smooth thus far, and JIRA does have “work logs” attached to tickets as well. However, to keep all our work logs consistent, no matter what the customer expects, we had to double-book into ledger and JIRA. And as you might imagine, we made mistakes synchronizing these two tools by hand — lots of mistakes.</p><p>So, being the “dev-ops” we are, we automated! We wrote “<a href="https://github.com/plapadoo/ledger-jira-sync">ledger-jira-sync</a>”, a tool that takes the following inputs:</p><ul><li>your ledger work logs</li><li>a file that links each work log account to a JIRA ticket</li><li>your JIRA login information (including the JIRA URL)</li><li>your name (which you have to attach to the ledger accounts by means of a tag)</li></ul><p>and does the following¹:</p><ul><li>determines all the work you clocked into ledger</li><li>determines all the work you clocked into JIRA</li><li>deletes every work log item in JIRA not present in ledger</li><li>adds all work log items to JIRA present in ledger</li></ul><p>This way, we constructed a unidirectional ledger → JIRA sync, meaning the ledger file will be the “ground truth”. The program is available for every platform supporting python 3 and ledger. Feel free to experiment and let us know if it works (or doesn’t work) for you.</p><p>¹ Don’t worry, the program first tells you what it’ll do and give you the option to cancel.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f0708211b52" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/syncing-jira-work-logs-with-ledger-5f0708211b52">Syncing JIRA work logs with ledger</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Patching Your Thinkpad T460/T470 Against Meltdown, Spectre, ROCA, and IME Vulnerabilities]]></title>
            <link>https://medium.com/plapadoo/patching-your-thinkpad-t460-t470-against-meltdown-spectre-roca-and-ime-vulnerabilities-c9bc4040343c?source=rss----b0b47b46d8ff---4</link>
            <guid isPermaLink="false">https://medium.com/p/c9bc4040343c</guid>
            <category><![CDATA[respect]]></category>
            <category><![CDATA[thinkpad]]></category>
            <category><![CDATA[roca]]></category>
            <category><![CDATA[meltdown]]></category>
            <category><![CDATA[intel-management-engine]]></category>
            <dc:creator><![CDATA[Michael Stypa]]></dc:creator>
            <pubDate>Sun, 15 Apr 2018 12:50:48 GMT</pubDate>
            <atom:updated>2018-04-15T12:50:47.814Z</atom:updated>
            <content:encoded><![CDATA[<h4>A Guide For Linux Users</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xi8s5ePoSYWMVSRBptyqVg.jpeg" /><figcaption>The Intel Management Engine’s BIOS default password is “admin”.</figcaption></figure><p>Patches for Meltdown and Spectre seem to be readily available from most vendors at this point. Additionally the whole chaos around Intel’s Management Engine (IME) bugs has calmed down. This should be a good time to patch everything up. The fixes seem to be stable enough to roll out and we did just that at <a href="https://plapadoo.com/">plapadoo</a>. Here, we present our findings to help others get a quick overview what has to be done.</p><p><strong><em>Note: We have only tested with Thinkpads of the T460 and T470 series, but this article should also be applicable to other models of Lenovo’s T-series.</em></strong></p><p><strong><em>Note: Even though this article aims at linux users, you will still need windows to install some security patches.</em></strong></p><h3>Intel Management Engine Firmware Update</h3><h4>The situation</h4><p><a href="https://security-center.intel.com/advisory.aspx?intelid=intel-sa-00075&amp;languageid=en-fr">Intel’s Security Advisory</a> describes a privilege escalation in their Management Engine that is implemented in a wide range of products (<strong>INTEL-SA-00075</strong>). The escalation can be performed locally or remotely.</p><p>There is a <a href="https://security-center.intel.com/advisory.aspx?intelid=intel-sa-00086&amp;languageid=en-fr">separate advisory page</a> (<strong>INTEL-SA-00086</strong>) dedicated to followup patches fixing additional security holes in the IME.</p><p>While you <em>can</em> use Linux to check if your IME firmware is vulnerable to<br>SA-00075, or SA-00086, <strong>you will need Windows to update the firmware</strong> and actually fix the vulnerabilities.</p><h4>Checking if you are vulnerable</h4><p>You can use Intel’s <strong>detection tools </strong>for <a href="https://github.com/intel/INTEL-SA-00075-Linux-Detection-And-Mitigation-Tools">SA-00075</a> and <a href="https://downloadcenter.intel.com/download/27150?v=t">SA-00086</a> to check if your system is vulnerable to these security issues. To do so, you will need python2 (only for SA-00086 detection tool) and root access. Also, your kernel has to have <strong>CONFIG_INTEL_MEI</strong> and <strong>CONFIG_INTEL_MEI_ME</strong> enabled. If this is the case, you should have a device called <strong>/dev/mei0</strong>.</p><p>You can run the SA-00075 detection tool like this:</p><pre>cd /tmp &amp;&amp; git clone https://github.com/intel/INTEL-SA-00075-Linux-Detection-And-Mitigation-Tools SA-00075 &amp;&amp; cd SA-00075 &amp;&amp; make &amp;&amp; sudo ./INTEL-SA-00075-Discovery-Tool</pre><p>It will print something like the following in case you are vulnerable:</p><pre> — — — — — — — — — Vulnerability Status — — — — — — — — — — <br>Based on the version of the Intel(R) MEI, the System is Vulnerable.<br>If Vulnerable, contact your OEM for support and remediation of this system.<br>For more information, refer to CVE-2017–5689 at:<br><a href="https://nvd.nist.gov/vuln/detail/CVE-2017-5689">https://nvd.nist.gov/vuln/detail/CVE-2017-5689</a> or the Intel security advisory<br>Intel-SA-00075 at:<br><a href="https://security-center.intel.com/advisory.aspx?intelid=INTEL-SA-00075&amp;languageid=en-fr">https://security-center.intel.com/advisory.aspx?intelid=INTEL-SA-00075&amp;languageid=en-fr</a><br> — — — — — — — — — — — — — — — — — — — — — — — — — — — — — </pre><p>The following will be printed if your system is already patched:</p><pre>— — — — — — — — — Vulnerability Status — — — — — — — — — — <br>System is not Vulnerable, no further action needed.<br>— — — — — — — — — — — — — — — — — — — — — — — — — — — — —</pre><p>To run the SA-00086 detection tool, you can use the following command:</p><pre>cd /tmp &amp;&amp; curl -fsSL <a href="https://downloadmirror.intel.com/27150/eng/SA00086_Linux.tar.gz">https://downloadmirror.intel.com/27150/eng/SA00086_Linux.tar.gz</a> | tar -xz &amp;&amp; sudo python2 intel_sa00086.py</pre><p>It will print something like the following in case you are vulnerable:</p><pre>*** Risk Assessment ***<br>Based on the analysis performed by this tool: This system is vulnerable.<br>Explanation:<br>The detected version of the Intel(R) Management Engine firmware<br>  is considered vulnerable for INTEL-SA-00086.<br>  Contact your system manufacturer for support and remediation of this system.</pre><p>The following will be printed if your system is already patched:</p><pre>*** Risk Assessment ***<br>Based on the analysis performed by this tool: This system is not vulnerable. It has already been patched.</pre><h4>Patching the IME firmware</h4><p>Unfortunately, you will need Windows to install the IME firmware update which fixes the vulnerabilities. Go to <a href="https://support.lenovo.com/">Lenovo’s support page</a>, search for your specific Thinkpad model, and download the latest version of the IME firmware and install it. Wait for all the reboots to happen. Later, run the detection tools under Linux again as described above and check if your system is now patched.</p><h4>Setting a password for IME BIOS Access</h4><p>You should also change the password of your IME’s own BIOS by hitting <strong><em>&lt;CTRL&gt;+&lt;P&gt; </em></strong>during boot. The default password is “admin”. Make sure to change it to a strong password. Using simple passwords will be rejected with a generic message saying “Error applying new password”. Steve Gibson talks about this in his Podcast “Security Now” and gives some details about why it is a good idea to set a strong IME BIOS password:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FLh6Es_ucAZ8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLh6Es_ucAZ8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FLh6Es_ucAZ8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd04bd23674ba9b4b0efd34e2176708f/href">https://medium.com/media/bd04bd23674ba9b4b0efd34e2176708f/href</a></iframe><h3>Infineon TPM Chip Firmware Update</h3><p>As you already have Windows up and running, you may also want to update your TPM chip’s firmware. Go to <a href="https://support.lenovo.com/">Lenovo’s support page</a>, search for your specific Thinkpad model, and download for the “TPM Firmware Update Utility”. Run it and let it update your firmware.</p><p><strong><em>Important: The firmware update will erase data stored on the TPM chip. So if you are already using the TPM chip, you have to make sure that you don’t lose any important keys. Losing a key would mean the loss of all data encrypted with that key.</em></strong></p><p>Updating the TPM firmware fixes the so-called <strong>“ROCA”</strong> vulnerability where Infineon TPM chips generate weak RSA keys in some cases. This also affected older Yubikeys. Watch Steve Gibson explaining ROCA in “Security Now”:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3vG02Za5zuk%3Fstart%3D940%26feature%3Doembed%26start%3D940&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3vG02Za5zuk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3vG02Za5zuk%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/892e053e705515a0a7de0a16ec2f6026/href">https://medium.com/media/892e053e705515a0a7de0a16ec2f6026/href</a></iframe><h3>Meltdown and Spectre</h3><p>There are different measures to mitigate Meltdown, Spectre v1, and Spectre v2. Basically, a combination of the following gives good protection against these attacks:</p><ul><li>Using a <strong>kernel &gt;= 4.16.0</strong></li><li>Compiling your software (especially the kernel) with <strong>gcc 7.3 or higher</strong></li><li>Updating your CPU’s microcode</li></ul><h4>Checking which measures are already in place</h4><p>Since kernel 4.15, you can check which mitigations are already active by running:</p><pre>grep . /sys/devices/system/cpu/vulnerabilities/*</pre><p>For a fully protected system, the output should look like this:</p><pre>/sys/devices/system/cpu/vulnerabilities/meltdown:Mitigation: PTI<br>/sys/devices/system/cpu/vulnerabilities/spectre_v1:Mitigation: __user pointer sanitization<br>/sys/devices/system/cpu/vulnerabilities/spectre_v2:Mitigation: Full generic retpoline, IBPB, IBRS_FW</pre><p>If your kernel is compiled with gcc &lt; 7.3, you will get <em>Minimal generic ASM retpoline</em> instead of <em>Full generic retpoline</em>.</p><p>If your CPU’s microcode is not up to date, you will be missing <em>IBPB, IBRS_FW</em>. If this is the case, update your UEFI Firmware to make sure an up to date microcode is loaded into the CPU at boot time. You can find the latest UEFI Firmware by going to <a href="https://support.lenovo.com/">Lenovo’s support page</a> and searching for your specific Thinkpad model.</p><p>Alternatively, there are ways to load microcode patches with Linux in grub, inserted into the kernel, or manually from user space. For more information about microcode loading have at look at these gentoo wiki pages:</p><ul><li><a href="https://wiki.gentoo.org/wiki/Microcode">https://wiki.gentoo.org/wiki/Microcode</a></li><li><a href="https://wiki.gentoo.org/wiki/Intel_microcode">https://wiki.gentoo.org/wiki/Intel_microcode</a></li></ul><p>You can also check <strong>dmesg</strong> to find information about the running microcode version:</p><pre>dmesg | grep microcode</pre><p>You should get some lines like this:</p><pre>[    0.493690] microcode: sig=0x506e3, pf=0x20, revision=0x84<br>[    0.493838] microcode: Microcode Update Driver: v2.2.</pre><p>And after you updated the microcode the revision number increased:</p><pre>[    0.504084] microcode: sig=0x506e3, pf=0x20, revision=0xc2<br>[    0.504247] microcode: Microcode Update Driver: v2.2.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9bc4040343c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/plapadoo/patching-your-thinkpad-t460-t470-against-meltdown-spectre-roca-and-ime-vulnerabilities-c9bc4040343c">Patching Your Thinkpad T460/T470 Against Meltdown, Spectre, ROCA, and IME Vulnerabilities</a> was originally published in <a href="https://medium.com/plapadoo">plapadoo</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>