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(filter): Allow generic Slackbot to pass #947

Merged
merged 5 commits into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -12,6 +12,7 @@
- Fix a problem with Data Scrubbing source names (PII selectors) that caused `$frame.abs_path` to match, but not `$frame.abs_path || **` or `$frame.abs_path && **`. ([#932](https://github.com/getsentry/relay/pull/932))
- Make username pii-strippable. ([#935](https://github.com/getsentry/relay/pull/935))
- Respond with `400 Bad Request` and an error message `"empty envelope"` instead of `429` when envelopes without items are sent to the envelope endpoint. ([#937](https://github.com/getsentry/relay/pull/937))
- Allow generic Slackbot ([#947](https://github.com/getsentry/relay/pull/947))

**Internal**:

Expand Down
12 changes: 9 additions & 3 deletions relay-filter/src/web_crawlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{FilterConfig, FilterStatKey};
/// Checks if the event originates from a known web crawler.
pub fn matches(event: &Event) -> bool {
if let Some(user_agent) = user_agent::get_user_agent(event) {
WEB_CRAWLERS.is_match(user_agent)
WEB_CRAWLERS.is_match(user_agent) && !ALLOWED_WEB_CRAWLERS.is_match(user_agent)
} else {
false
}
Expand Down Expand Up @@ -57,6 +57,13 @@ lazy_static! {
"#
)
.expect("Invalid web crawlers filter Regex");

static ref ALLOWED_WEB_CRAWLERS: Regex = Regex::new(
r#"(?ix)
Slackbot\s1\.\d+ # Slack - see https://api.slack.com/robots
"#
)
.expect("Invalid allowed web crawlers filter Regex");
}

#[cfg(test)]
Expand Down Expand Up @@ -96,15 +103,13 @@ mod tests {
"spider ",
"spider;",
"spider)",
"Slack",
"Calypso AppCrawler",
"pingdom",
"lyticsbot",
"AWS Security Scanner",
"Mozilla/5.0 (Linux; Android 6.0.1; Calypso AppCrawler Build/MMB30Y; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.124 Mobile Safari/537.36",
"Slackbot-LinkExpanding 1.0 (+https://api.slack.com/robots)",
"Slack-ImgProxy 0.19 (+https://api.slack.com/robots)",
"Slackbot 1.0(+https://api.slack.com/robots)",
"Twitterbot/1.0",
"FeedFetcher-Google; (+http://www.google.com/feedfetcher.html)",
"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
Expand Down Expand Up @@ -134,6 +139,7 @@ mod tests {
"safari",
"APIs-Google (+https://developers.google.com/webmasters/APIs-Google.html)",
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36",
"Slackbot 1.0(+https://api.slack.com/robots)",
];
for user_agent in &normal_user_agents {
let event = testutils::get_event_with_user_agent(user_agent);
Expand Down