A technical deep dive into Pinata's detection engine, scoring algorithm, and AI-powered features.
Pinata is a static analysis tool that scans source code for security vulnerabilities and test coverage gaps. It uses pattern matching against a curated database of detection rules, then scores results and optionally generates tests.
When you run pinata analyze, the following steps execute:
.pinataignore patterns.Each detection category is defined in YAML with the following structure:
id: sql-injection
version: 1
name: SQL Injection
description: |
Detects SQL queries built with string concatenation...
domain: security
priority: P0
severity: critical
applicableLanguages:
- python
- typescript
detectionPatterns:
- id: ts-template-literal-query
type: regex
language: typescript
pattern: "(query|execute).*`.*\\$\\{"
confidence: high
description: Detects template literals in SQL queries
negativePattern: "parameterized|prepared"
testTemplates:
- id: jest-sql-injection
language: typescript
framework: jest
template: |
describe('SQL Injection', () => {
it('uses parameterized queries', () => {
// Test code...
});
});
Each pattern has a confidence level that affects filtering and scoring:
By default, Pinata only reports high confidence findings. Use --confidence medium or --confidence low to see more.
The Pinata Score (0-100) represents your codebase's security health. Higher is better.
The score also considers which risk domains have been scanned. If your codebase has no database code, the Data domain won't penalize you for missing data validation patterns.
After 10 gaps of the same category, additional gaps have reduced impact. This prevents a single repeated issue from dominating the score.
Pinata integrates with LLMs (Anthropic Claude, OpenAI GPT) for enhanced analysis:
┌─────────────────────────────────────────────────┐
│ AI Service │
├─────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ │
│ │ Explainer │ │ Generator │ │
│ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────────────────────────────┐ │
│ │ Provider Abstraction │ │
│ │ (Anthropic / OpenAI / Mock) │ │
│ └─────────────────────────────────────┘ │
└─────────────────────────────────────────────────┘
The AI service abstracts away provider differences. You can switch between Anthropic and OpenAI by changing your API key configuration.
Pinata is designed for speed:
On a typical codebase (10,000 files, 500K LOC), Pinata completes in under 10 seconds. AI features add latency based on provider response times.
Pinata is designed for customization:
Add your own detection categories by creating YAML files in your project:
# .pinata/categories/my-company-auth.yml
id: my-company-auth
name: MyCompany Auth Standards
domain: security
severity: high
detectionPatterns:
- id: legacy-auth-function
pattern: "legacyAuthenticate\\("
confidence: high
description: Legacy auth function deprecated
Integrate with any system using standard output formats:
Pinata is designed with security in mind:
When using AI features, code snippets are sent to your configured AI provider (Anthropic or OpenAI). Use the --no-ai flag to disable all AI features in sensitive environments.