// Configuration management with validation
const Joi = require('joi');
// Define schema for all environment variables
const envSchema = Joi.object({
NODE_ENV: Joi.string()
class WebhookSignature
class VerificationError < StandardError; end
TOLERANCE = 300 # seconds
def initialize(payload:, header:, secrets:)
# ECS Task Execution Role (pull images, push logs)
resource "aws_iam_role" "ecs_execution" {
name = "${var.project_name}-ecs-execution"
assume_role_policy = jsonencode({
Version = "2012-10-17"
// 1. DANGEROUS: Never use innerHTML with user input
const userInput = '<img src=x onerror="alert('XSS')">';
// WRONG - vulnerable to XSS
document.getElementById('output').innerHTML = userInput;
# === Vault Agent Injector: Auto-inject secrets into pods ===
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-server
namespace: production
package middleware
import (
"net/http"
)
class PaymentService
def initialize
Stripe.api_key = Rails.application.credentials.stripe[:secret_key]
end
def create_payment_intent(amount:, currency: 'usd')
<?php
declare(strict_types=1);
namespace App\Security;
package auth
import "golang.org/x/crypto/bcrypt"
func HashPassword(pw string, cost int) ([]byte, error) {
if cost == 0 {
package upload
import (
"errors"
"io"
"log"
class AttachmentContentTypeValidator < ActiveModel::EachValidator
SIGNATURES = {
"image/png" => ["\x89PNG\r\n\x1a\n".b],
"image/jpeg" => ["\xFF\xD8\xFF".b],
"image/gif" => ["GIF87a".b, "GIF89a".b],
"application/pdf" => ["%PDF-".b]
import hmac
import hashlib
import time
from fastapi import Request, HTTPException, status