|
| 1 | +# Handling Pull Requests from Forked Repositories |
| 2 | + |
| 3 | +This guide outlines the process for reviewing and testing PRs from forked repositories, which require special handling due to security restrictions. |
| 4 | + |
| 5 | +## Security Considerations |
| 6 | + |
| 7 | +⚠️ **CRITICAL: Security Review Required** |
| 8 | + |
| 9 | +Before approving any workflows for forked PRs, carefully review the code changes for: |
| 10 | + |
| 11 | +- **Secret exposure attempts**: Code that tries to print, log, or transmit environment variables, secrets, or credentials |
| 12 | +- **Malicious network requests**: Unauthorized API calls or data exfiltration attempts |
| 13 | +- **File system access**: Attempts to read sensitive files or configuration |
| 14 | +- **Process execution**: Suspicious shell commands or script execution |
| 15 | +- **Dependency injection**: New dependencies that could contain malicious code |
| 16 | + |
| 17 | +**Never approve workflows without thorough code review first.** |
| 18 | + |
| 19 | +## Review Process |
| 20 | + |
| 21 | +### 1. Code Security Review |
| 22 | + |
| 23 | +1. Carefully examine all changed files |
| 24 | +2. Look for any attempts to access `process.env`, `secrets.*`, or `vars.*` |
| 25 | +3. Check for suspicious network requests or file operations |
| 26 | +4. Verify new dependencies are legitimate and necessary |
| 27 | +5. Ensure no code attempts to expose or steal secrets |
| 28 | + |
| 29 | +### 2. Approve Unit Tests |
| 30 | + |
| 31 | +Once security review is complete: |
| 32 | + |
| 33 | +1. Go to the PR's "Checks" tab |
| 34 | +2. Click "Approve and run" for unit tests only |
| 35 | +3. Wait for unit tests to pass before proceeding |
| 36 | + |
| 37 | +### 3. Run Integration Tests Locally |
| 38 | + |
| 39 | +Since integration tests are automatically skipped for forked PRs (they require AWS secrets), you must run them locally. |
| 40 | + |
| 41 | +#### Prerequisites |
| 42 | + |
| 43 | +```bash |
| 44 | +# Install dependencies |
| 45 | +npm ci |
| 46 | + |
| 47 | +# Build the project |
| 48 | +npm run build |
| 49 | +``` |
| 50 | + |
| 51 | +#### AWS Setup |
| 52 | + |
| 53 | +Configure AWS credentials with permissions for: |
| 54 | + |
| 55 | +- Lambda functions (create, invoke, delete) |
| 56 | +- CloudWatch Logs (create, delete log groups) |
| 57 | +- IAM role for Lambda execution |
| 58 | + |
| 59 | +```bash |
| 60 | +# Option 1: AWS CLI |
| 61 | +aws configure |
| 62 | + |
| 63 | +# Option 2: Environment variables |
| 64 | +export AWS_ACCESS_KEY_ID=your_key |
| 65 | +export AWS_SECRET_ACCESS_KEY=your_secret |
| 66 | +export AWS_REGION=us-east-1 |
| 67 | +``` |
| 68 | + |
| 69 | +#### Pull and Test the PR |
| 70 | + |
| 71 | +```bash |
| 72 | +# Fetch the PR branch |
| 73 | +git fetch origin pull/PR_NUMBER/head:pr-branch-name |
| 74 | +git checkout pr-branch-name |
| 75 | + |
| 76 | +# Rebuild with PR changes |
| 77 | +npm run build |
| 78 | + |
| 79 | +# Run integration tests |
| 80 | +node .github/workflows/scripts/integration-test/integration-test.js --runtime 22.x |
| 81 | + |
| 82 | +# Or run step by step: |
| 83 | +# 1. Deploy functions |
| 84 | +node .github/workflows/scripts/integration-test/integration-test.js --deploy-only --runtime 22.x |
| 85 | + |
| 86 | +# 2. Run tests |
| 87 | +node .github/workflows/scripts/integration-test/integration-test.js --test-only --runtime 22.x |
| 88 | + |
| 89 | +# 3. Cleanup (important!) |
| 90 | +node .github/workflows/scripts/integration-test/integration-test.js --cleanup-only --runtime 22.x |
| 91 | +``` |
| 92 | + |
| 93 | +#### Alternative: Examples Package Tests |
| 94 | + |
| 95 | +```bash |
| 96 | +cd packages/aws-durable-execution-sdk-js-examples |
| 97 | +npm run test:integration |
| 98 | +``` |
| 99 | + |
| 100 | +### 4. Approval Decision |
| 101 | + |
| 102 | +Only approve the PR if: |
| 103 | + |
| 104 | +- ✅ Security review passed (no malicious code) |
| 105 | +- ✅ Unit tests passed |
| 106 | +- ✅ Integration tests passed locally |
| 107 | +- ✅ Code quality meets project standards |
| 108 | + |
| 109 | +## Why This Process Exists |
| 110 | + |
| 111 | +GitHub Actions automatically restricts access to repository secrets for PRs from forked repositories. This prevents: |
| 112 | + |
| 113 | +- Malicious actors from accessing AWS credentials |
| 114 | +- Accidental exposure of sensitive information |
| 115 | +- Unauthorized resource usage |
| 116 | + |
| 117 | +Our CI automatically skips integration tests for forked PRs using this condition: |
| 118 | + |
| 119 | +```yaml |
| 120 | +if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' |
| 121 | +``` |
0 commit comments