Communitygithub.com

bg-szy/TOP-SKILLS

Trail of Bits が開発したカバレッジガイド型 Ruby ファザー「Ruzzy」をセットアップ&実行します。ハーネス構造、ピュア Ruby および gem 内のネイティブ C 拡張のファジング、サニタイザビルドに対応。Ruby ライブラリや gem のファジング、Ruby C 拡張のメモリ安全性テスト、Ruby のファジング方法を知りたいときに使用します。

TOP-SKILLS とは?

このスキルは、Trail of Bits が開発したカバレッジガイド型ファザー **Ruzzy** を Ruby コードに対してセットアップ・実行するための包括的なガイドです。Ruzzy は libFuzzer をベースにしており、純粋な Ruby コードと Ruby C 拡張の両方をファジングでき、メモリ破壊や未定義動作を検出するためのサニタイザも統合されています。 主な機能として、**インストール手順**(clang コンパイラフラグの指定、トラブルシューティング含む)、**ハーネス作成方法**(純粋 Ruby 用のトレーサースクリプトと、C 拡張用の単一スクリプトの両方を解説)、**サニタイザとの統合**(AddressSanitizer と UndefinedBehaviorSanitizer の使い分け)、**キャンペーン実行**(コーパスの指定、libFuzzer オプションの受け渡し、クラッシュの再現方法)をカバーしています。 また、実用的な例として msgpack-ruby のファジングや純粋 Ruby パーサーのファジングの完全なコード例を提供し、トラブルシューティング表や関連スキルへのリンクも含まれています。このスキルは、Ruby アプリケーションや gem のセキュリティテスト、特に C 拡張のメモリ安全性を検証する際に非常に有用です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/bg-szy/TOP-SKILLS/tree/HEAD/skills/skills/ruzzy

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

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

ドキュメント

Ruzzy

Ruzzy は、libFuzzer をベースにした Ruby 用のカバレッジガイド型ファザーです。純粋な Ruby コードと Ruby C 拡張の両方をファジングでき、メモリ破壊や未定義動作を検出するためのサニタイザをサポートしています。

使用するタイミング

Ruzzy は現在、Ruby 向けの唯一のプロダクションレディなカバレッジガイド型ファザーです。

Ruzzy を選ぶべきケース:

  • Ruby アプリケーションまたはライブラリのファジング
  • Ruby C 拡張のメモリ安全性問題のテスト
  • Ruby コードにカバレッジガイド型ファジングが必要な場合
  • ネイティブ拡張を持つ Ruby gem を扱う場合

クイックスタート

環境を設定します:

export ASAN_OPTIONS="allocator_may_return_null=1:detect_leaks=0:use_sigaltstack=0"

付属のサンプル例でテストします:

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby -e 'require "ruzzy"; Ruzzy.dummy'

これにより、Ruzzy が正しく動作していることを示すクラッシュがすぐに見つかるはずです。

インストール

プラットフォームサポート

Ruzzy は Linux x86-64 および AArch64/ARM64 をサポートしています。macOS または Windows の場合は、Dockerfile または 開発環境 を使用してください。

前提条件

  • Linux x86-64 または AArch64/ARM64
  • 最新バージョンの clang(14.0.0 以降でテスト済み、最新リリース推奨)
  • gem がインストールされた Ruby

インストールコマンド

clang コンパイラフラグを指定して Ruzzy をインストールします:

MAKE="make --environment-overrides V=1" \
CC="/path/to/clang" \
CXX="/path/to/clang++" \
LDSHARED="/path/to/clang -shared" \
LDSHAREDXX="/path/to/clang++ -shared" \
    gem install ruzzy

環境変数の説明:

  • MAKE:後続の環境変数を優先するように make を上書きします
  • CC、CXX、LDSHARED、LDSHAREDXX:最新の機能を利用するために適切な clang バイナリを使用します

インストールのトラブルシューティング

インストールが失敗した場合は、デバッグ出力を有効にします:

RUZZY_DEBUG=1 gem install --verbose ruzzy

インストールの確認

クイックスタートのサンプル例を実行してインストールを確認します(クイックスタートセクションを参照)。

ハーネスの作成

純粋な Ruby コードのファジング

純粋な Ruby のファジングには、Ruby インタプリタの実装の詳細により、2 つのスクリプトが必要です。

