<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <updated>2026-10-16T11:42:32Z</updated>
  <generator>https://njump.me</generator>

  <title>Nostr notes by Enrico&#39;s blog (Unofficial)</title>
  <author>
    <name>Enrico&#39;s blog (Unofficial)</name>
  </author>
  <link rel="self" type="application/atom+xml" href="https://njump.me/npub17ee7rm3cgvjmrurhuppmlpesayjj3prey4afrt4md9ndh4yjjh2q8uhsrd.rss" />
  <link href="https://njump.me/npub17ee7rm3cgvjmrurhuppmlpesayjj3prey4afrt4md9ndh4yjjh2q8uhsrd" />
  <id>https://njump.me/npub17ee7rm3cgvjmrurhuppmlpesayjj3prey4afrt4md9ndh4yjjh2q8uhsrd</id>
  <icon>https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/1f986.png</icon>
  <logo>https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/72x72/1f986.png</logo>




  <entry>
    <id>https://njump.me/nevent1qqsyy94cyujutejtldslmt3kla8993qkf3ys3ylyy9hax6tzcn4hc6gzyrm88c0w8ppjtv0swlsy80u8xr5j22yy0yjh4ydwhd5kdk75j22agcc0rcp</id>
    
      <title type="html">Sandboxing pre-commit pre-commit is a tool that is often a ...</title>
    
    <link rel="alternate" href="https://njump.me/nevent1qqsyy94cyujutejtldslmt3kla8993qkf3ys3ylyy9hax6tzcn4hc6gzyrm88c0w8ppjtv0swlsy80u8xr5j22yy0yjh4ydwhd5kdk75j22agcc0rcp" />
    <content type="html">
      Sandboxing pre-commit&lt;br/&gt;&lt;br/&gt;pre-commit is a tool that is often a&lt;br/&gt;prerequisite for contributing to Python upstream projects. It installs as a git&lt;br/&gt;pre-commit hook and runs various checks on commit, using tools installed in a&lt;br/&gt;set of virtualenvs that it automatically manages.&lt;br/&gt;In other words, it is a Remote Code Execution engine running with the&lt;br/&gt;permissions of your own user, and with read and write access to all your&lt;br/&gt;information (including, say, ~/.ssh or ~/.netrc). If you are lucky, and for&lt;br/&gt;as long as you&amp;#39;re lucky, it will perform useful tasks on your code.&lt;br/&gt;The recent eMudhra certificate situation, where I learnt how Python, as well as&lt;br/&gt;several other ecosystems, likes to embed CA certificate bundles in&lt;br/&gt;virtualenvs, caused my&lt;br/&gt;tolerance for this to lower to a point where I felt the need to limit&lt;br/&gt;pre-commit&amp;#39;s reach.&lt;br/&gt;However, I didn&amp;#39;t want to end up with another containerized OS tree that it&amp;#39;s&lt;br/&gt;then my responsibility to manage, and I tried to go the&lt;br/&gt;bubblewrap way, so that the&lt;br/&gt;environment where pre-commit runs will get the same security updates as the&lt;br/&gt;rest of my system.&lt;br/&gt;The result is a pre-commit wrapper script&lt;br/&gt;that:&lt;br/&gt;Runs in a private filesystem, with no access to user&amp;#39;s files or system&lt;br/&gt;configuration&lt;br/&gt;Runs in a filesystem where everything is read-only, except for the git&lt;br/&gt;working directory&lt;br/&gt;Even the .git directory is readonly, so that changes in the code can be&lt;br/&gt;reliably detected via git diff&lt;br/&gt;Runs without network unless explicitly requested by the user&lt;br/&gt;Here&amp;#39;s a breakdown of the bwrap options I used so far.&lt;br/&gt;Set up usual filesystem expectations:&lt;br/&gt;--ro-bind /usr /usr \&lt;br/&gt;--symlink usr/bin /bin \&lt;br/&gt;--symlink usr/lib64 /lib64 \&lt;br/&gt;--symlink usr/lib /lib \&lt;br/&gt;--proc /proc \&lt;br/&gt;--dev /dev \&lt;br/&gt;Make the working directory and pre-commit&amp;#39;s environments storage available and&lt;br/&gt;writable:&lt;br/&gt;--bind ${CURDIR} &amp;#34;$GUEST_DIR&amp;#34; \&lt;br/&gt;--bind ~/.cache/pre-commit &amp;#34;/home/${USER}/.cache/pre-commit&amp;#34; \&lt;br/&gt;--chdir &amp;#34;$GUEST_DIR&amp;#34; \&lt;br/&gt;Forward git&amp;#39;s configuration:&lt;br/&gt;--ro-bind /etc/gitconfig /etc/gitconfig \&lt;br/&gt;--ro-bind ~/.gitconfig /home/${USER}/.gitconfig \&lt;br/&gt;Make .git writable (pre-commit needs to stash, for example), but use a tmpfs&lt;br/&gt;overlay so that the writes don&amp;#39;t persist:&lt;br/&gt;--overlay-src &amp;#34;$CURDIR/.git&amp;#34; \&lt;br/&gt;--tmp-overlay &amp;#34;$GUEST_DIR/.git&amp;#34; \&lt;br/&gt;Remove access to everything except the above. Prevent keystroke injection at&lt;br/&gt;the terminal. Propagate ^C.&lt;br/&gt;--unshare-all \&lt;br/&gt;--new-session \&lt;br/&gt;--die-with-parent&lt;br/&gt;If network is needed:&lt;br/&gt;--share-net \&lt;br/&gt;--ro-bind /etc/resolv.conf /etc/resolv.conf \&lt;br/&gt;--ro-bind /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt&lt;br/&gt;To run it, you can set up the wrapper script to run with a higher priority in&lt;br/&gt;$PATH, but you need to edit .git/hooks/pre-commit to remove the first&lt;br/&gt;branch of the if that, frustratingly, tries to run it as python3 -m&lt;br/&gt;pre_commit.&lt;br/&gt;I&amp;#39;m looking forward to a time where it becomes stadard practice to manage user&lt;br/&gt;commands this way: why should a desktop solitaire game have access to ~/.ssh?&lt;br/&gt;Or network? Why is it still normal, in 2026, to run a Desktop system like that?&lt;br/&gt;&lt;br/&gt;&lt;a href=&#34;https://www.ezini.eu/blog/2026/python/sandboxing-pre-commit&#34;&gt;https://www.ezini.eu/blog/2026/python/sandboxing-pre-commit&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#runs #user #code #python #curdir #make #codeexecution #remotecode #set #remove&lt;br/&gt;&lt;br/&gt;#rss #feeds #linksharing #qwibbit
    </content>
    <updated>2026-10-27T02:59:34Z</updated>
  </entry>

</feed>