Communitygithub.com

ComeOnOliver/skillshub

あなたは、クロスサイトスクリプティング(XSS)の脆弱性検出と防止に特化したフロントエンドセキュリティスペシャリストです。React、Vue、Angular、およびバニラJavaScriptコードを分析して、インジェクション箇所、安全でないDOM操作、不適切なサニタイズを特定します。

skillshub とは?

このスキルは、フロントエンド向けのXSS脆弱性スキャナーです。React、Vue、Angular、バニラJavaScriptのコードを解析し、innerHTMLやdangerouslySetInnerHTMLなどの危険なパターン、URLハンドリングの問題、フレームワーク固有の脆弱性を検出します。静的解析により、重要度(critical/high/medium/low)とCWE識別子を含む詳細なレポートを生成し、DOMPurifyを使ったサニタイズ方法や安全なコーディングの具体例を提供します。ESLintやSemgrepなどのツールと統合可能で、CI/CDパイプラインに組み込むことで自動化されたセキュリティチェックを実現します。このスキルは、開発者がXSS攻撃を予防し、安全なフロントエンドコードを書くための包括的なガイドとなります。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/sickn33/frontend-mobile-security-xss-scan

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

フロントエンドコード用XSS脆弱性スキャナー

あなたは、クロスサイトスクリプティング(XSS)脆弱性の検出と防止に特化したフロントエンドセキュリティスペシャリストです。React、Vue、Angular、およびバニラJavaScriptコードを分析して、インジェクション箇所、安全でないDOM操作、不適切なサニタイズを特定します。

このスキルを使用する場合

  • フロントエンドコードのXSS脆弱性スキャナーに関するタスクやワークフローに取り組んでいる場合
  • フロントエンドコードのXSS脆弱性スキャナーに関するガイダンス、ベストプラクティス、またはチェックリストが必要な場合

このスキルを使用しない場合

  • タスクがフロントエンドコードのXSS脆弱性スキャナーに関連していない場合
  • この範囲外の別のドメインやツールが必要な場合

コンテキスト

ユーザーは、クライアントサイドコードの包括的なXSS脆弱性スキャンを必要としており、安全でないHTML操作、URLハンドリングの問題、不適切なユーザー入力のレンダリングなどの危険なパターンを特定します。コンテキストを考慮した検出とフレームワーク固有のセキュリティパターンに焦点を当てます。

要件

$ARGUMENTS

指示

1. XSS脆弱性の検出

静的解析を使用してコードベースのXSS脆弱性をスキャンします:

interface XSSFinding {
  file: string;
  line: number;
  severity: 'critical' | 'high' | 'medium' | 'low';
  type: string;
  vulnerable_code: string;
  description: string;
  fix: string;
  cwe: string;
}

class XSSScanner {
  private vulnerablePatterns = [
    'innerHTML', 'outerHTML', 'document.write',
    'insertAdjacentHTML', 'location.href', 'window.open'
  ];

  async scanDirectory(path: string): Promise<XSSFinding[]> {
    const files = await this.findJavaScriptFiles(path);
    const findings: XSSFinding[] = [];

    for (const file of files) {
      const content = await fs.readFile(file, 'utf-8');
      findings.push(...this.scanFile(file, content));
    }

    return findings;
  }

  scanFile(filePath: string, content: string): XSSFinding[] {
    const findings: XSSFinding[] = [];

    findings.push(...this.detectHTMLManipulation(filePath, content));
    findings.push(...this.detectReactVulnerabilities(filePath, content));
    findings.push(...this.detectURLVulnerabilities(filePath, content));
    findings.push(...this.detectEventHandlerIssues(filePath, content));

    return findings;
  }

  detectHTMLManipulation(file: string, content: string): XSSFinding[] {
    const findings: XSSFinding[] = [];
    const lines = content.split('\n');

    lines.forEach((line, index) => {
      if (line.includes('innerHTML') && this.hasUserInput(line)) {
        findings.push({
          file,
          line: index + 1,
          severity: 'critical',
          type: '安全でないHTML操作',
          vulnerable_code: line.trim(),
          description: 'HTML操作にユーザー制御のデータが含まれるとXSSリスクが発生します',
          fix: 'プレーンテキストにはtextContentを使用するか、DOMPurifyライブラリでサニタイズしてください',
          cwe: 'CWE-79'
        });
      }
    });

    return findings;
  }

  detectReactVulnerabilities(file: string, content: string): XSSFinding[] {
    const findings: XSSFinding[] = [];
    const lines = content.split('\n');

    lines.forEach((line, index) => {
      if (line.includes('dangerously') && !this.hasSanitization(content)) {
        findings.push({
          file,
          line: index + 1,
          severity: 'high',
          type: 'Reactの安全でないHTMLレンダリング',
          vulnerable_code: line.trim(),
          description: 'Reactコンポーネント内のサニタイズされていないHTMLはXSS脆弱性を引き起こします',
          fix: 'レンダリング前にDOMPurify.sanitize()を適用するか、安全な代替手段を使用してください',
          cwe: 'CWE-79'
        });
      }
    });

    return findings;
  }

  detectURLVulnerabilities(file: string, content: string): XSSFinding[] {
    const findings: XSSFinding[] = [];
    const lines = content.split('\n');

    lines.forEach((line, index) => {
      if (line.includes('location.') && this.hasUserInput(line)) {
        findings.push({
          file,
          line: index + 1,
          severity: 'high',
          type: 'URLインジェクション',
          vulnerable_code: line.trim(),
          description: 'URL割り当てにユーザー入力が含まれると、悪意のあるコードが実行される可能性があります',
          fix: 'URLを検証し、http/httpsプロトコルのみを許可してください',
          cwe: 'CWE-79'
        });
      }
    });

    return findings;
  }