トレーサースクリプト(test_tracer.rb):

# frozen_string_literal: true

require 'ruzzy'

Ruzzy.trace('test_harness.rb')

ハーネススクリプト(test_harness.rb):

# frozen_string_literal: true

require 'ruzzy'

def fuzzing_target(input)
  # ここにファジング対象のコードを記述
  if input.length == 4
    if input[0] == 'F'
      if input[1] == 'U'
        if input[2] == 'Z'
          if input[3] == 'Z'
            raise
          end
        end
      end
    end
  end
end

test_one_input = lambda do |data|
  fuzzing_target(data)
  return 0
end

Ruzzy.fuzz(test_one_input)

実行:

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby test_tracer.rb

Ruby C 拡張のファジング

C 拡張はトレーサー不要で、1 つのハーネスファイルでファジングできます。

msgpack 用のハーネス例(fuzz_msgpack.rb):

# frozen_string_literal: true

require 'msgpack'
require 'ruzzy'

test_one_input = lambda do |data|
  begin
    MessagePack.unpack(data)
  rescue Exception
    # メモリ破壊を探しているため、Ruby 例外は無視
  end
  return 0
end

Ruzzy.fuzz(test_one_input)

実行:

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby fuzz_msgpack.rb

ハーネスのルール

すべきことしてはいけないこと
C 拡張をテストする場合は Ruby 例外をキャッチするRuby 例外でファザーをクラッシュさせる
test_one_input ラムダから 0 を返す他の値を返す
ハーネスを決定論的に保つ乱数や時間ベースのロジックを使用する
純粋な Ruby にはトレーサースクリプトを使用する純粋な Ruby コードでトレーサーを省略する

関連情報: 詳細なハーネス作成テクニック、複雑な入力のパターン、高度な戦略については、fuzz-harness-writing テクニックスキルを参照してください。

コンパイル

サニタイザ付き gem のインストール

ファジング用に C 拡張を含む Ruby gem をインストールする場合は、サニタイザフラグを指定してコンパイルします:

MAKE="make --environment-overrides V=1" \
CC="/path/to/clang" \
CXX="/path/to/clang++" \
LDSHARED="/path/to/clang -shared" \
LDSHAREDXX="/path/to/clang++ -shared" \
CFLAGS="-fsanitize=address,fuzzer-no-link -fno-omit-frame-pointer -fno-common -fPIC -g" \
CXXFLAGS="-fsanitize=address,fuzzer-no-link -fno-omit-frame-pointer -fno-common -fPIC -g" \
    gem install <gem-name>

ビルドフラグ

フラグ目的
-fsanitize=address,fuzzer-no-linkAddressSanitizer とファザー計測を有効化
-fno-omit-frame-pointerスタックトレースの品質を向上
-fno-commonサニタイザとの互換性を向上
-fPIC共有ライブラリ用の位置独立コード
-gデバッグシンボルを含める

キャンペーンの実行

環境設定

ファジングキャンペーンを実行する前に、ASAN_OPTIONS を設定します:

export ASAN_OPTIONS="allocator_may_return_null=1:detect_leaks=0:use_sigaltstack=0"

オプションの説明:

  1. allocator_may_return_null=1:影響の小さい一般的な割り当て失敗(DoS)をスキップ
  2. detect_leaks=0:Ruby インタプリタはデータをリークするため、当面はリーク検出を無効化
  3. use_sigaltstack=0:Ruby は ASan で sigaltstack を無効にすることを推奨

基本実行

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby harness.rb

注意: LD_PRELOAD はサニタイザ注入のために必要です。ASAN_OPTIONS とは異なり、他のプログラムに干渉する可能性があるためエクスポートしないでください。

コーパスを使用する場合

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby harness.rb /path/to/corpus

libFuzzer オプションの受け渡し

すべての libFuzzer オプションを引数として渡せます:

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby harness.rb /path/to/corpus -max_len=1024 -timeout=10

詳細は libFuzzer のオプション を参照してください。

クラッシュの再現

クラッシュファイルを渡して再実行します:

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby harness.rb ./crash-253420c1158bc6382093d409ce2e9cff5806e980

出力の解釈

