ベータ Shoulder はベータ版です — 結果が誤っている場合があります。皆さまのフィードバックが次に修正する内容を決定します。 フィードバックを送る
🔒

Use of Hard-coded, Security-relevant Constants

🛡️ 2 件のルールが検出します

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 言語をカバー
影響度
ミディアム
レビュー推奨
予防
文書化済み
2 件の修正例
2 予防
2 予防

この脆弱性の修正方法

2 件の Shoulder 検出ルールに基づく Hardcoded Security Constants の予防策。

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()
  

主要なプラクティス

  • Use environment variables
  • configurable via environment variables
4 警告サイン
4 警告サイン

コードレビューで注目すべき点

これらのパターンはUse of Hard-coded, Security-relevant Constantsの潜在的な脆弱性を示しています。コードレビューとセキュリティ監査中に探してください。

🔵
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
🔍

コードベースをスキャン: Use of Hard-coded, Security-relevant Constants

Shoulder CLI はコードベース全体から脆弱なパターンを見つけます。