-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathtest-quality-validation.js
More file actions
39 lines (33 loc) · 1.23 KB
/
Copy pathtest-quality-validation.js
File metadata and controls
39 lines (33 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* ⚠️ WARNING: INTENTIONAL SECURITY VULNERABILITIES FOR TESTING
*
* This file contains deliberate SQL injection vulnerabilities for security testing purposes.
* DO NOT copy any code from this file to production without proper parameterization.
*
* Vulnerable patterns demonstrated:
* - String concatenation in SQL queries
* - No input validation/sanitization
* - Direct user input in query construction
*
* Secure approach (use in production):
* const query = "SELECT * FROM users WHERE id = ?";
* db.execute(query, [userId]);
*/
// Test file for quality validation
// Contains INTENTIONAL vulnerabilities for testing
const API_KEY = "sk-TESTONLY_000000000000"; // P0: FAKE CREDENTIAL FOR TESTING ONLY
function authenticateUser(userId, password) {
const query = "SELECT * FROM users WHERE id=" + userId; // P0: SQL injection
const hash = md5(password); // P0: Weak hashing
// TODO: Implement proper error handling // Stop-slop candidate
return query;
}
// This is a very important function that is crucial for the system // Stop-slop filler
function processData(data) {
try {
const result = JSON.parse(data); // Extra try-catch
return result;
} catch (e) {
return null;
}
}