Skip to content

Commit e99f58b

Browse files
committed
Merge branch 'master' into denrase/flutter-sentry-run-zoned-guarded
2 parents 3e2a94b + 6e67955 commit e99f58b

File tree

113 files changed

+2070
-670
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+2070
-670
lines changed

app/platform-redirect/page.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {SmartLink} from 'sentry-docs/components/smartLink';
88
import {extractPlatforms, getDocsRootNode, nodeForPath} from 'sentry-docs/docTree';
99
import {setServerContext} from 'sentry-docs/serverContext';
1010

11+
import {sanitizeNext} from './utils';
12+
1113
export const metadata: Metadata = {
1214
robots: 'noindex',
1315
title: 'Platform Specific Content',
@@ -27,8 +29,7 @@ export default async function Page(props: {
2729
next = next[0];
2830
}
2931

30-
// discard the hash
31-
const [pathname, _] = next.split('#');
32+
const pathname = sanitizeNext(next);
3233
const rootNode = await getDocsRootNode();
3334
const defaultTitle = 'Platform Specific Content';
3435
let description = '';
@@ -64,7 +65,7 @@ export default async function Page(props: {
6465
p => p.key === requestedPlatform?.toLowerCase()
6566
);
6667
if (isValidPlatform) {
67-
return redirect(`/platforms/${requestedPlatform}${next}`);
68+
return redirect(`/platforms/${requestedPlatform}${pathname}`);
6869
}
6970
}
7071

@@ -83,7 +84,7 @@ export default async function Page(props: {
8384
<ul>
8485
{platformList.map(p => (
8586
<li key={p.key}>
86-
<SmartLink to={`/platforms/${p.key}${next}`}>
87+
<SmartLink to={`/platforms/${p.key}${pathname}`}>
8788
<PlatformIcon
8889
size={16}
8990
platform={p.icon ?? p.key}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {describe, expect, it} from 'vitest';
2+
3+
import {sanitizeNext} from './utils';
4+
5+
describe('sanitizeNext', () => {
6+
it('should return an empty string for external URLs', () => {
7+
expect(sanitizeNext('http://example.com')).toBe('');
8+
expect(sanitizeNext('https://example.com')).toBe('');
9+
expect(sanitizeNext('//example.com')).toBe('');
10+
});
11+
12+
it('should prepend a slash if missing', () => {
13+
expect(sanitizeNext('path/to/resource')).toBe('/path/to/resource');
14+
});
15+
16+
it('should not modify a valid internal path', () => {
17+
expect(sanitizeNext('/path/to/resource')).toBe('/path/to/resource');
18+
});
19+
20+
it('should remove unsafe characters', () => {
21+
expect(sanitizeNext('/path/to/resource?query=1')).toBe('/path/to/resource');
22+
expect(sanitizeNext('/path/to/resource#hash')).toBe('/path/to/resource');
23+
});
24+
25+
it('should allow alphanumeric and hyphens', () => {
26+
expect(sanitizeNext('/path-to/resource123')).toBe('/path-to/resource123');
27+
});
28+
29+
it('should return an empty string for paths with colons', () => {
30+
expect(sanitizeNext('/path:to/resource')).toBe('');
31+
});
32+
33+
it('should return an empty string for the root path', () => {
34+
expect(sanitizeNext('/')).toBe('');
35+
});
36+
37+
it('should decode URL encoded characters', () => {
38+
expect(sanitizeNext('/path%2Fwith%2Fslashes')).toBe('/path/with/slashes');
39+
});
40+
41+
it('should return an empty string for a malformed URI component', () => {
42+
const input = '%E0%A4%A'; // Malformed URI
43+
const expectedOutput = '';
44+
expect(sanitizeNext(input)).toBe(expectedOutput);
45+
});
46+
});

app/platform-redirect/utils.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
export const sanitizeNext = (next: string) => {
2+
// Safely decode URI component
3+
let sanitizedNext: string;
4+
try {
5+
sanitizedNext = decodeURIComponent(next);
6+
} catch (e) {
7+
// Return empty string if decoding fails
8+
return '';
9+
}
10+
11+
// Validate that next is an internal path
12+
if (
13+
sanitizedNext.startsWith('//') ||
14+
sanitizedNext.startsWith('http') ||
15+
sanitizedNext.includes(':')
16+
) {
17+
// Reject potentially malicious redirects
18+
sanitizedNext = '';
19+
}
20+
21+
// Ensure next starts with a forward slash and only contains safe characters
22+
if (sanitizedNext && !sanitizedNext.startsWith('/')) {
23+
sanitizedNext = '/' + sanitizedNext;
24+
}
25+
26+
// Discard hash and path parameters
27+
const [pathname] = sanitizedNext.split('#')[0].split('?');
28+
29+
// Only allow alphanumeric, hyphens
30+
sanitizedNext = pathname.replace(/[^\w\-\/]/g, '');
31+
32+
return sanitizedNext === '/' ? '' : sanitizedNext;
33+
};

develop-docs/api-server/application-domains/database-migrations/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ Extra care is needed here if the table is referenced as a foreign key in other t
287287

288288
- Make a pull request to remove all uses of the model in the codebase in a separate pull request. This mostly helps with code cleanliness. This should be merged ahead of the migration pull requests, but we don't need to worry about whether it is deployed first.
289289
- Make another pull request to:
290-
- Remove any database level foreign key constraints from this table to other tables by setting `db_constraint=False` on the columns.
290+
- Remove any database level foreign key constraints from this table to other tables by setting `db_constraint=False` on the columns. If it's a hybrid cloud foreign key, set `null=True` instead.
291291
- Remove the model and in the generated migration use `SafeDeleteModel(..., deletion_action=DeletionAction.MOVE_TO_PENDING)` to replace `DeleteModel(...)`. This only marks the state for the model as removed.
292292
- Deploy. It's important that all previous pull requests are in production before we remove the actual table.
293293
- Make a pull request that creates a new migration that has the same `SafeDeleteModel` operation as before, but set `deletion_action=DeletionAction.DELETE` instead. This deletes the actual table from Postgres.

develop-docs/engineering-practices/rust.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,26 +50,26 @@ During migration you may need normal functions which return futures, for their s
5050

5151
### Async Traits
5252

53-
In **traits** you can not yet use `async fn` ([see this blog post](https://smallcultfollowing.com/babysteps/blog/2019/10/26/async-fn-in-traits-are-hard/)).
54-
In this case, functions should return `-> Pin<Box<dyn Future<Output = ...> + Send>>`:
53+
Support for async in **traits** has [landed in Rust](https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html)
54+
and should generally be preferred now.
5555

5656
```rust
57-
trait Database {
58-
fn get_user(&self) -> Pin<Box<dyn Future<Output = User> + Send + '_>>;
57+
pub trait Database {
58+
fn get_user(&self) -> impl Future<Output = User> + Send;
5959
}
6060

61-
impl Database for MyDB {
62-
fn get_user(&self) -> Pin<Box<dyn Future<Output = User> + Send + '_>> {
63-
Box::pin(async {
64-
// ...
65-
})
66-
}
61+
impl Database for MyDatabase {
62+
async fn get_user(&self) -> User {
63+
todo!()
64+
}
6765
}
6866
```
6967

7068
Note that the returned future type is `Send`, to ensure that it can run on a multi-threaded runtime.
7169

72-
This corresponds to what the [async-trait crate](https://crates.io/crates/async-trait) does.
70+
When you need dynamic dispatch or have to support Rust versions older than 1.75 consider using the
71+
[`async-trait`](https://docs.rs/async-trait/) crate.
72+
7373

7474
### Avoid `.unwrap()`
7575

develop-docs/frontend/design-tenets.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Why minimize content refreshes?
5858
Spinners should be used carefully. Having multiple spinners on the page is distracting. Reserve spinners for primary content that has an unknown height. Favor the usage of sized placeholder elements where the height of content is known, or the content is secondary to the main goal of the page.
5959

6060
Why use placeholders?
61-
- Less layout shifts / render thrash (see video below)
61+
- Less layout shifts / render thrash
6262
- Better perceived performance
6363
- Avoids having multiple loading spinner animations at once, which looks ugly
6464

develop-docs/frontend/using-styled-components.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ The `style` and `css` attributes can be used, but the values of `style` are not
112112
```tsx
113113
import styled from '@emotion/styled';
114114
import {css} from '@emotion/react';
115+
import {space} from 'sentry/styles/space';
115116

116117
// ✅ Don't be afraid of inline styles for one-off values
117118
const Grid = styled('div')`

develop-docs/sdk/data-model/event-payloads/contexts.mdx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,17 @@ To summarize:
261261

262262
: _Optional_. An unprocessed description string obtained by the operating system. For some well-known runtimes, Sentry will attempt to parse `name` and `version` from this string, if they are not explicitly given.
263263

264-
`distribution`
264+
`distribution_name`
265265

266-
: _Optional_. An object that provides meta-data for Linux distributions. The values correspond to entries from the [`/etc/os-release`](https://www.freedesktop.org/software/systemd/man/latest/os-release.html#Options) configuration. Contains the following keys:
266+
: _Optional_. A stable name for each distribution. This maps to `ID` in [`/etc/os-release`](https://www.freedesktop.org/software/systemd/man/latest/os-release.html#ID=) (examples: `ubuntu`, `rhel`, `alpine`; a full list of tested identifiers is available in the [Native SDK repository](https://github.com/getsentry/sentry-native/blob/master/tests/fixtures/os_releases/distribution_names.txt))
267267

268+
`distribution_version`
268269

269-
- `name`: A stable name for each distribution. This maps to `ID` in `/etc/os-release` (examples: `ubuntu`, `rhel`, `alpine`; a full list of tested identifiers is available in the [Native SDK repository](https://github.com/getsentry/sentry-native/blob/feat/add_linux_distros_to_os_context/tests/fixtures/os_releases/distribution_names.txt).
270-
- `version`: _Optional_. Typically identifies at least the major release version number. This maps to `VERSION_ID` in `/etc/os-release`. Distributions with rolling releases only, will not provide a version.
271-
- `pretty_name`: _Optional_. Typically provides the full name, full version, and release alias. This maps to `PRETTY_NAME` in `/etc/os-release` (examples: `Ubuntu 22.04.4 LTS`, `Raspian GNU/Linux 10 (buster)`).
270+
: _Optional_. Typically identifies at least the major release version number. This maps to `VERSION_ID` in [`/etc/os-release`](https://www.freedesktop.org/software/systemd/man/latest/os-release.html#VERSION_ID=). Distributions with rolling releases only, will not provide a version.
271+
272+
`distribution_pretty_name`
273+
274+
: _Optional_. Typically provides the full name, full version, and release alias. This maps to `PRETTY_NAME` in [`/etc/os-release`](https://www.freedesktop.org/software/systemd/man/latest/os-release.html#PRETTY_NAME=) (examples: `Ubuntu 22.04.4 LTS`, `Raspian GNU/Linux 10 (buster)`).
272275

273276
### Example OS Context
274277

@@ -293,10 +296,9 @@ The OS Context for the 3 major OSs should look like this:
293296
"type": "os",
294297
"name": "Linux",
295298
"version": "6.1.82(99.168.amzn2023.x86_64)",
296-
"distribution": {
297-
"name": "amzn",
298-
"version": "2023",
299-
"pretty_name": "Amazon Linux 2023.4.20240401"
299+
"distribution_name": "amzn",
300+
"distribution_version": "2023",
301+
"distribution_pretty_name": "Amazon Linux 2023.4.20240401"
300302
}
301303
}
302304
}
@@ -628,7 +630,7 @@ Additional information that allows Sentry to connect multiple transactions, span
628630

629631
`span_id`
630632

631-
: _Required_. The ID of the span.
633+
: _Required_. The ID of the span or transaction. For non-transaction events, and if performance monitoring is disabled, it may still be desired to attach events to a trace via a trace ID. In these cases, you still need to provide a span ID. This span ID can effectively be entirely random and doesn't need to relate to an actual span, however, it is recommended to consider using the same span ID for multiple events within the same unit-of-execution (e.g. a request). [See the TwP docs](/sdk/telemetry/traces/tracing-without-performance/#attaching-trace-data-to-events-and-envelopes) for more details.
632634

633635
- Example: `"bb8f278130535c3c"`
634636

develop-docs/sdk/processes/releases.mdx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Nice!
8484

8585
This file is used to trigger the release from the GitHub UI.
8686

87-
You'll notice it uses `secrets.GH_RELEASE_PAT` -- this should already be
87+
You'll notice it uses `vars.SENTRY_RELEASE_BOT_CLIENT_ID` and `secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY` -- these should be
8888
available to your repository automatically!
8989

9090
```yaml
@@ -105,14 +105,20 @@ jobs:
105105
runs-on: ubuntu-latest
106106
name: "Release a new version"
107107
steps:
108+
- name: Get auth token
109+
id: token
110+
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
111+
with:
112+
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
113+
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
108114
- uses: actions/checkout@v3
109115
with:
110-
token: ${{ secrets.GH_RELEASE_PAT }}
116+
token: ${{ steps.token.outputs.token }}
111117
fetch-depth: 0
112118
- name: Prepare release
113119
uses: getsentry/action-prepare-release@v1
114120
env:
115-
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
121+
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
116122
with:
117123
version: ${{ github.event.inputs.version }}
118124
force: ${{ github.event.inputs.force }}
@@ -132,11 +138,16 @@ Here's [an example PR] and the [follow-up to fix `fetch-depth`].
132138
Give the following teams access to your repository:
133139

134140
- `engineering` -> `write`
135-
- `release-bot` -> `elevated bot`
136141

137142
You can do this self-service via the settings page of your repository:
138143
`https://github.com/getsentry/REPONAME_HERE/settings/access`
139144

145+
## Create Ruleset for the Repo
146+
147+
Download and save the [default ruleset template](/json/Default_ruleset.json) as a JSON file.
148+
149+
Visit the ruleset setting page of your repository: `https://github.com/getsentry/REPONAME_HERE/settings/rules`, click on the green **New ruleset** button, choose **Import a ruleset**, and select the JSON file you just downloaded. You can tweak the ruleset settings, but please don't remove the App in the Bypass List.
150+
140151
## Making Your First Release!
141152

142153
Navigate to the actions tab of your repository, locate the release workflow,

develop-docs/self-hosted/troubleshooting.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,25 @@ CSRF_TRUSTED_ORIGINS = ["https://sentry.example.com", "http://10.100.10.10", "ht
2323

2424
See [Django's documentation on CSRF](https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-CSRF_TRUSTED_ORIGINS) for further detail.
2525

26+
### `sentry-data` volume not being cleaned up
27+
28+
You may see the `sentry-data` taking too much disk space. You can clean it manually (or putting the cleanup cronjob in place).
29+
30+
Find the Docker mountpoint for the volume by executing:
31+
```bash
32+
docker volume inspect sentry-data
33+
34+
# Or if you prefer to do it directly (assuming you have `jq` on your system):
35+
docker volume inspect sentry-data | jq -r .[0].Mountpoint
36+
```
37+
38+
Then run the following command to remove the contents of the volume for the last 30 days (change the `30` to whatever you want, it's in days):
39+
```bash
40+
# `/var/lib/docker/volumes/sentry-data/_data` refers to the mountpoint of the volume
41+
# from the output of the previous command. Change it if it's different.
42+
find /var/lib/docker/volumes/sentry-data/_data -type f -mtime +30 -delete
43+
```
44+
2645
## Kafka
2746

2847
One of the most likely things to cause issues is Kafka. The most commonly reported error is

0 commit comments

Comments
 (0)