mirror of
https://github.com/openai/codex-security.git
synced 2026-11-24 03:45:49 +08:00
BREAKING CHANGE: Set CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1 to use external import and publication workflows.
41 lines
1.9 KiB
Bash
41 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# Resolve the environment on the host; these checks need no running container.
|
|
for compose_file in compose.yaml compose.runner.yaml; do
|
|
endpoint="https://embeddings.example.com/custom/v1/embeddings?api-version=synthetic"
|
|
CODEX_SECURITY_EMBEDDINGS_URL="$endpoint" CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS=1 \
|
|
docker compose --env-file /dev/null -f "$compose_file" config --format json |
|
|
jq --exit-status --arg endpoint "$endpoint" \
|
|
'.services["codex-security"].environment | .CODEX_SECURITY_EMBEDDINGS_URL == $endpoint and .CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS == "1"' > /dev/null
|
|
|
|
env -u CODEX_SECURITY_EMBEDDINGS_URL -u CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS \
|
|
docker compose --env-file /dev/null -f "$compose_file" config --format json |
|
|
jq --exit-status \
|
|
'.services["codex-security"].environment | .CODEX_SECURITY_EMBEDDINGS_URL == null and .CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS == null' > /dev/null
|
|
|
|
CODEX_SECURITY_EMBEDDINGS_URL="" CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS="" \
|
|
docker compose --env-file /dev/null -f "$compose_file" config --format json |
|
|
jq --exit-status \
|
|
'.services["codex-security"].environment | .CODEX_SECURITY_EMBEDDINGS_URL == "" and .CODEX_SECURITY_ENABLE_EXTERNAL_IMPORTS == ""' > /dev/null
|
|
done
|
|
|
|
mkdir -p results state
|
|
chmod 700 results state
|
|
printf 'id,repository,revision\n' > repositories.csv
|
|
CODEX_SECURITY_USER="$(id -u):$(id -g)"
|
|
export CODEX_SECURITY_USER
|
|
docker compose config --quiet
|
|
docker compose run --rm codex-security --version
|
|
if output="$(docker compose run --rm codex-security 2>&1)"; then
|
|
echo 'An empty repository CSV must not start a security scan.' >&2
|
|
exit 1
|
|
else
|
|
status=$?
|
|
fi
|
|
if [[ "$status" -ne 2 ]] || ! grep -Fq 'Multiscan CSV must contain at least one repository.' <<< "$output"; then
|
|
printf 'Unexpected empty-repository scan behavior:\n%s\n' "$output" >&2
|
|
exit 1
|
|
fi
|