<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>白名单 on Zhang's Notes</title><link>https://zhangsnotes.com/tags/%E7%99%BD%E5%90%8D%E5%8D%95/</link><description>Recent content in 白名单 on Zhang's Notes</description><generator>Hugo</generator><language>zh-CN</language><copyright>Zhang's Notes</copyright><lastBuildDate>Thu, 24 Sep 2026 14:19:02 +0800</lastBuildDate><atom:link href="https://zhangsnotes.com/tags/%E7%99%BD%E5%90%8D%E5%8D%95/index.xml" rel="self" type="application/rss+xml"/><item><title>开发 IDE 的杀毒软件白名单配置指南</title><link>https://zhangsnotes.com/posts/ide-antivirus-whitelist/</link><pubDate>Thu, 24 Sep 2026 13:50:00 +0800</pubDate><guid>https://zhangsnotes.com/posts/ide-antivirus-whitelist/</guid><description>从原理到实践，梳理 Android Studio、JetBrains 全家桶、VS Code、Visual Studio、Xcode 等常见开发 IDE 与构建工具在杀毒软件中应当加白的目录与进程，避免实时扫描拖垮编译速度。</description><content:encoded><![CDATA[<h1 id="为什么开发环境要加白名单">为什么开发环境要加白名单</h1>
<p>杀毒软件的实时防护（Real-time Protection）会对每一个被读取/写入的文件做特征扫描。普通办公场景下这很合理，但对开发环境几乎是「灾难」：</p>
<ul>
<li>一次 <code>Build</code> 会生成、读取、删除成千上万个小文件（<code>.class</code>、<code>.dex</code>、<code>.o</code>、<code>.js</code> 缓存、依赖 jar 等）；</li>
<li>Gradle / npm / cargo / Maven 在同步与下载时会疯狂解压、硬链接、写缓存；</li>
<li>IDE 的「全文索引」「代码补全」「类型推断」会反复扫描整个项目与 SDK 源码；</li>
<li>Android 模拟器（QEMU）在运行时会持续读写数 GB 的镜像文件。</li>
</ul>
<p>这些动作全部落在杀软的扫描路径上，结果是：CPU 占用拉满、构建时间被拉长数倍、模拟器卡成幻灯片、IDE 索引半天不结束。把相关目录加入杀软的「排除 / 信任区」，是性价比最高、几乎零风险的性能优化。</p>
<h1 id="加白名单的基本原则">加白名单的基本原则</h1>
<ol>
<li><strong>加目录而不是单个文件</strong>，并且务必勾选「包含子文件夹」。构建产物路径会变，单文件排除很容易漏。</li>
<li><strong>实时防护、右键扫描、计划扫描三处都加</strong>。很多杀软这几项是独立的排除列表，只加实时防护没用。</li>
<li><strong>目录排除 + 进程排除配合</strong>。目录排除管「文件读写」，进程排除管「这个程序干啥都不扫」，两者互补。</li>
<li><strong>不要无脑加整个用户目录</strong>（<code>C:\Users\xxx</code>）。真正的风险面是下载目录、邮件附件、浏览器缓存，这些反而应该让杀软继续扫。只加你确认是开发产物的目录。</li>
<li><strong>加完要验证</strong>：做一次 <code>Clean Project</code> + 重新 Gradle 同步 + 全量构建，对比耗时是否明显下降。</li>
</ol>
<h1 id="跨-ide-的通用目录建议一律加白">跨 IDE 的通用目录（建议一律加白）</h1>
<p>无论你用哪种 IDE，下面这些「构建与依赖缓存」目录几乎都会成为瓶颈：</p>
<div class="code-block">
  <div class="code-block-header">
    <span class="code-block-lang">text</span>
    <button type="button" class="code-copy" aria-label="Copy code">
      <span class="code-copy-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
</span>
      <span class="code-copy-icon code-copy-icon-check"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
      <span class="code-copy-label">Copy</span>
    </button>
  </div>
  <pre tabindex="0"><code># 各语言/工具的本地缓存（按你实际用到的加）
C:\Users\user\.gradle\            # Gradle 缓存、daemon、wrapper
C:\Users\user\.m2\repository\     # Maven 本地仓库
C:\Users\user\.npm\               # npm 缓存
C:\Users\user\AppData\Roaming\npm\# 全局 npm 脚本/二进制（含 opencode、codex 等）
C:\Users\user\AppData\Local\npm-cache\
C:\Users\user\go\                 # GOPATH / 模块缓存
C:\Users\user\.cargo\             # Rust 依赖与构建缓存
C:\Users\user\.venv\              # Python 虚拟环境
C:\Users\user\venv\

