Merge branch 'master' into testing-branch #30
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pre-Release Validation | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| test_intensity: | ||
| description: 'Test intensity level' | ||
| required: true | ||
| default: 'standard' | ||
| type: choice | ||
| options: | ||
| - 'quick' | ||
| - 'standard' | ||
| - 'comprehensive' | ||
| create_release: | ||
| description: 'Create release after successful tests' | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| pull_request: | ||
| branches: [ master, main ] | ||
| types: [ opened, synchronize, ready_for_review ] | ||
| jobs: | ||
| pre-release-tests: | ||
| name: Pre-Release Testing | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| version: ${{ steps.version.outputs.version }} | ||
| tests-passed: ${{ steps.tests.outputs.passed }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -e . | ||
| pip install pytest pytest-asyncio PyYAML | ||
| - name: Get version information | ||
| id: version | ||
| run: | | ||
| VERSION=$(python -c "import src.analyzeMFT; print(src.analyzeMFT.__version__)" 2>/dev/null || echo "unknown") | ||
| echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
| echo "Detected version: $VERSION" | ||
| - name: Quick validation tests | ||
| if: github.event.inputs.test_intensity == 'quick' || github.event_name == 'pull_request' | ||
| run: | | ||
| echo "[[ RUNNING QUICK VALIDATION TESTS ]]" | ||
| python analyzeMFT.py --generate-test-mft quick_test.mft --test-records 20 | ||
| python analyzeMFT.py -f quick_test.mft -o quick.csv --csv | ||
| python analyzeMFT.py -f quick_test.mft -o quick.db --sqlite | ||
| [ -s quick.csv ] && echo "[[ SUCCESS ]] CSV export working" | ||
| [ -s quick.db ] && echo "[[ SUCCESS ]] SQLite export working" | ||
| - name: Standard validation tests | ||
| if: github.event.inputs.test_intensity == 'standard' || github.event.inputs.test_intensity == '' | ||
| run: | | ||
| echo "[[ RUNNING STANDARD VALIDATION TESTS ]]" | ||
| python analyzeMFT.py --generate-test-mft std_normal.mft --test-records 100 --test-type normal | ||
| python analyzeMFT.py --generate-test-mft std_anomaly.mft --test-records 50 --test-type anomaly | ||
| python analyzeMFT.py -f std_normal.mft -o std.csv --csv -v | ||
| python analyzeMFT.py -f std_normal.mft -o std.json --json -v | ||
| python analyzeMFT.py -f std_normal.mft -o std.db --sqlite -v | ||
| python analyzeMFT.py -f std_normal.mft -o std.xml --xml -v | ||
| python analyzeMFT.py --list-profiles | ||
| python analyzeMFT.py -f std_normal.mft -o std_quick.csv --profile quick -v | ||
| python analyzeMFT.py -f std_normal.mft -o std_forensic.csv --profile forensic -v | ||
| python analyzeMFT.py --create-config test_config.json | ||
| python analyzeMFT.py -f std_normal.mft -o std_config.csv --config test_config.json -v | ||
| python analyzeMFT.py -f std_normal.mft -o std_chunk.csv --chunk-size 25 -v | ||
| python analyzeMFT.py -f std_normal.mft -o std_hash.csv --hash -v | ||
| python -c " | ||
| import csv, json, sqlite3 | ||
| with open('std.csv') as f: | ||
| rows = list(csv.reader(f)) | ||
| assert len(rows) > 1, 'CSV should have data' | ||
| print(f'[[ SUCCESS ]] CSV has {len(rows)-1} records') | ||
| with open('std.json') as f: | ||
| data = json.load(f) | ||
| assert len(data) > 0, 'JSON should have data' | ||
| print(f'[[ SUCCESS ]] JSON has {len(data)} records') | ||
| conn = sqlite3.connect('std.db') | ||
| cursor = conn.cursor() | ||
| cursor.execute('SELECT COUNT(*) FROM mft_records') | ||
| count = cursor.fetchone()[0] | ||
| assert count > 0, 'SQLite should have records' | ||
| print(f'[[ SUCCESS ]] SQLite has {count} records') | ||
| conn.close() | ||
| " | ||
| - name: Comprehensive validation tests | ||
| if: github.event.inputs.test_intensity == 'comprehensive' | ||
| run: | | ||
| echo "[[ RUNNING COMPREHENSIVE VALIDATION TESTS ]]" | ||
| python analyzeMFT.py --generate-test-mft comp_normal.mft --test-records 500 --test-type normal | ||
| python analyzeMFT.py --generate-test-mft comp_anomaly.mft --test-records 200 --test-type anomaly | ||
| for format in csv json xml sqlite body timeline tsk; do | ||
| echo "Testing $format format..." | ||
| case $format in | ||
| csv) flag="--csv" ;; | ||
| json) flag="--json" ;; | ||
| xml) flag="--xml" ;; | ||
| sqlite) flag="--sqlite" ;; | ||
| body) flag="--body" ;; | ||
| timeline) flag="--timeline" ;; | ||
| tsk) flag="--tsk" ;; | ||
| esac | ||
| python analyzeMFT.py -f comp_normal.mft -o "comp_normal.$format" $flag -v | ||
| python analyzeMFT.py -f comp_anomaly.mft -o "comp_anomaly.$format" $flag -v | ||
| done | ||
| for profile in default quick forensic performance; do | ||
| for chunk in 10 50 100; do | ||
| echo "Testing profile $profile with chunk size $chunk..." | ||
| python analyzeMFT.py -f comp_normal.mft -o "comp_${profile}_${chunk}.csv" --profile $profile --chunk-size $chunk -v | ||
| done | ||
| done | ||
| echo "Running performance test..." | ||
| python -c " | ||
| import time, subprocess, os | ||
| start = time.time() | ||
| subprocess.run(['python', 'analyzeMFT.py', '-f', 'comp_normal.mft', '-o', 'perf_test.csv', '--csv'], check=True) | ||
| duration = time.time() - start | ||
| size = os.path.getsize('comp_normal.mft') | ||
| print(f'[[ PERFORMANCE ]] Processed {size} bytes in {duration:.2f}s ({500/duration:.1f} rec/s)') | ||
| " | ||
| - name: Security and error handling tests | ||
| run: | | ||
| echo "[[ RUNNING SECURITY AND ERROR HANDLING TESTS ]]" | ||
| python analyzeMFT.py -f nonexistent.mft -o error.csv 2>&1 | grep -q "Error\|No such file" && echo "[[ SUCCESS ]] Proper error handling for missing files" | ||
| echo "Invalid MFT data" > invalid.mft | ||
| python analyzeMFT.py -f invalid.mft -o invalid.csv 2>&1 | grep -q "Error\|Invalid" && echo "[[ SUCCESS ]] Proper error handling for invalid MFT files" | ||
| touch readonly.mft | ||
| chmod 000 readonly.mft 2>/dev/null || echo "Skipping permission test on this platform" | ||
| python analyzeMFT.py -f readonly.mft -o readonly.csv 2>&1 | grep -q "Error\|Permission" && echo "[[ SUCCESS ]] Proper error handling for permission issues" || echo "[[ WARNING ]] Permission test skipped" | ||
| chmod 644 readonly.mft 2>/dev/null || true | ||
| - name: Set test results | ||
| id: tests | ||
| run: | | ||
| echo "passed=true" >> $GITHUB_OUTPUT | ||
| echo "[[ SUCCESS ]] All pre-release tests passed!" | ||
| - name: Upload test artifacts | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: pre-release-test-results | ||
| path: | | ||
| *.csv | ||
| *.json | ||
| *.xml | ||
| *.db | ||
| *.body | ||
| *.timeline | ||
| *.tsk | ||
| *.mft | ||
| test_config.json | ||
| retention-days: 3 | ||
| quality-checks: | ||
| name: Code Quality Checks | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.11' | ||
| - name: Install quality tools | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install flake8 black bandit safety mypy | ||
| pip install -e . | ||
| - name: Code formatting check | ||
| run: | | ||
| echo "[[ CHECKING CODE FORMATTING ]]" | ||
| black --check --diff . || echo "[[ WARNING ]] Code formatting issues found" | ||
| - name: Linting check | ||
| run: | | ||
| echo "[[ RUNNING LINTING CHECKS ]]" | ||
| flake8 src/ --max-line-length=127 --exclude=__pycache__ || echo "[[ WARNING ]] Linting issues found" | ||
| - name: Security scan | ||
| run: | | ||
| echo "[[ RUNNING SECURITY SCAN ]]" | ||
| bandit -r src/ -f json -o security-report.json || echo "[[ WARNING ]] Security issues found" | ||
| - name: Dependency safety check | ||
| run: | | ||
| echo "[[ CHECKING DEPENDENCY SECURITY ]]" | ||
| safety check || echo "[[ WARNING ]] Dependency security issues found" | ||
| - name: Type checking | ||
| run: | | ||
| echo "[[ RUNNING TYPE CHECKS ]]" | ||
| mypy src/ --ignore-missing-imports || echo "[[ WARNING ]] Type checking issues found" | ||
| - name: Upload quality reports | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: quality-reports | ||
| path: | | ||
| security-report.json | ||
| retention-days: 7 | ||
| create-release: | ||
| name: Create Release | ||
| runs-on: ubuntu-latest | ||
| needs: [pre-release-tests, quality-checks] | ||
| if: github.event.inputs.create_release == 'true' && needs.pre-release-tests.outputs.tests-passed == 'true' | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
| - name: Create Release | ||
| run: | | ||
| gh release create "v${{ needs.pre-release-tests.outputs.version }}" \ | ||
| --title "Release v${{ needs.pre-release-tests.outputs.version }}" \ | ||
| --notes "## analyzeMFT v${{ needs.pre-release-tests.outputs.version }} | ||
| - Automated release with comprehensive testing | ||
| - All functionality validated across multiple platforms | ||
| - [[ SUCCESS ]] All export formats working (CSV, JSON, XML, SQLite, Body, Timeline, TSK) | ||
| - [[ SUCCESS ]] All analysis profiles working (Default, Quick, Forensic, Performance) | ||
| - [[ SUCCESS ]] Configuration system working | ||
| - [[ SUCCESS ]] Chunked processing working | ||
| - [[ SUCCESS ]] Hash computation working | ||
| - [[ SUCCESS ]] Error handling working | ||
| - [[ SUCCESS ]] Cross-platform compatibility verified | ||
| \`\`\`bash | ||
| pip install analyzeMFT | ||
| \`\`\` | ||
| \`\`\`bash | ||
| python analyzeMFT.py --generate-test-mft test.mft --test-records 100 | ||
| python analyzeMFT.py -f test.mft -o output.csv --csv -v | ||
| python analyzeMFT.py -f test.mft -o output.db --sqlite -v | ||
| python analyzeMFT.py -f test.mft -o forensic.csv --profile forensic -v | ||
| \`\`\`" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| notify-success: | ||
| name: Notify Success | ||
| runs-on: ubuntu-latest | ||
| needs: [pre-release-tests, quality-checks] | ||
| if: always() && needs.pre-release-tests.outputs.tests-passed == 'true' | ||
| steps: | ||
| - name: Success notification | ||
| run: | | ||
| echo "[[ ALL TESTS PASSED ]]" | ||
| echo "[[ SUCCESS ]] All tests passed" | ||
| echo "[[ SUCCESS ]] Code quality checks completed" | ||
| echo "[[ READY FOR RELEASE ]] Ready for release!" | ||