diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c8dd83d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +name: CI + +on: + push: + branches: ["main"] + pull_request: + types: [opened, synchronize] + +jobs: + build: + name: Build and Test + timeout-minutes: 15 + runs-on: macos-latest + + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ vars.TURBO_TEAM }} + TURBO_REMOTE_ONLY: true + + steps: + - name: Check out code + uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'npm' + + - name: Setup Rust environment + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Install nj-cli build + run: cargo install nj-cli + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e9cab19 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,24 @@ +[submodule "grammars/tree-sitter-javascript"] + path = grammars/tree-sitter-javascript + url = git@github.com:tree-sitter/tree-sitter-javascript.git +[submodule "grammars/tree-sitter-html"] + path = grammars/tree-sitter-html + url = https://github.com/tree-sitter/tree-sitter-html +[submodule "grammars/tree-sitter-cpp"] + path = grammars/tree-sitter-cpp + url = git@github.com:tree-sitter/tree-sitter-cpp.git +[submodule "grammars/tree-sitter-bash"] + path = grammars/tree-sitter-bash + url = git@github.com:tree-sitter/tree-sitter-bash.git +[submodule "grammars/tree-sitter-rust"] + path = grammars/tree-sitter-rust + url = git@github.com:tree-sitter/tree-sitter-rust.git +[submodule "grammars/tree-sitter-diff"] + path = grammars/tree-sitter-diff + url = git@github.com:the-mikedavis/tree-sitter-diff.git +[submodule "grammars/tree-sitter-c"] + path = grammars/tree-sitter-c + url = https://github.com/tree-sitter/tree-sitter-c +[submodule "grammars/tree-sitter-typescript"] + path = grammars/tree-sitter-typescript + url = https://github.com/tree-sitter/tree-sitter-typescript diff --git a/app/[slug]/page.tsx b/app/[slug]/page.tsx index 773a3c7..fb0c47d 100644 --- a/app/[slug]/page.tsx +++ b/app/[slug]/page.tsx @@ -1,7 +1,8 @@ import {readFileSync} from 'fs'; import remarkGfm from 'remark-gfm'; import PostPage from './blog-page'; -import rehypeTrestSitter from 'rehype-trest-sitter'; +import rehypeTreeSitter from 'rehype-tree-sitter'; +// import rehypeTrestSitter from 'rehype-trest-sitter'; import {compileMDX} from 'next-mdx-remote/rsc'; import dynamic from 'next/dynamic'; import Image from 'next/image'; @@ -33,7 +34,21 @@ async function getMDXSource(slug: string) { mdxOptions: { remarkPlugins: [remarkGfm], rehypePlugins: [ - [rehypeTrestSitter, {url: 'https://trest.zeb.zone', apiKey: process.env.TREST_API_KEY}], + [rehypeTreeSitter, { + treeSitterGrammarRoot: "./grammars/", + scopeMap: { + typescript: "source.ts", + ts: "source.ts", + javascript: "source.js", + js: "source.js", + cpp: "source.cpp", + c: "source.c", + sh: "source.bash", + rust: "source.rust", + html: "text.html.basic", + }, + }] + // [rehypeTrestSitter, {url: 'https://trest.zeb.zone', apiKey: process.env.TREST_API_KEY}], ], }, }, diff --git a/app/posts/2022/12/reverse-engineering-tiktok-vm-obfuscation/reverse-engineering-tiktok-vm-1.mdx b/app/posts/2022/12/reverse-engineering-tiktok-vm-obfuscation/reverse-engineering-tiktok-vm-1.mdx index 41d83ce..2454cbf 100644 --- a/app/posts/2022/12/reverse-engineering-tiktok-vm-obfuscation/reverse-engineering-tiktok-vm-1.mdx +++ b/app/posts/2022/12/reverse-engineering-tiktok-vm-obfuscation/reverse-engineering-tiktok-vm-1.mdx @@ -21,7 +21,7 @@ of a request made on tiktok.com can begin to paint the picture for us. Let's sta for the term "food". Upon pressing enter, TikTok sends off a GET request with our search term and some extra telemetry embedded. -``` +```sh curl -G \ -d 'aid=1988' \ -d 'app_language=en' \ diff --git a/app/posts/2023/08/compiling-browser-to-bypass-antibot-measures.mdx b/app/posts/2023/08/compiling-browser-to-bypass-antibot-measures.mdx index 7eb2256..da35ea0 100644 --- a/app/posts/2023/08/compiling-browser-to-bypass-antibot-measures.mdx +++ b/app/posts/2023/08/compiling-browser-to-bypass-antibot-measures.mdx @@ -658,13 +658,13 @@ Where `block` is just the `result` from this current block and `this._lastCipher [^8]: This is why it's crucial the procedures for decryption and encryption key extraction are used on the *first* time `decrypt` and `encrypt` are called, otherwise we'd be stuck not knowing the last cipher block. -```c +```cpp partial_decrypt_result ^ round_key ^ decrypt_iv = plaintext ``` Where everything is known except for `round_key`. This formula can be rearranged to calculate the `round_key`: -```c +```cpp round_key = partial_decrypt_result ^ plaintext ^ decrypt_iv ``` diff --git a/app/styles/penumbra.css b/app/styles/penumbra.css index 23bb0d7..1a43b11 100644 --- a/app/styles/penumbra.css +++ b/app/styles/penumbra.css @@ -29,7 +29,7 @@ pre { .type { color: var(--green); } -.type.enum.variant { +.type\.enum\.variant { color: var(--green); } .label { @@ -41,25 +41,28 @@ pre { .constant { color: var(--purple); } -.constant.numeric { +.constant\.numeric { color: var(--cyan); } -.constant.character { +.constant\.character { color: var(--purple); } .string { color: var(--yellow); } -.string.special.symbol { +.string\.special\.symbol { color: var(--cyan); } -.string.special.path { +.string\.special\.path { color: var(--cyan); } .variable { color: var(--sky); } -.variable.builtin { +.variable\.parameter { + color: var(--sky); +} +.variable\.builtin { color: var(--red); } .keyword { @@ -68,25 +71,31 @@ pre { .function { color: var(--blue); } -.function.macro { +.function\.method { + color: var(--blue); +} +.function\.macro { color: var(--purple); } .punctuation { color: var(--sky); } +.punctuation\.bracket { + color: var(--sky); +} .operator { color: var(--magenta); } .namespace { color: var(--sky); } -.diff.plus { +.diff\.plus { color: var(--green); } -.diff.minus { +.diff\.minus { color: var(--red); } -.diff.delta { +.diff\.delta { color: var(--cyan); } .hint { @@ -101,101 +110,101 @@ pre { .error { color: var(--red); } -.ui.background { +.ui\.background { background-color: var(--shade); } -.ui.background.separator { +.ui\.background\.separator { color: var(--sky); } -.ui.cursor.match { +.ui\.cursor\.match { background-color: var(--shadeplus); } -.ui.cursorline.primary { +.ui\.cursorline\.primary { background-color: var(--shademinus); } -.ui.linenr { +.ui\.linenr { color: var(--skyminus); } -.ui.linenr.selected { +.ui\.linenr\.selected { color: var(--sky); } -.ui.statusline { +.ui\.statusline { color: var(--shade); background-color: var(--sky); } -.ui.statusline.inactive { +.ui\.statusline\.inactive { color: var(--sky); background-color: var(--shadeplus); } -.ui.statusline.normal { +.ui\.statusline\.normal { color: var(--shade); background-color: var(--blue); } -.ui.statusline.insert { +.ui\.statusline\.insert { color: var(--shade); background-color: var(--green); } -.ui.statusline.select { +.ui\.statusline\.select { color: var(--shade); background-color: var(--purple); } -.ui.popup { +.ui\.popup { background-color: var(--shademinus); } -.ui.popup.info { +.ui\.popup\.info { background-color: var(--shade); } -.ui.window { +.ui\.window { color: var(--sky); } -.ui.help { +.ui\.help { color: var(--sky); background-color: var(--shademinus); } -.ui.text { +.ui\.text { color: var(--sky); } -.ui.text.focus { +.ui\.text\.focus { color: var(--blue); } -.ui.text.info { +.ui\.text\.info { color: var(--sky); } -.ui.virtual.ruler { +.ui\.virtual\.ruler { background-color: var(--shademinus); } -.ui.virtual.whitespace { +.ui\.virtual\.whitespace { color: var(--skyminus); } -.ui.virtual.indent-guide { +.ui\.virtual\.indent-guide { color: var(--shadeplus); } -.ui.menu { +.ui\.menu { color: var(--sky); background-color: var(--shademinus); } -.ui.menu.selected { +.ui\.menu\.selected { color: var(--blue); } -.ui.menu.scroll { +.ui\.menu\.scroll { color: var(--sky); background-color: var(--shadeplus); } -.ui.selection { +.ui\.selection { background-color: var(--shadeplus); } -.markup.heading { +.markup\.heading { color: var(--skyplus); } -.markup.list { +.markup\.list { color: var(--sky); } -.markup.link.text { +.markup\.link\.text { color: var(--magenta); } -.markup.quote { +.markup\.quote { color: var(--green); } -.markup.raw { +.markup\.raw { color: var(--orange); } diff --git a/grammars/tree-sitter-bash b/grammars/tree-sitter-bash new file mode 160000 index 0000000..bdcd56c --- /dev/null +++ b/grammars/tree-sitter-bash @@ -0,0 +1 @@ +Subproject commit bdcd56c5a3896f7bbb7684e223c43d9f24380351 diff --git a/grammars/tree-sitter-c b/grammars/tree-sitter-c new file mode 160000 index 0000000..f1075f2 --- /dev/null +++ b/grammars/tree-sitter-c @@ -0,0 +1 @@ +Subproject commit f1075f2d65ecb62725821fd8a34ce68c1fa8ae51 diff --git a/grammars/tree-sitter-cpp b/grammars/tree-sitter-cpp new file mode 160000 index 0000000..a90f170 --- /dev/null +++ b/grammars/tree-sitter-cpp @@ -0,0 +1 @@ +Subproject commit a90f170f92d5d70e7c2d4183c146e61ba5f3a457 diff --git a/grammars/tree-sitter-diff b/grammars/tree-sitter-diff new file mode 160000 index 0000000..c165725 --- /dev/null +++ b/grammars/tree-sitter-diff @@ -0,0 +1 @@ +Subproject commit c165725c28e69b36c5799ff0e458713a844f1aaf diff --git a/grammars/tree-sitter-html b/grammars/tree-sitter-html new file mode 160000 index 0000000..e5d7d7d --- /dev/null +++ b/grammars/tree-sitter-html @@ -0,0 +1 @@ +Subproject commit e5d7d7decbbdec5a4c90bbc69436b3828f5646e7 diff --git a/grammars/tree-sitter-javascript b/grammars/tree-sitter-javascript new file mode 160000 index 0000000..f1e5a09 --- /dev/null +++ b/grammars/tree-sitter-javascript @@ -0,0 +1 @@ +Subproject commit f1e5a09b8d02f8209a68249c93f0ad647b228e6e diff --git a/grammars/tree-sitter-rust b/grammars/tree-sitter-rust new file mode 160000 index 0000000..17a6b15 --- /dev/null +++ b/grammars/tree-sitter-rust @@ -0,0 +1 @@ +Subproject commit 17a6b15562b09db1f27b8f5f26f17edbb2aac097 diff --git a/grammars/tree-sitter-typescript b/grammars/tree-sitter-typescript new file mode 160000 index 0000000..d847898 --- /dev/null +++ b/grammars/tree-sitter-typescript @@ -0,0 +1 @@ +Subproject commit d847898fec3fe596798c9fda55cb8c05a799001a diff --git a/package.json b/package.json index f87b1d9..e0abd63 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "scripts": { "dev": "next", "dev:watch": "next-remote-watch ./posts", - "build": "next build", + "install-grammars": "cd grammars/tree-sitter-typescript && npm install && cd ../tree-sitter-cpp && npm install", + "build": "npm run install-grammars && turbo run build", "export": "next export", "start": "next start", "lint": "eslint ." @@ -32,10 +33,12 @@ "next-mdx-remote": "^4.4.1", "react": "latest", "react-dom": "latest", + "rehype-tree-sitter": "^0.2.4", "rehype-trest-sitter": "^0.1.0", "remark-gfm": "^3.0.1", "remark-images": "^3.1.0", "sharp": "^0.30.7", + "turbo": "^1.10.13", "urlcat": "^2.0.4" }, "devDependencies": { diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..da3ee83 --- /dev/null +++ b/turbo.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://turbo.build/schema.json", + "pipeline": { + "build": { + "outputs": [".next/**", "!.next/cache/**"], + "dependsOn": ["^build"] + }, + "test": { + "dependsOn": ["^build"] + } + } + } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 6a9d5e3..7704a8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1327,11 +1327,13 @@ __metadata: prettier: ^2.6.1 react: latest react-dom: latest + rehype-tree-sitter: ^0.2.4 rehype-trest-sitter: ^0.1.0 remark-gfm: ^3.0.1 remark-images: ^3.1.0 sharp: ^0.30.7 tailwindcss: ^3.0.23 + turbo: ^1.10.13 typescript: ^4.6.3 urlcat: ^2.0.4 languageName: unknown @@ -3241,7 +3243,7 @@ __metadata: languageName: node linkType: hard -"hastscript@npm:^7.0.0": +"hastscript@npm:^7.0.0, hastscript@npm:^7.2.0": version: 7.2.0 resolution: "hastscript@npm:7.2.0" dependencies: @@ -5704,6 +5706,18 @@ __metadata: languageName: node linkType: hard +"rehype-tree-sitter@npm:^0.2.4": + version: 0.2.4 + resolution: "rehype-tree-sitter@npm:0.2.4" + dependencies: + hastscript: ^7.2.0 + rehype: ^12.0.1 + string-byte-slice: ^2.0.0 + unist-util-visit: ^5.0.0 + checksum: 0136cb6d5de3b3382c050bf36bf8a4967e274c7c328a68b4b4fdd1f93a419ded37b132b336aa22fe7fc17aff17e818ff6c23f17332e571adc058a585eed2fca5 + languageName: node + linkType: hard + "rehype-trest-sitter@npm:^0.1.0": version: 0.1.0 resolution: "rehype-trest-sitter@npm:0.1.0" @@ -6200,6 +6214,13 @@ __metadata: languageName: node linkType: hard +"string-byte-slice@npm:^2.0.0": + version: 2.0.0 + resolution: "string-byte-slice@npm:2.0.0" + checksum: 45cace58c3aff16416959e4847d078f886a32827ca2853bb0c9f8293cea592f7bbf0a36f7e6e88578e86aab06fb6752c30ed40d9b2a2c85c866e5213b35f778f + languageName: node + linkType: hard + "string-width@npm:^1.0.2 || 2 || 3 || 4, string-width@npm:^4.2.3": version: 4.2.3 resolution: "string-width@npm:4.2.3" @@ -6563,6 +6584,77 @@ __metadata: languageName: node linkType: hard +"turbo-darwin-64@npm:1.10.13": + version: 1.10.13 + resolution: "turbo-darwin-64@npm:1.10.13" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"turbo-darwin-arm64@npm:1.10.13": + version: 1.10.13 + resolution: "turbo-darwin-arm64@npm:1.10.13" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"turbo-linux-64@npm:1.10.13": + version: 1.10.13 + resolution: "turbo-linux-64@npm:1.10.13" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"turbo-linux-arm64@npm:1.10.13": + version: 1.10.13 + resolution: "turbo-linux-arm64@npm:1.10.13" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"turbo-windows-64@npm:1.10.13": + version: 1.10.13 + resolution: "turbo-windows-64@npm:1.10.13" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + +"turbo-windows-arm64@npm:1.10.13": + version: 1.10.13 + resolution: "turbo-windows-arm64@npm:1.10.13" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"turbo@npm:^1.10.13": + version: 1.10.13 + resolution: "turbo@npm:1.10.13" + dependencies: + turbo-darwin-64: 1.10.13 + turbo-darwin-arm64: 1.10.13 + turbo-linux-64: 1.10.13 + turbo-linux-arm64: 1.10.13 + turbo-windows-64: 1.10.13 + turbo-windows-arm64: 1.10.13 + dependenciesMeta: + turbo-darwin-64: + optional: true + turbo-darwin-arm64: + optional: true + turbo-linux-64: + optional: true + turbo-linux-arm64: + optional: true + turbo-windows-64: + optional: true + turbo-windows-arm64: + optional: true + bin: + turbo: bin/turbo + checksum: 0c000c671534c8c80270c6d1fc77646df0e44164c0db561a85b3fefadd4bda6d5920626d067abb09af38613024e3984fb8d8bc5be922dae6236eda6aab9447a2 + languageName: node + linkType: hard + "type-check@npm:^0.4.0, type-check@npm:~0.4.0": version: 0.4.0 resolution: "type-check@npm:0.4.0"