lokalise-security-basics
Apply Lokalise security best practices for API tokens and access control. Use when securing API tokens, implementing least privilege access, or auditing Lokalise security configuration. Trigger with phrases like "lokalise security", "lokalise secrets", "secure lokalise", "lokalise API token security".
- License 许可
- MIT
- 最近更新
- 2026-03-20
- Stars
- ★ 4
- Forks
- 0
01 前言 Front Matter
- name
- lokalise-security-basics
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Apply Lokalise security best practices for API tokens and access control. Use when securing API tokens, implementing least privilege access, or auditing Lokalise security configuration. Trigger with phrases like "lokalise security", "lokalise secrets", "secure lokalise", "lokalise API token security".
- allowed-tools
- Read, Write, Grep
- compatible-with
- claude-code, codex, openclaw
03 SKILL.md 正文
Lokalise Security Basics
Overview
Security practices for Lokalise translation management integrations. Lokalise handles translation strings that may contain user-facing content, brand messaging, and occasionally PII embedded in translation keys.
Prerequisites
- Lokalise API token provisioned
- Understanding of token permission scopes
- Secret management infrastructure
Instructions
Step 1: Token Scope Management
Lokalise tokens can have different permission levels. Use the minimum scope needed.
import os
# BAD: using admin token for read-only operations
# GOOD: create scoped tokens per use case
LOKALISE_READ_TOKEN = os.environ.get("LOKALISE_READ_TOKEN") # read-only
LOKALISE_WRITE_TOKEN = os.environ.get("LOKALISE_WRITE_TOKEN") # read + write
LOKALISE_ADMIN_TOKEN = os.environ.get("LOKALISE_ADMIN_TOKEN") # admin (CI only)
def get_client(scope: str = "read"):
import lokalise
tokens = {"read": LOKALISE_READ_TOKEN, "write": LOKALISE_WRITE_TOKEN, "admin": LOKALISE_ADMIN_TOKEN}
token = tokens.get(scope)
if not token:
raise RuntimeError(f"LOKALISE_{scope.upper()}_TOKEN not configured")
return lokalise.Client(token)
Step 2: Protect Translation Content
Translation strings may contain interpolation variables. Validate before processing.
import re
def validate_translation(key: str, value: str) -> list[str]:
issues = []
# Check for potential code injection in translations
if re.search(r'<script|javascript:|on\w+=', value, re.IGNORECASE):
issues.append(f"Potential XSS in translation {key}")
# Check for leaked credentials
if re.search(r'(api_key|password|secret|token)\s*[:=]', value, re.IGNORECASE):
issues.append(f"Possible credential in translation {key}")
# Validate interpolation variables match expected format
placeholders = re.findall(r'\{[^}]+\}|%[sd]|\$\{[^}]+\}', value)
for p in placeholders:
if re.search(r'[<>\'"]', p):
issues.append(f"Suspicious placeholder in {key}: {p}")
return issues
Step 3: CI/CD Token Security
# GitHub Actions: use repository secrets
name: Sync Translations
on: push
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pull translations
env:
LOKALISE_TOKEN: ${{ secrets.LOKALISE_READ_TOKEN }}
run: |
lokalise2 file download \
--token $LOKALISE_TOKEN \
--project-id ${{ vars.LOKALISE_PROJECT_ID }} \
--format json \
--dest ./locales/
Step 4: Audit Translation Changes
Track who changed what translations for compliance.
def audit_translation_change(project_id: str, key: str, old_value: str, new_value: str, user: str):
log_entry = {
"timestamp": datetime.utcnow().isoformat(),
"project_id": project_id,
"key": key,
"user": user,
"action": "update",
"changes": {"old_length": len(old_value), "new_length": len(new_value)}
# Don't log actual content if it may contain PII
}
audit_logger.info("Translation changed", extra=log_entry)
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Token leaked in CI logs | Token in command output | Use environment variables, mask in CI |
| XSS via translations | Unsanitized translation content | Validate translations before use |
| Overprivileged access | Using admin token everywhere | Create scoped read/write tokens |
| Unauthorized changes | No audit trail | Log translation changes with user info |
Examples
Security Check Script
# Scan for hardcoded tokens
grep -rn "LOKALISE" --include="*.py" --include="*.ts" src/ | grep -v "os.environ\|process.env"
Resources
Output
- Configuration files or code changes applied to the project
- Validation report confirming correct implementation
- Summary of changes made and their rationale
04 同仓库更多 Skills
azure-apim-architecture
Analyzes and explains Azure API Management architecture decisions for enterprise API marketplace implementations using VNet Internal mode, Front Door, hybrid authentication, and multi-environment strategies. Use when discussing APIM component selection, network topology, cost optimization, or comparing alternatives like workspaces vs instances, VNet Internal vs External mode, or Front Door vs Application Gateway.
apiops-deployment
Guides deployment of Azure API Management infrastructure using Infrastructure as Code (Bicep/Terraform), CI/CD pipelines (GitHub Actions/Azure DevOps), and APIOps workflows. Use when deploying APIM, creating pipelines, or implementing dev→test→prod promotion strategies.
apim-policy-authoring
Creates production-ready Azure API Management policy XML for authentication (OAuth 2.0, JWT validation, subscription keys), rate limiting, CORS configuration, error handling, and API transformations. Use when implementing API security, access control, or request/response processing logic.
api-security-review
Reviews Azure API Management configurations for security vulnerabilities, OWASP API Security Top 10 compliance, VNet Internal mode validation, Private Link verification, and Azure Security Benchmark alignment. Use when performing security audits, pre-deployment validation, or compliance reviews.
jira-cli
Interact with Jira from the command line to create, list, view, edit, and transition issues, manage sprints and epics, and perform common Jira workflows. Use when the user asks about Jira tasks, tickets, issues, sprints, or needs to manage project work items.
calculator
Performs arbitrary-precision arithmetic calculations including addition, subtraction, multiplication, division, and exponents. Use when the user asks to calculate, compute, or evaluate math expressions, or when precise decimal arithmetic is needed to avoid floating-point errors.