# 自己的项目根目录（构建产物 build/、.gradle/、node_modules/ 都会被父目录覆盖）
D:\Projects\                     # 改成你实际放代码的地方</code></pre>
</div>
<blockquote>
<p>经验法则：只要一个目录里的文件「是你自己编译/下载出来的、且不在浏览器/聊天软件/下载目录里」，就可以放心加白。</p>
</blockquote>
<h1 id="分-ide-清单">分 IDE 清单</h1>
<h2 id="android-studio">Android Studio</h2>
<p>Android 开发是杀软重灾区（Gradle + SDK + 模拟器三重打击），建议整组加白：</p>
<div class="code-block">
  <div class="code-block-header">
    <span class="code-block-lang">text</span>
    <button type="button" class="code-copy" aria-label="Copy code">
      <span class="code-copy-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
</span>
      <span class="code-copy-icon code-copy-icon-check"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
      <span class="code-copy-label">Copy</span>
    </button>
  </div>
  <pre tabindex="0"><code>C:\Program Files\Android\Android Studio\   # IDE 本体、内置 JBR、adb/emulator
C:\Users\user\AppData\Local\Android\Sdk\    # build-tools / platform-tools / emulator / 系统镜像
C:\Users\user\.gradle\                      # Gradle 缓存与 daemon
C:\Users\user\.android\                     # adb 密钥、emulator 配置、avd\ 下的虚拟机镜像
C:\Users\user\.jdks\                        # Gradle/IDE 使用的独立 JDK
C:\Users\user\.jbr\                         # JetBrains Runtime
C:\Users\user\AppData\Roaming\Google\AndroidStudio*\    # IDE 配置（通配覆盖所有版本）
C:\Users\user\AppData\Local\Google\AndroidStudio*\      # IDE 缓存/日志/索引</code></pre>
</div>
<p>进程排除（进阶）：<code>studio64.exe</code>、<code>java.exe</code>、<code>gradle.exe</code>、<code>adb.exe</code>、<code>qemu-system-x86_64.exe</code>。</p>
<h2 id="jetbrains-全家桶intellij-idea--pycharm--webstorm--clion-">JetBrains 全家桶（IntelliJ IDEA / PyCharm / WebStorm / CLion …）</h2>
<div class="code-block">
  <div class="code-block-header">
    <span class="code-block-lang">text</span>
    <button type="button" class="code-copy" aria-label="Copy code">
      <span class="code-copy-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
</span>
      <span class="code-copy-icon code-copy-icon-check"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
      <span class="code-copy-label">Copy</span>
    </button>
  </div>
  <pre tabindex="0"><code>C:\Program Files\JetBrains\           # 各 IDE 安装目录（或你自定义的安装盘）
C:\Users\user\AppData\Roaming\JetBrains\   # 配置
C:\Users\user\AppData\Local\JetBrains\     # 缓存、日志、索引
C:\Users\user\.gradle\                    # 若用 Gradle
C:\Users\user\.m2\repository\             # 若用 Maven</code></pre>
</div>
<p>进程排除：<code>idea64.exe</code> / <code>pycharm64.exe</code> 等对应 launcher，以及 <code>java.exe</code>。</p>
<h2 id="visual-studio-code">Visual Studio Code</h2>
<div class="code-block">
  <div class="code-block-header">
    <span class="code-block-lang">text</span>
    <button type="button" class="code-copy" aria-label="Copy code">
      <span class="code-copy-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
</span>
      <span class="code-copy-icon code-copy-icon-check"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
      <span class="code-copy-label">Copy</span>
    </button>
  </div>
  <pre tabindex="0"><code>C:\Users\user\AppData\Local\Programs\Microsoft VS Code\   # 安装目录
C:\Users\user\.vscode\extensions\                          # 已安装扩展
C:\Users\user\.vscode-server\                             # 远程/WSL 开发服务端
C:\Users\user\AppData\Roaming\Code\                        # 用户数据、缓存</code></pre>
</div>
<p>进程排除：<code>Code.exe</code>、<code>node.exe</code>（VS Code 大量逻辑跑在 node 上）、<code>electron</code>。</p>
<h2 id="visual-studiowindows-原生">Visual Studio（Windows 原生）</h2>
<div class="code-block">
  <div class="code-block-header">
    <span class="code-block-lang">text</span>
    <button type="button" class="code-copy" aria-label="Copy code">
      <span class="code-copy-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
</span>
      <span class="code-copy-icon code-copy-icon-check"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
      <span class="code-copy-label">Copy</span>
    </button>
  </div>
  <pre tabindex="0"><code>C:\Program Files\Microsoft Visual Studio\     # 安装目录