出力意味
INFO: Running with entropic power scheduleファジングキャンペーンが開始
ERROR: AddressSanitizer: heap-use-after-freeメモリ破壊を検出
SUMMARY: libFuzzer: fuzz target exitedRuby 例外が発生
artifact_prefix='./'; Test unit written to ./crash-*クラッシュ入力が保存されました
Base64: ...クラッシュ入力の Base64 エンコード

サニタイザの統合

AddressSanitizer(ASan)

Ruzzy にはプリコンパイル済みの AddressSanitizer ライブラリが含まれています:

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby harness.rb

ASan は以下の検出に使用します:

  • ヒープバッファオーバーフロー
  • スタックバッファオーバーフロー
  • Use-after-free
  • Double-free
  • メモリリーク(Ruzzy ではデフォルトで無効)

UndefinedBehaviorSanitizer(UBSan)

Ruzzy には UBSan も含まれています:

LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::UBSAN_PATH') \
    ruby harness.rb

UBSan は以下の検出に使用します:

  • 符号付き整数オーバーフロー
  • NULL ポインタ参照外し
  • アライメントされていないメモリアクセス
  • ゼロ除算

よくあるサニタイザの問題

問題解決策
Ruby インタプリタのリーク警告ASAN_OPTIONS=detect_leaks=0 を使用
Sigaltstack の競合ASAN_OPTIONS=use_sigaltstack=0 を使用
割り当て失敗の大量出力ASAN_OPTIONS=allocator_may_return_null=1 を使用
LD_PRELOAD がツールに干渉するエクスポートせず、ruby コマンドとインラインで設定

関連情報: 詳細なサニタイザ設定、一般的な問題、高度なフラグについては、address-sanitizer および undefined-behavior-sanitizer テクニックスキルを参照してください。

実際の例

例:msgpack-ruby

msgpack MessagePack パーサーのメモリ破壊ファジング。

サニタイザ付きでインストール:

MAKE="make --environment-overrides V=1" \
CC="/path/to/clang" \
CXX="/path/to/clang++" \
LDSHARED="/path/to/clang -shared" \
LDSHAREDXX="/path/to/clang++ -shared" \
CFLAGS="-fsanitize=address,fuzzer-no-link -fno-omit-frame-pointer -fno-common -fPIC -g" \
CXXFLAGS="-fsanitize=address,fuzzer-no-link -fno-omit-frame-pointer -fno-common -fPIC -g" \
    gem install msgpack

ハーネス(fuzz_msgpack.rb):

# frozen_string_literal: true

require 'msgpack'
require 'ruzzy'

test_one_input = lambda do |data|
  begin
    MessagePack.unpack(data)
  rescue Exception
    # メモリ破壊を探しているため、Ruby 例外は無視
  end
  return 0
end

Ruzzy.fuzz(test_one_input)

実行:

export ASAN_OPTIONS="allocator_may_return_null=1:detect_leaks=0:use_sigaltstack=0"
LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby fuzz_msgpack.rb

例:純粋な Ruby ターゲット

カスタムパーサーを使用した純粋な Ruby コードのファジング。

トレーサー(test_tracer.rb):

# frozen_string_literal: true

require 'ruzzy'

Ruzzy.trace('test_harness.rb')

ハーネス(test_harness.rb):

# frozen_string_literal: true

require 'ruzzy'
require_relative 'my_parser'

test_one_input = lambda do |data|
  begin
    MyParser.parse(data)
  rescue StandardError
    # 不正な入力による予期される例外
  end
  return 0
end

Ruzzy.fuzz(test_one_input)

実行:

export ASAN_OPTIONS="allocator_may_return_null=1:detect_leaks=0:use_sigaltstack=0"
LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \
    ruby test_tracer.rb

トラブルシューティング

問題原因解決策
インストール失敗clang のバージョンまたはパスが間違っているclang のパスを確認し、clang 14.0.0+ を使用
cannot open shared object fileLD_PRELOAD が設定されていないruby コマンドとインラインで LD_PRELOAD を設定
ファザーがすぐに終了するコーパスディレクトリがないコーパスディレクトリを作成するか、引数として渡す
カバレッジが進まない純粋な Ruby にはトレーサーが必要純粋な Ruby コードにはトレーサースクリプトを使用
リーク検出の大量出力Ruby インタプリタのリークASAN_OPTIONS=detect_leaks=0 を設定
インストールのデバッグが必要コンパイルエラーRUZZY_DEBUG=1 gem install --verbose ruzzy を使用

