<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>The Ops Community ⚙️: Jochen Lillich</title>
    <description>The latest articles on The Ops Community ⚙️ by Jochen Lillich (@geewiz).</description>
    <link>https://community.ops.io/geewiz</link>
    <image>
      <url>https://community.ops.io/images/mtGrQdH2c-hACbrek8RGZeLOOennL7VXxfYwBSH1t08/rs:fill:90:90/g:sm/mb:500000/ar:1/aHR0cHM6Ly9jb21t/dW5pdHkub3BzLmlv/L3JlbW90ZWltYWdl/cy91cGxvYWRzL3Vz/ZXIvcHJvZmlsZV9p/bWFnZS8xMDIvOTk1/MGE2NmEtNjRlMC00/MmU0LWFlYTctZmVj/NzI0OTdiNTM5Lmpw/Zw</url>
      <title>The Ops Community ⚙️: Jochen Lillich</title>
      <link>https://community.ops.io/geewiz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://community.ops.io/feed/geewiz"/>
    <language>en</language>
    <item>
      <title>An easy and secure way to launch helper scripts in a project</title>
      <dc:creator>Jochen Lillich</dc:creator>
      <pubDate>Thu, 06 Feb 2020 11:59:00 +0000</pubDate>
      <link>https://community.ops.io/geewiz/an-easy-and-secure-way-to-launch-helper-scripts-in-a-project-2h9f</link>
      <guid>https://community.ops.io/geewiz/an-easy-and-secure-way-to-launch-helper-scripts-in-a-project-2h9f</guid>
      <description>&lt;p&gt;On one of my recent &lt;a href="https://www.twitch.tv/fullstacklive"&gt;live coding streams&lt;/a&gt;, a viewer asked what my &lt;code&gt;abe&lt;/code&gt; script does. I showed that it simply launched a Ruby command in my project’s application container. Since I’m using Docker Compose to spin up most of my development environments, I have to run all development tasks within the application container. Typing &lt;code&gt;abe rake test&lt;/code&gt; is much faster than typing &lt;code&gt;docker-compose exec app bundle exec rake test&lt;/code&gt;, so I added this script to my project’s &lt;code&gt;bin&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash
docker-compose exec app bundle exec $@

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s a nifty time-saver, but the smart part of this isn’t the script itself but how I make helper scripts in the &lt;code&gt;bin&lt;/code&gt; directory of my projects easy to launch without having to prepend every command with &lt;code&gt;./bin/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you’re familiar with how a Unix shell finds the right program to execute, you ‘ll probably suggest just adding &lt;code&gt;./bin&lt;/code&gt; to the environment variable &lt;code&gt;PATH&lt;/code&gt;. But that’s a risky move because you don’t want to accidentally launch a malicious script after checking out a repository that happens to have an executable &lt;code&gt;ls&lt;/code&gt; command in its &lt;code&gt;bin&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;Once again, it was the talented devs over at &lt;a href="https://thoughtbot.com/blog/git-safe"&gt;ThoughtBot&lt;/a&gt; who found a better solution. Instead of adding &lt;code&gt;./bin&lt;/code&gt; to &lt;code&gt;PATH&lt;/code&gt;, they recommend adding &lt;code&gt;.git/safe/../../bin&lt;/code&gt;. With this entry, the shell descends into &lt;code&gt;.git&lt;/code&gt;, further down into &lt;code&gt;safe&lt;/code&gt;, all the way back to the repository root and only then into &lt;code&gt;bin&lt;/code&gt;. What makes this seemingly roundabout way to find your helper scripts secure is that it only works if you’ve first manually created the subdirectory &lt;code&gt;safe&lt;/code&gt; within &lt;code&gt;.git&lt;/code&gt;. The latter is, after all, git’s data directory which normally doesn’t contain a directory named &lt;code&gt;safe&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There you have it — easy access to your project’s helper scripts is simple to achieve. And without any additional effort, it’s safe as well!&lt;/p&gt;

</description>
      <category>devops</category>
    </item>
  </channel>
</rss>
