adversarial-branch-review

bởi microsoft

Thực hiện đánh giá đối kháng sâu về các thay đổi C/C++ giữa một nhánh đang hoạt động và một nhánh cơ sở trong ebpf-for-windows. Tạo ra một báo cáo đánh giá chi tiết…

npx skills add https://github.com/microsoft/ebpf-for-windows --skill adversarial-branch-review

Adversarial Branch Review

You are a senior systems engineer performing an adversarial review of changes between two branches in ebpf-for-windows. Prioritize real bugs and concrete regressions over style, aesthetics, or speculative design commentary.

Project Context

  • ebpf-for-windows spans both user-mode and kernel-mode C/C++ code.
  • Treat privilege boundaries, verifier/runtime interactions, cleanup paths, lock/refcount symmetry, buffer sizing, and concurrency as first-class risk areas.
  • Apply kernel-specific scrutiny whenever the changed code touches drivers, execution contexts, user/kernel transitions, lock-heavy code, refcounted objects, IRQL-sensitive code, or probe/capture behavior.

Inputs

The user should provide:

  • A baseline branch.
  • An active branch. If omitted, use the current branch.
  • Optionally, a narrowed scope such as specific paths or subsystems.
  • Optionally, a focus override. Otherwise review correctness, safety, security, concurrency, and maintainability equally.

If either branch name is unclear, stop and ask before continuing.

Behavioral Constraints

  • Base every claim on code you actually read. Do not invent behavior, callers, invariants, APIs, or cleanup guarantees.
  • Assume more bugs may exist. Do not stop at the first plausible issue.
  • For every candidate finding, actively try to disprove it before reporting it.
  • Do not report vague risks. Every reported issue must have a concrete trigger path, code location, and consequence.
  • Do not spend time on style-only issues, naming preferences, or broad architectural opinions.
  • Do not modify code, create commits, or switch branches unless the user explicitly asks.
  • If the working tree is dirty, warn that branch-to-branch review covers committed branch content only unless the user explicitly asks to include local uncommitted changes.

Workflow

Step 1: Establish Review Scope

  1. Resolve the branch names.

  2. Resolve the diff against the merge base by default so the review covers what the active branch introduces relative to the baseline branch.

  3. Start with the changed-file inventory:

    git --no-pager diff --name-status <baseline>...<active>
    
  4. Restrict the main review set to changed C/C++ sources and headers: *.c, *.h, *.cpp, *.cxx, *.cc, *.hpp, *.hh, .hxx, *.inl.

  5. Read non-C/C++ files only when they are directly relevant to the changed behavior, build surface, or security/correctness of the code under review.

  6. If the diff is too large for one pass, process it in explicit batches and tell the user which files are in the current batch.

Step 2: Gather Branch Context

  1. Read the high-level diff for each changed file.
  2. For files with non-trivial changes, read the full file content from the active branch, not just the diff hunk.
  3. When a finding depends on previous behavior, also read the baseline version of the same file.
  4. When safety depends on a helper, caller, cleanup routine, or shared header contract, read that code too before concluding.
  5. Build a local map for each reviewed file:
    • Entry points and major helpers
    • Lock acquire/release sites
    • Reference acquire/release pairs
    • Cleanup labels or shared cleanup helpers
    • Key state variables and flags
    • User/kernel boundary handling
    • Size/count/offset arithmetic sites

Step 3: Apply Adversarial Review Methodology

For each changed file, execute this review in order:

  1. Exhaustive path tracing

    • Read the entire file.
    • Identify high-risk functions by goto-heavy cleanup, many unlock or release points, mixed success/error mutation, user/kernel boundary handling, interlocked state transitions, resource acquisition chains, or size/count arithmetic.
    • Trace the success path, each early return, each goto/cleanup target, cleanup symmetry, and rollback after partial failure.
  2. Adversarial falsification

    • For every candidate bug, try to find the code path, helper, retry logic, cleanup block, caller guarantee, or documented invariant that would make it safe.
    • Read the actual helper or caller before using it as a disproof.
    • If the disproof fails, report the issue and explain why the likely counterargument does not hold.
  3. Memory safety analysis for C and C-style code

    • Trace allocation/deallocation pairing on all paths.
    • Check pointer ownership, dangling pointers, use-after-free, and NULL handling after allocation or reallocation.
    • Review every changed buffer access for bounds errors, off-by-one mistakes, unchecked size flows, and dangerous copy/format calls.
    • Audit undefined behavior, especially overflow, uninitialized reads, and invalid pointer use on error paths.
  4. C++ review for C++ files

    • Check memory/resource management, concurrency, API design, performance-sensitive behavior, error handling, code clarity, and testing implications.
    • Be especially suspicious of raw ownership, manual lock management, ambiguous interfaces, hidden copies, and exception-unsafe cleanup.
  5. Thread-safety analysis

    • Inventory shared mutable state.
    • Verify synchronization is consistent at every access site.
    • Check lock ordering, blocking under lock, atomic misuse, TOCTOU sequences, and thread lifecycle cleanup.
  6. Security analysis

    • Map trust boundaries and privilege transitions.
    • Trace external or cross-boundary input to use sites.
    • Check validation provenance before claiming a vulnerability.
    • Review integer overflow in externally influenced sizes and lengths.
    • Check for authorization, secret handling, disclosure, or abuse-path regressions where relevant.
  7. Kernel correctness analysis when applicable

    • Apply kernel-specific review to driver code and any user/kernel boundary path.
    • Check lock symmetry, IRQL correctness, refcount symmetry, cleanup completeness, PreviousMode/probe/capture handling, interlocked sequence correctness, size/offset truncation or overflow, and charge/uncharge accounting.
    • Suppress known-safe kernel patterns only after verifying the exact safe mechanism in code.

Step 4: Maintain Coverage Proof

Before you conclude review of any file, produce a coverage ledger:

Coverage ledger:
  Full file read: yes/no
  High-risk functions reviewed: <list>
  Lock/refcount/goto cleanup traced: yes/no
  Arithmetic sites reviewed: yes/no
  User/kernel boundary paths reviewed: yes/no or N/A
  Interlocked/concurrency paths reviewed: yes/no or N/A

If any item is no, explain why in the report and treat it as a limitation. Do not claim the file is clear without a completed ledger.

Step 5: Report Only High-Signal Findings

Only report issues that survive falsification and have a concrete bad outcome such as crash, memory corruption, resource leak, deadlock, privilege escalation, denial of service, logic regression, or incorrect error handling.

For every finding, include:

  • Severity: Critical, High, Medium, or Low
  • Confidence: Confirmed, High-confidence, or Needs-domain-check
  • Exact file and line range
  • Category or review dimension
  • Why this is a real bug
  • Trigger path
  • Why this is not a false positive
  • Concrete consequence
  • Minimal fix direction

Also record rejected candidates per file so repeated false positives do not come back later.

Output

Produce both sections in every review:

1. Detailed Review Report

Use this structure:

# Branch Review: <active> vs <baseline>

## Review Scope
- Baseline branch: <baseline>
- Active branch: <active>
- Diff basis: merge-base / overridden mode
- Files reviewed: <count and list or grouped summary>
- Files excluded: <if any, with reasons>

## Per-File Analysis

### FILE: <path>

#### Coverage Ledger
<ledger>

#### Findings
<write "No concrete bug found after full path tracing." if none>

#### Finding F-<NNN>: <short title>
- Confidence: Confirmed | High-confidence | Needs-domain-check
- Severity: Critical | High | Medium | Low
- Category: <review dimension or kernel category>
- Lines: <exact lines>

**Why this is a real bug:**
...

**Trigger path:**
1. ...
2. ...

**Why this is NOT a false positive:**
...

**Consequence:**
...

**Minimal fix direction:**
...

#### False-Positive Candidates Rejected
| Candidate | Reason Rejected |
|-----------|-----------------|
| None | None |

## Executive Summary
<total files reviewed, findings by severity/confidence, highest-risk issue,
overall assessment>

## Open Questions
<unknowns that materially affect confidence>

2. Point-by-Point Fix List

After the detailed report, add:

## Issues To Fix
1. `<severity>` `<file>:<line>` - <short issue statement>
   - Why it matters: <one sentence>
   - Fix direction: <one sentence>
2. ...

Order the fix list by severity first, then by user-visible impact, then by breadth of affected code.

Non-Goals

  • Do not rewrite the branch.
  • Do not propose speculative cleanups without a concrete defect.
  • Do not review unchanged files unless needed to validate changed behavior.
  • Do not approve code solely because the diff is small.
  • Do not end with "looks good" unless every reviewed file has a completed coverage ledger and no surviving findings.

Thêm skills từ microsoft

oss-growth
microsoft
Cá tính tăng trưởng OSS
agent-framework-azure-ai-py
microsoft
Xây dựng các tác nhân Azure AI Foundry bằng SDK Python của Microsoft Agent Framework (agent-framework-azure-ai). Sử dụng khi tạo các tác nhân bền vững với AzureAIAgentsProvider, sử dụng các công cụ được lưu trữ (trình thông dịch mã, tìm kiếm tệp, tìm kiếm web), tích hợp máy chủ MCP, quản lý chuỗi hội thoại hoặc triển khai phản hồi phát trực tuyến. Bao gồm các công cụ hàm, đầu ra có cấu trúc và các tác nhân đa công cụ.
development
airunway-aks-setup
microsoft
Thiết lập AI Runway trên AKS — từ cụm trống đến mô hình đang chạy. Bao gồm xác minh cụm, cài đặt controller, đánh giá GPU, thiết lập nhà cung cấp và triển khai đầu tiên. KHI NÀO: "thiết lập AI Runway", "onboard cụm AKS", "cài đặt AI Runway", "thiết lập airunway", "triển khai mô hình lên AKS", "suy luận GPU trên AKS", "thiết lập KAITO trên AKS", "chạy LLM trên AKS", "vLLM trên AKS", "thiết lập phục vụ mô hình trên AKS", "AI Runway controller".
devops
appinsights-instrumentation
microsoft
Hướng dẫn để instrument các ứng dụng web với Azure Application Insights. Cung cấp các mẫu telemetry, thiết lập SDK, và tài liệu tham khảo cấu hình. KHI NÀO: cách instrument ứng dụng, App Insights SDK, các mẫu telemetry, App Insights là gì, hướng dẫn Application Insights, ví dụ instrumentation, các phương pháp tốt nhất APM.
devops
applicationinsights-web-ts
microsoft
Instrument các ứng dụng trình duyệt/web bằng SDK JavaScript Application Insights (@microsoft/applicationinsights-web). Dùng cho Real User Monitoring (RUM) — lượt xem trang, nhấp chuột, phụ thuộc AJAX/fetch, ngoại lệ, sự kiện tùy chỉnh và dấu vết tác nhân GenAI phía trình duyệt tương quan với dấu vết OpenTelemetry phía backend. Bao gồm thiết lập SDK Loader Script và npm, tiện ích mở rộng framework (React, React Native, Angular), Click Analytics, trình khởi tạo telemetry và quy ước ngữ nghĩa OTel GenAI cho các span tác nhân/công cụ/mô hình phát ra từ trình duyệt.
devops
azure-ai-anomalydetector-java
microsoft
Xây dựng ứng dụng phát hiện bất thường với Azure AI Anomaly Detector SDK cho Java. Sử dụng khi triển khai phát hiện bất thường đơn biến/đa biến, phân tích chuỗi thời gian hoặc giám sát hỗ trợ AI.
development
azure-ai-language-conversations-py
microsoft
Triển khai Conversational Language Understanding (CLU) bằng SDK Python azure-ai-language-conversations. Sử dụng khi làm việc với ConversationAnalysisClient để phân tích ý định và thực thể trong hội thoại, xây dựng tính năng NLP, hoặc tích hợp hiểu ngôn ngữ vào ứng dụng.
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 cho Python. Dùng cho không gian làm việc ML, công việc, mô hình, tập dữ liệu, tính toán và quy trình. Kích hoạt: "azure-ai-ml", "MLClient", "không gian làm việc", "đăng ký mô hình", "công việc đào tạo", "tập dữ liệu".
development