Skip to content

Commit 09b17a5

Browse files
committed
feat!: holy fuck i'm so close to making permission based plugins
1 parent 7ae6f31 commit 09b17a5

File tree

8 files changed

+110
-5
lines changed

8 files changed

+110
-5
lines changed

bun.lockb

3.2 KB
Binary file not shown.

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<link rel="icon" href="/src-tauri/icons/128x128.png" />
7+
<link rel="stylesheet" href="./assets/index-CsDBtkr9.css" />
78
<title>Kaede</title>
89
</head>
910
<body>
1011
<div id="app"></div>
12+
<div id="blue_archive" style="position:absolute;left:0;top:0;right:0;bottom:0"></div>
1113
<script type="module" src="/src/main.ts"></script>
1214
</body>
1315
</html>

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@
2727
"@tauri-apps/plugin-shell": "~2",
2828
"@tauri-apps/plugin-upload": "~2",
2929
"@vueuse/core": "^14.0.0",
30+
"buffer": "^6.0.3",
31+
"core-js": "^3.46.0",
32+
"core-js-pure": "^3.46.0",
3033
"m3ripple-vue": "^0.1.0",
34+
"ses": "^1.14.0",
35+
"shadowrealm-api": "^0.8.3",
3136
"tauri-plugin-drpc": "^1.0.3",
3237
"typebox": "^1.0.8",
3338
"vue": "^3.5.17",

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"visible": false,
2424
"center": true,
2525
"minWidth": 512,
26-
"minHeight": 384
26+
"minHeight": 288
2727
}
2828
],
2929
"security": {

src/App.vue

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,114 @@ import { RouteItems } from "@/constants/routes.ts";
2323
import { capitalize } from "@/lib/helpers/capitalize.ts";
2424
import { log } from "@/lib/handlers/log.ts";
2525
import { Command } from "@tauri-apps/plugin-shell";
26+
import "ses";
27+
// eslint-disable-next-line unicorn/prefer-node-protocol
28+
import { Buffer } from "buffer";
29+
// import ShadowRealm from "shadowrealm-api";
2630
2731
const LogViewer = defineAsyncComponent(
2832
() => import("@/components/logging/LogViewer.vue"),
2933
);
3034
3135
(async () => {
36+
const url = "./assets/index-CQUR_vLf.js";
37+
const response = await fetch(url);
38+
const _code = await response.text();
39+
const _cleaned = _code
40+
.replace("<!--", "<")
41+
.replace("-->", ">")
42+
.replace("-->", ">");
3243
const result = await Command.create("java", [
3344
"--version",
3445
]).execute();
3546
36-
console.log(result);
47+
console.log(result, () => _cleaned);
48+
49+
// const realm = new ShadowRealm;
50+
51+
// await realm.importValue("document", "document");
52+
53+
// realm.evaluate(_cleaned);
54+
55+
console.log("Hardened Javascript test using SES");
56+
console.log(window["__core-js_shared__"]);
57+
58+
const t1 = performance.now();
59+
60+
try {
61+
console.log("Action: Trying to lockdown every JS globals");
62+
// lockdown({
63+
// "evalTaming": "unsafeEval",
64+
// });
65+
} catch {
66+
console.log("Already locked down");
67+
}
68+
69+
window.Buffer = Buffer;
70+
71+
console.log("Action: Creating a safe compartment");
72+
const c = new Compartment({
73+
"globals": {
74+
"console" : console,
75+
"log" : log,
76+
"document": document,
77+
"window" : window,
78+
"location": location,
79+
"fetch" : (...args: unknown[]) => fetch(args),
80+
Symbol,
81+
Uint8Array,
82+
Buffer,
83+
MathMLElement,
84+
HTMLElement,
85+
HTMLDivElement,
86+
global: window,
87+
globalThis: window,
88+
Date,
89+
requestAnimationFrame: window.requestAnimationFrame.bind(window),
90+
cancelAnimationFrame: window.cancelAnimationFrame.bind(window),
91+
"performance": window.performance,
92+
ElementPrototype: Element.prototype,
93+
HTMLElementPrototype: HTMLElement.prototype,
94+
NodePrototype: Node.prototype,
95+
EventTargetPrototype: EventTarget.prototype,
96+
SVGElement,
97+
Element,
98+
WebGLRenderingContext,
99+
WebGL2RenderingContext,
100+
navigator,
101+
screen,
102+
"dispatchEvent" : EventTarget.prototype.dispatchEvent,
103+
"addEventListener" : EventTarget.prototype.addEventListener,
104+
"removeEventListener": EventTarget.prototype.removeEventListener,
105+
HTMLCanvasElement,
106+
HTMLInputElement,
107+
CanvasRenderingContext2D,
108+
CanvasGradient,
109+
CanvasPattern,
110+
ImageBitmap,
111+
ImageData,
112+
TextMetrics,
113+
OffscreenCanvas,
114+
Path2D,
115+
ImageBitmapRenderingContext,
116+
"yi": {
117+
"__core-js_shared__": window["__core-js_shared__"],
118+
},
119+
"__core-js_shared__": window["__core-js_shared__"],
120+
},
121+
"__options__": true,
122+
});
123+
const t2 = performance.now();
124+
125+
console.log("Action: Running the contained code");
126+
try {
127+
await c.evaluate(_cleaned);
128+
} catch (error) {
129+
console.error("Error in the container:", error);
130+
}
131+
132+
const t3 = performance.now();
133+
console.log("Locking down & hardening done in", t2 - t1, "ms\n", "Evaluation done in", t3 - t2, "ms");
37134
})();
38135
39136
const globalStates = shallowReactive<GlobalStatesType>({

src/components/layout/Layout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ useEventListener(window, "mousedown", (event: MouseEvent) => {
6060
<div
6161
@contextmenu.prevent
6262
@contextmenu="showContextMenu"
63-
class="flex flex-nowrap gap-0 relative w-full h-vh overflow-hidden bg-neutral-950 text-white"
63+
class="flex flex-nowrap gap-0 relative w-full h-vh overflow-hidden text-white"
6464
>
6565
<div id="__kaede-extensions" class="block" />
6666
<ContextMenu

src/components/logging/LogViewer.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import MaterialRipple from "@/components/misc/MaterialRipple.vue";
1313
const virtualList = useTemplateRef("virtualList");
1414
1515
const logs = shallowRef<Array<string>>(["__kaede-trigger-loading"]);
16-
const horizontalScroll = ref<boolean>(true);
16+
const horizontalScroll = ref<boolean>(false);
1717
const fileData = ref<{
1818
"size": string | undefined;
1919
"time": string | undefined;
@@ -93,7 +93,7 @@ onMounted(async () => {
9393
return;
9494
}
9595
96-
const filesize = (existingLogs.length / (1024 * 1024)).toFixed(2);
96+
const filesize = (existingLogs.length / (1024 * 1024)).toFixed(3);
9797
9898
log.info("Log file is not empty");
9999
log.debug("Adding existing logs to the 'logs' state");

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import "@unocss/reset/tailwind.css";
1212
import "@/globals.css";
1313
// Import styles that are necessary for Material You ripple effect
1414
import "m3ripple-vue/style.css";
15+
import "core-js/actual";
1516

1617
await prepareLogFile().catch((error: unknown) => {
1718
log.error("Failed to prepare a log file:", JSON.stringify(error));

0 commit comments

Comments
 (0)