Skip to content

Fix more vulns#4930

Merged
lukaszgryglicki merged 4 commits intodevfrom
unicron-address-codeql-and-dependabot-vulns-2
Mar 11, 2026
Merged

Fix more vulns#4930
lukaszgryglicki merged 4 commits intodevfrom
unicron-address-codeql-and-dependabot-vulns-2

Conversation

@lukaszgryglicki
Copy link
Copy Markdown
Member

Signed-off-by: Lukasz Gryglicki lgryglicki@cncf.io

Assisted by OpenAI

Assisted by GitHub Copilot

Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)
@lukaszgryglicki lukaszgryglicki self-assigned this Mar 11, 2026
Copilot AI review requested due to automatic review settings March 11, 2026 05:13
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f16761d8-34d9-4b0f-b4e7-5df4da5ff68b

📥 Commits

Reviewing files that changed from the base of the PR and between 1fbb4b1 and 0f5ce5d.

📒 Files selected for processing (1)
  • cla-backend/cla/utils.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • cla-backend/cla/utils.py

Walkthrough

Simplified and harmonized logging and error messages across GitHub auth and utility modules; tightened exception handling and minor session handling changes; added minimatch and validator to main deps; upgraded newman and expanded/converted test dependency overrides in tests REST package.

Changes

Cohort / File(s) Summary
GitHub auth models
cla-backend/cla/models/github_models.py
Simplified and reworded log messages around OAuth2/session handling, replaced some del session.pop patterns with session.pop, generalized exception logs, mapped certain OAuth2 code errors to HTTP 400, and generalized GraphQL error logging.
Utilities
cla-backend/cla/utils.py
Added concise fetch_token debug log; generalized API error warnings in GitHub/GitLab lookups; on GitLab HTTP errors return an empty list; reworked extract_pull_request_number to early-return on empty input, narrow exception handling to (ValueError, json.JSONDecodeError, AttributeError, KeyError), and log generic parse errors.
Main package dependencies
package.json
Added dependencies: minimatch ^10.0.1 and validator ^13.15.22.
Tests REST package
tests/rest/package.json
Upgraded newman to ^6.2.1; replaced resolutions with overrides; updated direct deps (ajv, tough-cookie); expanded overrides to include many packages (e.g., minimatch, brace-expansion, handlebars, json-schema, crypto-js, simple-git, marked, semver, async, sanitize-html, ansi-regex, node-forge, jose, etc.).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (1 warning, 2 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is vague and generic, using the non-descriptive term 'vulns' without specifying which vulnerabilities are being fixed or what the main changes entail. Provide a more specific title that describes the primary change, such as 'Fix security vulnerabilities in OAuth2 and dependency versions' or similar.
Description check ❓ Inconclusive The description lacks meaningful detail about the changeset—it only includes sign-off information and tool attribution without explaining what vulnerabilities were fixed or what changes were made. Add a description that explains the vulnerabilities being addressed and the key changes in the pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unicron-address-codeql-and-dependabot-vulns-2

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to address reported vulnerabilities by updating JavaScript dependencies/lockfiles and reducing sensitive detail in backend logging.

Changes:

  • Updated Node dependency versions/lockfiles (including new package-lock.json, plus yarn.lock updates).
  • Upgraded tests/rest Newman dependency set and adjusted dependency pinning configuration.
  • Reduced detail in Python backend logs around OAuth/session/API error handling.

Reviewed changes

Copilot reviewed 4 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
yarn.lock Updates resolved URLs and bumps several transitive packages (e.g., minimatch/brace-expansion/validator) for vuln remediation.
tests/rest/yarn.lock Large lockfile refresh for REST test tooling dependencies.
tests/rest/package.json Bumps newman and changes dependency pinning mechanism (now overrides).
package.json Adds direct dependencies (minimatch, validator) to address advisories.
package-lock.json Introduces an npm lockfile at repo root.
cla-backend/cla/utils.py Reduces log detail and tweaks error handling messages in utility helpers.
cla-backend/cla/models/github_models.py Reduces log detail around sessions/OAuth and adjusts some error handling/log messages.

Comment thread cla-backend/cla/models/github_models.py Outdated
Comment thread cla-backend/cla/models/github_models.py Outdated
Comment thread tests/rest/package.json
Comment thread cla-backend/cla/utils.py Outdated
Comment thread cla-backend/cla/models/github_models.py Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cla-backend/cla/models/github_models.py`:
- Around line 1591-1598: The code logs when token is None but then proceeds to
create OAuth2Session and call GitHub; change the control flow in the block that
references token and fn so that if token is None you log the warning and
immediately return an error (e.g., {"error": "Missing authentication token"})
instead of creating OAuth2Session or calling oauth2.get; update the branch that
currently reads "if token is None:" to return early to avoid unauthenticated
calls to OAuth2Session and the "/user/emails" request.
- Around line 1434-1438: The current use of del session["github_oauth2_state"]
and del session["github_oauth2_token"] can raise KeyError and mask the original
auth failure; update the code around session and fn to clear those keys
defensively by using a safe removal approach (e.g., call session.pop for
"github_oauth2_state" and "github_oauth2_token" with a default/no-op fallback or
check membership before deleting) before logging the warning and raising the
falcon.HTTPError so missing keys won’t raise additional exceptions.

In `@cla-backend/cla/utils.py`:
- Around line 2053-2055: The except Exception is too broad when extracting the
pull request number; narrow it to only the expected parse failures (e.g., except
(ValueError, IndexError) or a specific ParseError you use) around the extraction
logic and log that error via cla.log.warning(f"{fn} - error - unable to extract
pull request number from message: {e}"); for any other unexpected exceptions
re-raise them so they don't get swallowed (i.e., use a specific except for parse
errors and then a bare raise in a general except to propagate unexpected
errors).
- Around line 1745-1746: The failure branch currently returns a set literal
because of the braced f-string; change that to return a dict with an "error" key
so callers get a consistent, structured response. Replace the line returning
{f"..."} with something like return {"error": f"Could not get user gitlab group
id: {organization_id} members"}, keeping the cla.log.warning(...) call as-is;
this ensures the error branch of the function (the code around cla.log.warning
and the subsequent return) returns a mapping instead of a set.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b03fbb8b-587e-4c7d-9e4b-a219386b2a92

📥 Commits

Reviewing files that changed from the base of the PR and between 63c3355 and 5650844.

⛔ Files ignored due to path filters (4)
  • package-lock.json is excluded by !**/package-lock.json
  • tests/rest/package-lock.json is excluded by !**/package-lock.json
  • tests/rest/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • cla-backend/cla/models/github_models.py
  • cla-backend/cla/utils.py
  • package.json
  • tests/rest/package.json

Comment thread cla-backend/cla/models/github_models.py Outdated
Comment thread cla-backend/cla/models/github_models.py
Comment thread cla-backend/cla/utils.py Outdated
Comment thread cla-backend/cla/utils.py Outdated
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cla-backend/cla/models/github_models.py`:
- Around line 400-402: The current broad except Exception around the GitHub
token exchange (the block referencing fn, cla.log.warning and raising
falcon.HTTPBadRequest) incorrectly maps all failures to a 400; change it to only
catch and handle expected token-validation errors (e.g., the specific
exception(s) raised by your token-exchange routine such as ValueError or the
requests/HTTP client exception used in that path), log the warning and raise
falcon.HTTPBadRequest only for those cases, and let any other exceptions
propagate (or re-raise them) so they surface as 5xx; keep the existing log
message and falcon.HTTPBadRequest behavior for the narrowed exception types and
do not swallow unexpected exceptions.

In `@cla-backend/cla/utils.py`:
- Around line 1745-1752: The current code in the GitLab org users fetch path
logs the error and returns [] (using status_code and organization_id), which
hides API failures; instead, stop returning an empty list and propagate an
explicit error: raise a descriptive exception (e.g., GitLabAPIError or re-raise
the caught exception) that includes organization_id and status_code so callers
can distinguish a failed API call from an empty group; update the
fetch-gitlab-org-users function (the block that references status_code,
organization_id, and cla.log.warning) to raise that error after logging, and
adjust callers to handle or bubble the exception accordingly.
- Around line 2059-2061: The handler that parses pull_request_message currently
calls pull_request_message.splitlines()[0] without guarding against an empty
string, causing an unhandled IndexError; update the code around where
pull_request_message is used (look for the pull_request_message variable and the
splitlines()[0] call) to either check if pull_request_message is truthy and has
at least one line before indexing or add IndexError to the existing except tuple
(currently catching ValueError, json.JSONDecodeError, AttributeError, KeyError)
so empty messages are handled gracefully and the existing cla.log.warning path
is taken.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03c61a87-4162-4d16-b7e0-e3e4bd28390b

📥 Commits

Reviewing files that changed from the base of the PR and between 5650844 and f6a8866.

⛔ Files ignored due to path filters (1)
  • tests/rest/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (2)
  • cla-backend/cla/models/github_models.py
  • cla-backend/cla/utils.py

Comment thread cla-backend/cla/models/github_models.py
Comment thread cla-backend/cla/utils.py
Comment thread cla-backend/cla/utils.py
Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
cla-backend/cla/utils.py (1)

2068-2070: ⚠️ Potential issue | 🟡 Minor

Remove the unused exception variable and consider cleaning up exception types.

The static analysis correctly flags that e is assigned but never used. Additionally, json.JSONDecodeError and KeyError don't appear applicable since this function doesn't perform JSON parsing or dict key access.

🔧 Proposed fix
-    except (ValueError, json.JSONDecodeError, AttributeError, KeyError) as e:
+    except (ValueError, AttributeError):
         cla.log.warning(f"{fn} - error - unable to extract pull request number from message, parse error occurred")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@cla-backend/cla/utils.py` around lines 2068 - 2070, Remove the unused
exception variable and tighten the exception tuple in the except clause that
logs pull request parse failures: change the except (ValueError,
json.JSONDecodeError, AttributeError, KeyError) as e: to a bare except for the
relevant types (e.g., except (ValueError, AttributeError):) and drop the "as e"
since the variable is never used; keep the existing cla.log.warning(...) call
and fn reference unchanged to preserve the log message.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@cla-backend/cla/utils.py`:
- Around line 2068-2070: Remove the unused exception variable and tighten the
exception tuple in the except clause that logs pull request parse failures:
change the except (ValueError, json.JSONDecodeError, AttributeError, KeyError)
as e: to a bare except for the relevant types (e.g., except (ValueError,
AttributeError):) and drop the "as e" since the variable is never used; keep the
existing cla.log.warning(...) call and fn reference unchanged to preserve the
log message.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35d5f929-2309-4ac7-8e7e-4fb4fe42ed0c

📥 Commits

Reviewing files that changed from the base of the PR and between f6a8866 and 1fbb4b1.

📒 Files selected for processing (1)
  • cla-backend/cla/utils.py

Signed-off-by: Lukasz Gryglicki <lgryglicki@cncf.io>

Assisted by [OpenAI](https://platform.openai.com/)

Assisted by [GitHub Copilot](https://github.com/features/copilot)
@lukaszgryglicki lukaszgryglicki merged commit a0f277b into dev Mar 11, 2026
4 checks passed
@lukaszgryglicki lukaszgryglicki deleted the unicron-address-codeql-and-dependabot-vulns-2 branch March 11, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants