@@ -46,6 +46,18 @@ These instructions guide GitHub Copilot to suggest secure, intentional code patt
4646- Always hash passwords with ` PasswordHasher<TUser> ` or a vetted library — never store plaintext.
4747- Use configuration providers like ` Azure Key Vault ` , ` AWS Secrets Manager ` , or environment-based secrets — avoid ` appsettings.json ` for secrets.
4848
49+ ### 🐍 Python
50+
51+ - Always validate and sanitize external input — use ` pydantic ` , ` cerberus ` , or ` marshmallow ` for structured validation.
52+ - Prefer parameterized queries with libraries like ` psycopg2 ` , ` sqlite3 ` , or ` SQLAlchemy ` — avoid building SQL with string concat or f-strings.
53+ - Use built-in escaping via ` html.escape() ` or templating engines like Jinja2 (autoescaping on!) to prevent XSS.
54+ - Default to ` secrets ` or ` cryptography ` libs for key generation and secure token handling — never ` random ` for cryptographic use.
55+ - Avoid dynamic code execution (` eval ` , ` exec ` ) — prefer explicit, safe alternatives.
56+ - Don’t load YAML or pickle files without hardening — always use ` safe_load() ` and avoid untrusted input.
57+ - Store secrets in secure vaults or env vars passed through orchestrators — avoid hardcoded strings or ` .env ` files in prod.
58+ - Use logging filters to redact PII and secrets — avoid logging full request payloads or exception chains that include sensitive data.
59+ - Always hash passwords with ` bcrypt ` , ` argon2 ` , or ` passlib ` — never ` md5 ` , ` sha1 ` , or plain ` hashlib ` .
60+
4961---
5062
5163## 🚫 3. Do Not Suggest
@@ -77,6 +89,16 @@ These instructions guide GitHub Copilot to suggest secure, intentional code patt
7789- Do not log full exception objects or HTTP request bodies without redacting PII.
7890- Do not disable certificate validation (` ServerCertificateValidationCallback = delegate { return true; } ` ) in production.
7991
92+ ### Python
93+
94+ - Do not build SQL queries with string concat, f-strings, or ` .format() ` — always use parameterized queries.
95+ - Do not use ` eval ` , ` exec ` , or dynamic imports on user input — these are unsafe unless tightly sandboxed.
96+ - Do not log sensitive values (e.g. API keys, passwords) or full stack traces with PII.
97+ - Do not load pickle or YAML files from untrusted sources without safe loaders and validation.
98+ - Do not use insecure hash functions like ` md5 ` or ` sha1 ` for password storage — use a modern password hashing lib.
99+ - Do not commit ` .env ` files or hardcode secrets — use secrets management infrastructure.
100+
101+
80102---
81103
82104## 🧠 4. AI-Generated Code Safety
0 commit comments