sentry-cli 2.31.0__tar.gz → 2.31.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/Cargo.lock +1 -1
  2. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/Cargo.toml +1 -1
  3. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/PKG-INFO +1 -1
  4. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/sentry_cli.egg-info/PKG-INFO +1 -1
  5. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/sentry_cli.egg-info/SOURCES.txt +7 -1
  6. sentry_cli-2.31.2/src/api/connection_manager.rs +46 -0
  7. sentry_cli-2.31.2/src/api/encoding.rs +85 -0
  8. sentry_cli-2.31.2/src/api/errors/api_error.rs +89 -0
  9. sentry_cli-2.31.2/src/api/errors/mod.rs +12 -0
  10. sentry_cli-2.31.2/src/api/errors/sentry_error.rs +36 -0
  11. sentry_cli-2.31.0/src/api.rs → sentry_cli-2.31.2/src/api/mod.rs +12 -234
  12. sentry_cli-2.31.2/src/api/pagination.rs +42 -0
  13. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/debug_files/check.rs +8 -0
  14. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/react_native/xcode.rs +9 -4
  15. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/upload_proguard.rs +3 -2
  16. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/config.rs +15 -3
  17. sentry_cli-2.31.2/src/main.rs +9 -0
  18. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/ui.rs +3 -7
  19. sentry_cli-2.31.0/src/main.rs +0 -14
  20. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/LICENSE +0 -0
  21. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/MANIFEST.in +0 -0
  22. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/README.md +0 -0
  23. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/build.rs +0 -0
  24. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/pyproject.toml +0 -0
  25. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/sentry_cli.egg-info/dependency_links.txt +0 -0
  26. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/sentry_cli.egg-info/top_level.txt +0 -0
  27. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/setup.cfg +0 -0
  28. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/setup.py +0 -0
  29. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/bashsupport.sh +0 -0
  30. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/bash_hook.rs +0 -0
  31. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/debug_files/bundle_jvm.rs +0 -0
  32. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/debug_files/bundle_sources.rs +0 -0
  33. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/debug_files/find.rs +0 -0
  34. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/debug_files/mod.rs +0 -0
  35. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/debug_files/print_sources.rs +0 -0
  36. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/debug_files/upload.rs +0 -0
  37. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/deploys/list.rs +0 -0
  38. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/deploys/mod.rs +0 -0
  39. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/deploys/new.rs +0 -0
  40. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/events/list.rs +0 -0
  41. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/events/mod.rs +0 -0
  42. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/files/delete.rs +0 -0
  43. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/files/list.rs +0 -0
  44. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/files/mod.rs +0 -0
  45. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/files/upload.rs +0 -0
  46. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/info.rs +0 -0
  47. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/issues/list.rs +0 -0
  48. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/issues/mod.rs +0 -0
  49. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/issues/mute.rs +0 -0
  50. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/issues/resolve.rs +0 -0
  51. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/issues/unresolve.rs +0 -0
  52. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/login.rs +0 -0
  53. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/mod.rs +0 -0
  54. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/monitors/list.rs +0 -0
  55. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/monitors/mod.rs +0 -0
  56. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/monitors/run.rs +0 -0
  57. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/organizations/list.rs +0 -0
  58. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/organizations/mod.rs +0 -0
  59. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/projects/list.rs +0 -0
  60. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/projects/mod.rs +0 -0
  61. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/react_native/appcenter.rs +0 -0
  62. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/react_native/gradle.rs +0 -0
  63. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/react_native/mod.rs +0 -0
  64. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/archive.rs +0 -0
  65. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/delete.rs +0 -0
  66. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/finalize.rs +0 -0
  67. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/info.rs +0 -0
  68. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/list.rs +0 -0
  69. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/mod.rs +0 -0
  70. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/new.rs +0 -0
  71. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/propose_version.rs +0 -0
  72. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/restore.rs +0 -0
  73. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/releases/set_commits.rs +0 -0
  74. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/repos/list.rs +0 -0
  75. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/repos/mod.rs +0 -0
  76. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/send_envelope.rs +0 -0
  77. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/send_event.rs +0 -0
  78. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/sourcemaps/explain.rs +0 -0
  79. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/sourcemaps/inject.rs +0 -0
  80. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/sourcemaps/mod.rs +0 -0
  81. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/sourcemaps/resolve.rs +0 -0
  82. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/sourcemaps/upload.rs +0 -0
  83. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/uninstall.rs +0 -0
  84. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/update.rs +0 -0
  85. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/upload_dif.rs +0 -0
  86. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/commands/upload_dsym.rs +0 -0
  87. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/constants.rs +0 -0
  88. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/android.rs +0 -0
  89. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/appcenter.rs +0 -0
  90. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/args.rs +0 -0
  91. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/auth_token/auth_token_impl.rs +0 -0
  92. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/auth_token/error.rs +0 -0
  93. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/auth_token/mod.rs +0 -0
  94. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/auth_token/org_auth_token.rs +0 -0
  95. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/auth_token/test.rs +0 -0
  96. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/auth_token/user_auth_token.rs +0 -0
  97. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/chunks.rs +0 -0
  98. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/cordova.rs +0 -0
  99. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/dif.rs +0 -0
  100. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/dif_upload.rs +0 -0
  101. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/event.rs +0 -0
  102. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/file_search.rs +0 -0
  103. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/file_upload.rs +0 -0
  104. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/formatting.rs +0 -0
  105. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/fs.rs +0 -0
  106. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/http.rs +0 -0
  107. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/logging.rs +0 -0
  108. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/mod.rs +0 -0
  109. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/progress.rs +0 -0
  110. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/releases.rs +0 -0
  111. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/retry.rs +0 -0
  112. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/snapshots/sentry_cli__utils__vcs__generate_patch_default_twenty.snap +0 -0
  113. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/snapshots/sentry_cli__utils__vcs__generate_patch_ignore_missing.snap +0 -0
  114. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/snapshots/sentry_cli__utils__vcs__generate_patch_set_base.snap +0 -0
  115. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/snapshots/sentry_cli__utils__vcs__generate_patch_set_previous_commit.snap +0 -0
  116. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/snapshots/sentry_cli__utils__vcs__get_commits_from_git.snap +0 -0
  117. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/sourcemaps/inject.rs +0 -0
  118. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/sourcemaps.rs +0 -0
  119. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/system.rs +0 -0
  120. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/update.rs +0 -0
  121. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/vcs.rs +0 -0
  122. {sentry_cli-2.31.0 → sentry_cli-2.31.2}/src/utils/xcode.rs +0 -0
