Skip to content

Commit 7ae6f31

Browse files
committed
feat: configure shell plugin to be able to execute only java commands (still dangerous)
1 parent 5f13138 commit 7ae6f31

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

src-tauri/capabilities/plugin-os.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"$schema": "../gen/schemas/desktop-schema.json",
33
"identifier": "plugin-os",
4-
"description": "manages the os:* permissions",
4+
"description": "enables the os:* permissions",
55
"windows": [
66
"main"
77
],
88
"permissions": [
99
"os:allow-arch",
1010
"os:allow-exe-extension",
1111
"os:allow-family",
12+
"os:allow-hostname",
1213
"os:allow-locale",
1314
"os:allow-os-type",
1415
"os:allow-platform",

src-tauri/capabilities/plugin-shell.json

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,40 @@
66
"main"
77
],
88
"permissions": [
9-
"shell:allow-execute",
9+
{
10+
"identifier": "shell:allow-execute",
11+
"allow": [
12+
{
13+
"name": "java",
14+
"cmd": "java",
15+
"args": true,
16+
"sidecar": false
17+
}
18+
]
19+
},
20+
{
21+
"identifier": "shell:allow-spawn",
22+
"allow": [
23+
{
24+
"name": "java",
25+
"cmd": "java",
26+
"args": true,
27+
"sidecar": false
28+
}
29+
]
30+
},
31+
{
32+
"identifier": "shell:allow-stdin-write",
33+
"allow": [
34+
{
35+
"name": "java",
36+
"cmd": "java",
37+
"args": true,
38+
"sidecar": false
39+
}
40+
]
41+
},
1042
"shell:allow-kill",
11-
"shell:allow-open",
12-
"shell:allow-spawn",
13-
"shell:allow-stdin-write"
43+
"shell:allow-open"
1444
]
1545
}

src/App.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,20 @@ import NonBundledClasses from "@/components/misc/NonBundledClasses.vue";
2222
import { RouteItems } from "@/constants/routes.ts";
2323
import { capitalize } from "@/lib/helpers/capitalize.ts";
2424
import { log } from "@/lib/handlers/log.ts";
25+
import { Command } from "@tauri-apps/plugin-shell";
2526
2627
const LogViewer = defineAsyncComponent(
2728
() => import("@/components/logging/LogViewer.vue"),
2829
);
2930
31+
(async () => {
32+
const result = await Command.create("java", [
33+
"--version",
34+
]).execute();
35+
36+
console.log(result);
37+
})();
38+
3039
const globalStates = shallowReactive<GlobalStatesType>({
3140
"customLayout": false,
3241
"page" : "home",

0 commit comments

Comments
 (0)