From d48cb0fe576f9b9da3368ff1f5397ff9008bbfe2 Mon Sep 17 00:00:00 2001 From: LucasZF Date: Tue, 30 Apr 2024 21:07:29 -0300 Subject: [PATCH] Fix: Validate PrivacyInfo.xcprivacy and warn of missing privacy (#152) --- CHANGELOG.md | 77 ++++++++++++++++++- .../Sample.Xamarin.Core/Directory.Build.props | 1 + .../Directory.Build.props | 1 + .../Sample.Xamarin.Mac/Directory.Build.props | 1 + .../Sample.Xamarin.UWP/Directory.Build.props | 1 + .../Sample.Xamarin.iOS/Directory.Build.props | 1 + .../Sample.Xamarin.iOS/PrivacyInfo.xcprivacy | 49 ++++++++++++ .../Sample.Xamarin.iOS.csproj | 39 +++++----- Src/Directory.Build.props | 1 + .../Privacy/SentryPrivacyInfo.xcprivacy | 64 +++++++++++++++ Src/Sentry.Xamarin/Sentry.Xamarin.csproj | 3 + .../buildTransitive/Sentry.Xamarin.targets | 70 +++++++++++++++++ 12 files changed, 289 insertions(+), 19 deletions(-) create mode 100644 Samples/Sample.Xamarin.iOS/PrivacyInfo.xcprivacy create mode 100644 Src/Sentry.Xamarin/Privacy/SentryPrivacyInfo.xcprivacy create mode 100644 Src/Sentry.Xamarin/buildTransitive/Sentry.Xamarin.targets diff --git a/CHANGELOG.md b/CHANGELOG.md index 8996353..33cb492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,80 @@ # Changelog +## Unreleased + +### Fixes + +- Validate PrivacyInfo.xcprivacy and warn users of required missing privacy parameters ([#152](https://github.com/getsentry/sentry-xamarin/pull/152)) + + Due to a requirement by apple, all Projects will require a ([Privacy Manifest file](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files)). Sentry will automatically patch your project with the required fields by Sentry if no privacy manifest file is provided. Otherwise, it will validate your privacy manifest file for the required fields by Sentry and warn you during the build time if the required keys are present or not when building an iOS project. + Below you can find a snippet of the minimum required privacy manifest required by Sentry Xamarin: +```xml + + + + + NSPrivacyCollectedDataTypes + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypeCrashData + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAppFunctionality + + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypePerformanceData + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAppFunctionality + + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypeOtherDiagnosticData + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAppFunctionality + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + + +``` + ## 2.0.0 ### Sentry Self-hosted Compatibility @@ -411,4 +486,4 @@ Also available via NuGet: [Sentry](https://www.nuget.org/packages/Sentry/) [Sentry.Xamarin](https://www.nuget.org/packages/Sentry.Xamarin) -[Sentry.Xamarin.Forms](https://www.nuget.org/packages/Sentry.Xamarin.Forms) +[Sentry.Xamarin.Forms](https://www.nuget.org/packages/Sentry.Xamarin.Forms) \ No newline at end of file diff --git a/Samples/Sample.Xamarin.Core/Directory.Build.props b/Samples/Sample.Xamarin.Core/Directory.Build.props index b3a93f1..552f4c5 100644 --- a/Samples/Sample.Xamarin.Core/Directory.Build.props +++ b/Samples/Sample.Xamarin.Core/Directory.Build.props @@ -2,5 +2,6 @@ + diff --git a/Samples/Sample.Xamarin.Droid/Directory.Build.props b/Samples/Sample.Xamarin.Droid/Directory.Build.props index b3a93f1..552f4c5 100644 --- a/Samples/Sample.Xamarin.Droid/Directory.Build.props +++ b/Samples/Sample.Xamarin.Droid/Directory.Build.props @@ -2,5 +2,6 @@ + diff --git a/Samples/Sample.Xamarin.Mac/Directory.Build.props b/Samples/Sample.Xamarin.Mac/Directory.Build.props index b3a93f1..552f4c5 100644 --- a/Samples/Sample.Xamarin.Mac/Directory.Build.props +++ b/Samples/Sample.Xamarin.Mac/Directory.Build.props @@ -2,5 +2,6 @@ + diff --git a/Samples/Sample.Xamarin.UWP/Directory.Build.props b/Samples/Sample.Xamarin.UWP/Directory.Build.props index b3a93f1..552f4c5 100644 --- a/Samples/Sample.Xamarin.UWP/Directory.Build.props +++ b/Samples/Sample.Xamarin.UWP/Directory.Build.props @@ -2,5 +2,6 @@ + diff --git a/Samples/Sample.Xamarin.iOS/Directory.Build.props b/Samples/Sample.Xamarin.iOS/Directory.Build.props index b3a93f1..552f4c5 100644 --- a/Samples/Sample.Xamarin.iOS/Directory.Build.props +++ b/Samples/Sample.Xamarin.iOS/Directory.Build.props @@ -2,5 +2,6 @@ + diff --git a/Samples/Sample.Xamarin.iOS/PrivacyInfo.xcprivacy b/Samples/Sample.Xamarin.iOS/PrivacyInfo.xcprivacy new file mode 100644 index 0000000..a9d5fb2 --- /dev/null +++ b/Samples/Sample.Xamarin.iOS/PrivacyInfo.xcprivacy @@ -0,0 +1,49 @@ + + + + + Some Key Group + + + test + test + + + test + test + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + + Another Key Group + + + test + test + + + test + test + + + + \ No newline at end of file diff --git a/Samples/Sample.Xamarin.iOS/Sample.Xamarin.iOS.csproj b/Samples/Sample.Xamarin.iOS/Sample.Xamarin.iOS.csproj index 5d38afb..2a0531d 100644 --- a/Samples/Sample.Xamarin.iOS/Sample.Xamarin.iOS.csproj +++ b/Samples/Sample.Xamarin.iOS/Sample.Xamarin.iOS.csproj @@ -29,19 +29,19 @@ true - - - sentry-sdks - sentry-xamarin - + + sentry-sdks + sentry-xamarin + - - true - - true - --wait + + true + + true + --wait none true bin\iPhoneSimulator\Release @@ -49,8 +49,8 @@ 4 None x86_64 - - + + true @@ -76,9 +76,9 @@ Each of the below features are opt-in. Enable the features you wish to use. --> - - true - + + true + true none true @@ -88,8 +88,8 @@ ARM64 iPhone Developer Entitlements.plist - - + + @@ -101,6 +101,9 @@ + + Always + @@ -193,4 +196,4 @@ - + \ No newline at end of file diff --git a/Src/Directory.Build.props b/Src/Directory.Build.props index 7ddbfde..4936559 100644 --- a/Src/Directory.Build.props +++ b/Src/Directory.Build.props @@ -2,6 +2,7 @@ + diff --git a/Src/Sentry.Xamarin/Privacy/SentryPrivacyInfo.xcprivacy b/Src/Sentry.Xamarin/Privacy/SentryPrivacyInfo.xcprivacy new file mode 100644 index 0000000..35c9e93 --- /dev/null +++ b/Src/Sentry.Xamarin/Privacy/SentryPrivacyInfo.xcprivacy @@ -0,0 +1,64 @@ + + + + + NSPrivacyCollectedDataTypes + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypeCrashData + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAppFunctionality + + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypePerformanceData + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAppFunctionality + + + + NSPrivacyCollectedDataType + NSPrivacyCollectedDataTypeOtherDiagnosticData + NSPrivacyCollectedDataTypeLinked + + NSPrivacyCollectedDataTypeTracking + + NSPrivacyCollectedDataTypePurposes + + NSPrivacyCollectedDataTypePurposeAppFunctionality + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + + \ No newline at end of file diff --git a/Src/Sentry.Xamarin/Sentry.Xamarin.csproj b/Src/Sentry.Xamarin/Sentry.Xamarin.csproj index 49156d0..bfcfc46 100644 --- a/Src/Sentry.Xamarin/Sentry.Xamarin.csproj +++ b/Src/Sentry.Xamarin/Sentry.Xamarin.csproj @@ -46,6 +46,9 @@ + + + diff --git a/Src/Sentry.Xamarin/buildTransitive/Sentry.Xamarin.targets b/Src/Sentry.Xamarin/buildTransitive/Sentry.Xamarin.targets new file mode 100644 index 0000000..0b7eeb4 --- /dev/null +++ b/Src/Sentry.Xamarin/buildTransitive/Sentry.Xamarin.targets @@ -0,0 +1,70 @@ + + + + + PrivacyInfo.xcprivacy + true + + + + + + @(ProjectPrivacyInfoList->'%(FullPath)') + + + + + + false + false + + + \s*NSPrivacyAccessedAPIType\s*<\/\s*key\s*>]]> + + + \s*NSPrivacyAccessedAPICategoryFileTimestamp<\/\s*string\s*>]]> + + + \s*NSPrivacyAccessedAPICategorySystemBootTime<\/\s*string\s*>]]> + + + \s*NSPrivacyAccessedAPITypeReasons\s*<\/\s*key\s*>\s*<\s*array\s*>\s*<\s*string\s*>([^<]+)<\/\s*string\s*>\s*<\/\s*array\s*>\s*]]> + + + + + + + + + + true + true + + For more information, visit: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files + Or https://docs.sentry.io/platforms/dotnet/guides/xamarin/data-management/apple-privacy-manifest/ + + + + + + + + + + + $(MSBuildThisFileDirectory)../Privacy/SentryPrivacyInfo.xcprivacy + + + + $(PrivacyInfoFileName) + Always + + + +