@@ -2432,7 +2432,7 @@ dependencies = [
2432
2432
 
2433
2433
  [[package]]
2434
2434
  name = "sentry-cli"
2435
- version = "2.31.0"
2435
+ version = "2.31.2"
2436
2436
  dependencies = [
2437
2437
  "anyhow",
2438
2438
  "anylog",
@@ -2,7 +2,7 @@
2
2
  authors = ["Armin Ronacher <armin.ronacher@active-4.com>"]
3
3
  build = "build.rs"
4
4
  name = "sentry-cli"
5
- version = "2.31.0"
5
+ version = "2.31.2"
6
6
  edition = "2021"
7
7
  rust-version = "1.65"
8
8
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sentry_cli
3
- Version: 2.31.0
3
+ Version: 2.31.2
4
4
  Summary: A command line utility to work with Sentry.
5
5
  Home-page: https://github.com/getsentry/sentry-cli
6
6
  Author: Sentry
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sentry_cli
3
- Version: 2.31.0
3
+ Version: 2.31.2
4
4
  Summary: A command line utility to work with Sentry.
5
5
  Home-page: https://github.com/getsentry/sentry-cli
6
6
  Author: Sentry
@@ -11,11 +11,17 @@ sentry_cli.egg-info/PKG-INFO
11
11
  sentry_cli.egg-info/SOURCES.txt
12
12
  sentry_cli.egg-info/dependency_links.txt
13
13
  sentry_cli.egg-info/top_level.txt
14
- src/api.rs
15
14
  src/bashsupport.sh
16
15
  src/config.rs
17
16
  src/constants.rs
18
17
  src/main.rs
18
+ src/api/connection_manager.rs
19
+ src/api/encoding.rs
20
+ src/api/mod.rs
21
+ src/api/pagination.rs
22
+ src/api/errors/api_error.rs
23
+ src/api/errors/mod.rs
24
+ src/api/errors/sentry_error.rs
19
25
  src/commands/bash_hook.rs
20
26
  src/commands/info.rs
21
27
  src/commands/login.rs
@@ -0,0 +1,46 @@
1
+ use std::convert::Infallible;
2
+
3
+ pub(super) struct CurlConnectionManager;
4
+
5
+ impl r2d2::ManageConnection for CurlConnectionManager {
6
+ type Connection = curl::easy::Easy;
7
+ type Error = Infallible;
8
+
9
+ fn connect(&self) -> Result<curl::easy::Easy, Infallible> {
10
+ Ok(curl::easy::Easy::new())
11
+ }
12
+
13
+ fn is_valid(&self, _conn: &mut curl::easy::Easy) -> Result<(), Infallible> {
14
+ Ok(())
15
+ }
16
+
17
+ fn has_broken(&self, _conn: &mut curl::easy::Easy) -> bool {
18
+ false
19
+ }
20
+ }
21
+
22
+ #[cfg(test)]
23
+ mod tests {
24
+ use super::*;
25
+ use r2d2::ManageConnection;
26
+
27
+ #[test]
28
+ fn test_connect() {
29
+ let manager = CurlConnectionManager;
30
+
31
+ // Just make sure the connection can be established without panic.
32
+ manager.connect().unwrap();
33
+ }
34
+
35
+ #[test]
36
+ fn test_is_valid() {
37
+ let manager = CurlConnectionManager;
38
+ assert_eq!(manager.is_valid(&mut curl::easy::Easy::new()), Ok(()));
39
+ }
40
+
41
+ #[test]
42
+ fn test_has_broken() {
43
+ let manager = CurlConnectionManager;
44
+ assert!(!manager.has_broken(&mut curl::easy::Easy::new()));
45
+ }
46
+ }
@@ -0,0 +1,85 @@
1
+ use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
2
+ use std::fmt::{Display, Formatter, Result};
3
+
4
+ // Based on https://docs.rs/percent-encoding/1.0.1/src/percent_encoding/lib.rs.html#104
5
+ // WHATWG Spec: https://url.spec.whatwg.org/#percent-encoded-bytes
6
+ // RFC3986 Reserved Characters: https://www.rfc-editor.org/rfc/rfc3986#section-2.2
7
+ const QUERY_ENCODE_SET: AsciiSet = CONTROLS
8
+ .add(b' ')
9
+ .add(b'"')
10
+ .add(b'#')
11
+ .add(b'<')
12
+ .add(b'>')
13
+ .add(b'+');
14
+
15
+ const PATH_SEGMENT_ENCODE_SET: AsciiSet = QUERY_ENCODE_SET
16
+ .add(b'`')
17
+ .add(b'?')
18
+ .add(b'{')
19
+ .add(b'}')
20
+ .add(b'%')
21
+ .add(b'/');
22
+
23
+ /// Wrapper that escapes arguments for URL path segments.
24
+ pub(super) struct PathArg<A: Display>(pub(super) A);
25
+
26
+ /// Wrapper that escapes arguments for URL query segments.
27
+ pub(super) struct QueryArg<A: Display>(pub(super) A);
28
+
29
+ impl<A: Display> Display for PathArg<A> {
30
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
31
+ // if we put values into the path we need to url encode them. However
32
+ // special care needs to be taken for any slash character or path
33
+ // segments that would end up as ".." or "." for security reasons.
34
+ // Since we cannot handle slashes there we just replace them with the
35
+ // unicode replacement character as a quick workaround. This will
36
+ // typically result in 404s from the server.
37
+ let mut val = format!("{}", self.0).replace('/', "\u{fffd}");
38
+ if val == ".." || val == "." {
39
+ val = "\u{fffd}".into();
40
+ }
41
+ utf8_percent_encode(&val, &PATH_SEGMENT_ENCODE_SET).fmt(f)
42
+ }
43
+ }
44
+
45
+ impl<A: Display> Display for QueryArg<A> {
46
+ fn fmt(&self, f: &mut Formatter<'_>) -> Result {
47
+ utf8_percent_encode(&format!("{}", self.0), &QUERY_ENCODE_SET).fmt(f)
48
+ }
49
+ }
50
+
51
+ #[cfg(test)]
52
+ mod tests {
53
+ use rstest::rstest;
54
+
55
+ use super::*;
56
+
57
+ #[rstest]
58
+ #[case("/")]
59
+ #[case(".")]
60
+ #[case("..")]
61
+ fn test_path_arg_replacement_cases(#[case] input: &str) {
62
+ assert_eq!(
63
+ format!("{}", PathArg(input)),
64
+ format!("{}", utf8_percent_encode("\u{fffd}", CONTROLS)),
65
+ "case \"{input}\" failed"
66
+ );
67
+ }
68
+
69
+ #[rstest]
70
+ #[case(" ", "%20")]
71
+ #[case("\"", "%22")]
72
+ #[case("#", "%23")]
73
+ #[case("<", "%3C")]
74
+ #[case(">", "%3E")]
75
+ #[case("+", "%2B")]
76
+ #[case(" \"#<>+", "%20%22%23%3C%3E%2B")]
77
+ #[case("1 + 3 < 4", "1%20%2B%203%20%3C%204")]
78
+ fn test_path_arg_percent_encode(#[case] input: &str, #[case] expected: &str) {
79
+ assert_eq!(
80
+ format!("{}", PathArg(input)),
81
+ expected,
82
+ "case \"{input}\" failed"
83
+ );
84
+ }
85
+ }
@@ -0,0 +1,89 @@
1
+ use std::fmt;
2
+
3
+ #[derive(Debug, thiserror::Error)]
4
+ pub struct ApiError {
5
+ inner: ApiErrorKind,
6
+ #[source]
7
+ source: Option<anyhow::Error>,
8
+ }
9
+
10
+ /// Represents API errors.
11
+ #[derive(Copy, Clone, Eq, PartialEq, Debug, thiserror::Error)]
12
+ pub(in crate::api) enum ApiErrorKind {
13
+ #[error("could not serialize value as JSON")]
14
+ CannotSerializeAsJson,
15
+ #[error("could not parse JSON response")]
16
+ BadJson,
17
+ #[error("not a JSON response")]
18
+ NotJson,
19
+ #[error("request failed because API URL was incorrectly formatted")]
20
+ BadApiUrl,
21
+ #[error("organization not found")]
22
+ OrganizationNotFound,
23
+ #[error("resource not found")]
24
+ ResourceNotFound,
25
+ #[error("Project not found. Please check that you entered the project and organization slugs correctly.")]
26
+ ProjectNotFound,
27
+ #[error("release not found")]
28
+ ReleaseNotFound,
29
+ #[error("chunk upload endpoint not supported by sentry server")]
30
+ ChunkUploadNotSupported,
31
+ #[error("API request failed")]
32
+ RequestFailed,
33
+ #[error("could not compress data")]
34
+ CompressionFailed,
35
+ #[error("region overrides cannot be applied to absolute urls")]
36
+ InvalidRegionRequest,
37
+ #[error(
38
+ "Auth token is required for this request. Please run `sentry-cli login` and try again!"
39
+ )]
40
+ AuthMissing,
41
+ }
42
+
43
+ impl fmt::Display for ApiError {
44
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45
+ fmt::Display::fmt(&self.inner, f)
46
+ }
47
+ }
48
+
49
+ impl ApiError {
50
+ pub(in crate::api) fn with_source<E>(kind: ApiErrorKind, source: E) -> ApiError
51
+ where
52
+ E: Into<anyhow::Error>,
53
+ {
54
+ ApiError {
55
+ inner: kind,
56
+ source: Some(source.into()),
57
+ }
58
+ }
59
+
60
+ pub(in crate::api) fn kind(&self) -> ApiErrorKind {
61
+ self.inner
62
+ }
63
+
64
+ fn set_source<E: Into<anyhow::Error>>(mut self, source: E) -> ApiError {
65
+ self.source = Some(source.into());
66
+ self
67
+ }
68
+ }
69
+
70
+ impl From<ApiErrorKind> for ApiError {
71
+ fn from(kind: ApiErrorKind) -> ApiError {
72
+ ApiError {
73
+ inner: kind,
74
+ source: None,
75
+ }
76
+ }
77
+ }
78
+
79
+ impl From<curl::Error> for ApiError {
80
+ fn from(err: curl::Error) -> ApiError {
81
+ ApiError::from(ApiErrorKind::RequestFailed).set_source(err)
82
+ }
83
+ }
84
+
85
+ impl From<curl::FormError> for ApiError {
86
+ fn from(err: curl::FormError) -> ApiError {
87
+ ApiError::from(ApiErrorKind::RequestFailed).set_source(err)
88
+ }
89
+ }
@@ -0,0 +1,12 @@
1
+ mod api_error;
2
+ mod sentry_error;
3
+
4
+ pub(super) use api_error::{ApiError, ApiErrorKind};
5
+ pub(super) use sentry_error::SentryError;
6
+
7
+ #[derive(Clone, Debug, thiserror::Error)]
8
+ #[error("project was renamed to '{0}'\nPlease use this slug in your .sentryclirc file, sentry.properties file or in the CLI --project parameter")]
9
+ pub(super) struct ProjectRenamedError(pub(super) String);
10
+
11
+ /// Shortcut alias for results of this module.
12
+ pub(super) type ApiResult<T> = Result<T, ApiError>;
@@ -0,0 +1,36 @@
1
+ use std::fmt;
2
+
3
+ #[derive(Debug, thiserror::Error)]
4
+ pub(in crate::api) struct SentryError {
5
+ pub(in crate::api) status: u32,
6
+ pub(in crate::api) detail: Option<String>,
7
+ pub(in crate::api) extra: Option<serde_json::Value>,
8
+ }
9
+
10
+ impl fmt::Display for SentryError {
11
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12
+ let detail = self.detail.as_deref().unwrap_or("");
13
+ write!(
14
+ f,
15
+ "sentry reported an error: {} (http status: {})",
16
+ if detail.is_empty() {
17
+ match self.status {
18
+ 400 => "bad request",
19
+ 401 => "unauthorized",
20
+ 404 => "not found",
21
+ 500 => "internal server error",
22
+ 502 => "bad gateway",
23
+ 504 => "gateway timeout",
24
+ _ => "unknown error",
25
+ }
26
+ } else {
27
+ detail
28
+ },
29
+ self.status
30
+ )?;
31
+ if let Some(ref extra) = self.extra {
32
+ write!(f, "\n {extra:?}")?;
33
+ }
34
+ Ok(())
35
+ }
36
+ }
@@ -3,6 +3,11 @@
3
3
  //! to the GitHub API to figure out if there are new releases of the
