<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<title>Jorge&#x27;s blog</title>
	<link href="https://carrascomj.github.io/public/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="https://carrascomj.github.io/public/"/>
	<generator uri="https://www.getzola.org/">Zola</generator>
	<updated>2021-01-20T00:00:00+00:00</updated>
	<id>https://carrascomj.github.io/public/atom.xml</id>
	<entry xml:lang="en">
		<title>Getting fired with Github Actions!</title>
		<published>2021-01-20T00:00:00+00:00</published>
		<updated>2021-01-20T00:00:00+00:00</updated>
		<link href="https://carrascomj.github.io/public/article/getting-fired-1/" type="text/html"/>
		<id>https://carrascomj.github.io/public/article/getting-fired-1/</id>
		<content type="html">&lt;p&gt;Can your repository secrets be logged with Github Actions? A guide on trying
not to get sued and&#x2F;or fired!&lt;&#x2F;p&gt;
&lt;span id=&quot;continue-reading&quot;&gt;&lt;&#x2F;span&gt;
&lt;p&gt;While migrating travis CI to github actions, I wanted to test whether&#x2F;when the 
&lt;a href=&quot;https:&#x2F;&#x2F;docs.github.com&#x2F;en&#x2F;actions&#x2F;reference&#x2F;encrypted-secrets&quot;&gt;secrets on a repository&lt;&#x2F;a&gt;
get logged.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;set-some-secrets&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#set-some-secrets&quot;
   aria-label=&quot;Anchor link for: set-some-secrets&quot; style=&quot;opacity:0.2&quot;&gt;
    
    §
    
&lt;&#x2F;a&gt;Set some secrets&lt;&#x2F;h1&gt;
&lt;p&gt;I created an empty repository and set up some secrets (&lt;em&gt;Settings &amp;gt; Secrets &amp;gt;
New repository secret&lt;&#x2F;em&gt;):&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;NEVER_SEE_TOKEN, with value &amp;quot;SEENO EVIL&amp;quot;.&lt;&#x2F;li&gt;
&lt;li&gt;ECHOED_TOKEN, with value &amp;quot;echoed&amp;quot;:&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h1 id=&quot;good-usage-the-command-succeeds&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#good-usage-the-command-succeeds&quot;
   aria-label=&quot;Anchor link for: good-usage-the-command-succeeds&quot; style=&quot;opacity:0.2&quot;&gt;
    
    §
    
&lt;&#x2F;a&gt;Good usage: the command succeeds&lt;&#x2F;h1&gt;
&lt;p&gt;My very first attempt was running a command using the secret properly. Here, it is
expected that github will hide the secret variables.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;secret

&lt;&#x2F;span&gt;&lt;span style=&quot;color:#db9d63;&quot;&gt;on&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;push&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;branches&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;master

jobs&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;test&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;runs-on&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;ubuntu-latest
    steps&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;Check successful action with secret is not logged and works
      run&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#9acc76;&quot;&gt;echo ${{ secrets.NEVER_SEE_TOKEN }} | grep &amp;quot;SEENO&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Let&#x27;s check the log!&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;&amp;gt; Check successful action with secret is not logged and works

Run echo *** | grep &amp;quot;SEENO&amp;quot;
  echo *** | grep &amp;quot;SEENO&amp;quot;
  shell: &#x2F;bin&#x2F;bash -e {0}
***
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Fantastic, exactly how it should be.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;strange-usage-echoing-the-secrets&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#strange-usage-echoing-the-secrets&quot;
   aria-label=&quot;Anchor link for: strange-usage-echoing-the-secrets&quot; style=&quot;opacity:0.2&quot;&gt;
    
    §
    
&lt;&#x2F;a&gt;Strange usage: echoing the secrets&lt;&#x2F;h1&gt;
&lt;p&gt;Let&#x27;s add another step, echoing the secret to &lt;code&gt;STDOUT&lt;&#x2F;code&gt;. &lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;- &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;Echoed secrets are not logged!
      run&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#9acc76;&quot;&gt;echo ${{ secrets.ECHOED_TOKEN }}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Log:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code class=&quot;language-text&quot; data-lang=&quot;text&quot;&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;&amp;gt; Echoed secrets are not logged!

Run echo ***
  echo ***
  shell: &#x2F;bin&#x2F;bash -e {0}
***
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In this case, github actions saves us from doomsday but we are really flexing
our madness here. Nonetheless, if you really want the secret to be printed (maybe
for debugging) you may use &lt;a href=&quot;https:&#x2F;&#x2F;www.theserverside.com&#x2F;blog&#x2F;Coffee-Talk-Java-News-Stories-and-Opinions&#x2F;GitHub-Actions-Secrets-Example-Token-Tutorial&quot;&gt;the workaround posted here&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;- &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;This is going to be printed!
  run&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#9acc76;&quot;&gt;echo ${{secrets.SECRET_TOKEN}} | sed &amp;#39;s&#x2F;.&#x2F;&amp;amp; &#x2F;g&amp;#39; 
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h1 id=&quot;still-good-usage-the-command-fails-but-syntax-is-fine&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#still-good-usage-the-command-fails-but-syntax-is-fine&quot;
   aria-label=&quot;Anchor link for: still-good-usage-the-command-fails-but-syntax-is-fine&quot; style=&quot;opacity:0.2&quot;&gt;
    
    §
    
&lt;&#x2F;a&gt;Still good usage: the command fails but syntax is fine&lt;&#x2F;h1&gt;
&lt;p&gt;If one job failed, the secrets should not be printed, right?&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;test-bad&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;runs-on&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;ubuntu-latest
    steps&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;Check unsuccessful action with secret is not logged and works
      run&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#9acc76;&quot;&gt;echo ${{ secrets.NEVER_SEE_TOKEN }} | grep &amp;quot;GOOD&amp;quot;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Log:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;&amp;gt; Check unsuccessful action with secret is not logged and works
Run echo *** | grep &amp;quot;GOOD&amp;quot;
  echo *** | grep &amp;quot;GOOD&amp;quot;
  shell: &#x2F;bin&#x2F;bash -e {0}
Error: Process completed with exit code 1.
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Right!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;bad-usage-the-command-fails-because-of-wrong-syntax&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#bad-usage-the-command-fails-because-of-wrong-syntax&quot;
   aria-label=&quot;Anchor link for: bad-usage-the-command-fails-because-of-wrong-syntax&quot; style=&quot;opacity:0.2&quot;&gt;
    
    §
    
&lt;&#x2F;a&gt;Bad usage: the command fails because of wrong syntax&lt;&#x2F;h1&gt;
&lt;p&gt;This is when you get fired. If a command is called using the wrong syntax (or 
your secret refers to what should be a file but it isn&#x27;t, like in this case) the error trace of the
command might reveal the secrets, letting them exposed to the whole Internet.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;tests-bad-syntax&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;runs-on&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;ubuntu-latest
    steps&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;Check unsuccessful action with secret is logged and fails
      run&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#9acc76;&quot;&gt;grep &amp;quot;JULY&amp;quot; ${{ secrets.NEVER_SEE_TOKEN }}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Log:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;&amp;gt; Check unsuccessful action with secret is logged and fails
Run grep &amp;quot;JULY&amp;quot; ***
  grep &amp;quot;JULY&amp;quot; ***
  shell: &#x2F;bin&#x2F;bash -e {0}
grep: SEENO: No such file or directory
grep: EVIL: No such file or directory
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;how-to-fix-this-situation&quot;&gt;&lt;a class=&quot;zola-anchor&quot; href=&quot;#how-to-fix-this-situation&quot;
   aria-label=&quot;Anchor link for: how-to-fix-this-situation&quot; style=&quot;opacity:0.2&quot;&gt;
    
    §§
    
&lt;&#x2F;a&gt;How to fix this situation&lt;&#x2F;h2&gt;
&lt;p&gt;At least the first time using an action of this kind, we could redirect the
&lt;code&gt;STERR&lt;&#x2F;code&gt; to &lt;code&gt;&#x2F;dev&#x2F;null&lt;&#x2F;code&gt;. Thus, the possible stack of errors will be removed
from the logs.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;tests-bad-syntax-recovered&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;runs-on&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;ubuntu-latest
    steps&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;:
    - &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#eb6772;&quot;&gt;Check unsuccessful action with wrong syntax and secret is not logged
      run&lt;&#x2F;span&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#9acc76;&quot;&gt;grep &amp;quot;JULY&amp;quot; ${{ secrets.NEVER_SEE_TOKEN }} 2&amp;gt; &#x2F;dev&#x2F;null
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Log:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;&quot;&gt;
&lt;code&gt;&lt;span style=&quot;color:#abb2bf;&quot;&gt;&amp;gt; Check unsuccessful action with wrong syntax and secret is not logged
Run grep &amp;quot;JULY&amp;quot; *** 2&amp;gt; &#x2F;dev&#x2F;null
  grep &amp;quot;JULY&amp;quot; *** 2&amp;gt; &#x2F;dev&#x2F;null
  shell: &#x2F;bin&#x2F;bash -e {0}
Error: Process completed with exit code 2.
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Yay! Another way would be to &lt;em&gt;maybe&lt;&#x2F;em&gt; try the commands locally. Just maybe.&lt;&#x2F;p&gt;
</content>
	</entry>
</feed>
