mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-03 00:52:32 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
147 lines
4.5 KiB
Python
147 lines
4.5 KiB
Python
# Test cases for openai-hipaa-eligible-endpoints rules.
|
|
# ruff: noqa: F841, F401, E501 — assignments exist solely so semgrep has something to match.
|
|
|
|
from openai import AsyncOpenAI, OpenAI
|
|
|
|
client = OpenAI()
|
|
async_client = AsyncOpenAI()
|
|
|
|
|
|
# ============================================================
|
|
# openai-non-hipaa-assistants-threads — should FLAG
|
|
# ============================================================
|
|
|
|
|
|
def test_assistants_beta_attr() -> None:
|
|
# ruleid: openai-non-hipaa-assistants-threads
|
|
a = client.beta.assistants
|
|
|
|
|
|
def test_threads_beta_attr() -> None:
|
|
# ruleid: openai-non-hipaa-assistants-threads
|
|
t = client.beta.threads
|
|
|
|
|
|
def test_assistants_create() -> None:
|
|
# ruleid: openai-non-hipaa-assistants-threads
|
|
client.assistants.create(name="x", model="gpt-4")
|
|
|
|
|
|
def test_threads_create() -> None:
|
|
# ruleid: openai-non-hipaa-assistants-threads
|
|
client.threads.create()
|
|
|
|
|
|
# ============================================================
|
|
# openai-non-hipaa-assistants-threads — should NOT flag
|
|
# ============================================================
|
|
|
|
|
|
def test_chat_completions_ok() -> None:
|
|
# ok: openai-non-hipaa-assistants-threads
|
|
client.chat.completions.create(model="gpt-4", messages=[])
|
|
|
|
|
|
def test_responses_ok() -> None:
|
|
# ok: openai-non-hipaa-assistants-threads
|
|
client.responses.create(model="gpt-4.1-mini", input="hi")
|
|
|
|
|
|
# ============================================================
|
|
# openai-non-hipaa-fine-tuning — should FLAG
|
|
# ============================================================
|
|
|
|
|
|
def test_fine_tuning_jobs_create() -> None:
|
|
# ruleid: openai-non-hipaa-fine-tuning
|
|
client.fine_tuning.jobs.create(training_file="file-x", model="gpt-4")
|
|
|
|
|
|
def test_fine_tuning_direct_method() -> None:
|
|
# ruleid: openai-non-hipaa-fine-tuning
|
|
client.fine_tuning.list()
|
|
|
|
|
|
def test_fine_tuning_jobs_retrieve() -> None:
|
|
# ruleid: openai-non-hipaa-fine-tuning
|
|
client.fine_tuning.jobs.retrieve("ftjob-x")
|
|
|
|
|
|
# ============================================================
|
|
# openai-non-hipaa-realtime — should FLAG
|
|
# ============================================================
|
|
|
|
|
|
def test_realtime_method() -> None:
|
|
# ruleid: openai-non-hipaa-realtime
|
|
client.realtime.connect()
|
|
|
|
|
|
def test_beta_realtime_method() -> None:
|
|
# ruleid: openai-non-hipaa-realtime
|
|
client.beta.realtime.connect()
|
|
|
|
|
|
def test_beta_realtime_nested() -> None:
|
|
# ruleid: openai-non-hipaa-realtime
|
|
client.beta.realtime.sessions.create(model="gpt-4o-realtime")
|
|
|
|
|
|
# ============================================================
|
|
# openai-non-hipaa-legacy-completions — should FLAG
|
|
# ============================================================
|
|
|
|
|
|
def test_legacy_completions_create() -> None:
|
|
# ruleid: openai-non-hipaa-legacy-completions
|
|
client.completions.create(model="text-davinci-003", prompt="hi")
|
|
|
|
|
|
def test_legacy_completions_create_async() -> None:
|
|
# ruleid: openai-non-hipaa-legacy-completions
|
|
async_client.completions.create(model="text-davinci-003", prompt="hi")
|
|
|
|
|
|
# ============================================================
|
|
# openai-non-hipaa-legacy-completions — should NOT flag
|
|
# ============================================================
|
|
|
|
|
|
def test_chat_completions_create() -> None:
|
|
# ok: openai-non-hipaa-legacy-completions
|
|
client.chat.completions.create(model="gpt-4", messages=[{"role": "user", "content": "hi"}])
|
|
|
|
|
|
def test_chat_completions_create_async() -> None:
|
|
# ok: openai-non-hipaa-legacy-completions
|
|
async_client.chat.completions.create(model="gpt-4", messages=[{"role": "user", "content": "hi"}])
|
|
|
|
|
|
# ============================================================
|
|
# Other eligible endpoints — should NOT flag any rule
|
|
# ============================================================
|
|
|
|
|
|
def test_embeddings_ok() -> None:
|
|
# ok: openai-non-hipaa-assistants-threads
|
|
# ok: openai-non-hipaa-fine-tuning
|
|
# ok: openai-non-hipaa-realtime
|
|
# ok: openai-non-hipaa-legacy-completions
|
|
client.embeddings.create(model="text-embedding-3-small", input="hello")
|
|
|
|
|
|
def test_moderations_ok() -> None:
|
|
# ok: openai-non-hipaa-assistants-threads
|
|
# ok: openai-non-hipaa-fine-tuning
|
|
# ok: openai-non-hipaa-realtime
|
|
# ok: openai-non-hipaa-legacy-completions
|
|
client.moderations.create(input="hello")
|
|
|
|
|
|
def test_audio_transcriptions_ok() -> None:
|
|
# ok: openai-non-hipaa-assistants-threads
|
|
# ok: openai-non-hipaa-fine-tuning
|
|
# ok: openai-non-hipaa-realtime
|
|
# ok: openai-non-hipaa-legacy-completions
|
|
client.audio.transcriptions.create(model="whisper-1", file=b"")
|