Проверка rehash, login DoS и общего rate limit
This commit is contained in:
@@ -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.'
|
||||
Reference in New Issue
Block a user