Skip to content
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

fix(crons): Limit environment names on check-ins to 64 chars #2309

Merged
merged 20 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**Internal**:

- Add support for `sampled` field in the DSC and error tagging. ([#2290](https://github.com/getsentry/relay/pull/2290))
- Limit environment names on check-ins to 64 chars. ([#2309](https://github.com/getsentry/relay/pull/2309))
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you, please, move this to Unreleased section of the changelog

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, got moved during a bad merge


## 23.6.2

Expand Down
2 changes: 1 addition & 1 deletion relay-crash/sentry-native
rjo100 marked this conversation as resolved.
Show resolved Hide resolved
Submodule sentry-native updated 97 files
+43 −46 .github/workflows/ci.yml
+0 −9 .github/workflows/danger.yml
+0 −16 .github/workflows/enforce-license-compliance.yml
+3 −3 .gitignore
+0 −178 CHANGELOG.md
+6 −76 CMakeLists.txt
+4 −22 CONTRIBUTING.md
+3 −10 Makefile
+6 −29 README.md
+2 −176 examples/example.c
+7 −12 external/CMakeLists.txt
+1 −1 external/breakpad
+1 −1 external/crashpad
+1 −1 external/libunwindstack-ndk
+17 −700 include/sentry.h
+0 −7 src/CMakeLists.txt
+33 −57 src/backends/sentry_backend_breakpad.cpp
+30 −133 src/backends/sentry_backend_crashpad.cpp
+13 −296 src/backends/sentry_backend_inproc.c
+0 −109 src/modulefinder/sentry_modulefinder_aix.c
+17 −103 src/modulefinder/sentry_modulefinder_linux.c
+0 −6 src/modulefinder/sentry_modulefinder_linux.h
+27 −40 src/modulefinder/sentry_modulefinder_windows.c
+3 −29 src/path/sentry_path_unix.c
+0 −1 src/sentry_backend.h
+30 −427 src/sentry_core.c
+7 −39 src/sentry_core.h
+1 −42 src/sentry_database.c
+0 −10 src/sentry_database.h
+1 −62 src/sentry_envelope.c
+0 −6 src/sentry_envelope.h
+0 −19 src/sentry_info.c
+0 −44 src/sentry_json.c
+1 −76 src/sentry_options.c
+0 −6 src/sentry_options.h
+14 −67 src/sentry_os.c
+0 −8 src/sentry_ratelimiter.c
+0 −6 src/sentry_ratelimiter.h
+7 −74 src/sentry_scope.c
+0 −16 src/sentry_scope.h
+6 −10 src/sentry_session.c
+61 −0 src/sentry_string.c
+18 −56 src/sentry_string.h
+1 −76 src/sentry_sync.c
+0 −22 src/sentry_sync.h
+0 −543 src/sentry_tracing.c
+0 −50 src/sentry_tracing.h
+0 −19 src/sentry_transport.c
+0 −7 src/sentry_transport.h
+13 −39 src/sentry_utils.c
+1 −1 src/sentry_utils.h
+0 −22 src/sentry_uuid.c
+3 −13 src/sentry_uuid.h
+3 −67 src/sentry_value.c
+0 −33 src/sentry_value.h
+0 −189 src/symbolizer/sentry_symbolizer_unix.c
+0 −13 src/transports/sentry_transport_curl.c
+0 −18 src/transports/sentry_transport_winhttp.c
+2 −8 src/unwinder/sentry_unwinder_libbacktrace.c
+4 −59 tests/__init__.py
+21 −59 tests/assertions.py
+3 −9 tests/cmake.py
+2 −7 tests/conditions.py
+1 −16 tests/conftest.py
+3 −3 tests/requirements.txt
+1 −1 tests/test_build_static.py
+10 −190 tests/test_integration_crashpad.py
+23 −134 tests/test_integration_http.py
+0 −12 tests/test_integration_ratelimits.py
+28 −127 tests/test_integration_stdout.py
+0 −3 tests/unit/CMakeLists.txt
+2 −0 tests/unit/fuzz.c
+1 −0 tests/unit/test_attachments.c
+6 −116 tests/unit/test_basic.c
+1 −28 tests/unit/test_concurrency.c
+1 −0 tests/unit/test_consent.c
+1 −32 tests/unit/test_envelopes.c
+1 −0 tests/unit/test_failures.c
+1 −1 tests/unit/test_fuzzfailures.c
+0 −16 tests/unit/test_info.c
+1 −0 tests/unit/test_logger.c
+1 −0 tests/unit/test_modulefinder.c
+1 −0 tests/unit/test_mpack.c
+1 −0 tests/unit/test_path.c
+1 −0 tests/unit/test_ratelimiter.c
+0 −37 tests/unit/test_sampling.c
+1 −6 tests/unit/test_session.c
+1 −0 tests/unit/test_slice.c
+1 −12 tests/unit/test_symbolizer.c
+0 −20 tests/unit/test_sync.c
+0 −811 tests/unit/test_tracing.c
+2 −0 tests/unit/test_uninit.c
+2 −11 tests/unit/test_unwinder.c
+7 −43 tests/unit/test_utils.c
+2 −22 tests/unit/test_uuid.c
+1 −74 tests/unit/test_value.c
+0 −29 tests/unit/tests.inc
1 change: 1 addition & 0 deletions relay-monitors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ publish = false

[dependencies]
relay-common = { path = "../relay-common" }
relay-general = { path = "../relay-general" }
serde = { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.55"
regex = "1.5.5"
Expand Down
27 changes: 27 additions & 0 deletions relay-monitors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ use serde::{Deserialize, Serialize};
/// Maximum length of monitor slugs.
const SLUG_LENGTH: usize = 50;

/// Maximum length of environment names.
const ENVIRONMENT_LENGTH: usize = MaxChars::Environment.limit();

/// Error returned from [`process_check_in`].
#[derive(Debug, thiserror::Error)]
pub enum ProcessCheckInError {
Expand All @@ -32,6 +35,10 @@ pub enum ProcessCheckInError {
/// Monitor slug was empty after slugification.
#[error("the monitor slug is empty or invalid")]
EmptySlug,

/// Environment name was invalid.environment.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Environment name was invalid.environment.
/// Environment name was invalid.

#[error("the environment is invalid")]
InvalidEnvironment,
}

///
Expand Down Expand Up @@ -160,6 +167,10 @@ pub fn process_check_in(payload: &[u8]) -> Result<Vec<u8>, ProcessCheckInError>
return Err(ProcessCheckInError::EmptySlug);
}

if check_in.environment.len() > ENVIRONMENT_LENGTH {
rjo100 marked this conversation as resolved.
Show resolved Hide resolved
return Err(ProcessCheckInError::InvalidEnvironment);
}

Ok(serde_json::to_vec(&check_in)?)
}

Expand Down Expand Up @@ -285,4 +296,20 @@ mod tests {
let result = process_check_in(json.as_bytes());
assert!(matches!(result, Err(ProcessCheckInError::EmptySlug)));
}

#[test]
fn process_invalid_environment() {
let json = r#"{
"check_in_id": "a460c25ff2554577b920fcfacae4e5eb",
"monitor_slug": "test",
"status": "in_progress"
"environment": "1234567890123456789012345678901234567890123456789012345678901234567890"
}"#;

let result = process_check_in(json.as_bytes());
assert!(matches!(
result,
Err(ProcessCheckInError::InvalidEnvironment)
));
}
}