Commit 0610a76a54a for nodejs

commit 0610a76a54a0fd9f973a480d543e4ed8f0b55673
Author: Rafael Gonzaga <rafael.nunu@hotmail.com>
Date:   Fri Dec 4 17:40:05 2026 -0300

    sqlite: allow enabling extensions in permission audit mode

    Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
    PR-URL: https://github.com/nodejs/node/pull/67906
    Reviewed-By: Guilherme Araújo <arauujogui@gmail.com>
    Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>

diff --git a/doc/api/permissions.md b/doc/api/permissions.md
index 45e2c7679ae..5f533b320a0 100644
--- a/doc/api/permissions.md
+++ b/doc/api/permissions.md
@@ -516,7 +516,9 @@ There are constraints you need to know before using this system:
   chosen by the operator, gaps like this are treated as regular bugs rather
   than vulnerabilities. Please report them through the regular issue tracker.
 * Run-Time Loadable Extensions cannot be loaded when the Permission Model is
-  enabled, affecting the sqlite module.
+  enabled, affecting the sqlite module. In [audit mode](#audit-mode) they can
+  be enabled and loaded, and `database.loadExtension()` publishes a message
+  when the extension path is not covered by `--allow-fs-read`.
 * SQLite [URI filenames][] are disabled when the Permission Model is enabled.
   The `node:sqlite` module rejects {URL} objects and paths starting with
   `file:`, and `ATTACH DATABASE` treats such names as plain file paths.
diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc
index 001718d853e..375e7ad8701 100644
--- a/src/node_sqlite.cc
+++ b/src/node_sqlite.cc
@@ -1760,7 +1760,8 @@ bool Database::Open() {
   }

   if (enable_load_extension_) {
-    if (env()->permission()->enabled()) [[unlikely]] {
+    if (env()->permission()->enabled() && !env()->permission()->warning_only())
+        [[unlikely]] {
       THROW_ERR_LOAD_SQLITE_EXTENSION(env(),
                                       "Cannot load SQLite extensions when the "
                                       "permission model is enabled.");
diff --git a/test/parallel/test-permission-sqlite-load-extension.js b/test/parallel/test-permission-sqlite-load-extension.js
index e87849ffb2d..48ffcd6a846 100644
--- a/test/parallel/test-permission-sqlite-load-extension.js
+++ b/test/parallel/test-permission-sqlite-load-extension.js
@@ -15,3 +15,28 @@ common.spawnPromisified(
   assert.match(stderr, /code: 'ERR_LOAD_SQLITE_EXTENSION'/);
   assert.strictEqual(code, 1);
 }));
+
+// In audit mode extensions can be enabled, and loading reaches SQLite after
+// the file system read is published to the diagnostics channel.
+const auditCode = `const dc = require('node:diagnostics_channel');
+const sqlite = require('node:sqlite');
+const msgs = [];
+dc.subscribe('node:permission-model:fs', (m) => msgs.push(m.permission));
+const db = new sqlite.Database(':memory:', { allowExtension: true });
+try {
+  db.loadExtension('nonexistent');
+} catch (e) {
+  console.log('CODE ' + e.code);
+  console.log('MESSAGE ' + e.message);
+}
+console.log('AUDIT ' + JSON.stringify(msgs));`.replace(/\n/g, ' ');
+
+common.spawnPromisified(
+  process.execPath,
+  ['--permission-audit', '--eval', auditCode],
+).then(common.mustCall(({ code, stdout, stderr }) => {
+  assert.strictEqual(code, 0, stderr);
+  assert.match(stdout, /CODE ERR_LOAD_SQLITE_EXTENSION/);
+  assert.doesNotMatch(stdout, /permission model is enabled/);
+  assert.match(stdout, /AUDIT \["FileSystemRead"\]/);
+}));