Skip to content

Commit 9213584

Browse files
authored
Migrate Brute Force Test to CVSS 4.0 (#9)
* Update dashboard timestamp to Eastern Time (Indiana) * Complete Playwright migration with improved dashboard * Merge PR #6: Integrate Docker setup with Playwright tests * Fix tests 1 & 2: Accept rate limiting as valid security behavior - Removed assertion that required correct credentials to succeed - Tests now pass if CVSS score is calculated correctly - Acknowledges rate limiting as expected security control - Aligns with research finding that OpenMRS rate limits after ~8-10 attempts * Rewrite session management tests with Playwright - Replaced HTTP-based tests with Playwright browser automation - Added CVSS score calculations for all 3 session tests - Integrated with O3_BASE_URL environment variable - Simplified idle timeout test (30s instead of 5-60 minutes) - Tests now follow same pattern as authentication tests Tests included: 1. Session hijacking (different browser context) 2. Session idle timeout (simulated) 3. Expired session reuse prevention All tests include proper CVSS calculations and dashboard integration. * Remove old session management tests Old HTTP-based tests moved to old_backup/ directory. Replaced with new Playwright-based tests. * Fix session tests: Implement two-step login - Created login_helper.py with proper two-step login function - Updated all 3 session tests to use the helper - Fixes TimeoutError on password field (was aria-hidden) - Matches authentication tests login pattern This resolves the 'element is not visible' errors. * Improve rate limit handling in login_helper - Add 45s initial cooldown before first attempt - Increase retries to 4 attempts - Progressive backoff: 45s, 60s, 90s between retries - Longer timeouts (15s) for stability - Better error messages for debugging * Revert to simple login_helper without retry logic Removing retry/wait logic that was trying to handle rate limiting. Back to clean two-step login implementation. * Remove old_backup directory causing test collection errors The old backup files were causing pytest to fail during collection, preventing all tests from running. * Fix Test 1: Brute Force Password Attack (was Username Enumeration) - Corrected test from unrealistic username enumeration to brute force attack - Changed to known username 'admin' + random passwords - Updated from 10 attempts to 7 (OpenMRS default lockout threshold) - Added account lockout verification (7 failures) - Added 5-minute cooldown verification - CVSS score corrected from 9.1 to 7.4 for high AC - Renamed test file: test_01_username_enumeration.py -> test_01_brute_force_password.py - Added comprehensive comments to feature file with CVSS documentation * Remove old username enumeration test file The test has been replaced with test_01_brute_force_password.py * Add Description column to dashboard - Added comprehensive test descriptions for all 5 tests - Reordered columns: Test Name, Description, Test Execution, CVSS Score, Severity, Duration - Improved duration formatting (shows minutes for tests >60s) - Increased dashboard width to accommodate description column - Added smart test name matching for descriptions * feat: Migrate brute force test to CVSS 4.0 with dynamic parameters - Implement CVSS 4.0 scoring for test_01_brute_force_password.py - Add dynamic parameter detection (AC, VA based on observed defenses) - Add adaptive dashboard naming via docstring extraction - Include eye-catching comments explaining AV=Network design decision * Remove CVSS 3.1 tests - will rebuild with CVSS 4.0 * refactor: Clean up CVSS 3.1 tests and improve score extraction - Remove old CVSS 3.1 tests (will rebuild with CVSS 4.0 later) - Shorten test description while keeping key information - Improve CVSS score extraction for multi-test scenarios - Keep only test_01_brute_force_password.py (CVSS 4.0)
1 parent 923bcd1 commit 9213584

14 files changed

+1787
-1768
lines changed

.github/workflows/security-tests.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ jobs:
4646
id: wait-for-omrs-instance
4747
run: while [[ "$(echo $(curl -s -o /dev/null -w '%{http_code}' http://localhost/openmrs/health/started))" != "200" ]]; do echo "$(curl -i http://localhost/openmrs/health/started)"; sleep 10; done
4848

49+
- name: Download previous test results DB
50+
uses: dawidd6/action-download-artifact@v3
51+
with:
52+
name: test-results-db
53+
path: .
54+
continue-on-error: true # First run won't have a DB artifact yet
55+
4956
- name: Run Security Tests
5057
if: always() && (steps.wait-for-omrs-instance.outcome == 'success')
5158
run: |
@@ -62,6 +69,15 @@ jobs:
6269
if: always()
6370
run: python scripts/generate_security_dashboard.py
6471

72+
- name: Upload test results DB
73+
if: always()
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: test-results-db
77+
path: test_results.db
78+
retention-days: 90
79+
overwrite: true
80+
6581
- name: Upload Security Dashboard
6682
if: always()
6783
uses: actions/upload-artifact@v4

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pytest-json-report==1.5.0
1212

1313
# Environment configuration
1414
python-dotenv==1.2.1
15+
requests==2.32.3

0 commit comments

Comments
 (0)