C:\Program Files (x86)\Microsoft Visual Studio\
C:\Users\user\AppData\Local\Microsoft\VisualStudio\   # 缓存、IntelliSense 数据库
C:\Users\user\AppData\Local\Microsoft\MSBuild\
C:\Users\user\source\                             # 你的源码根（按需改）</code></pre>
</div>
<p>进程排除：<code>devenv.exe</code>、<code>MSBuild.exe</code>、<code>dotnet.exe</code>、<code>VBCSCompiler.exe</code>、<code>conhost.exe</code>（按需）。</p>
<h2 id="xcodemacos">Xcode（macOS）</h2>
<div class="code-block">
  <div class="code-block-header">
    <span class="code-block-lang">text</span>
    <button type="button" class="code-copy" aria-label="Copy code">
      <span class="code-copy-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
</span>
      <span class="code-copy-icon code-copy-icon-check"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
      <span class="code-copy-label">Copy</span>
    </button>
  </div>
  <pre tabindex="0"><code>/Applications/Xcode.app
~/Library/Developer/            # 派生数据、模拟器、工具链缓存
~/Library/Caches/com.apple.dt.Xcode
~/Library/Developer/CoreSimulator   # 模拟器镜像</code></pre>
</div>
<p>进程排除：<code>xcodebuild</code>、<code>swift</code>、<code>clang</code>、<code>Simulator</code>。</p>
<h1 id="ai-编码助手也要加白">AI 编码助手也要加白</h1>
<p>如果你在用 AI 编程工具，它们会在本地写大量会话/数据库/沙箱文件，同样值得加白：</p>
<div class="code-block">
  <div class="code-block-header">
    <span class="code-block-lang">text</span>
    <button type="button" class="code-copy" aria-label="Copy code">
      <span class="code-copy-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
</span>
      <span class="code-copy-icon code-copy-icon-check"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
      <span class="code-copy-label">Copy</span>
    </button>
  </div>
  <pre tabindex="0"><code>C:\Users\user\.config\opencode\        # OpenCode 配置 + node_modules
C:\Users\user\.local\share\opencode\   # opencode.db、repos、日志
C:\Users\user\.local\state\opencode\   # 运行时状态
C:\Users\user\.codex\                  # OpenAI Codex：配置、sessions、sqlite、sandbox</code></pre>
</div>
<p>进程排除：<code>opencode</code>、<code>codex</code>（及其 spawn 的子进程）。</p>
<h1 id="进程排除清单进阶直接贴给杀软">进程排除清单（进阶，直接贴给杀软）</h1>
<p>把下面这些可执行文件名加入「进程排除」，能进一步减少扫描开销：</p>
<div class="code-block">
  <div class="code-block-header">
    <span class="code-block-lang">text</span>
    <button type="button" class="code-copy" aria-label="Copy code">
      <span class="code-copy-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>
</span>
      <span class="code-copy-icon code-copy-icon-check"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
      <span class="code-copy-label">Copy</span>
    </button>
  </div>
  <pre tabindex="0"><code>studio64.exe
idea64.exe
pycharm64.exe
Code.exe
devenv.exe
MSBuild.exe
dotnet.exe
java.exe
gradle.exe
node.exe
adb.exe
qemu-system-x86_64.exe
xcodebuild
clang</code></pre>
</div>
<blockquote>
<p>注意：进程排除意味着「该进程读写任何文件都不扫」，权限较大。仅在你确认这些进程来源可信（官方安装）时启用。</p>
</blockquote>
<h1 id="安全提示">安全提示</h1>
<ul>
<li>加白≠裸奔。保持杀软对 <code>Downloads</code>、<code>Desktop</code>、<code>AppData</code> 里的浏览器/聊天数据、邮件附件、可移动盘的扫描。</li>
<li>模拟器镜像、<code>.gradle</code> 这类目录几乎不存在「被植入恶意代码却来自可信构建链」的风险，加白很安全。</li>
<li>如果你在企业环境，目录排除可能需要管理员/组策略权限，按公司安全规范走变更流程。</li>
<li>改动后务必观察一两天，确认没有「某目录被整体跳过导致漏报」。真不放心，可以只加白 <code>build</code>、<code>node_modules</code>、<code>.gradle</code> 这类纯产物目录，而非整个项目根。</li>
</ul>
<h1 id="验证是否生效">验证是否生效</h1>
<p>加完白名单后做三件事确认：</p>
<ol>
<li><strong>全量重建</strong>：<code>Build → Clean Project</code> 后重新构建，看构建日志时间是否明显下降（通常能快 30%–数倍）。</li>
<li><strong>模拟器冷启</strong>：首次启动 AVD 不再卡在「Waiting for target device」几十秒。</li>
<li><strong>杀软日志</strong>：打开杀软的实时防护日志，确认构建期间不再有对 <code>.gradle</code> / <code>Sdk</code> / <code>build</code> 下文件的高频扫描记录。</li>
</ol>
<p>如果三项都符合，说明白名单已经生效。</p>
]]></content:encoded></item></channel></rss>