4
4
  //! sentry-cli tool.
5
5
 
6
+ mod connection_manager;
7
+ mod encoding;
8
+ mod errors;
9
+ mod pagination;
10
+
6
11
  use std::borrow::Cow;
7
12
  use std::cell::RefCell;
8
13
  use std::collections::{HashMap, HashSet};
@@ -11,7 +16,6 @@ use std::fs::{create_dir_all, File};
11
16
  use std::io::{self, Read, Write};
12
17
  use std::path::Path;
13
18
  use std::rc::Rc;
14
- use std::str::FromStr;
15
19
  use std::sync::Arc;
16
20
  use std::{env, fmt};
17
21
 
@@ -27,7 +31,6 @@ use if_chain::if_chain;
27
31
  use lazy_static::lazy_static;
28
32
  use log::{debug, info, warn};
29
33
  use parking_lot::{Mutex, RwLock};
30
- use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS};
31
34
  use regex::{Captures, Regex};
32
35
  use sentry::protocol::{Exception, Values};
33
36
  use serde::de::{DeserializeOwned, Deserializer};
@@ -38,123 +41,25 @@ use symbolic::debuginfo::ObjectKind;
38
41
  use url::Url;
39
42
  use uuid::Uuid;
40
43
 
44
+ use crate::api::errors::ProjectRenamedError;
41
45
  use crate::config::{Auth, Config};