関連スキル

テクニックスキル

スキルユースケース
fuzz-harness-writing効果的なハーネス作成のための詳細ガイダンス
address-sanitizerファジング中のメモリエラー検出
undefined-behavior-sanitizerC 拡張における未定義動作の検出
libfuzzerlibFuzzer オプションの理解(Ruzzy は libFuzzer 上に構築)

関連ファザー

スキル検討するタイミング
libfuzzerRuby C 拡張のコードを C/C++ で直接ファジングする場合
aflppRuby インタプリタを計測して Ruby をファジングする代替アプローチ

リソース

主要な外部リソース

Ruzzy の紹介:カバレッジガイド型 Ruby ファザー Ruzzy を発表する Trail of Bits 公式ブログ記事。動機、アーキテクチャ、初期結果をカバー。

Ruzzy GitHub リポジトリ ソースコード、追加の例、開発手順。

libFuzzer ドキュメント Ruzzy は libFuzzer 上に構築されているため、libFuzzer のオプションと動作を理解することが重要です。

Ruby C 拡張のファジング コンパイルフラグと例を含む C 拡張ファジングの詳細ガイド。

純粋な Ruby コードのファジング 純粋な Ruby ファジングに必要なトレーサーパターンの詳細ガイド。

Individual skills in this repo

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

bg-szy/TOP-SKILLS

Brand-first landing page designer — runs a brand-identity interview (colors, typography, shape language), then generates and iterates on a polished landing page via Stitch with deployment-ready HTML. Use when the user asks to create, design, or build a landing page, homepage, or marketing page and has no established visual direction. Skip when they have a design mockup, need a dashboard or app UI, are working at component level, building a multi-page app, or restyling with known design tokens — use frontend-design instead.

bg-szy/TOP-SKILLS

Fill out Microsoft Azure Landing Zone (ALZ) Accelerator checklists by interviewing the user, mapping their Azure subscriptions, integrating IP addressing documentation, and applying Microsoft Cloud Adoption Framework best practices. Produces a completed Excel checklist (.xlsx) ready for ALZ deployment. Use this skill whenever the user mentions Azure Landing Zone, ALZ checklist, landing zone accelerator, platform landing zone configuration, ALZ bootstrap, hub-and-spoke setup, Azure network topology planning, or wants to fill out any ALZ-related checklist or configuration file. Also trigger when the user uploads an Excel file that contains tabs like "Accelerator - Bootstrap", "Accelerator - Bicep", or "Accelerator - Terraform".

bg-szy/TOP-SKILLS

Compose a premium, animated landing page section by section in Next.js + Tailwind + Motion (Framer Motion) — built on a real design system, with editorial copy and motion that feels human-crafted, not template-generated. Use when building or rebuilding a landing page, marketing site, or hero/feature/pricing/CTA sections that need to look production-ready and bespoke from day one.

bg-szy/TOP-SKILLS

Write high-converting landing page copy using proven frameworks like PAS (Problem-Agitate-Solution), AIDA, and StoryBrand. Creates headlines, value propositions, CTAs, and full page sections optimized for conversion. Use when users need landing page copy, sales page content, or marketing website text.

bg-szy/TOP-SKILLS

Optimize landing pages for conversions, performance, and SEO. Use when improving landing pages, increasing conversions, or optimizing page performance.

bg-szy/TOP-SKILLS

Review investment portfolios for risk, diversification, fees. Asset allocation recommendations, tax-loss harvesting, rebalancing.

bg-szy/TOP-SKILLS

Beads Viewer - Graph-aware triage engine for Beads projects. Computes PageRank, betweenness, critical path, and cycles. Use --robot-* flags for AI agents.

bg-szy/TOP-SKILLS

CI red? Call us. Pipeline fire brigade deploys. Use when user mentions CI failures, build errors, test failures, or pipeline issues. Do NOT load for: local builds, standard implementation work, reviews, or setup.

bg-szy/TOP-SKILLS

