-
Notifications
You must be signed in to change notification settings - Fork 0
Improve NPM issues implementation #539
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ VULN_URL="${VULN_URL}" | |
| VULN_DEP_NAME="${VULN_DEP_NAME}" | ||
| VULN_DEP_VERSION="${VULN_DEP_VERSION}" | ||
| VULN_SOURCE="${VULN_SOURCE}" | ||
| VULN_TITLE="${VULN_TITLE:-}" | ||
| VULN_MAIN_DEP_NAME="${VULN_MAIN_DEP_NAME:-}" | ||
| VULN_MAIN_DEP_PATH="${VULN_MAIN_DEP_PATH:-}" | ||
| NODEJS_STREAM="${NODEJS_STREAM}" | ||
|
|
@@ -35,6 +36,12 @@ ISSUE_BODY="A new vulnerability for ${VULN_DEP_NAME} ${VULN_DEP_VERSION} was fou | |
| Vulnerability ID: ${VULN_ID} | ||
| Vulnerability URL: ${VULN_URL}" | ||
|
|
||
| # Add vulnerability title if available | ||
| if [ -n "${VULN_TITLE}" ]; then | ||
| ISSUE_BODY="${ISSUE_BODY} | ||
| Vulnerability Title: ${VULN_TITLE}" | ||
| fi | ||
|
Comment on lines
+39
to
+43
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. 🛠️ Refactor suggestion Guard against the literal "null" value making it into the issue body. When matrix.vulnerabilities.title is missing, GitHub can pass the string "null". The current check would add “Vulnerability Title: null” to issues. Apply this diff: -if [ -n "${VULN_TITLE}" ]; then
+if [ -n "${VULN_TITLE}" ] && [ "${VULN_TITLE}" != "null" ]; then
ISSUE_BODY="${ISSUE_BODY}
Vulnerability Title: ${VULN_TITLE}"
fi🤖 Prompt for AI Agents |
||
|
|
||
| # Add npm-specific info if applicable | ||
| if [ "${VULN_SOURCE}" = "npm" ] && [ -n "${VULN_MAIN_DEP_NAME}" ]; then | ||
| ISSUE_BODY="${ISSUE_BODY} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,11 @@ def generate_labels_for_vulnerability(vuln: Dict[str, Any], nsolid_stream: str) | |||||||||||||
| if vuln.get("source") == "npm": | ||||||||||||||
| labels.append("NPM") | ||||||||||||||
|
|
||||||||||||||
| # Add main dependency name as label if present | ||||||||||||||
| main_dep_name = vuln.get("main_dep_name") | ||||||||||||||
| if main_dep_name and main_dep_name != "null": | ||||||||||||||
| labels.append(main_dep_name) | ||||||||||||||
|
|
||||||||||||||
| # Add severity label if available | ||||||||||||||
| severity = vuln.get("severity") | ||||||||||||||
| if severity and severity != "null": | ||||||||||||||
|
|
@@ -70,6 +75,9 @@ def build_vulnerability_matrix(vulnerabilities_data: Dict[str, Any], nsolid_stre | |||||||||||||
| matrix_entry["severity"] = vuln["severity"] | ||||||||||||||
| if "via" in vuln and vuln["via"]: | ||||||||||||||
| matrix_entry["via"] = vuln["via"] | ||||||||||||||
| # Extract title from via array for display purposes | ||||||||||||||
| if isinstance(vuln["via"], list) and vuln["via"]: | ||||||||||||||
| matrix_entry["title"] = vuln["via"][0] if vuln["via"][0] else "" | ||||||||||||||
|
Comment on lines
+78
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. 🛠️ Refactor suggestion Ensure title is a string; avoid non-string/JSON objects leaking to workflow env. If via elements are dicts in some legacy/edge cases, this could set a non-string object to "title", which may propagate poorly through GitHub Actions env interpolation. Coerce to str. Apply this diff: - if isinstance(vuln["via"], list) and vuln["via"]:
- matrix_entry["title"] = vuln["via"][0] if vuln["via"][0] else ""
+ if isinstance(vuln["via"], list) and vuln["via"]:
+ matrix_entry["title"] = str(vuln["via"][0]) if vuln["via"][0] else ""Optional: If you want to always provide a defined string (to avoid “null” in YAML/env), initialize title to "" in matrix_entry and then override when available. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
| if "main_dep_name" in vuln and vuln["main_dep_name"] is not None: | ||||||||||||||
| matrix_entry["main_dep_name"] = vuln["main_dep_name"] | ||||||||||||||
| if "main_dep_path" in vuln and vuln["main_dep_path"] is not None: | ||||||||||||||
|
|
||||||||||||||
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.
🛠️ Refactor suggestion
Coalesce null/undefined titles to empty string at the source.
This prevents the string "null" from being passed to the shell script and simplifies downstream checks.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents