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(symbol sources): Correct schema and validate builtin sources #87267

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
31 changes: 30 additions & 1 deletion src/sentry/lang/native/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,23 @@
"slashsymbols",
)

VALID_FILE_TYPES = ("pe", "pdb", "mach_debug", "mach_code", "elf_debug", "elf_code", "breakpad")
VALID_FILE_TYPES = (
"pe",
"pdb",
"portablepdb",
"mach_debug",
"mach_code",
"elf_debug",
"elf_code",
"wasm_debug",
"wasm_code",
"breakpad",
"sourcebundle",
"uuidmap",
"bcsymbolmap",
"il2cpp",
"proguard",
)

VALID_CASINGS = ("lowercase", "uppercase", "default")

Expand All @@ -48,11 +64,24 @@
"additionalProperties": False,
}

FILTERS_SCHEMA = {
"type": "object",
"properties": {
"filetypes": {"type": "array", "items": {"type": "string", "enum": list(VALID_FILE_TYPES)}},
"path_patterns": {"type": "array", "items": {"type": "string"}},
"requires_checksum": {"type": "boolean"},
},
"additionalProperties": False,
}

COMMON_SOURCE_PROPERTIES = {
"id": {"type": "string", "minLength": 1},
"name": {"type": "string"},
"layout": LAYOUT_SCHEMA,
"filters": FILTERS_SCHEMA,
# FIXME: This is temporarily included for backwards compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

What happens if we send a payload without filetypes? Will this fail to validate?

My worry is that once we fade out the old field, this code will fail validation.

"filetypes": {"type": "array", "items": {"type": "string", "enum": list(VALID_FILE_TYPES)}},
"is_public": {"type": "boolean"},
}

APP_STORE_CONNECT_SCHEMA = {
Expand Down
8 changes: 6 additions & 2 deletions tests/sentry/api/endpoints/test_project_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ def test_redacted_symbol_source_secrets(self, create_audit_entry):
"layout": {
"type": "native",
},
"filetypes": ["pe"],
"filters": {"filetypes": ["pe"]},
"type": "http",
"url": "http://honk.beep",
"username": "honkhonk",
Expand Down Expand Up @@ -1180,7 +1180,7 @@ def test_redacted_symbol_source_secrets_unknown_secret(self, create_audit_entry)
"layout": {
"type": "native",
},
"filetypes": ["pe"],
"filters": {"filetypes": ["pe"]},
"type": "http",
"url": "http://honk.beep",
"username": "honkhonk",
Expand Down Expand Up @@ -1215,6 +1215,8 @@ def symbol_sources(self):
"layout": {
"type": "native",
},
"filters": {"filetypes": ["pe"]},
# FIXME: This is temporarily included for backwards compatibility.
"filetypes": ["pe"],
"type": "http",
"url": "http://honk.beep",
Expand All @@ -1228,6 +1230,8 @@ def symbol_sources(self):
"layout": {
"type": "native",
},
"filters": {"filetypes": ["pe"]},
# FIXME: This is temporarily included for backwards compatibility.
"filetypes": ["pe"],
"type": "http",
"url": "http://honk.beep",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import jsonschema
import pytest
from django.conf import settings

from sentry.lang.native.sources import filter_ignored_sources
from sentry.lang.native.sources import SOURCE_SCHEMA, filter_ignored_sources
from sentry.testutils.helpers import override_options
from sentry.testutils.pytest.fixtures import django_db_all


@django_db_all
def test_validate_builtin_sources():
for source in settings.SENTRY_BUILTIN_SOURCES.values():
jsonschema.validate(source, SOURCE_SCHEMA)


class TestIgnoredSourcesFiltering:
@pytest.fixture
def sources(self):
Expand Down
Loading