プロジェクト

全般

プロフィール

バグ #338

未完了

Security-1: Rate Limiting・ポリシー (4h)

Redmine Admin さんが約11時間前に追加.

ステータス:
新規
優先度:
高め
担当者:
-
開始日:
2025-06-07
期日:
進捗率:

0%

予定工数:

説明

Rate Limitingとセキュリティポリシーを実装する。

実装内容

Rate Limiting実装

import rateLimit from 'express-rate-limit';
import RedisStore from 'rate-limit-redis';

// API Rate Limiting
export const apiLimiter = rateLimit({
  store: new RedisStore({
    client: redis,
    prefix: 'rate-limit:api:'
  }),
  windowMs: 15 * 60 * 1000, // 15分
  max: 100, // リクエスト数上限
  message: 'Too many API requests',
  standardHeaders: true,
  legacyHeaders: false
});

// 認証Rate Limiting
export const authLimiter = rateLimit({
  store: new RedisStore({
    client: redis,
    prefix: 'rate-limit:auth:'
  }),
  windowMs: 15 * 60 * 1000,
  max: 5, // 認証試行上限
  skipSuccessfulRequests: true,
  message: 'Too many authentication attempts'
});

// SSH実行Rate Limiting
export const sshLimiter = rateLimit({
  windowMs: 60 * 1000, // 1分
  max: 10, // SSH実行上限
  message: 'Too many SSH commands'
});

セキュリティポリシー

class SecurityPolicy {
  // 危険コマンドブラックリスト
  private dangerousCommands = [
    'rm -rf /',
    'mkfs',
    'dd if=',
    'chmod 777',
    'shutdown',
    'reboot',
    'passwd'
  ];

  validateCommand(command: string): boolean {
    return !this.dangerousCommands.some(dangerous => 
      command.toLowerCase().includes(dangerous.toLowerCase())
    );
  }

  // IP制限(オプション)
  validateIP(ip: string): boolean {
    // 設定されたIP範囲での制限
    return true; // 実装時に詳細設定
  }
}

成果物

  • Rate Limiting実装
  • セキュリティポリシー実装
  • 危険操作防止機能

作業時間: 4時間

表示するデータがありません

他の形式にエクスポート: Atom PDF