feat(secure): add :trust command and vim.secure.trust() (#21107)

Introduce vim.secure.trust() to programmatically manage the trust
database. Use this function in a new :trust ex command which can
be used as a simple frontend.

Resolves: https://github.com/neovim/neovim/issues/21092
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: ii14 <ii14@users.noreply.github.com>
This commit is contained in:
Jlll1
2022-11-28 20:23:04 +01:00
committed by GitHub
parent 77a0f4a542
commit f004812b33
13 changed files with 541 additions and 29 deletions

View File

@@ -53,6 +53,7 @@
#include "nvim/highlight_group.h"
#include "nvim/indent.h"
#include "nvim/input.h"
#include "nvim/lua/executor.h"
#include "nvim/macros.h"
#include "nvim/main.h"
#include "nvim/mark.h"
@@ -4960,3 +4961,29 @@ void ex_oldfiles(exarg_T *eap)
}
}
}
void ex_trust(exarg_T *eap)
{
const char *const p = skiptowhite(eap->arg);
char *arg1 = xmemdupz(eap->arg, (size_t)(p - eap->arg));
const char *action = "allow";
const char *path = skipwhite(p);
if (strcmp(arg1, "++deny") == 0) {
action = "deny";
} else if (strcmp(arg1, "++remove") == 0) {
action = "remove";
} else if (*arg1 != '\0') {
semsg(e_invarg2, arg1);
goto theend;
}
if (path[0] == '\0') {
path = NULL;
}
nlua_trust(action, path);
theend:
xfree(arg1);
}