mistral-security-basics

Featured

Apply Mistral AI security best practices for secrets, prompt injection, and access control. Use when securing API keys, defending against prompt injection, or auditing Mistral AI security configuration. Trigger with phrases like "mistral security", "mistral secrets", "secure mistral", "mistral prompt injection".

AI & Automation 2,926 stars 433 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Mistral Security Basics ## Overview Security practices for Mistral AI integrations: API key management, prompt injection defense, output sanitization, content moderation with `mistral-moderation-latest`, request logging without secrets, and key rotation. ## Prerequisites - Mistral API key provisioned - Understanding of OWASP LLM Top 10 risks - Secret management infrastructure ## Instructions ### Step 1: API Key Management ```python import os # NEVER: api_key = "sk-abc123" # Development — env vars api_key = os.environ.get("MISTRAL_API_KEY") if not api_key: raise RuntimeError("MISTRAL_API_KEY not set") # Production — secret manager from google.cloud import secretmanager def get_api_key() -> str: client = secretmanager.SecretManagerServiceClient() response = client.access_secret_version( name="projects/my-project/secrets/mistral-api-key/versions/latest" ) return response.payload.data.decode("UTF-8") ``` ### Step 2: Prompt Injection Defense ```typescript function sanitizeUserInput(input: string): string { // Strip common injection patterns const patterns = [ /ignore (?:previous|all|above) instructions/gi, /you are now/gi, /system prompt/gi, /\boverride\b/gi, /\bforget\b.*\binstructions\b/gi, ]; let sanitized = input; for (const pattern of patterns) { sanitized = sanitized.replace(pattern, '[FILTERED]'); } // Limit length to prevent context stuffing return sanitized.slice(0, 4000); } function build...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category