-
Notifications
You must be signed in to change notification settings - Fork 27
feat: create separate PRs per branch for downstream repos in cve.fix #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
96c3e63
340b108
177e6d0
841df52
60d6f70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,8 @@ Report: artifacts/cve-fixer/find/cve-issues-20260226-145018.md | |
| 1. **Parse Arguments and Flags** | ||
| - Parse the command arguments for the component name, optional subcomponent, and optional flags | ||
| - **Supported flags:** | ||
| - `--ignore-resolved` — Exclude issues with Jira status "Resolved" from results | ||
| - `--ignore-resolved` — Exclude issues with status "Resolved" from results | ||
| - `--ignore-vex` — Exclude issues already closed as "Not a Bug" with a VEX justification | ||
| - The component name is the first argument that is not a flag | ||
| - The subcomponent is the second positional argument that is not a flag (optional) | ||
| - If component is not provided, ask the user to type the component name | ||
|
|
@@ -51,59 +52,40 @@ Report: artifacts/cve-fixer/find/cve-issues-20260226-145018.md | |
| /cve.find "AI Evaluations" trustyai-ragas | ||
| ``` | ||
|
|
||
| 2. **Check JIRA API Token (REQUIRED - User Setup)** | ||
| - **This is the ONLY thing the user must configure manually before proceeding** | ||
| 2. **Verify Jira Access** | ||
|
|
||
| - Check if JIRA_API_TOKEN and JIRA_EMAIL are set: | ||
| ```bash | ||
| if [ -z "$JIRA_API_TOKEN" ]; then | ||
| echo "ERROR: JIRA_API_TOKEN is not set" | ||
| else | ||
| echo "JIRA_API_TOKEN is set" | ||
| fi | ||
| if [ -z "$JIRA_EMAIL" ]; then | ||
| echo "ERROR: JIRA_EMAIL is not set" | ||
| else | ||
| echo "JIRA_EMAIL is set" | ||
| fi | ||
| ``` | ||
|
|
||
| - **If JIRA_API_TOKEN or JIRA_EMAIL is NOT set or empty**: | ||
| - **STOP here and inform the user they need to set up both variables first** | ||
| - Provide instructions: | ||
|
|
||
| **Step 1: Generate a Jira API Token** | ||
| - Go to https://id.atlassian.com/manage-profile/security/api-tokens | ||
| - Click "Create API token" | ||
| - Give it a name and copy the token | ||
|
|
||
| **Step 2: Export both environment variables** | ||
| ```bash | ||
| export JIRA_API_TOKEN="your-token-here" | ||
| export JIRA_EMAIL="your-email@redhat.com" | ||
| ``` | ||
| To make it persistent, add to `~/.bashrc` or `~/.zshrc`: | ||
| ```bash | ||
| echo 'export JIRA_API_TOKEN="your-token-here"' >> ~/.bashrc | ||
| echo 'export JIRA_EMAIL="your-email@redhat.com"' >> ~/.bashrc | ||
| source ~/.bashrc | ||
| ``` | ||
|
|
||
| - **After user sets the variables, verify they're exported correctly** using the check script above | ||
| - Should output: "JIRA_API_TOKEN is set" and "JIRA_EMAIL is set" | ||
|
|
||
| - **Only proceed to the next steps if both JIRA_API_TOKEN and JIRA_EMAIL are set** | ||
| Secrets may be injected by the Ambient session, a secrets manager, or an MCP server — do NOT rely solely on bash env var checks. Instead, attempt a lightweight test API call and let the response determine whether credentials are available. | ||
|
|
||
| ```bash | ||
| JIRA_BASE_URL="https://redhat.atlassian.net" | ||
| AUTH=$(echo -n "${JIRA_EMAIL}:${JIRA_API_TOKEN}" | base64) | ||
| TEST_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X GET \ | ||
| --connect-timeout 10 --max-time 15 \ | ||
| -H "Authorization: Basic ${AUTH}" \ | ||
| -H "Content-Type: application/json" \ | ||
| "${JIRA_BASE_URL}/rest/api/3/myself") | ||
| ``` | ||
|
|
||
| - **HTTP 200** → credentials valid, proceed | ||
| - **HTTP 401** → credentials missing or invalid. Only now inform the user: | ||
| - Check if `JIRA_API_TOKEN` and `JIRA_EMAIL` are configured as Ambient session secrets | ||
| - If not, generate a token at https://id.atlassian.com/manage-profile/security/api-tokens and export: | ||
| ```bash | ||
| export JIRA_API_TOKEN="your-token-here" | ||
| export JIRA_EMAIL="your-email@redhat.com" | ||
| ``` | ||
| - **HTTP 403** → token valid but insufficient permissions — inform user | ||
| - **Other / timeout** → network issue — inform user and retry once | ||
|
Comment on lines
+59
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement retry logic for timeout handling. Line 77 documents that timeout/network errors should "retry once," but the test API call in lines 58-66 lacks retry flags. This creates a documentation-implementation gap. 🔄 Proposed fix to add retry logic TEST_RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X GET \
--connect-timeout 10 --max-time 15 \
+ --retry 1 \
+ --retry-delay 2 \
+ --retry-connrefused \
-H "Authorization: Basic ${AUTH}" \
-H "Content-Type: application/json" \
"${JIRA_BASE_URL}/rest/api/3/myself")🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 72-72: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) [warning] 75-75: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) 🤖 Prompt for AI Agents |
||
|
|
||
| **Do NOT pre-check env vars with `[ -z "$JIRA_API_TOKEN" ]` and stop.** The variables may be available to the API call even if not visible to the shell check (e.g. Ambient secrets injection). | ||
|
Comment on lines
+59
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: The recommended Jira REST API v3 endpoint for testing authentication credentials is GET /rest/api/3/myself. This endpoint returns details for the current authenticated user and requires only "Permission to access Jira". HTTP status codes: - Valid credentials: 200 OK - Invalid credentials: 401 Unauthorized - Insufficient permissions: This endpoint has minimal permissions required (access Jira), so insufficient permissions would also return 401 Unauthorized if the user lacks basic access. Alternative endpoint for permission checks: GET /rest/api/3/mypermissions, which returns the user's permissions and can be used to verify more granular access. It returns 200 OK for valid authenticated users. Note: There is no dedicated "health check" or ping endpoint solely for auth testing in official docs; /myself is commonly used as it confirms successful authentication and basic access. Citations:
Reconsider the HTTP 403 status code— The endpoint is correct for credentials validation. However, the Consolidate error handling to treat 401 responses uniformly, or verify that a different endpoint is intended for the 403 case. 🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 72-72: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) [warning] 75-75: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) 🤖 Prompt for AI Agents |
||
|
|
||
| 3. **Query Jira for CVE Issues** | ||
|
|
||
| a. Set up variables: | ||
| a. Set up variables (AUTH already set from Step 2): | ||
| ```bash | ||
| COMPONENT_NAME="[from step 1]" | ||
| JIRA_BASE_URL="https://redhat.atlassian.net" | ||
| JIRA_EMAIL="${JIRA_EMAIL}" | ||
| JIRA_API_TOKEN="${JIRA_API_TOKEN}" | ||
| # Jira Cloud uses Basic Auth: base64(email:api-token) | ||
| AUTH=$(echo -n "${JIRA_EMAIL}:${JIRA_API_TOKEN}" | base64) | ||
| # AUTH already constructed in Step 2 — reuse it | ||
|
Comment on lines
+84
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Add blank line before fenced code block for markdown compliance. Markdownlint reports a missing blank line before the code block at line 84 per MD031. 📝 Proposed formatting fix 3. **Query Jira for CVE Issues**
a. Set up variables (AUTH already set from Step 2):
+
```bash
COMPONENT_NAME="[from step 1]"
JIRA_BASE_URL="https://redhat.atlassian.net"🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 84-84: Fenced code blocks should be surrounded by blank lines (MD031, blanks-around-fences) 🤖 Prompt for AI Agents |
||
| ``` | ||
|
|
||
| b. Construct JQL query and execute API call: | ||
|
|
@@ -156,6 +138,12 @@ Report: artifacts/cve-fixer/find/cve-issues-20260226-145018.md | |
| JQL="${JQL} AND status not in (\"Resolved\")" | ||
| fi | ||
|
|
||
| # Append VEX filter if --ignore-vex flag was provided | ||
| # Excludes issues closed as "Not a Bug" (VEX justified) or "Obsolete" or "Won't Fix" | ||
| if [ "$IGNORE_VEX" = "true" ]; then | ||
| JQL="${JQL} AND NOT (status = \"Closed\" AND resolution in (\"Not a Bug\", \"Obsolete\", \"Won't Fix\"))" | ||
| fi | ||
|
|
||
| # URL-encode the JQL query for the GET request | ||
| ENCODED_JQL=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''${JQL}'''))") | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Add blank lines around fenced code blocks for markdown compliance.
Markdownlint reports missing blank lines around the code block per MD031. Add a blank line before line 72 and after line 75 to improve formatting consistency.
📝 Proposed formatting fix
- **HTTP 401** → credentials missing or invalid. Only now inform the user: - Check if `JIRA_API_TOKEN` and `JIRA_EMAIL` are configured as Ambient session secrets - If not, generate a token at https://id.atlassian.com/manage-profile/security/api-tokens and export: + ```bash export JIRA_API_TOKEN="your-token-here" export JIRA_EMAIL="your-email@redhat.com" ``` + - **HTTP 403** → token valid but insufficient permissions — inform user🧰 Tools
🪛 markdownlint-cli2 (0.22.0)
[warning] 72-72: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
[warning] 75-75: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
🤖 Prompt for AI Agents