This document describes the static security analysis tools and processes used in the Stellar Micro-Donation API project.
Static security analysis runs automatically on every pull request to detect common security issues before code is merged.
We use ESLint with the following security-focused plugins:
- eslint-plugin-security: Detects common security anti-patterns
- eslint-plugin-no-secrets: Prevents accidental commit of secrets and high-entropy strings
-
Unsafe Patterns
- Use of
eval()ornew Function() - Unsafe regular expressions (ReDoS vulnerabilities)
- Insecure random number generation
- Buffer operations without assertions
- Use of
-
Secret Detection
- High-entropy strings that may be API keys or tokens
- Hardcoded credentials
- Private keys in code
-
Injection Vulnerabilities
- Non-literal file system paths
- Non-literal require statements
- Object injection sinks
- Possible timing attacks
-
Code Quality Issues
- Unused variables
- Unreachable code
- Loss of precision in numbers
# Run security linting
npm run lint:security
# Run all linting
npm run lintStatic security analysis runs automatically on:
- Pull requests to
mainordevelopbranches - Pushes to
mainordevelopbranches
The workflow is defined in .github/workflows/static-security.yml.
Some warnings are expected and acceptable:
- Object Injection Warnings: Often false positives when accessing object properties with validated keys
- Non-literal FS Paths: Acceptable when paths are constructed from validated configuration
- Test Keys: Development/test Stellar keys trigger secret detection but are not real secrets
Use inline comments sparingly and only for legitimate cases:
// eslint-disable-next-line no-secrets/no-secrets -- Explanation
const testKey = 'GBRPYHIL2CI3WHZDTOOQFC6EB4KJJGUJMUC5XNODMZTQYBB5XYZXYUU';Or for blocks:
/* eslint-disable no-secrets/no-secrets */
// Test keys for development
const keys = [...];
/* eslint-enable no-secrets/no-secrets */- 0: No errors (warnings are acceptable)
- 1: Errors found (blocks CI)
.eslintrc.js: ESLint configuration with security rules.eslintignore: Files/directories excluded from linting.github/workflows/static-security.yml: CI workflow
- Never commit real secrets: Use environment variables
- Review warnings: Even if they don't block CI, they may indicate issues
- Keep dependencies updated: Security plugins are regularly updated
- Document suppressions: Always explain why a warning is suppressed
As of the latest run:
- Errors: 0
- Warnings: 37 (mostly false positives for object injection)
- Status: ✅ Passing