42
46
  use crate::constants::{ARCH, DEFAULT_URL, EXT, PLATFORM, RELEASE_REGISTRY_LATEST_URL, VERSION};
43
47
  use crate::utils::file_upload::UploadContext;
44
- use crate::utils::http::{self, is_absolute_url, parse_link_header};
48
+ use crate::utils::http::{self, is_absolute_url};
45
49
  use crate::utils::progress::ProgressBar;
46
50
  use crate::utils::retry::{get_default_backoff, DurationAsMilliseconds};
47
51
  use crate::utils::sourcemaps::get_sourcemap_reference_from_headers;
48
52
  use crate::utils::ui::{capitalize_string, make_byte_progress_bar};
49
53
 
50
- // Based on https://docs.rs/percent-encoding/1.0.1/src/percent_encoding/lib.rs.html#104
51
- // WHATWG Spec: https://url.spec.whatwg.org/#percent-encoded-bytes
52
- // RFC3986 Reserved Characters: https://www.rfc-editor.org/rfc/rfc3986#section-2.2
53
- const QUERY_ENCODE_SET: AsciiSet = CONTROLS
54
- .add(b' ')
55
- .add(b'"')
56
- .add(b'#')
57
- .add(b'<')
58
- .add(b'>')
59
- .add(b'+');
60
- const PATH_SEGMENT_ENCODE_SET: AsciiSet = QUERY_ENCODE_SET
61
- .add(b'`')
62
- .add(b'?')
63
- .add(b'{')
64
- .add(b'}')
65
- .add(b'%')
66
- .add(b'/');
67
-
68
- /// Wrapper that escapes arguments for URL path segments.
69
- pub struct PathArg<A: fmt::Display>(A);
70
-
71
- /// Wrapper that escapes arguments for URL query segments.
72
- pub struct QueryArg<A: fmt::Display>(A);
73
-
74
- struct CurlConnectionManager;
75
-
76
- impl r2d2::ManageConnection for CurlConnectionManager {
77
- type Connection = curl::easy::Easy;
78
- type Error = curl::Error;
79
-
80
- fn connect(&self) -> Result<curl::easy::Easy, curl::Error> {
81
- Ok(curl::easy::Easy::new())
82
- }
83
-
84
- fn is_valid(&self, _conn: &mut curl::easy::Easy) -> Result<(), curl::Error> {
85
- Ok(())
86
- }
87
-
88
- fn has_broken(&self, _conn: &mut curl::easy::Easy) -> bool {
89
- false
90
- }
91
- }
54
+ use self::pagination::Pagination;
55
+ use connection_manager::CurlConnectionManager;
56
+ use encoding::{PathArg, QueryArg};
57
+ use errors::{ApiError, ApiErrorKind, ApiResult, SentryError};
92
58
 
