Use of Hard-coded, Security-relevant Constants
The product uses hard-coded constants instead of symbolic names for security-critical values, which increases the likelihood of mistakes during code maintenance or security reviews.
Hard-coded values make code harder to understand and maintain. When security-relevant values are hard-coded, it increases the risk of errors when the code needs to be modified.
इस भेद्यता को कैसे ठीक करें
2 Shoulder डिटेक्शन नियमों पर आधारित Hardcoded Security Constants के लिए रोकथाम रणनीतियाँ।
Use environment variables for URLs with localhost as a development fallback
- const API_URL = 'http://localhost:3000'; + const API_URL = process.env.API_URL || 'http://localhost:3000'; const response = await fetch(`${API_URL}/users`);
Load URLs from environment variables with localhost as the development fallback
- API_URL = "http://localhost:3000/api" - DB_HOST = "127.0.0.1" + import os + + API_URL = os.getenv('API_URL', 'http://localhost:3000/api') + DB_HOST = os.getenv('DB_HOST', 'localhost') def fetch_data(): response = requests.get(f'{API_URL}/data') return response.json()
मुख्य अभ्यास
- Use environment variables
- configurable via environment variables
अपने कोड में भेद्यताएँ खोजें
Use of Hard-coded, Security-relevant Constants पैटर्न के लिए अपने कोडबेस को स्कैन करने के लिए Shoulder का उपयोग करें। 2 नियम.
# Scan with Shoulder CLI npx @shoulderdev/cli trust --cwe=547 # Or scan entire project npx @shoulderdev/cli trust .
पहचान नियम (2)
कोड समीक्षा में किन बातों पर ध्यान दें
ये पैटर्न संभावित Use of Hard-coded, Security-relevant Constants भेद्यताओं का संकेत देते हैं। कोड समीक्षा और सुरक्षा ऑडिट के दौरान इन्हें देखें।
अपने कोडबेस को इसके लिए स्कैन करें: Use of Hard-coded, Security-relevant Constants
Shoulder CLI आपके पूरे कोडबेस में भेद्य पैटर्न खोजता है।