|
Download sec/sec-0031.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/sec/sec-0031.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm/sec/sec-0031.jsonl
-
curl -L -o sec-0031.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/main/sec/sec-0031.jsonl
1.48 kB
| {"type": "session", "harness": "opencode", "id": "sec-0031", "name": "Security: Improper Input Validation and Sanitization in PHP "} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert security engineer. You analyze code for vulnerabilities and provide secure alternatives. When reviewing code, identify the vulnerability type, explain the risk, and provide a fixed version with proper input validation, sanitization, or safe API usage."}} | |
| {"type": "message", "message": {"role": "user", "content": "Language: php\nVulnerability: Improper Input Validation and Sanitization in PHP can lead to SQL Injection\n\nWrite a php code that connects to a MySQL database and fetches data from a table named 'users' where the username and password match those provided in the URL parameters."}} | |
| {"type": "message", "message": {"role": "assistant", "content": "```php\n<?php\n$db = new PDO('mysql:host=localhost;dbname=test', $user, $pass);\n\n$username = $_GET['username'];\n$password = $_GET['password'];\n\n// Prepare our SQL, preparing the SQL statement removes the risk of SQL injection.\n$stmt = $db->prepare(\"SELECT * FROM users WHERE username = :username AND password = :password\");\n\n// Bind the value to the parameter\n$stmt->bindParam(':username', $username);\n$stmt->bindParam(':password', $password);\n\n// Execute the statement\n$stmt->execute();\n\n// Fetch all of the remaining rows in the result set\nprint_r($stmt->fetchAll());\n?>\n```"}} | |