package export
import (
"encoding/csv"
"log"
"net/http"
require "securerandom"
require "digest"
class SlidingWindowLimiter
Result = Struct.new(:allowed, :count, :remaining)
use std::time::Duration;
use rand::Rng;
#[derive(Clone, Debug)]
pub struct BackoffPolicy {
pub base_delay: Duration,
import random
from dataclasses import dataclass
from typing import Iterator
@dataclass(frozen=True)
package com.example.security;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.JwtException;
import io.jsonwebtoken.io.Decoders;
auth:
- authentication required for non-public endpoints
- authorization rules documented and tested
data:
- secrets stored outside source control
- encryption in transit enabled
#!/usr/bin/env bash
set -euo pipefail
cosign sign --key env://COSIGN_PRIVATE_KEY ghcr.io/example/codesnips:${GITHUB_SHA}
cosign verify --key env://COSIGN_PUBLIC_KEY ghcr.io/example/codesnips:${GITHUB_SHA}
example.com. IN TXT "v=spf1 include:_spf.google.com -all"
default._domainkey IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqh..."
_dmarc.example.com. IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com; adkim=s; aspf=s"
severities:
sev1: customer-impacting active compromise or confirmed data exposure
sev2: high risk suspicious activity with potential customer impact
sev3: contained issue with low current impact
first_hour:
class CspReportsController < ActionController::API
def create
Rails.logger.warn({
event: 'csp_report',
report: params.to_unsafe_h,
ip: request.remote_ip,
user = User.find_by(email: params[:email].to_s.downcase.strip)
if user
raw_token = SecureRandom.urlsafe_base64(32)
user.password_resets.create!(token_digest: Digest::SHA256.hexdigest(raw_token), expires_at: 30.minutes.from_now)
PasswordResetMailer.with(user: user, token: raw_token).deliver_later
final class PinnedSessionDelegate: NSObject, URLSessionDelegate {
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
guard let serverTrust = challenge.protectionSpace.serverTrust else {
completionHandler(.cancelAuthenticationChallenge, nil)
return
}