Skip to content

Commit 6577709

Browse files
authored
docs: strengthen Python SDK security contribution guidance (openai#3639)
- [x] I understand that this repository is auto-generated and my pull request may not be merged ## Changes being requested - Add focused Python SDK security requirements for coding agents and contributors: safe fake fixtures, credential and log redaction, direct/transitive dependency and lockfile review, reviewed GitHub Action pins, least-privilege CI, and protected PyPI Trusted Publishing. - Require SDK CODEOWNER review and relevant synchronous/asynchronous regression tests for authentication, X.509, webhook, network, file, serialization, dependency, and release-sensitive changes. - Explicitly direct vulnerability reports to the existing private coordinated-disclosure process instead of public issues, discussions, or pull requests. ## Verification - `git diff --check` - CommonMark parsing, local-link validation, security-policy coverage assertions, and credential-like-literal checks for all three changed Markdown files. - `python scripts/check-python-version-policy.py` — passed. - `python -m pytest -o addopts= -p no:cacheprovider -k 'not aiohttp' tests/test_utils/test_logging.py tests/test_auth.py tests/api_resources/test_webhooks.py` — 72 passed; 13 optional `aiohttp` cases were deselected because that extra is absent from the existing environment. ## Additional context & links Documentation only: no generated SDK source, GitHub workflows, repository settings, credentials, or release controls were changed.
1 parent 3e8301c commit 6577709

3 files changed

Lines changed: 60 additions & 0 deletions

File tree

‎AGENTS.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,35 @@ changing generated files. Handwritten policy, automation, tests, and examples
77
should remain small and should not alter exported SDK APIs unless the change
88
explicitly requires it.
99

10+
## Security requirements for coding agents
11+
12+
- Never commit real API or admin keys, bearer tokens, webhook secrets, cloud
13+
credentials, X.509 private keys, release credentials, or `.env` files. Read
14+
`OPENAI_API_KEY`, `OPENAI_ADMIN_KEY`, `OPENAI_WEBHOOK_SECRET`, and other
15+
credentials from the environment; use clearly fake examples and fixtures.
16+
- Redact credentials, `Authorization` and `api-key` headers, customer data, and
17+
sensitive request or response bodies from logs, exceptions, snapshots, and
18+
test output. Clearly fake or sanitized fixtures and safe `APIError.body`
19+
diagnostics may remain. Preserve existing sensitive-header filtering,
20+
including debug logging.
21+
- Review direct and transitive dependency changes in `pyproject.toml`, optional
22+
extras, `requirements.lock`, `requirements-dev.lock`, and `uv.lock`. Check
23+
package provenance, build backends, and install scripts before accepting or
24+
running them.
25+
- Pin third-party GitHub Actions to reviewed full commit SHAs. Minimize
26+
job-level token permissions and never expose secrets or write-capable tokens
27+
to untrusted pull-request code.
28+
- Preserve separate build and publish jobs, protected release credentials, and
29+
PyPI Trusted Publishing. Grant `id-token: write` only to the trusted,
30+
upload-only publishing job; do not introduce long-lived PyPI tokens.
31+
- Obtain SDK CODEOWNER review and add focused synchronous and asynchronous
32+
security regression tests, as applicable, for changes to authentication,
33+
X.509 or webhook verification, HTTP destinations, redirects, proxies, TLS,
34+
cloud metadata, file uploads, serialization, dependencies, GitHub Actions,
35+
or release workflows.
36+
- Report suspected vulnerabilities privately as described in `SECURITY.md`;
37+
never disclose them in public issues, pull requests, or logs.
38+
1039
## Python version policy
1140

1241
- `requires-python` in `pyproject.toml` is the authoritative technical minimum.

‎CONTRIBUTING.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@ Most of the SDK is generated code. Modifications to code will be persisted betwe
4343
result in merge conflicts between manual patches and changes from the generator. The generator will never
4444
modify the contents of the `src/openai/lib/` and `examples/` directories.
4545

46+
## Security requirements for contributions
47+
48+
- Never commit API or admin keys, bearer tokens, webhook secrets, cloud
49+
credentials, private keys, publishing credentials, or `.env` files. Load real
50+
credentials from environment variables such as `OPENAI_API_KEY`,
51+
`OPENAI_ADMIN_KEY`, and `OPENAI_WEBHOOK_SECRET`; use clearly fake values and
52+
sanitized data in examples, tests, fixtures, and recorded responses.
53+
- Redact `Authorization` and `api-key` headers, other credentials, and customer
54+
request or response data from logs, exceptions, snapshots, and debug output.
55+
Prefer the mock server or mocked HTTP transport over live credentials in tests.
56+
- Review direct and transitive dependency changes, package provenance, build or
57+
install hooks, and diffs to `pyproject.toml`, optional extras,
58+
`requirements.lock`, `requirements-dev.lock`, and `uv.lock`.
59+
- Pin third-party GitHub Actions to reviewed full commit SHAs, minimize job
60+
permissions, and keep secrets and write-capable tokens away from untrusted
61+
pull-request code. Protect release-app credentials and preserve the separate
62+
build and upload jobs, protected publishing environment, and PyPI Trusted
63+
Publishing. Limit OIDC access to the trusted publishing job.
64+
- Request SDK CODEOWNER review for authentication, X.509, webhook verification,
65+
network destinations, redirects, TLS, cloud metadata, file handling,
66+
serialization, dependency, CI, and release changes. Add synchronous and
67+
asynchronous regression tests as applicable, including credential redaction
68+
and invalid signatures.
69+
- Report suspected vulnerabilities privately through the process in
70+
[SECURITY.md](./SECURITY.md), never through public issues or pull requests.
71+
4672
## Adding and running examples
4773

4874
All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.

‎SECURITY.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Please report potential security vulnerabilities through OpenAI's
66
[coordinated vulnerability disclosure process](https://openai.com/policies/coordinated-vulnerability-disclosure-policy).
77
For questions about that process, contact disclosure@openai.com.
88

9+
Do not report vulnerabilities through public GitHub issues, discussions, pull
10+
requests, or other public channels. When reporting privately, include the
11+
affected SDK version, impact, and reproduction steps where possible; redact API
12+
keys, authentication headers, private keys, and customer data from all reports.
13+
914
## Responsible Disclosure
1015

1116
Please allow OpenAI a reasonable amount of time to investigate and address the

0 commit comments

Comments
 (0)