Skip to content

:trust puts incorrect(?) SHA-256 to trust database #31241

@andrey-starodubtsev

Description

@andrey-starodubtsev

Problem

trust command writes incorrect hash to trust database

Steps to reproduce

echo "vim.o.exrc = true" > %LOCALAPPDATA%/nvim/init.lua
mkdir "C:\tmp\1.d"
cd "C:\tmp\1.d"
echo abc = 1 > .nvim.lua

open nvim, press a to trust .nvim.lua in current directory and exit NeoVim

cat %LOCALAPPDATA%/nvim-data/trust
65ccf3b8a852603a341b039e58b211d1311b6b7d20df7d904def399171aba85b C:\tmp\1.d\.nvim.lua

@rem C:\Program Files\Git\usr\bin\sha256sum.exe is used here
sha256sum -t .nvim.lua
ee550c37003c2b228311e0148c5edf8a6de34c669b48dd987fca06eebff1c489  .nvim.lua

open nvim .nvim.lua, add one empty line at the end of the file, execute :w | trust | q

cat %LOCALAPPDATA%/nvim-data/trust
9acde475de7c19b8d2725504270568a0c4a08e1243b2b60c9d7b6bd18956e636 C:\tmp\1.d\.nvim.lua

sha256sum -t .nvim.lua
9acde475de7c19b8d2725504270568a0c4a08e1243b2b60c9d7b6bd18956e636  .nvim.lua

(!) open nvim .nvim.lua, it complains about file not being trusted; press a(llow) and exit nvim.

cat %LOCALAPPDATA%/nvim-data/trust
84c32a397500f69ffe7e452fa0be8e019ad431466fa3e08f77f243abd216d083 C:\tmp\1.d\.nvim.lua

sha256sum -t .nvim.lua
9acde475de7c19b8d2725504270568a0c4a08e1243b2b60c9d7b6bd18956e636  .nvim.lua

Expected behavior

After trust command is issued for .nvim.lua, next time it's loaded, it's already in trust database.

Nvim version (nvim -v)

NVIM v0.10.2, Build type: Release, LuaJIT 2.1.1713484068

Vim (not Nvim) behaves the same?

vim doesn't have trust feature

Operating system/version

Windows 11 Home

Terminal name/version

cmd.exe, Microsoft Windows [Version 10.0.22631.4460]

$TERM environment variable

absent

Installation

winget

Metadata

Metadata

Assignees

No one assigned

    Labels

    filesystemfile metadata/attributes, filenames, path manipulationneeds:reproWe need minimal steps to reproduce the issueplatform:windows

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions