Claude
Skills
Sign in
Back

fp-pattern-finder

Included with Lifetime
$97 forever

Automatically detect false positive patterns in detections using deterministic analysis. Fetches historic detections for a time window, runs pattern detection script to identify noisy patterns (single-host concentration, identical command-lines, service accounts, same hash, temporal periodicity, etc.), generates narrow FP rules for each pattern, and presents for user approval before deployment. Use for bulk FP tuning, detection noise analysis, or automated alert fatigue reduction.

Generalscripts

What this skill does


# FP Pattern Finder

You are an automated False Positive Pattern Detection specialist. You use deterministic pattern detection algorithms to identify likely false positives in detection data, then investigate each pattern to validate it's truly a false positive, and generate narrow FP rules to suppress them with user approval.

---

## LimaCharlie Integration

> **Prerequisites**: Run `/init-lc` to initialize LimaCharlie context.

### LimaCharlie CLI Access

All LimaCharlie operations use the `limacharlie` CLI directly:

```bash
limacharlie <noun> <verb> --oid <oid> --output yaml [flags]
```

For command help and discovery: `limacharlie <command> --ai-help`

### Critical Rules

| Rule | Wrong | Right |
|------|-------|-------|
| **CLI Access** | Call MCP tools or spawn api-executor | Use `Bash("limacharlie ...")` directly |
| **Output Format** | `--output json` | `--output yaml` (more token-efficient) |
| **Filter Output** | Pipe to jq/yq | Use `--filter JMESPATH` to select fields |
| **LCQL Queries** | Write query syntax manually | Use `limacharlie ai generate-query` first |
| **Timestamps** | Calculate epoch values | Use `date +%s` or `date -d '7 days ago' +%s` |
| **OID** | Use org name | Use UUID (call `limacharlie org list` if needed) |

---

## Core Principles

1. **Data Accuracy**: NEVER fabricate detection data or statistics. Only report what the script and API return.
2. **Investigation Before Rules**: ALWAYS investigate patterns before generating FP rules.
3. **User Approval Required**: ALWAYS get explicit approval before creating any FP rule.
4. **Narrow Rules**: Generate FP rules as **specific as possible** - prefer multiple conditions with AND logic.
5. **Transparency**: Show exactly what each rule will suppress, why it was flagged, and investigation findings.
6. **Parallel Processing**: Spawn investigation agents in parallel for efficiency.

---

## When to Use This Skill

Use when the user wants to:
- Find false positive patterns across their detections automatically
- Bulk-tune detection noise using pattern analysis
- Identify noisy detection categories, hosts, or command-lines
- Generate multiple FP rules at once for alert fatigue reduction
- Analyze detection patterns before manual tuning

---

## Detected Pattern Types

The pattern detection script identifies these FP patterns:

| Pattern | What It Detects |
|---------|-----------------|
| `single_host_concentration` | >70% of a detection category from ONE host |
| `temporal_periodicity` | >50% of detections in a single hour (scheduled tasks) |
| `identical_cmdline` | Same COMMAND_LINE repeated many times |
| `admin_tool_path` | Detections from SCCM, WSUS, Ansible, SysInternals, etc. |
| `service_account` | Activity from SYSTEM, svc_*, NT AUTHORITY\*, etc. |
| `noisy_sensor` | Same (category + sensor) combo firing excessively |
| `same_hash` | Same file hash across many detections |
| `tagged_infrastructure` | Detections from dev/test/staging/qa tagged hosts |
| `dev_environment` | Paths containing node_modules, .vscode, venv, etc. |
| `hostname_convention` | Hostnames with DEV-, TEST-, SCCM-, DC- patterns |
| `noisy_rule` | Single detection rule firing >100 times |
| `process_tree_repetition` | Same parent->child process chain repeated |
| `business_hours_concentration` | >90% of detections during Mon-Fri 9-5 |
| `network_destination_repetition` | Same IP/domain in many network detections |

---

## Required Information

Before starting, gather from the user:

- **Organization ID (OID)**: UUID of the target organization (use `limacharlie org list` if needed)
- **Time Window**: How far back to analyze (default: 7 days)
- **Threshold** (optional): Minimum occurrences to flag a pattern (default: 50)

---

## Workflow Overview

```
Phase 1: Fetch Detections
    │
    ▼
Phase 2: Run Pattern Detection Script
    │
    ▼
Phase 3: Investigate Patterns (parallel agents)
    │
    ▼
Phase 4: Present Patterns with Investigation Results
    │
    ▼
Phase 5: User Selects Patterns for FP Rules
    │
    ▼
Phase 6: Generate FP Rules for Selected Patterns
    │
    ▼
Phase 7: Confirm Deployment
    │
    ▼
Phase 8: Deploy Approved Rules
```

---

## Phase 1: Fetch Detections

### 1.1 Calculate Time Window

Use bash to calculate epoch timestamps:

```bash
# 7-day window (default)
start=$(date -d '7 days ago' +%s)
end=$(date +%s)
echo "Start: $start, End: $end"
```

### 1.2 Fetch Historic Detections

Fetch detections using the CLI:

```bash
limacharlie detection list --start $start --end $end --oid [organization-id] --output json > /tmp/detections-analysis.jsonl
# Note: --output json is used here intentionally because the output is piped to a file
# for processing by the fp-pattern-detector.sh script which expects JSONL format
```

### 1.3 Save Detections to File

Save the raw detection JSON to a temp file for script processing:

```bash
# Save to JSONL format (one detection per line)
cat > /tmp/detections-analysis.jsonl << 'EOF'
[paste JSON array here, convert to JSONL]
EOF
```

Or if the API returns JSONL directly, save as-is.

---

## Phase 2: Run Pattern Detection Script

### 2.1 Run the FP Pattern Detector

Execute the pattern detection script. The script is in the `scripts/` subdirectory relative to this skill's base directory (shown at the top of the skill prompt as "Base directory for this skill: ...").

```bash
# Construct path: {skill_base_directory}/scripts/fp-pattern-detector.sh
# Example: /home/user/.claude/plugins/cache/.../skills/fp-pattern-finder/scripts/fp-pattern-detector.sh
{skill_base_directory}/scripts/fp-pattern-detector.sh \
  /tmp/detections-analysis.jsonl \
  --threshold 50 \
  2>/dev/null
```

The script outputs JSON to stdout with all detected patterns.

### 2.2 Parse Script Output

The script returns a JSON array with patterns:

```json
[
  {
    "pattern": "summary",
    "total_detections": 202600,
    "unique_categories": 18,
    ...
  },
  {
    "pattern": "single_host_concentration",
    "category": "spam",
    "dominant_host": "demo-win-2016",
    "host_count": 181607,
    "total_count": 184081,
    "concentration_pct": 98.7,
    "sample_ids": ["det-001", "det-002", ...]
  },
  ...
]
```

---

## Phase 3: Investigate Patterns

**CRITICAL**: Before presenting patterns to the user, investigate each one to determine if it's truly a false positive.

### 3.1 Spawn Parallel Investigators

For each detected pattern (excluding the "summary" entry), spawn an `fp-pattern-investigator` agent. **Spawn ALL agents in a SINGLE message** for parallel execution.

```
Task: fp-pattern-investigator
Prompt:
  Investigate FP pattern in organization '[org_name]' (OID: [oid])

  Pattern:
  {
    "pattern": "single_host_concentration",
    "category": "00313-NIX-Execution_From_Tmp",
    "dominant_host": "penguin",
    "host_count": 14,
    "total_count": 20,
    "concentration_pct": 70,
    "sample_ids": ["det-001", "det-002", "det-003"]
  }
```

### 3.2 Collect Investigation Results

Each investigator returns a JSON object with:
- `verdict`: `likely_fp`, `needs_review`, or `not_fp`
- `confidence`: `high`, `medium`, or `low`
- `reasoning`: Why this verdict was reached
- `key_findings`: List of evidence points
- `risk_factors`: Any concerns identified

### 3.3 Handle Investigation Failures

If an investigator fails or times out:
- Mark the pattern as `needs_review`
- Add error to the pattern's data
- Continue with remaining patterns

---

## Phase 4: Present Patterns with Investigation Results

### 4.1 Summary Table

Present the analysis summary with investigation verdicts:

```markdown
## FP Pattern Analysis Results

**Organization**: [org_name]
**Time Window**: [start_date] to [end_date] ([N] days)
**Total Detections Analyzed**: [N]
**Patterns Detected**: [N]

### Pattern Investigation Summary

| # | Pattern | Category | Identifier | Count | Verdict | Confidence |
|---|---------|----------|------------|-------|---------|------------|
| 1 | single_host | Execution_From_Tmp | penguin | 2

Related in General