93
59
  lazy_static! {
94
60
  static ref API: Mutex<Option<Arc<Api>>> = Mutex::new(None);
95
61
  }
96
62
 
97
- #[derive(Debug, Clone)]
98
- pub struct Link {
99
- results: bool,
100
- cursor: String,
101
- }
102
-
103
- #[derive(Debug, Default, Clone)]
104
- pub struct Pagination {
105
- next: Option<Link>,
106
- }
107
-
108
- impl Pagination {
109
- pub fn into_next_cursor(self) -> Option<String> {
110
- self.next
111
- .and_then(|x| if x.results { Some(x.cursor) } else { None })
112
- }
113
- }
114
-
115
- impl FromStr for Pagination {
116
- type Err = ();
117
-
118
- fn from_str(s: &str) -> Result<Pagination, ()> {
119
- let mut rv = Pagination::default();
120
- for item in parse_link_header(s) {
121
- let target = match item.get("rel") {
122
- Some(&"next") => &mut rv.next,
123
- _ => continue,
124
- };
125
-
126
- *target = Some(Link {
127
- results: item.get("results") == Some(&"true"),
128
- cursor: (*item.get("cursor").unwrap_or(&"")).to_string(),
129
- });
130
- }
131
-
132
- Ok(rv)
133
- }
134
- }
135
-
136
- impl<A: fmt::Display> fmt::Display for QueryArg<A> {
137
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
138
- utf8_percent_encode(&format!("{}", self.0), &QUERY_ENCODE_SET).fmt(f)
139
- }
140
- }
141
-
142
- impl<A: fmt::Display> fmt::Display for PathArg<A> {
143
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
144
- // if we put values into the path we need to url encode them. However
145
- // special care needs to be taken for any slash character or path
146
- // segments that would end up as ".." or "." for security reasons.
147
- // Since we cannot handle slashes there we just replace them with the
148
- // unicode replacement character as a quick workaround. This will
149
- // typically result in 404s from the server.
150
- let mut val = format!("{}", self.0).replace('/', "\u{fffd}");
151
- if val == ".." || val == "." {
152
- val = "\u{fffd}".into();
153
- }
154
- utf8_percent_encode(&val, &PATH_SEGMENT_ENCODE_SET).fmt(f)
155
- }
156
- }
157
-
158
63
  #[derive(Clone)]
