Проверка rehash, login DoS и общего rate limit

This commit is contained in:
EgorAnti
2026-11-27 11:48:33 +03:00
parent 16760f4072
commit 0fa4b66df6
14 changed files with 841 additions and 10 deletions
+42
View File
@@ -0,0 +1,42 @@
[CmdletBinding()]
param(
[string]$EnvFile = '.env',
[string]$Python = 'python',
[string]$BaseUrl = 'https://localhost:8443',
[int]$MinimumInstances = 2,
[switch]$SourceBudget,
[switch]$IncludeArgon2
)
$ErrorActionPreference = 'Stop'
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
Set-Location $projectRoot
if(-not (Test-Path (Join-Path $projectRoot 'compose.yaml'))) {
throw "Run the repository copy of this script: $projectRoot does not contain compose.yaml."
}
$ca = (Resolve-Path 'secrets\pki\public-ca\ca.crt').Path
$replicas = @(& docker compose --env-file $EnvFile ps -q api)
if($replicas.Count -lt $MinimumInstances){
throw "At least $MinimumInstances running API replicas are required"
}
# Check storage/logs before the DoS phase consumes the source budget.
& $Python 'tests/credential_storage.py' --base-url $BaseUrl --ca-file $ca --env-file $EnvFile
if($LASTEXITCODE -ne 0){ throw 'Credential storage/log check failed' }
if($IncludeArgon2){
& "$PSScriptRoot\benchmark-argon2.ps1"
if($LASTEXITCODE -ne 0){ throw 'Argon2id benchmark failed' }
}
$testArguments = @(
'tests/login_dos.py',
'--base-url', $BaseUrl,
'--ca-file', $ca,
'--minimum-instances', "$MinimumInstances"
)
if($SourceBudget){ $testArguments += '--source-budget' }
& $Python @testArguments
if($LASTEXITCODE -ne 0){ throw 'Login DoS budget test failed' }
Write-Host 'PASS: shared login budget, fast rate-limit rejection and credential non-disclosure verified.'