BETA Shoulder jest w wersji beta — Wyniki mogą czasami być błędne. Twoja opinia kształtuje to, co naprawimy w następnej kolejności. Podziel się opinią
🔒

Use of Hard-coded, Security-relevant Constants

🛡️ 2 reguł wykrywa to

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.

Rozpowszechnienie
Skupiona
Pokryto 2 języków
Wplyw
Średni
Zalecany przegląd
Zapobieganie
Udokumentowane
2 przykładów poprawek
2 Zapobieganie
2 Zapobieganie

Jak naprawić tę podatność

Strategie zapobiegania dla Hardcoded Security Constants oparte na 2 regułach detekcji Shoulder.

Hardcoded Development URLs LOW

Use environment variables for URLs with localhost as a development fallback

+1 -1 javascript
- const API_URL = 'http://localhost:3000';
+ const API_URL = process.env.API_URL || 'http://localhost:3000';
  const response = await fetch(`${API_URL}/users`);
  
Hardcoded Development URLs LOW

Load URLs from environment variables with localhost as the development fallback

+4 -2 python
- 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()
  

Kluczowe praktyki

  • Use environment variables
  • configurable via environment variables
4 Sygnaly Ostrzegawcze
4 Sygnaly Ostrzegawcze

Na co zwracac uwage podczas przegladu kodu

Te wzorce wskazuja na potencjalne podatnosci Use of Hard-coded, Security-relevant Constants. Szukaj ich podczas przegladow kodu i audytow bezpieczenstwa.

🔵
Hardcoded development URL found: ... Development URLs like localhost should be configured via environment variables. javascript-hardcoded-dev-urls
🔵
hardcoded development URLs (localhost, 127 javascript-hardcoded-dev-urls
🔵
Development URL found at line ...: ... python-hardcoded-dev-urls
🔵
hardcoded development URLs such as localhost or 127 python-hardcoded-dev-urls
🔍

Przeskanuj swój kod w poszukiwaniu Use of Hard-coded, Security-relevant Constants

Shoulder CLI znajduje podatne wzorce w całym Twoim kodzie.