159
64
  pub enum ProgressBarMode {
160
65
  Disabled,
@@ -200,133 +105,6 @@ pub struct RegionSpecificApi<'a> {
200
105
  region_url: Option<Box<str>>,
201
106
  }
202
107
 
203
- #[derive(Debug, thiserror::Error)]
204
- pub struct SentryError {
205
- status: u32,
206
- detail: Option<String>,
207
- extra: Option<serde_json::Value>,
208
- }
209
-
210
- impl fmt::Display for SentryError {
211
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
212
- let detail = self.detail.as_deref().unwrap_or("");
213
- write!(
214
- f,
215
- "sentry reported an error: {} (http status: {})",
216
- if detail.is_empty() {
217
- match self.status {
218
- 400 => "bad request",
219
- 401 => "unauthorized",
220
- 404 => "not found",
221
- 500 => "internal server error",
222
- 502 => "bad gateway",
223
- 504 => "gateway timeout",
224
- _ => "unknown error",
225
- }
226
- } else {
227
- detail
228
- },
229
- self.status
230
- )?;
231
- if let Some(ref extra) = self.extra {
232
- write!(f, "\n {extra:?}")?;
233
- }
234
- Ok(())
235
- }
236
- }
237
-
238
- #[derive(Clone, Debug, thiserror::Error)]
239
- #[error("project was renamed to '{0}'\nPlease use this slug in your .sentryclirc file, sentry.properties file or in the CLI --project parameter")]
240
- pub struct ProjectRenamedError(String);
241
-
242
- /// Represents API errors.
243
- #[derive(Copy, Clone, Eq, PartialEq, Debug, thiserror::Error)]
244
- pub enum ApiErrorKind {
245
- #[error("could not serialize value as JSON")]
246
- CannotSerializeAsJson,
247
- #[error("could not parse JSON response")]
248
- BadJson,
249
- #[error("not a JSON response")]
250
- NotJson,
251
- #[error("request failed because API URL was incorrectly formatted")]
252
- BadApiUrl,
253
- #[error("organization not found")]
254
- OrganizationNotFound,
255
- #[error("resource not found")]
256
- ResourceNotFound,
257
- #[error("Project not found. Please check that you entered the project and organization slugs correctly.")]
258
- ProjectNotFound,
259
- #[error("release not found")]
260
- ReleaseNotFound,
261
- #[error("chunk upload endpoint not supported by sentry server")]
262
- ChunkUploadNotSupported,
263
- #[error("API request failed")]
264
- RequestFailed,
265
- #[error("could not compress data")]
266
- CompressionFailed,
267
- #[error("region overrides cannot be applied to absolute urls")]
268
- InvalidRegionRequest,
269
- #[error(
270
- "Auth token is required for this request. Please run `sentry-cli login` and try again!"
271
- )]
272
- AuthMissing,
273
- }
274
-
275
- #[derive(Debug, thiserror::Error)]
276
- pub struct ApiError {
277
- inner: ApiErrorKind,
278
- #[source]
279
- source: Option<anyhow::Error>,
280
- }
281
-
282
- impl fmt::Display for ApiError {
283
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
284
- fmt::Display::fmt(&self.inner, f)
285
- }
286
- }
287
-
288
- impl ApiError {
289
- pub fn with_source<E: Into<anyhow::Error>>(kind: ApiErrorKind, source: E) -> ApiError {
290
- ApiError {
291
- inner: kind,
292
- source: Some(source.into()),
293
- }
294
- }
295
-
296
- pub fn kind(&self) -> ApiErrorKind {
297
- self.inner
298
- }
299
-
300
- fn set_source<E: Into<anyhow::Error>>(mut self, source: E) -> ApiError {
301
- self.source = Some(source.into());
302
- self
303
- }
304
- }
305
-
306
- impl From<ApiErrorKind> for ApiError {
307
- fn from(kind: ApiErrorKind) -> ApiError {
308
- ApiError {
309
- inner: kind,
310
- source: None,
311
- }
312
- }
313
- }
314
-
315
- impl From<curl::Error> for ApiError {
316
- fn from(err: curl::Error) -> ApiError {
317
- ApiError::from(ApiErrorKind::RequestFailed).set_source(err)
318
- }
319
- }
320
-
321
- impl From<curl::FormError> for ApiError {
322
- fn from(err: curl::FormError) -> ApiError {
323
- ApiError::from(ApiErrorKind::RequestFailed).set_source(err)
324
- }
325
- }
326
-
327
- /// Shortcut alias for results of this module.
328
- pub type ApiResult<T> = Result<T, ApiError>;
329
-
330
108
  /// Represents an HTTP method that is used by the API.
