<?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: Giuseppe Maglione</title>
    <description>The latest articles on DEV Community by Giuseppe Maglione (@titangra16).</description>
    <link>https://dev.to/titangra16</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%2F4277257%2F3fab0153-088e-4303-a1a3-06ef0211a972.png</url>
      <title>DEV Community: Giuseppe Maglione</title>
      <link>https://dev.to/titangra16</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/titangra16"/>
    <language>en</language>
    <item>
      <title>How to check Playwright HAR files for sensitive data before committing them</title>
      <dc:creator>Giuseppe Maglione</dc:creator>
      <pubDate>Tue, 01 Dec 2026 23:53:23 +0000</pubDate>
      <link>https://dev.to/titangra16/how-to-check-playwright-har-files-for-sensitive-data-before-committing-them-4mbg</link>
      <guid>https://dev.to/titangra16/how-to-check-playwright-har-files-for-sensitive-data-before-committing-them-4mbg</guid>
      <description>&lt;p&gt;The first CI run on my demo pull request failed with two findings. The next run passed. Both runs checked the same file, &lt;code&gt;fixtures/profile.har&lt;/code&gt;. The difference was two fields in a recorded API response.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;HAR Privacy Check&lt;/strong&gt; for developers who keep Playwright network recordings alongside their tests. It has a local CLI, a pre-commit hook, and a GitHub Action. Here’s the small example I used to test it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What was in the recording?
&lt;/h2&gt;

&lt;p&gt;Playwright can replay recorded HTTP traffic with &lt;code&gt;routeFromHAR()&lt;/code&gt;. In my demo, the recording contains a response from a fictional profile endpoint. This is the JSON stored inside the HAR response body:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"displayName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Demo Student"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"access_token"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"DEMO_ONLY_SENTINEL"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"student@example.invalid"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The profile test only needs &lt;code&gt;displayName&lt;/code&gt;. The other two fields are synthetic, but they illustrate how a fixture can carry more data than the test uses.&lt;/p&gt;

&lt;p&gt;On the first commit, the scanner reported:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HAR 1 | entry 1 | response body | sensitive field
HAR 1 | entry 1 | response body | sensitive field
1 HAR file(s), 2 finding(s). Coverage: supported fields only.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those two identical lines are intentional. Each finding points to the first HAR entry and its response body. Neither the token nor the email appears in the CI log. The trade-off is that someone inspecting a large response still has to locate the fields.&lt;/p&gt;

&lt;p&gt;I then restored the fixture containing only &lt;code&gt;displayName&lt;/code&gt; and pushed a second commit. The same check reported &lt;code&gt;0 finding(s)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/TitanGra16/har-privacy-check-demo/pull/1" rel="noopener noreferrer"&gt;See the demo pull request&lt;/a&gt; · &lt;a href="https://github.com/TitanGra16/har-privacy-check-demo/actions/runs/46766874863/job/143069821741" rel="noopener noreferrer"&gt;Failing run&lt;/a&gt; · &lt;a href="https://github.com/TitanGra16/har-privacy-check-demo/actions/runs/46767135607/job/143070733617" rel="noopener noreferrer"&gt;Passing run&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the pre-commit hook reads the Git index
&lt;/h2&gt;

&lt;p&gt;Suppose you run &lt;code&gt;git add fixtures/profile.har&lt;/code&gt;, spot an email address, and remove it in your editor. Your working copy is now clean. Until you stage the correction, Git still has the earlier version queued for the commit.&lt;/p&gt;

&lt;p&gt;That detail shaped the hook. It reads the &lt;strong&gt;staged Git blob&lt;/strong&gt;. A regression test stages a fixture with sensitive fields, overwrites the working copy with a clean fixture, and verifies that the check still fails. You can inspect that case in the &lt;a href="https://github.com/TitanGra16/har-privacy-check/blob/v0.1.1/test/check.test.ts" rel="noopener noreferrer"&gt;test suite&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The timing matters too. The local hook can catch a finding before a commit. A GitHub Actions check runs after the push, when the file has already reached the remote repository.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it locally
&lt;/h2&gt;

&lt;p&gt;With Git and Node.js 24.12 or later, you can reproduce both results using the bundled synthetic fixtures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone --branch v0.1.1 https://github.com/TitanGra16/har-privacy-check.git
&lt;span class="nb"&gt;cd&lt;/span&gt; har-privacy-check

node src/cli.ts examples/clean.har
node src/cli.ts examples/synthetic-sensitive.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first command that runs the scanner exits with &lt;code&gt;0&lt;/code&gt;. The second exits with &lt;code&gt;1&lt;/code&gt; and reports two findings. You can run this example without installing dependencies or using a real browser recording.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add it to a GitHub Actions workflow
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;.github/workflows/har-privacy.yml&lt;/code&gt; in a repository that tracks &lt;code&gt;.har&lt;/code&gt; fixtures:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HAR privacy&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;push&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;pull_request&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1&lt;/span&gt; &lt;span class="c1"&gt;# v7.0.1
&lt;/span&gt;        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;persist-credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;

      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;TitanGra16/har-privacy-check@12aff46c4db620830034eb26c7901c042fdb114d&lt;/span&gt; &lt;span class="c1"&gt;# v0.1.1
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One detail worth checking on the first run is the &lt;strong&gt;file count&lt;/strong&gt;. If the log says &lt;code&gt;0 HAR file(s), 0 finding(s)&lt;/code&gt;, the scanner had no tracked &lt;code&gt;.har&lt;/code&gt; files to inspect. In the clean demo, the result is &lt;code&gt;1 HAR file(s), 0 finding(s)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a clean result tells you
&lt;/h2&gt;

&lt;p&gt;Version &lt;code&gt;v0.1.1&lt;/code&gt; checks plain JSON HAR files up to 8 MiB each. Its rules cover known sensitive field names in structured data, cookies, and query parameters, including those in redirect targets. A secret under an unrelated JSON key can escape detection. Compressed HAR archives are outside the index scan.&lt;/p&gt;

&lt;p&gt;I’d be interested in feedback from people who maintain Playwright fixtures: &lt;strong&gt;when a response contains hundreds of fields, would you want the warning to include a JSON path such as &lt;code&gt;profile.email&lt;/code&gt;, while keeping the value out of the log?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/marketplace/actions/har-privacy-check" rel="noopener noreferrer"&gt;GitHub Marketplace&lt;/a&gt; · &lt;a href="https://github.com/TitanGra16/har-privacy-check" rel="noopener noreferrer"&gt;Source code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Writing disclosure: I used ChatGPT to draft this article from the project source and its public demo runs.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>playwright</category>
      <category>security</category>
      <category>testing</category>
      <category>githubactions</category>
    </item>
  </channel>
</rss>