CASS Memory System - procedural memory for AI coding agents. Three-layer cognitive architecture with confidence decay, anti-pattern learning, cross-agent knowledge transfer, trauma guard safety system. Bun/TypeScript CLI.

bg-szy/TOP-SKILLS

Mandatory entry point: read this first for any request to make, create, edit, animate, or render a video, animation, or motion graphic, including a promo, explainer, captioned clip, title card, overlay, slideshow or interactive deck, Remotion port, or any HyperFrames HTML composition. Also use it to inspect, diagnose, validate, preview, publish, or batch-render an existing HyperFrames project. Inputs may be a website URL, GitHub PR, Figma design or URL, text or brief, existing footage, or music. It resumes project state, captures intent when applicable, selects and installs the owning workflow, and routes domain capabilities. HyperFrames is the default output framework unless the user explicitly chooses another framework for the deliverable or asks only to record a browser session.

bg-szy/TOP-SKILLS

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

bg-szy/TOP-SKILLS

Use when the user asks to "pre-launch check the landing page", "run a Quality-Score preflight", or "verify ad-to-page message match before launch"; produces an ad↔page continuity report — message-match gaps, above-the-fold check, page-speed read, form-friction count, mobile-render flags — as a pass/fix punch list. Not for redesigning or rewriting the page — use landing-optimizer; not for scoring the account or the RQS — use ad-account-auditor. 落地页体验预检/广告落地页一致性检查

bg-szy/TOP-SKILLS

Use when the user asks to "optimize our landing page for influencer traffic", "fix our promo-code landing page", or "improve conversion from a creator campaign"; produces a message-match audit, page-structure and social-proof recommendations, a promo-code/CTA conversion plan, and an A/B test roadmap. Not for measuring campaign results after launch — use performance-analyzer.

bg-szy/TOP-SKILLS

Audit a landing page, sales page or checkout page for conversion leaks and return a fix list ordered by expected revenue impact. Use when asked to review, critique or improve a landing page, sales page, opt-in page, product page or checkout flow, when conversion rate is low, when paid traffic is not converting, or when someone asks "why isn't this page converting" or wants a CRO / landing page review.

bg-szy/TOP-SKILLS

Landing page conversion optimization with layout rules, hero section design, and CTA psychology. Covers above-the-fold formula, social proof placement, mobile design, and F-pattern reading. Use for: startup landing pages, product pages, SaaS marketing, conversion optimization. Triggers: landing page, hero section, above the fold, conversion optimization, landing page design, cta button, hero image, landing page layout, saas landing page, product page design, conversion rate, landing page best practices

bg-szy/TOP-SKILLS

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.

bg-szy/TOP-SKILLS

Landing page conversion optimization with layout rules, hero section design, and CTA psychology. Covers above-the-fold formula, social proof placement, mobile design, and F-pattern reading. Use for: startup landing pages, product pages, SaaS marketing, conversion optimization. Triggers: landing page, hero section, above the fold, conversion optimization, landing page design, cta button, hero image, landing page layout, saas landing page, product page design, conversion rate, landing page best practices

bg-szy/TOP-SKILLS

Account assets, equity and fund positions, P&L, cash flow records, account statements, margin ratios, buy-power estimates, order management, and DCA recurring investments via Longbridge (most require Trade permission). Frameworks: portfolio diagnosis, rebalancing, asset allocation, risk analysis (VaR/CVaR), performance attribution, and tax-loss harvesting. Triggers: "持仓", "账户", "盈亏", "资产", "对账单", "下单", "买入", "卖出", "撤单", "定投", "组合诊断", "再平衡", "资产配置", "风险分析", "绩效归因", "税损收割", "持倉", "賬戶", "盈虧", "對賬單", "下單", "買入", "賣出", "組合診斷", "再平衡", "稅損收割", "positions", "portfolio", "P&L", "order", "buy", "sell", "DCA", "statement", "risk analysis", "rebalancing", "tax harvesting", "我的风险", "持仓风险", "风险敞口", "資產", "資產配置", "風險分析", "績效歸因", "撤單

bg-szy/TOP-SKILLS

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.

bg-szy/TOP-SKILLS

Process video files with audio extraction, format conversion (mp4, webm), and Whisper transcription. Use when user mentions video conversion, audio extraction, transcription, mp4, webm, ffmpeg, or whisper transcription.

関連スキル