331
109
  #[derive(Eq, PartialEq, Debug)]
332
110
  pub enum Method {
@@ -2146,7 +1924,7 @@ impl ApiResponse {
2146
1924
  }
2147
1925
 
2148
1926
  /// Like convert but produces resource not found errors.
2149
- pub fn convert_rnf<T: DeserializeOwned>(self, res_err: ApiErrorKind) -> ApiResult<T> {
1927
+ fn convert_rnf<T: DeserializeOwned>(self, res_err: ApiErrorKind) -> ApiResult<T> {
2150
1928
  match self.status() {
2151
1929
  301 | 302 if res_err == ApiErrorKind::ProjectNotFound => {
2152
1930
  #[derive(Deserialize, Debug)]
@@ -0,0 +1,42 @@
1
+ use std::str::FromStr;
2
+
3
+ use crate::utils::http;
4
+
5
+ #[derive(Debug, Clone)]
6
+ pub struct Link {
7
+ results: bool,
8
+ cursor: String,
9
+ }
10
+
11
+ #[derive(Debug, Default, Clone)]
12
+ pub struct Pagination {
13
+ next: Option<Link>,
14
+ }
15
+
16
+ impl Pagination {
17
+ pub fn into_next_cursor(self) -> Option<String> {
18
+ self.next
19
+ .and_then(|x| if x.results { Some(x.cursor) } else { None })
20
+ }
21
+ }
22
+
23
+ impl FromStr for Pagination {
24
+ type Err = ();
25
+
26
+ fn from_str(s: &str) -> Result<Pagination, ()> {
27
+ let mut rv = Pagination::default();
28
+ for item in http::parse_link_header(s) {
29
+ let target = match item.get("rel") {
30
+ Some(&"next") => &mut rv.next,
31
+ _ => continue,
32
+ };
33
+
34
+ *target = Some(Link {
35
+ results: item.get("results") == Some(&"true"),
36
+ cursor: (*item.get("cursor").unwrap_or(&"")).to_string(),
37
+ });
38
+ }
39
+
40
+ Ok(rv)
41
+ }
42
+ }
@@ -43,6 +43,14 @@ pub fn make_command(command: Command) -> Command {
43
43
  pub fn execute(matches: &ArgMatches) -> Result<()> {
44
44
  let path = Path::new(matches.get_one::<String>("path").unwrap());
45
45
 
46
+ if path.is_dir() {
47
+ anyhow::bail!(
48
+ "This command can only check individual debug files, but the provided \
49
+ path leads to a directory. Please a pass a path to an individual file, \
50
+ instead!"
51
+ );
52
+ }
53
+
46
54
  // which types should we consider?
47
55
  let ty = matches
48
56
  .get_one::<String>("type")
@@ -373,10 +373,15 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
373
373
  Ok(Some(plist)) => {
374
374
  // Successfully discovered and parsed Info.plist
375
375
  let dist_string = plist.build().to_string();
376
- let release_string = format!("{}@{}+{}", plist.bundle_id(), plist.version(), dist_string);
376
+ let release_string = format!(
377
+ "{}@{}+{}",
378
+ plist.bundle_id(),
379
+ plist.version(),
380
+ dist_string
381
+ );
377
382
  info!("Parse result from Info.plist: {:?}", &plist);
378
383
  (Some(dist_string), Some(release_string))
379
- },
384
+ }
380
385
  _ => {
381
386
  bail!("Info.plist was not found or an parsing error occurred");
382
387
  }
@@ -556,8 +561,8 @@ pub fn wrap_call() -> Result<()> {
556
561
  if let (Ok(packager_sourcemap), Ok(mut hermes_sourcemap)) =
557
562
  (packager_sourcemap_result, hermes_sourcemap_result)
558
563
  {
559
- if hermes_sourcemap.get("debugId").is_none()
560
- && hermes_sourcemap.get("debug_id").is_none()
564
+ if !hermes_sourcemap.contains_key("debugId")
565
+ && !hermes_sourcemap.contains_key("debug_id")
561
566
  {
562
567
  if let Some(debug_id) = packager_sourcemap
563
568
  .get("debugId")
@@ -142,8 +142,6 @@ pub fn make_command(command: Command) -> Command {
142
142
  }
143
143
 
144
144
  pub fn execute(matches: &ArgMatches) -> Result<()> {
145
- let api = Api::current();
146
- let authenticated_api = api.authenticated()?;
147
145
 
148
146
  let paths: Vec<_> = match matches.get_many::<String>("paths") {
149
147
  Some(paths) => paths.collect(),
@@ -244,6 +242,9 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
244
242
  org, project
245
243
  );
246
244
 
245
+ let api = Api::current();
246
+ let authenticated_api = api.authenticated()?;
247
+
247
248
  let rv = authenticated_api
248
249
  .region_specific(&org)
249
250
  .upload_dif_archive(&project, tf.path())?;
@@ -21,6 +21,9 @@ use crate::utils::auth_token::AuthToken;
21
21
  use crate::utils::auth_token::AuthTokenPayload;
22
22
  use crate::utils::http::is_absolute_url;
23
23
 
24
+ #[cfg(target_os = "macos")]
25
+ use crate::utils::xcode;
26
+
24
27
  /// Represents the auth information
25
28
  #[derive(Debug, Clone)]
26
29
  pub enum Auth {
@@ -214,7 +217,7 @@ impl Config {
214
217
  bail!("Two different url values supplied: `{token_url}` (from token), `{url}`.");
215
218
  }
216
219
 
217
- self.cached_base_url = url.to_owned();
220
+ url.clone_into(&mut self.cached_base_url);
218
221
  self.ini
219
222
  .set_to(Some("defaults"), "url".into(), self.cached_base_url.clone());
220
223
  Ok(())
@@ -575,6 +578,15 @@ fn load_global_config_file() -> Result<(PathBuf, Ini)> {
575
578
  }
576
579
  }
577
580
 
581
+ fn failed_local_config_load_message(file_desc: &str) -> String {
582
+ let msg = format!("Failed to load {file_desc}.");
583
+ #[cfg(target_os = "macos")]
584
+ if xcode::launched_from_xcode() {
585
+ return msg + (" Hint: Please ensure that ${SRCROOT}/.sentryclirc is added to the Input Files of this Xcode Build Phases script.");
586
+ }
587
+ msg
588
+ }
589
+
578
590
  fn load_cli_config() -> Result<(PathBuf, Ini)> {
579
591
  let (global_filename, mut rv) = load_global_config_file()?;
580
592
 
@@ -584,8 +596,8 @@ fn load_cli_config() -> Result<(PathBuf, Ini)> {
584
596
  CONFIG_RC_FILE_NAME,
585
597
  project_config_path.display()
586
598
  );
587
- let mut f =
588
- fs::File::open(&project_config_path).context(format!("Failed to load {file_desc}"))?;
599
+ let mut f = fs::File::open(&project_config_path)
600
+ .context(failed_local_config_load_message(&file_desc))?;
589
601
  let ini = Ini::read_from(&mut f).context(format!("Failed to parse {file_desc}"))?;
590
602
  for (section, props) in ini.iter() {
591
603
  for (key, value) in props.iter() {
@@ -0,0 +1,9 @@
1
+ mod api;
2
+ mod commands;
3
+ mod config;
4
+ mod constants;
5
+ mod utils;
6
+
7
+ pub fn main() {
8
+ commands::main()
9
+ }
@@ -45,14 +45,10 @@ pub fn capitalize_string(s: &str) -> String {
45
45
  }
46
46
 
47
47
  /// Like ``io::copy`` but advances a progress bar set to bytes.
48
- pub fn copy_with_progress<R: ?Sized, W: ?Sized>(
49
- pb: &ProgressBar,
50
- reader: &mut R,
51
- writer: &mut W,
52
- ) -> io::Result<u64>
48
+ pub fn copy_with_progress<R, W>(pb: &ProgressBar, reader: &mut R, writer: &mut W) -> io::Result<u64>
53
49
  where
54
- R: Read,
55
- W: Write,
50
+ R: Read + ?Sized,
51
+ W: Write + ?Sized,
56
52
  {
57
53
  let mut buf = [0; 16384];
58
54
  let mut written = 0;
@@ -1,14 +0,0 @@
1
- //! This is the library that powers the `sentry-cli` tool. The primary
2
- //! exported function is `main` which is directly invoked from the
3
- //! compiled binary that links against this library.
4
-
5
- mod api;
6
- mod commands;
7
- mod config;
8
- mod constants;
9
- mod utils;
10
-
11
- /// Executes the command line application and exits the process.
12
- pub fn main() {
13
- commands::main()
14
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes