Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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: |
Expand Down
28 changes: 22 additions & 6 deletions .github/workflows/deploy-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,23 @@ 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

- 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 }}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
6 changes: 6 additions & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/?$
32 changes: 9 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<meta charset="utf-8">
<script src="https://decodebox.owasp.org/api.js"></script>
<script>
DecodeBox.ready.then(async () => {
const result = await DecodeBox.executeOperation("from-base64", "SGVsbG8=");
console.log(result); // Hello
});
</script>
```
## 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

Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.rspress/
.rspress-dev/
generated/
content/operations/
content/sdk-reference/
content/public/
56 changes: 48 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -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.
24 changes: 0 additions & 24 deletions docs/architecture.md

This file was deleted.

47 changes: 47 additions & 0 deletions docs/components/ArgumentsForm.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="sdk-field">
<label htmlFor={id}>{name}</label>
{type === 'boolean' && <input {...common} type="checkbox" checked={Boolean(value)}
onChange={(event) => updateValue(event.currentTarget.checked)} />}
{type === 'option' && <select {...common} value={String(value)}
onChange={(event) => updateValue(event.currentTarget.value)}>
{argument.options?.map((option) => <option key={option} value={option}>
{argument.optionLabels?.[option] ?? option}
</option>)}
</select>}
{type === 'number' && <input {...common} type="number" required step="any"
min={argument.min} max={argument.max} defaultValue={String(value)}
onChange={(event) => updateValue(event.currentTarget.valueAsNumber)} />}
{type === 'textarea' && <textarea {...common} value={String(value)} rows={3}
onChange={(event) => updateValue(event.currentTarget.value)} />}
{(type === 'string' || type === 'toggleString') && <input {...common}
type="text" value={String(value)} onChange={(event) => updateValue(event.currentTarget.value)} />}
{type === 'toggleString' && argument.toggleValues && (
<div>
<label htmlFor={id + '-format'}>{name} format</label>
<select id={id + '-format'} value={argument.toggleValue ?? ''} onChange={(event) => onChange({
...argument, toggleValue: event.currentTarget.value,
})}>
{argument.toggleValues.map((format) => <option key={format}>{format}</option>)}
</select>
</div>
)}
<small id={hintId}>{hint}</small>
</div>
);
}
76 changes: 76 additions & 0 deletions docs/components/CodecLab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { useId, useState } from 'react';
import { rewrap } from '../../src/engine/core/rewrap';
import { codecDirections, codecModeArgument, type CodecDirection } from '../../src/sdk/codecMetadata';
import catalogue from '../generated/operations.json';
import { OperationRunner } from './OperationRunner';
import type { Operation, OperationArg } from './sdk';

const operations = catalogue as Operation[];
const codecs = operations.flatMap((operation) =>
codecDirections(operation).map((direction) => ({ operation, direction })));
const getPartner = (id: string, mode: CodecDirection) => codecs.find(
({ operation, direction }) => operation.id === id && direction !== mode,
);

export function CodecLab() {
const id = useId();
const [mode, setMode] = useState<CodecDirection>('encode');
const [selectedId, setSelectedId] = useState('');
const [input, setInput] = useState('');
const [inverseArgs, setInverseArgs] = useState<OperationArg[]>();
const choices = codecs.filter((item) => item.direction === mode).map((item) => item.operation);
const operation = choices.find((item) => item.id === selectedId);
const inverseOf = (args: OperationArg[]) => operation && rewrap(
[{ uid: 'codec', opId: operation.id, args, disabled: false }], operations, () => 'inverse',
);
const inverse = operation && inverseOf(operation.args);
const partner = inverse && inverse.ok && getPartner(inverse.steps[0]?.opId ?? '', mode);
const modeArgument = operation && codecModeArgument(operation);
const initialArgs = inverseArgs ?? operation?.args.map((argument) => {
if (argument !== modeArgument) return argument;
return { ...argument, value: argument.options?.find((option) => option.toLowerCase() === mode) ?? argument.value };
});

function swap(output: string, args: OperationArg[]) {
const inverse = inverseOf(args);
if (!inverse?.ok) return;
const step = inverse.steps[0];
const next = step && getPartner(step.opId, mode);
if (!next) return;
setInput(output);
setMode(next.direction);
setSelectedId(next.operation.id);
setInverseArgs(step.args);
}

return (
<section className="sdk-tool" aria-label="Encoding and Decoding Lab">
<div className="sdk-grid sdk-selectors">
<fieldset className="sdk-mode">
<legend>Mode</legend>
{(['encode', 'decode'] as const).map((direction) => (
<label key={direction}>
<input type="radio" name={id + '-mode'} checked={mode === direction}
onChange={() => { setMode(direction); setSelectedId(''); setInverseArgs(undefined); }} />
{direction === 'encode' ? 'Encode' : 'Decode'}
</label>
))}
</fieldset>
<div>
<label htmlFor={id + '-format'}>Format</label>
<select id={id + '-format'} value={operation?.id ?? ''}
onChange={(event) => { setSelectedId(event.currentTarget.value); setInverseArgs(undefined); }}>
<option value="">Choose a format</option>
{choices.map((item) => <option key={item.id} value={item.id}>{item.name}</option>)}
</select>
</div>
</div>
{operation && <>
<p>{operation.description}</p>
<OperationRunner key={operation.id} operation={operation} input={input} onInputChange={setInput}
runLabel={mode === 'encode' ? 'Encode' : 'Decode'} initialArgs={initialArgs}
onSwap={partner ? swap : undefined} />
</>}
</section>
);
}
21 changes: 21 additions & 0 deletions docs/components/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useState } from 'react';

export function CopyButton({ text, label }: { text: string; label: string }) {
const [result, setResult] = useState('');

async function copy() {
try {
await navigator.clipboard.writeText(text);
setResult('Copied');
} catch {
setResult('Copy failed');
}
}

return (
<span className="sdk-copy">
<button type="button" onClick={() => void copy()}>{label}</button>
<span role="status">{result}</span>
</span>
);
}
Loading
Loading