Skip to content
Merged
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
31 changes: 31 additions & 0 deletions .github/actions/scan-nginx/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Scan upstream Nginx
description: Check the running binary against upstream advisories and verify that Grype identified it.
inputs:
container:
description: Running container serving the site
required: true
grype-version:
description: Grype version used for the runtime image scan
required: true
runs:
using: composite
steps:
- name: Locate Grype
id: grype
uses: anchore/scan-action/download-grype@27805bf3b4e84b4a5c980df22ed233c00390a439 # v7.4.2
with:
grype-version: ${{ inputs.grype-version }}
- name: Scan the running Nginx version
shell: bash
env:
CONTAINER: ${{ inputs.container }}
GRYPE: ${{ steps.grype.outputs.cmd }}
GRYPE_CHECK_FOR_APP_UPDATE: 'false'
run: |
scan_dir=$(mktemp -d "$RUNNER_TEMP/nginx-upstream.XXXXXXXX")
mkdir "$scan_dir/bin"
docker cp "$CONTAINER:/usr/sbin/nginx" "$scan_dir/bin/nginx"
version=$(docker exec "$CONTAINER" /usr/sbin/nginx -v 2>&1)
report="$scan_dir/report.cdx.json"
"$GRYPE" "dir:$scan_dir/bin" --fail-on negligible --only-fixed=false -o table -o "cyclonedx-json=$report"
node scripts/check-nginx-scan.mjs "$version" < "$report"
9 changes: 8 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ on:

env:
IMAGE_NAME: bankofai/docs
GRYPE_VERSION: v0.121.3

jobs:
lint:
Expand Down Expand Up @@ -88,7 +89,7 @@ jobs:
uses: anchore/scan-action@27805bf3b4e84b4a5c980df22ed233c00390a439 # v7.4.2
with:
image: bankofai/docs:security-check
grype-version: v0.121.3
grype-version: ${{ env.GRYPE_VERSION }}
fail-build: true
severity-cutoff: negligible
only-fixed: false
Expand All @@ -99,6 +100,12 @@ jobs:
docker run --detach --name docs-security-smoke -p 127.0.0.1:8080:80 bankofai/docs:security-check
node scripts/check-http-security.mjs http://127.0.0.1:8080

- name: Scan the custom Nginx binary against upstream advisories
uses: ./.github/actions/scan-nginx
with:
container: docs-security-smoke
grype-version: ${{ env.GRYPE_VERSION }}

- name: Remove test container
if: always()
run: docker rm --force docs-security-smoke || true
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

env:
IMAGE_NAME: bankofai/docs
GRYPE_VERSION: v0.121.3

jobs:
checks:
Expand Down Expand Up @@ -56,7 +57,7 @@ jobs:
uses: anchore/scan-action@27805bf3b4e84b4a5c980df22ed233c00390a439 # v7.4.2
with:
image: bankofai/docs:security-check
grype-version: v0.121.3
grype-version: ${{ env.GRYPE_VERSION }}
fail-build: true
severity-cutoff: negligible
only-fixed: false
Expand All @@ -67,6 +68,12 @@ jobs:
docker run --detach --name docs-security-smoke -p 127.0.0.1:8080:80 bankofai/docs:security-check
node scripts/check-http-security.mjs http://127.0.0.1:8080

- name: Scan the custom Nginx binary against upstream advisories
uses: ./.github/actions/scan-nginx
with:
container: docs-security-smoke
grype-version: ${{ env.GRYPE_VERSION }}

- name: Remove test container
if: always()
run: docker rm --force docs-security-smoke || true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/site-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: yarn install --frozen-lockfile --non-interactive

- name: Audit all dependency severities
run: yarn audit --non-interactive --network-timeout 60000
run: node scripts/audit-dependencies.mjs

- name: Lint
run: yarn lint
Expand Down
31 changes: 22 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ WORKDIR /app

# Copy package.json and yarn.lock
COPY package*.json yarn.lock ./
COPY scripts/patch-picomatch.mjs ./scripts/

RUN echo "Build environment is ${APP_ENV}"

Expand All @@ -28,13 +29,26 @@ COPY . .
# Build the Docusaurus app
RUN yarn build

