diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1acaac9..1158511 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,9 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: npm + cache-dependency-path: | + package-lock.json + docs/package-lock.json - name: Install clean packages run: npm clean-install @@ -55,6 +58,14 @@ jobs: - name: Build run: npm run build + - name: Build and verify the Developer Portal + if: matrix.node-version == '24' + working-directory: docs + run: | + npm ci + npm run build:site + npm run typecheck + - name: Verify SDK distribution run: npm run check:sdk-dist @@ -64,6 +75,9 @@ jobs: server=$! trap 'kill "$server"' EXIT node scripts/check-sdk-browser.mjs http://127.0.0.1:8765/ + if [[ "${{ matrix.node-version }}" == "24" ]]; then + node docs/scripts/check-browser.mjs http://127.0.0.1:8765 + fi - name: Exercise the Java runtime provider run: | diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml index 8e3b5f0..a64d0c1 100644 --- a/.github/workflows/deploy-pages.yml +++ b/.github/workflows/deploy-pages.yml @@ -57,6 +57,9 @@ jobs: with: node-version-file: '.nvmrc' cache: npm + cache-dependency-path: | + package-lock.json + docs/package-lock.json - name: Install clean packages run: npm clean-install @@ -64,6 +67,13 @@ jobs: - name: Build run: npm run build + - name: Build the Developer Portal + working-directory: docs + run: | + npm ci + npm run build:site + npm run typecheck + - name: Check new SDK artifacts and retain published versions env: GH_TOKEN: ${{ github.token }} @@ -105,6 +115,7 @@ jobs: run: | test -s dist/index.html || { echo "::error::dist/index.html is missing"; exit 1; } test -s dist/decodebox.html || { echo "::error::dist/decodebox.html is missing - the download button would 404"; exit 1; } + test -s dist/docs/index.html || { echo "::error::dist/docs/index.html is missing"; exit 1; } # The application must never call out to a third party at runtime. This is a # coarse check, but it catches an accidental CDN reference before it ships. if grep -rIloE 'https?://(cdn|unpkg|jsdelivr)' dist --include='*.js' --include='*.html' | head -1 | grep -q .; then @@ -173,14 +184,19 @@ jobs: # that finishes does the CDN start serving the new files. It usually # takes a minute; it has taken twenty. Eight attempts over 160 seconds # was calling that a failure, which is a check that cries wolf. + docs_url="${url%/}/docs/" + docs_body=$(mktemp) + trap 'rm -f "$docs_body"' EXIT for attempt in $(seq 1 24); do body=$(curl -fsSL --max-time 30 "$url" || true) case "$body" in *"$entry"*) - echo "$url is serving this build." - npm run check:sdk-dist -- dist "$url" - node scripts/check-sdk-browser.mjs "${url%/}/" - exit 0 + if curl -fsSL --max-time 30 "$docs_url" -o "$docs_body" && cmp -s dist/docs/index.html "$docs_body"; then + echo "$url and $docs_url are serving this build." + npm run check:sdk-dist -- dist "$url" + node scripts/check-sdk-browser.mjs "${url%/}/" + exit 0 + fi ;; *src/app/main.tsx*) # This one never resolves itself: it means Pages is pointed at @@ -189,8 +205,8 @@ jobs: exit 1 ;; esac - echo "Attempt $attempt/24: $url is not serving $entry yet." + echo "Attempt $attempt/24: the application and Developer Portal are not both serving this build yet." sleep 20 done - echo "::error::$url did not serve $entry within eight minutes. gh-pages has the build - check whether GitHub's own 'pages build and deployment' run is still queued, and re-run this job once it has finished." + echo "::error::$url and $docs_url did not serve the expected build within eight minutes. gh-pages has the build - check whether GitHub's own 'pages build and deployment' run is still queued, and re-run this job once it has finished." exit 1 diff --git a/.lycheeignore b/.lycheeignore index 3977266..6f27033 100644 --- a/.lycheeignore +++ b/.lycheeignore @@ -17,3 +17,9 @@ https://groups.google.com/a/owasp.com/ # GitHub upload links (the README demo video) answer 404 to anonymous requests; # GitHub signs them when it renders the page. ^https://github\.com/user-attachments/ + +# The portal build generates these references and validates their rendered links. +^file://.*/docs/content/(operations|sdk-reference)/index\.md$ + +# The Pages deployment verifies this URL after publishing the portal artifact. +^https://decodebox\.owasp\.org/docs/?$ diff --git a/README.md b/README.md index e5bafb4..30666ad 100644 --- a/README.md +++ b/README.md @@ -26,32 +26,18 @@ evidence you can inspect, and the steps that reach a layer can become an editabl - **Capture the flag (CTF).** Search decoded layers for flag patterns, review ranked hints for the next transformation, and copy the findings into a Markdown report. -## JavaScript SDK - -Use the workbench’s operations, recipes and multilayer analysis in browsers or Java-enabled GraalJS. -**Official SDK deployment is pending.** Once published, add this snippet to an HTML page -and open the console to see `Hello`. The hosted SDK runs in the browser without a local build. - -```html - - - -``` +## Documentation -The [SDK guide](docs/sdk/README.md) explains the distribution paths and versioning. -To use the SDK before deployment, follow -[local and offline setup](docs/sdk/README.md#local-development--offline-usage). +[DecodeBox Developer Portal](https://decodebox.owasp.org/docs) ## Development -Use Node.js 24, run `npm ci`, then `npm run dev`. The [development guide](docs/development.md) -covers regression tests and builds for the site, standalone application and SDK. See the -[documentation index](docs/README.md) for the project layout and API reference. +Use Node.js 24. Install dependencies and start the development server: + +```bash +npm ci +npm run dev +``` ## Standalone Edition @@ -71,7 +57,7 @@ anyone with the link can read it. Report vulnerabilities privately through the For decoding errors, include a small, non-sensitive sample, your recipe, and the expected result. Contributions to operations should include test vectors. Follow the -[OWASP contributing guidelines](https://github.com/OWASP/.github/blob/master/CONTRIBUTING.md) +[OWASP contributing guidelines](https://raw.githubusercontent.com/OWASP/.github/master/CONTRIBUTING.md) and [Code of Conduct](https://policy.owasp.org/operational/code-of-conduct). ## Project Leader diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000..e44c1bf --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,6 @@ +.rspress/ +.rspress-dev/ +generated/ +content/operations/ +content/sdk-reference/ +content/public/ diff --git a/docs/README.md b/docs/README.md index d3a5cd6..de4f98b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,10 +1,50 @@ -# DecodeBox documentation +# DecodeBox Developer Portal -Use the [workbench](https://decodebox.owasp.org/) to inspect data interactively, or embed the -same operations and analysis engine in an application. +The portal uses Rspress and is published under +[decodebox.owasp.org/docs](https://decodebox.owasp.org/docs). -- [Architecture](architecture.md) describes the workbench, worker, engine and runtime providers. -- [Development](development.md) covers local development, tests, builds and publishing. -- [JavaScript SDK](sdk/README.md) covers the hosted Quick Start, distribution paths and offline use. -- [API reference](sdk/api-reference.md) documents inputs, options, results and failure handling. -- [Integrations](sdk/integrations.md) covers browsers, TypeScript, GraalJS and ZAP. +## Local development + +Use Node.js 24. From the repository root, install the application dependencies, +then start the documentation development server: + +```bash +npm ci +cd docs +npm ci +npm run dev +``` + +Open the URL printed by Rspress at the `/docs/` path. Restart the server after +changing the SDK to regenerate the references and refresh the local SDK bundle. + +## Production build + +From the repository root: + +```bash +npm run build +npm --prefix docs run build:site +npm run preview +``` + +The root build creates the application, standalone edition and official SDK. +The portal build generates SDK and operation Markdown from that SDK and places +the website under `dist/docs/`. Open `/docs/` on the Vite preview server to +preview the complete artifact with the SDK served from the same origin. + +Edit the authored pages in `content/`. The build recreates the reference pages +and navigation, so changes to those belong in the SDK or generator. + +## Browser verification + +With the complete build served on port 4173 and Google Chrome installed, run +this smoke check from the repository root: + +```bash +node docs/scripts/check-browser.mjs http://127.0.0.1:4173 +``` + +Pass the documentation dev server's URL and add `--local-dev` to test the +locally built SDK. The check covers navigation, search, SDK execution, and +clipboard actions. diff --git a/docs/architecture.md b/docs/architecture.md deleted file mode 100644 index bc011cd..0000000 --- a/docs/architecture.md +++ /dev/null @@ -1,24 +0,0 @@ -# Architecture - -The React entry point lives in [src/app](../src/app/). Components, hooks, Zustand state, -translations and styles have their own directories under `src/`. UI conveniences such as -favorites, recipe sharing and browser storage belong to the application. - -The application calls the [engine façade](../src/engine/index.ts), which loads the processing -code on demand. The [worker](../src/engine/worker/) handles work away from the UI thread. -The standalone HTML embeds its scripts, styles and fonts and runs the engine on the main thread. - -The [operation registry](../src/engine/operations/index.ts) owns operation IDs, arguments, -metadata and implementations. [Core](../src/engine/core/) executes recipes and handles bytes. -Detection, recursive analysis, inspection and CTF hints use these same operations. -Engine regression tests live in [src/engine/tests](../src/engine/tests/). - -The [SDK](../src/sdk/index.ts) validates requests and exposes detached registry metadata. -The classic entry point installs the global object. The module entry point exports the same API. -Neither calls React, the application store or the worker client. - -Platform services implement the [runtime interface](../src/engine/runtime/provider.ts). -The web provider uses native browser primitives. The SDK selects the Java provider when GraalJS -exposes Java interop. It uses JCA, SecureRandom, in-memory ZIP streams and Java time zone rules. -Bundled encoding and URL parsers cover APIs that plain GraalJS lacks. The host controls access -to Java classes. New adapters belong behind this internal interface. diff --git a/docs/components/ArgumentsForm.tsx b/docs/components/ArgumentsForm.tsx new file mode 100644 index 0000000..e98ea8a --- /dev/null +++ b/docs/components/ArgumentsForm.tsx @@ -0,0 +1,47 @@ +import { useId } from 'react'; +import type { OperationArg } from './sdk'; + +interface Props { + argument: OperationArg; + onChange: (next: OperationArg) => void; +} + +export function ArgumentField({ argument, onChange }: Props) { + const id = useId(); + const hintId = id + '-hint'; + const { name, value, type, hint } = argument; + const common = { id, 'aria-describedby': hintId }; + const updateValue = (next: OperationArg['value']) => onChange({ ...argument, value: next }); + + return ( +
+ + {type === 'boolean' && updateValue(event.currentTarget.checked)} />} + {type === 'option' && } + {type === 'number' && updateValue(event.currentTarget.valueAsNumber)} />} + {type === 'textarea' &&