Instruments authentication, authorization, and input-handling code paths to monitor security-relevant events and states at runtime. Use this skill when developers need to add security monitoring and logging to their code, including tracking authentication attempts (login/logout), authorization decisions (access control checks), input validation failures, session management events, and other security-critical operations. Supports Python, JavaScript/TypeScript, and Java with structured logging patterns. Triggers when users ask to add security instrumentation, monitor security events, log authentication/authorization, track security-sensitive operations, or add security observability to their codebase.
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Add structured logging instrumentation to security-critical code paths for runtime monitoring of authentication, authorization, input validation, session management, and other security-relevant events.
Identify security-sensitive code paths - Locate authentication, authorization, input validation, or session management code that needs instrumentation
Determine event types - Classify the security events to monitor (see security_events.md for taxonomy)
Review best practices - Check best_practices.md for what to log and what to avoid (never log passwords, secrets, or sensitive PII)
Select language patterns - Use language_patterns.md for language-specific instrumentation code (Python, JavaScript/TypeScript, Java)
Add instrumentation - Insert structured logging calls at key decision points:
Include context - Log relevant data points:
Verify instrumentation - Ensure:
Authentication (Python/Flask):
log_security_event(
event_type='authentication_attempt',
username=username,
ip_address=request.remote_addr
)Authorization (JavaScript/Express):
logSecurityEvent('authorization_check', {
user_id: user.id,
resource: resourceId,
permission: requiredPermission,
decision: hasPermission ? 'granted' : 'denied'
});Validation (Java/Spring):
Map<String, Object> data = new HashMap<>();
data.put("user_id", user.getId());
data.put("errors", validationErrors);
SecurityLogger.logSecurityEvent("validation_failure", data);Use scripts/generate_instrumentation.py to generate code snippets:
# Generate Python authentication instrumentation
python scripts/generate_instrumentation.py python authentication
# Generate JavaScript authorization instrumentation
python scripts/generate_instrumentation.py javascript authorization
# Generate Java validation instrumentation
python scripts/generate_instrumentation.py java validationNever log:
Always log:
Use structured logging (JSON format) for machine parsing and analysis.
ArabelaTso/Skills-4-SE
4f38503
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.