# Stage 2: Assemble the Nginx runtime without BusyBox (CVE-2025-60876).
# Package installation and inspection tools stay in this intermediate stage.
FROM nginx:1.31-alpine3.24 AS runtime-files

RUN apk upgrade --no-cache \
&& apk add --no-cache 'brotli-libs>=1.2.1-r0' scanelf

# Build a signed HTTP-only package. abuild records the compiled ELF dependencies.
FROM alpine:3.24 AS nginx-build
RUN apk add --no-cache abuild build-base pcre2-dev zlib-dev \
&& adduser -D -G abuild builder
WORKDIR /home/builder/docs/nginx
COPY docker/nginx/APKBUILD .
RUN chown builder:abuild . \
&& su builder -c 'abuild-keygen -an' \
&& cp /home/builder/.abuild/*.rsa.pub /etc/apk/keys/ \
&& su builder -c 'abuild' \
&& mkdir /out \
&& cp /home/builder/packages/docs/*/nginx-*.apk /home/builder/.abuild/*.rsa.pub /out/ \
&& rm /home/builder/.abuild/*.rsa

# Resolve current Alpine libraries for the actual binary on every CI build.
FROM alpine:3.24 AS runtime-files
RUN addgroup -S -g 101 nginx \
&& adduser -S -D -H -u 101 -G nginx -s /sbin/nologin nginx

COPY --from=nginx-build /out/ /tmp/nginx-package/
COPY scripts/prepare-nginx-runtime.sh /usr/local/bin/prepare-nginx-runtime
RUN sh /usr/local/bin/prepare-nginx-runtime

Expand All @@ -43,8 +57,7 @@ COPY default.conf /runtime/etc/nginx/conf.d/default.conf
COPY --from=build /app/.site-security/nginx-headers.conf /runtime/etc/nginx/snippets/security-headers.conf
COPY --from=build /app/build /runtime/usr/share/nginx/html

# Stage 3: Only the server, its shared libraries, package inventory and site ship.
# The upstream shell entrypoint is unnecessary: all configuration is copied above.
# Only the server, its shared libraries, package inventory and site ship.
FROM scratch AS runtime
COPY --from=runtime-files /runtime/ /

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ The site explicitly loads the official docs, pages, debug and sitemap plugins an

### Production security checks

The container assembles a minimal runtime from the official Alpine Nginx binary and its ELF library dependencies. BusyBox, its `wget`/`ssl_client` tooling, shells, package managers and unused dynamic Nginx modules stay outside the final image. The runtime keeps the original Nginx APK inventory and the installed libraries' package records so Grype still scans the software that ships. CI refreshes the `runtime-files` stage on every build; its Alpine packages are not reused from a cached security-update layer.
The container serves HTTP behind the TLS-terminating reverse proxy. Alpine's `abuild` verifies the pinned Nginx source archive, builds it without OpenSSL, and records the binary's ELF dependencies in a signed APK. CI refreshes the runtime libraries on every build and rejects OpenSSL shared libraries, BusyBox and shell tooling in the runtime. Grype scans the installed Alpine packages and checks the extracted Nginx binary against upstream advisories. Publishing requires the upstream scan to identify the version reported by the running server. To upgrade Nginx, verify the new upstream release signature and update the version and SHA-512 in `docker/nginx/APKBUILD`.

The container still listens on port 80 and writes logs to `/app/logs`. Its entrypoint directly runs `/usr/sbin/nginx`, preserves graceful `SIGQUIT` shutdown, and validates configuration with an exec-form `nginx -t` during the build. There is no `docker exec ... sh`; inspect logs externally or run `docker run --rm IMAGE -t` to check configuration.

Expand Down
39 changes: 39 additions & 0 deletions docker/nginx/APKBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pkgname=nginx
pkgver=1.31.8
pkgrel=0
pkgdesc="NGINX HTTP server for BofAI docs"
url="https://nginx.org/"
arch="all"
license="BSD-2-Clause"
makedepends="pcre2-dev zlib-dev"
source="https://nginx.org/download/nginx-$pkgver.tar.gz"

build() {
# TLS terminates at the ingress. The default HTTP build includes gzip,
# PCRE and the modules used by nginx.conf, without linking OpenSSL.
./configure \
--prefix=/var/cache/nginx \
--conf-path=/etc/nginx/nginx.conf \
--pid-path=/run/nginx.pid \
--lock-path=/run/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--user=nginx --group=nginx \
--with-cc-opt="$CFLAGS $CPPFLAGS" \
--with-ld-opt="$LDFLAGS -Wl,-z,relro,-z,now"
make
}

check() {
test "$(objs/nginx -v 2>&1)" = "nginx version: nginx/$pkgver"
}

package() {
install -Dm755 objs/nginx "$pkgdir/usr/sbin/nginx"
install -Dm644 conf/mime.types "$pkgdir/etc/nginx/mime.types"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/nginx/LICENSE"
}

sha512sums="
b05679bd30746f41b17343be570ed62b2bb0bc64e15d24d8af307db03d5227ab6b1da57bb4b640ad4d4c854a0c0233285d5ba294caa4ad199c49522883700fce nginx-1.31.8.tar.gz
"
9 changes: 6 additions & 3 deletions docs/llmservice/api/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

B.AI provides a unified large language model API compatible with the OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages protocols, as well as a Decisions API compatible with the TypeSafe System One protocol. Use the same B.AI API Key with different protocols and choose the endpoint that matches your application or client.

B.AI also provides an asynchronous [Video Generation API](./videos.md) to create tasks, query their status, and download completed videos.
B.AI also provides the [MiniMax Image Generation API](./minimax-image-generation.md) for synchronous text-to-image generation and reference-image editing, with optional SSE streaming. The asynchronous [Video Generation API](./videos.md) supports creating tasks, querying their status, and downloading completed videos.

The [Recharge API](./recharges.md) uses a separate service origin, `https://chat.b.ai`, for cryptocurrency recharge orders. To use it through an Agent, see the [Recharge Skill Guide](./recharge-skill-guide.md).

- **API version:** `v1`
- **Production Base URL:** `https://api.b.ai/v1`
- **Request format:** `application/json`
- **Request format:** `application/json` by default; image editing also supports `multipart/form-data`, which is required for reference-image uploads.
- **Character encoding:** UTF-8
- **Text-generation streaming:** Server-Sent Events (SSE)

Expand Down Expand Up @@ -52,7 +52,7 @@ Replace `your-model-id` with a model ID enabled for the selected endpoint.

B.AI supports the following authentication headers. Both use the same platform-issued API Key; choose either one.

For video generation, use the Bearer authentication shown in the [Video Generation API](./videos.md) request example; `x-api-key` support for that endpoint is not documented here.
For image generation, editing, reference-image uploads, and video generation, use the Bearer authentication shown in the [MiniMax Image Generation API](./minimax-image-generation.md) and [Video Generation API](./videos.md) examples. This reference does not establish `x-api-key` support for those endpoints.

Recharge endpoints also require Bearer authentication. Do not assume that the model service's `x-api-key` alternative applies to recharge requests.

Expand Down Expand Up @@ -94,6 +94,9 @@ Example:
| `POST` | `/responses` | OpenAI Responses | Agents, reasoning, tool use, and Codex |
| `POST` | `/chat/completions` | OpenAI Chat Completions | General chat completions and existing OpenAI-compatible applications |
| `POST` | `/messages` | Anthropic Messages | Claude SDK, Claude Code, and other Anthropic-compatible clients |
| `POST` | [`/images/generations`](./minimax-image-generation.md) | OpenAI SDK-compatible; see model-specific parameters | Generate MiniMax images synchronously, with optional SSE streaming |
| `POST` | [`/images/edits`](./minimax-image-generation.md) | OpenAI SDK-compatible; see model-specific parameters | Edit MiniMax images using references; accepts JSON or multipart form data |
| `POST` | [`/files/upload`](./minimax-image-generation.md#upload-reference-images) | - | Upload reference images with `purpose=image_generation_input` for `mm_file://` references |
| `POST` | [`/videos`](./videos.md) | - | Create an asynchronous video-generation task |
| `GET` | [`/videos/{task_id}`](./videos.md) | - | Query a video task's generation and billing status |
| `GET` | [`/videos/{task_id}/content`](./videos.md) | - | Download a completed and settled video with authentication |
Expand Down
Loading
Loading