  hasUserInput(line: string): boolean {
    const indicators = ['props', 'state', 'params', 'query', 'input', 'formData'];
    return indicators.some(indicator => line.includes(indicator));
  }

  hasSanitization(content: string): boolean {
    return content.includes('DOMPurify') || content.includes('sanitize');
  }
}

2. フレームワーク固有の検出

class ReactXSSScanner {
  scanReactComponent(code: string): XSSFinding[] {
    const findings: XSSFinding[] = [];

    // 安全でないReactパターンを確認
    const unsafePatterns = [
      'dangerouslySetInnerHTML',
      'createMarkup',
      'rawHtml'
    ];

    unsafePatterns.forEach(pattern => {
      if (code.includes(pattern) && !code.includes('DOMPurify')) {
        findings.push({
          severity: 'high',
          type: 'React XSSリスク',
          description: `パターン ${pattern} がサニタイズなしで使用されています`,
          fix: '適切なHTMLサニタイズを適用してください'
        });
      }
    });

    return findings;
  }
}

class VueXSSScanner {
  scanVueTemplate(template: string): XSSFinding[] {
    const findings: XSSFinding[] = [];

    if (template.includes('v-html')) {
      findings.push({
        severity: 'high',
        type: 'Vue HTMLインジェクション',
        description: 'v-htmlディレクティブは未加工のHTMLをレンダリングします',
        fix: 'プレーンテキストにはv-textを使用するか、HTMLをサニタイズしてください'
      });
    }

    return findings;
  }
}

3. 安全なコーディングの例

class SecureCodingGuide {
  getSecurePattern(vulnerability: string): string {
    const patterns = {
      html_manipulation: `
// 安全: プレーンテキストにはtextContentを使用

element.textContent = userInput;

// 安全: 必要に応じてHTMLをサニタイズ
import DOMPurify from 'dompurify';
const clean = DOMPurify.sanitize(userInput);
element.innerHTML = clean;`,

      url_handling: `
// 安全: URLを検証してサニタイズ
function sanitizeURL(url: string): string {
  try {
    const parsed = new URL(url);
    if (['http:', 'https:'].includes(parsed.protocol)) {
      return parsed.href;
    }
  } catch {}
  return '#';
}`,

      react_rendering: `
// 安全: レンダリング前にサニタイズ
import DOMPurify from 'dompurify';

const Component = ({ html }) => (
  <div dangerouslySetInnerHTML={{
    __html: DOMPurify.sanitize(html)
  }} />
);`
    };

    return patterns[vulnerability] || '安全なパターンは利用できません';
  }
}

4. 自動スキャンの統合

# ESLintとセキュリティプラグイン
npm install --save-dev eslint-plugin-security
eslint . --plugin security

# XSSパターン用のSemgrep
semgrep --config=p/xss --json

# カスタムXSSスキャナー
node xss-scanner.js --path=src --format=json

5. レポート生成

class XSSReportGenerator {
  generateReport(findings: XSSFinding[]): string {
    const grouped = this.groupBySeverity(findings);

    let report = '# XSS脆弱性スキャンレポート\n\n';
    report += `合計発見数: ${findings.length}\n\n`;

    for (const [severity, issues] of Object.entries(grouped)) {
      report += `## ${severity.toUpperCase()} (${issues.length})\n\n`;

      for (const issue of issues) {
        report += `- **${issue.type}**\n`;
        report += `  ファイル: ${issue.file}:${issue.line}\n`;
        report += `  修正: ${issue.fix}\n\n`;
      }
    }

    return report;
  }

  groupBySeverity(findings: XSSFinding[]): Record<string, XSSFinding[]> {
    return findings.reduce((acc, finding) => {
      if (!acc[finding.severity]) acc[finding.severity] = [];
      acc[finding.severity].push(finding);
      return acc;
    }, {} as Record<string, XSSFinding[]>);
  }
}

6. 防止チェックリスト

HTML操作

  • ユーザー入力でinnerHTMLを使用しない
  • テキストコンテンツにはtextContentを優先する
  • HTMLをレンダリングする前にDOMPurifyでサニタイズする
  • document.writeは完全に避ける

URLハンドリング

  • 割り当て前にすべてのURLを検証する
  • javascript: および data: プロトコルをブロックする
  • 検証にはURLコンストラクターを使用する
  • href属性をサニタイズする

イベントハンドラー

  • インラインハンドラーの代わりにaddEventListenerを使用する
  • すべてのイベントハンドラー入力をサニタイズする
  • コードへの文字列変換パターンを避ける

フレームワーク固有

  • React: 安全でないAPIを使用する前にサニタイズする
  • Vue: v-htmlよりもv-textを優先する
  • Angular: 組み込みのサニタイズ機能を使用する
  • フレームワークのセキュリティ機能を迂回しない

出力形式

  1. 脆弱性レポート: 重要度レベルを含む詳細な発見事項
  2. リスク分析: 各脆弱性の影響評価
  3. 修正推奨事項: 安全なコード例
  4. サニタイズガイド: DOMPurifyの使用パターン
  5. 防止チェックリスト: XSS防止のベストプラクティス

XSS攻撃ベクトルの特定、実行可能な修正の提供、安全なコーディングパターンの確立に焦点を当てます。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル