<?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>DEV Community: Umud Hasanli</title>
    <description>The latest articles on DEV Community by Umud Hasanli (@umudhasanli).</description>
    <link>https://dev.to/umudhasanli</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4249647%2F9ecf8b88-0260-4396-bbdc-57695bdb8ad4.jpg</url>
      <title>DEV Community: Umud Hasanli</title>
      <link>https://dev.to/umudhasanli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/umudhasanli"/>
    <language>en</language>
    <item>
      <title>Your logger redaction only hides the fields you remembered</title>
      <dc:creator>Umud Hasanli</dc:creator>
      <pubDate>Tue, 17 Nov 2026 10:58:53 +0000</pubDate>
      <link>https://dev.to/umudhasanli/your-logger-redaction-only-hides-the-fields-you-remembered-2hc7</link>
      <guid>https://dev.to/umudhasanli/your-logger-redaction-only-hides-the-fields-you-remembered-2hc7</guid>
      <description>&lt;p&gt;Every leaked secret I have seen started the same way. Someone wrote &lt;code&gt;logger.info({ user })&lt;/code&gt;, the code looked harmless, and &lt;code&gt;user&lt;/code&gt; carried a session token. Now that token lives in the log aggregator, the error tracker and a few vendors' systems, for as long as they keep logs.&lt;/p&gt;

&lt;p&gt;Most loggers have an answer for this. pino has a &lt;code&gt;redact&lt;/code&gt; option, and you can write a winston format. Both work the same way: you list the paths that are sensitive, and those fields are masked.&lt;/p&gt;

&lt;p&gt;The trouble is the list. It only covers what you remembered. The leak is always somewhere else:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a free-text &lt;code&gt;note&lt;/code&gt; field where a customer pasted an API key&lt;/li&gt;
&lt;li&gt;a nested payload from a third-party SDK you never looked inside&lt;/li&gt;
&lt;li&gt;an error message that includes the request URL, with a token in the query string&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Read the values, not the names
&lt;/h3&gt;

&lt;p&gt;I built &lt;a href="https://github.com/flare-collection/flare-redact" rel="noopener noreferrer"&gt;flare-redact&lt;/a&gt; to check the content itself. It knows what an AWS key, a GitHub token, a JWT, a card number or an IBAN looks like, and checks a checksum wherever one exists, so the card number &lt;code&gt;4242 4242 4242 4242&lt;/code&gt; is masked but &lt;code&gt;4242 4242 4242 4243&lt;/code&gt;, which fails the card checksum, is left alone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;redact&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'flare-redact'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;redact&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'bob@corp.com'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'hunter2'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'my key is AKIAIOSFODNN7EXAMPLE'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// { user: 'b***@***', password: '***', note: 'my key is AKIA***' }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is nothing to configure and no list to maintain. The shape you pass in is the shape you get back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Turn it on without touching the code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node --import flare-redact/register app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every &lt;code&gt;console.log&lt;/code&gt;, &lt;code&gt;warn&lt;/code&gt; and &lt;code&gt;error&lt;/code&gt; is redacted before it is written. You can add it to a Dockerfile or a deploy setting without opening the code. For pino and winston there are one-line integrations.&lt;/p&gt;

&lt;h3&gt;
  
  
  LLM prompts are the new log file
&lt;/h3&gt;

&lt;p&gt;The same leak now happens in prompts. A support bot sends the customer's message to a model, and the message contains an email and a card number. Wrap the client once:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'openai'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;wrapOpenAI&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'flare-redact/llm'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;openai&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;wrapOpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;OpenAI&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model sees &lt;code&gt;[FR_EMAIL_7f2a…]&lt;/code&gt; instead of the address, and your app gets the real value back in the reply, streaming included.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sentry and commits
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;sentryRedact()&lt;/code&gt; redacts events, spans and breadcrumbs before they leave your process, while keeping Sentry's own ids and stack frames so grouping still works. And &lt;code&gt;npx flare-redact init --hook&lt;/code&gt; adds a pre-commit hook that scans only the lines a commit adds, so it does not block you for old code.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it does not do
&lt;/h3&gt;

&lt;p&gt;It is honest pattern matching, not a model. It will miss a person's name with no context around it, and a clean scan is not proof that data has no PII. If you need model-level recall for names in prose, you can plug a local model in. It also does not replace gitleaks or TruffleHog, which scan your git history; flare-redact covers runtime data. They work well together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Try it
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install flare-redact
npx flare-redact init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a &lt;a href="https://flare-collection.github.io/flare-redact/" rel="noopener noreferrer"&gt;playground&lt;/a&gt; that runs entirely in the browser. If it misses something or masks something it should not, please open an issue. Those reports are the most useful thing for a library like this.&lt;/p&gt;

</description>
      <category>node</category>
      <category>security</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
