Skip to content

Commit c76b46f

Browse files
authored
fix(nix_flake_fmt): ask the user if the project is trusted (#280)
1 parent db2a48b commit c76b46f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lua/null-ls/builtins/formatting/nix_flake_fmt.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@ end
259259
local find_nix_fmt = function(opts, done)
260260
done = vim.schedule_wrap(done)
261261

262+
-- A malicious project could make `nix fmt` do anything to your computer,
263+
-- so we ask the user if the project is trusted before we do that.
264+
local is_project_trusted = vim.secure.read(opts.root)
265+
if not is_project_trusted then
266+
log:warn(string.format("nix_flake_fmt disabled because project is not trusted: %s", opts.root))
267+
done(nil)
268+
return
269+
end
270+
262271
local async = require("plenary.async")
263272

264273
local notification_title = "discovering `nix fmt` entrypoint"

0 commit comments

Comments
 (0)