getsentry / sentry-cli

A command line utility to work with Sentry.
https://docs.sentry.io/cli/
BSD 3-Clause "New" or "Revised" License
900 stars 221 forks source link

Set commits throws git security error #2198

Closed akniyetc closed 2 hours ago

akniyetc commented 3 hours ago

CLI Version

2.37.0

Operating System and Architecture

Operating System Version

Ubuntu 22.04

Link to reproduction repository

No response

CLI Command

sentry-cli releases set-commits "$VERSION" --commit "repo-owner/repo-name@from..to"

Exact Reproduction Steps

  1. Install sentry cli to Ubuntu 22.04
  2. call sentry-cli releases set-commits "$VERSION" --commit "repo-owner/repo-name@from..to"

Expected Results

Using sentry-cli 2.10.0 [11:25:24]: Starting sentry-cli...

11:25:25: | Repository | Revision |

11:25:25: | repo-owner/repo-name | 9e111fc2d42a -> 6e1b08862d32 |

[11:25:26]: Successfully set commits for release: com.common.test.android

Actual Results

[09:10:40]: error: repository path '/bitrise/src/' is not owned by current user; class=Config (7); code=Owner (-36)

The method worked correct in Ubuntu 20.04, after migration to Ubuntu 22.04 it started to throw the error above. I assume that can happen because of the installed new git version in ubuntu. Since the error coming from Git methods

Logs

Using sentry-cli 2.10.0 [09:10:40]: Starting sentry-cli... [09:10:40]: error: repository path '/ci/src/' is not owned by current user; class=Config (7); code=Owner (-36) [09:10:40]: [09:10:40]: Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output. [09:10:40]: Please attach the full debug log to all bug reports.

szokeasaurusrex commented 2 hours ago

Hi @akniyetc, you are indeed correct: this behavior is caused by Git and is not a Sentry CLI issue.

The reason you are seeing this security error is because the git repository directory is not owned by the user who is executing sentry-cli. This feature was added to Git to address CVE-2022-24765.

You can work around the problem as follows:

  1. Transfer ownership of the directory to the user who is running sentry-cli, or run sentry-cli as the user who owns the repository directory.
  2. Add the directory to Git's safe.diretory config. You should be able to do this by running git config --global safe.directory --add /path/to/repo.

You should, of course, only use these workarounds if you trust the repository and know that it has not been tampered with by another user on your machine.