| 
 | 1 | +# RADAR Label Workflow - Setup Instructions  | 
 | 2 | + | 
 | 3 | +## ✅ Completed Changes  | 
 | 4 | + | 
 | 5 | +### 1. Code Updates (Committed & Deployed)  | 
 | 6 | +- **GitHubClient.py**: Added `add_label()` method for consistent label management  | 
 | 7 | +- **CveSpecFilePRCheck.py**: Pipeline now adds `radar-issues-detected` label when posting PR check comments  | 
 | 8 | +- **function_app.py**: Azure Function now uses `GITHUB_TOKEN` (bot PAT) and adds `radar-acknowledged` label  | 
 | 9 | + | 
 | 10 | +### 2. Authentication Pattern  | 
 | 11 | +Following the same pattern as `GitHubClient`:  | 
 | 12 | +```python  | 
 | 13 | +# Both pipeline and Azure Function use GITHUB_TOKEN  | 
 | 14 | +GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN", "")  | 
 | 15 | + | 
 | 16 | +# Use 'token' format for GitHub PATs (not 'Bearer')  | 
 | 17 | +headers = {  | 
 | 18 | +    "Authorization": f"token {GITHUB_TOKEN}",  | 
 | 19 | +    "Accept": "application/vnd.github.v3+json"  | 
 | 20 | +}  | 
 | 21 | +```  | 
 | 22 | + | 
 | 23 | +### 3. Deployment Status  | 
 | 24 | +- ✅ Azure Function deployed successfully (radarfunc-labels.zip)  | 
 | 25 | +- ✅ Code committed to `abadawi/multi-spec-radar` branch  | 
 | 26 | +- ⏸️ Pending: Configure `GITHUB_TOKEN` environment variable  | 
 | 27 | + | 
 | 28 | +---  | 
 | 29 | + | 
 | 30 | +## 🔧 Required Configuration  | 
 | 31 | + | 
 | 32 | +### Step 1: Add GITHUB_TOKEN to Azure Function  | 
 | 33 | + | 
 | 34 | +The Azure Function needs the same bot PAT that the pipeline uses (`githubPrPat`).  | 
 | 35 | + | 
 | 36 | +**Option A: If you know the PAT value:**  | 
 | 37 | +```bash  | 
 | 38 | +az functionapp config appsettings set \  | 
 | 39 | +  --name radarfunc \  | 
 | 40 | +  --resource-group Radar-Storage-RG \  | 
 | 41 | +  --settings "GITHUB_TOKEN=<your_github_pat_here>"  | 
 | 42 | +```  | 
 | 43 | + | 
 | 44 | +**Option B: Retrieve from Azure DevOps Key Vault:**  | 
 | 45 | +The pipeline gets this from `$(githubPrPat)` variable. You may need to:  | 
 | 46 | +1. Check Azure DevOps variable groups for the PAT value  | 
 | 47 | +2. Or regenerate a new PAT from the CBL Mariner bot GitHub account  | 
 | 48 | + | 
 | 49 | +### Step 2: Create GitHub Labels  | 
 | 50 | + | 
 | 51 | +Create these 2 labels in the `microsoft/azurelinux` repository:  | 
 | 52 | + | 
 | 53 | +**Label 1: radar-issues-detected**  | 
 | 54 | +- Name: `radar-issues-detected`  | 
 | 55 | +- Description: `RADAR detected potential issues in this PR`  | 
 | 56 | +- Color: `#D73A4A` (red)  | 
 | 57 | + | 
 | 58 | +**Label 2: radar-acknowledged**  | 
 | 59 | +- Name: `radar-acknowledged`  | 
 | 60 | +- Description: `Feedback submitted for RADAR findings`  | 
 | 61 | +- Color: `#0E8A16` (green)  | 
 | 62 | + | 
 | 63 | +**How to create labels:**  | 
 | 64 | +1. Go to https://github.com/microsoft/azurelinux/labels  | 
 | 65 | +2. Click "New label"  | 
 | 66 | +3. Enter name, description, and color  | 
 | 67 | +4. Click "Create label"  | 
 | 68 | +5. Repeat for the second label  | 
 | 69 | + | 
 | 70 | +---  | 
 | 71 | + | 
 | 72 | +## 📋 Complete Workflow  | 
 | 73 | + | 
 | 74 | +### When Pipeline Detects Issues:  | 
 | 75 | +1. ✅ Pipeline runs CVE spec file check  | 
 | 76 | +2. ✅ If issues found (severity >= WARNING):  | 
 | 77 | +   - Posts comment to PR with findings  | 
 | 78 | +   - **Adds `radar-issues-detected` label**  | 
 | 79 | +3. ✅ Comment includes link to interactive HTML report (blob storage)  | 
 | 80 | + | 
 | 81 | +### When User Submits Challenge:  | 
 | 82 | +1. ✅ User opens HTML report, clicks "Challenge" button  | 
 | 83 | +2. ✅ User authenticates with GitHub OAuth  | 
 | 84 | +3. ✅ User fills out challenge form (False Alarm/Needs Context/Acknowledged)  | 
 | 85 | +4. ✅ Azure Function receives challenge:  | 
 | 86 | +   - Saves to analytics.json in blob storage  | 
 | 87 | +   - Posts comment to PR (using bot account with user attribution)  | 
 | 88 | +   - **Adds `radar-acknowledged` label**  | 
 | 89 | + | 
 | 90 | +### Label Benefits:  | 
 | 91 | +- **Filtering**: Easily find PRs with RADAR issues or feedback  | 
 | 92 | +- **Dashboards**: Track how many PRs have issues vs. acknowledged  | 
 | 93 | +- **Automation**: Could trigger additional workflows based on labels  | 
 | 94 | +- **Visibility**: Labels appear prominently in PR list and on the PR page  | 
 | 95 | + | 
 | 96 | +---  | 
 | 97 | + | 
 | 98 | +## 🧪 Testing Plan  | 
 | 99 | + | 
 | 100 | +### Test 1: Pipeline Label Addition  | 
 | 101 | +1. Push changes to `test/basic-antipatterns` branch  | 
 | 102 | +2. Pipeline should run and detect issues  | 
 | 103 | +3. Verify PR #14904 has:  | 
 | 104 | +   - Comment posted by CBL Mariner bot  | 
 | 105 | +   - `radar-issues-detected` label added  | 
 | 106 | + | 
 | 107 | +### Test 2: Challenge Label Addition  | 
 | 108 | +1. Open latest HTML report from blob storage  | 
 | 109 | +2. Submit a challenge for any finding  | 
 | 110 | +3. Verify PR #14904 has:  | 
 | 111 | +   - New comment posted by CBL Mariner bot (showing user attribution)  | 
 | 112 | +   - `radar-acknowledged` label added  | 
 | 113 | + | 
 | 114 | +### Test 3: End-to-End Workflow  | 
 | 115 | +1. Create fresh test PR with spec file changes  | 
 | 116 | +2. Pipeline runs → comment + `radar-issues-detected` label  | 
 | 117 | +3. Submit challenge → comment + `radar-acknowledged` label  | 
 | 118 | +4. Both labels visible on PR  | 
 | 119 | + | 
 | 120 | +---  | 
 | 121 | + | 
 | 122 | +## 📝 Next Steps  | 
 | 123 | + | 
 | 124 | +### Immediate (Required):  | 
 | 125 | +1. **Add GITHUB_TOKEN to Azure Function** (see Step 1 above)  | 
 | 126 | +2. **Create the 2 labels** in GitHub repository (see Step 2 above)  | 
 | 127 | +3. **Test the workflow** on PR #14904  | 
 | 128 | + | 
 | 129 | +### Future Enhancements:  | 
 | 130 | +- Add PR metadata to HTML reports (title, author, branches)  | 
 | 131 | +- Create dashboard to track challenge statistics  | 
 | 132 | +- Add webhook to notify team when challenges submitted  | 
 | 133 | +- Implement auto-close for PRs with all findings acknowledged  | 
 | 134 | + | 
 | 135 | +---  | 
 | 136 | + | 
 | 137 | +## 🔍 Troubleshooting  | 
 | 138 | + | 
 | 139 | +### If labels not added:  | 
 | 140 | +- Check function logs: `az functionapp logs tail --name radarfunc --resource-group Radar-Storage-RG`  | 
 | 141 | +- Verify `GITHUB_TOKEN` is configured: `az functionapp config appsettings list --name radarfunc --resource-group Radar-Storage-RG`  | 
 | 142 | +- Ensure labels exist in GitHub repository  | 
 | 143 | +- Check that bot PAT has `repo` scope permissions  | 
 | 144 | + | 
 | 145 | +### If comments not posted:  | 
 | 146 | +- Verify `GITHUB_TOKEN` has correct permissions  | 
 | 147 | +- Check bot account has write access to repository  | 
 | 148 | +- Review function logs for detailed error messages  | 
 | 149 | + | 
 | 150 | +---  | 
 | 151 | + | 
 | 152 | +## 📚 Files Changed  | 
 | 153 | + | 
 | 154 | +- `.pipelines/prchecks/CveSpecFilePRCheck/GitHubClient.py`  | 
 | 155 | +- `.pipelines/prchecks/CveSpecFilePRCheck/CveSpecFilePRCheck.py`  | 
 | 156 | +- `.pipelines/prchecks/CveSpecFilePRCheck/azure-function/function_app.py`  | 
 | 157 | + | 
 | 158 | +**Commit**: `d5ad71165` on `abadawi/multi-spec-radar` branch  | 
 | 159 | +**Deployment**: Successfully deployed to `radarfunc` Azure Function  | 
0 commit comments