|
Download code/bad006.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/7fe6853bcbe998c7aec3aa0f7086f584cc091586/code/bad006.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@7fe6853bcbe998c7aec3aa0f7086f584cc091586/code/bad006.jsonl
-
curl -L -o bad006.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/7fe6853bcbe998c7aec3aa0f7086f584cc091586/code/bad006.jsonl
2.27 kB
| {"type": "session", "harness": "deepseek-harness", "id": "bad006", "name": "Security anti-patterns"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}} | |
| {"type": "message", "message": {"role": "user", "content": "What are common security anti-patterns in code?"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "**Critical Mistakes:**\n\n1. **Hardcoded Secrets:**\n```python\n# NEVER DO THIS\nAPI_KEY = \"sk-1234567890abcdef\"\nDB_PASSWORD = \"admin123\"\nSECRET_KEY = \"supersecret\"\n\n# Good: environment variables\nimport os\nAPI_KEY = os.getenv(\"API_KEY\")\n```\n\n2. **SQL Injection:**\n```python\n# Bad: string formatting\nquery = f\"SELECT * FROM users WHERE name = '{name}'\"\n\n# Good: parameterized queries\nquery = \"SELECT * FROM users WHERE name = %s\"\ncursor.execute(query, (name,))\n```\n\n3. **XSS (Cross-Site Scripting):**\n```html\n<!-- Bad: directly inserting user input -->\n<div>{{ user_input }}</div>\n\n<!-- Good: escape output -->\n<div>{{ user_input|escape }}</div>\n```\n\n4. **Weak Password Hashing:**\n```python\n# Bad\nimport hashlib\nhashed = hashlib.md5(password).hexdigest()\n\n# Good\nfrom bcrypt import hashpw, gensalt\nhashed = hashpw(password.encode(), gensalt())\n```\n\n5. **No Input Validation:**\n```python\n# Bad: trusting user input\nage = int(request.form['age'])\n\n# Good: validate and sanitize\nage = request.form.get('age', type=int)\nif age is None or age < 0 or age > 150:\n raise ValueError(\"Invalid age\")\n```\n\n6. **Insecure Deserialization:**\n```python\n# Bad: never unpickle untrusted data\nimport pickle\ndata = pickle.loads(user_input)\n\n# Good: use safe formats like JSON\nimport json\ndata = json.loads(user_input)\n```\n\n7. **Logging Secrets:**\n```python\n# Bad\nlogger.info(f\"User {username} logged in with password {password}\")\n\n# Good\nlogger.info(f\"User {username} login attempt\")\n```"}} | |