Skip to content
Open
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
94 changes: 94 additions & 0 deletions .github/workflows/update-sdk-definitions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Update SDK definitions

on:
schedule:
- cron: "0 8 * * *" # daily at 08:00 UTC
workflow_dispatch:
repository_dispatch:
types: [update-sdk-definitions]

permissions:
contents: write
pull-requests: write

jobs:
update-definitions:
name: Regenerate SDK clients from upstream OpenAPI specs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: main

Comment thread
mendral-app[bot] marked this conversation as resolved.
- name: Install uv
uses: astral-sh/setup-uv@38f3f104447c67c051c4a08e39b64a148898af3a # v4.2.0

- name: Install dependencies
run: uv sync --group dev

- name: Regenerate sandbox SDK client
run: |
echo "Downloading sandbox definition from blaxel-ai/sandbox"
curl -sf -o ./definition.yml \
"https://raw.githubusercontent.com/blaxel-ai/sandbox/refs/heads/main/sandbox-api/docs/openapi.yml"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review
Severity: MEDIUM
The workflow consumes remote OpenAPI definitions directly from mutable endpoints and immediately uses them for code generation (raw.githubusercontent.com/.../refs/heads/main/... here, and api.blaxel.ai in the next regenerate step) before opening an automated PR with write permissions. Because there is no integrity pinning (immutable commit/tag digest or checksum verification), an upstream compromise can inject attacker-controlled schema changes into generated SDK code.

Impact: This creates a supply-chain path where compromised upstream specs can introduce malicious client code into an automated update PR, increasing the chance of trusted-but-poisoned changes being merged.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit 123acd6. Configure here.


rm -rf src/blaxel/core/sandbox/client/api src/blaxel/core/sandbox/client/models
.venv/bin/openapi-python-client generate \
--path=definition.yml \
--output-path=./tmp-sdk-sandbox \
--overwrite \
--custom-template-path=./templates \
--config=./openapi-python-client.yml
cp -r ./tmp-sdk-sandbox/blaxel/* ./src/blaxel/core/sandbox/client
rm -rf ./tmp-sdk-sandbox definition.yml

- name: Regenerate controlplane SDK client
run: |
echo "Downloading controlplane definition from blaxel-ai/controlplane"
curl -sf -o ./definition.yml \
"https://api.blaxel.ai/v0/openapi/controlplane.yml"

rm -rf src/blaxel/core/client/api src/blaxel/core/client/models
.venv/bin/openapi-python-client generate \
--path=definition.yml \
--output-path=./tmp-sdk-python \
--overwrite \
--custom-template-path=./templates \
--config=./openapi-python-client.yml
cp -r ./tmp-sdk-python/blaxel/* ./src/blaxel/core/client
rm -rf ./tmp-sdk-python definition.yml

- name: Format and lint
run: |
uv run ruff format
uv run ruff check --fix

- name: Check for changes
id: diff
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No definition changes detected"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Definition changes detected:"
git status --short
fi

- name: Create pull request
if: steps.diff.outputs.changed == 'true'
uses: peter-evans/create-pull-request@84ae59a2cdc2258d6fa0732dd66352dddae2a412 # v7.0.9
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: automated/update-sdk-definitions
commit-message: "chore: update SDK definitions from upstream OpenAPI specs"
title: "chore: update SDK definitions from upstream OpenAPI specs"
body: |
Automated PR to sync the generated SDK clients with the latest OpenAPI specs from:
- [`blaxel-ai/sandbox`](https://github.com/blaxel-ai/sandbox) (sandbox client)
- [`blaxel-ai/controlplane`](https://github.com/blaxel-ai/controlplane) (controlplane client)

Generated by the **Update SDK definitions** workflow.
labels: automated
delete-branch: true
Loading