fix(privacy): stop matching ads inside ordinary identifiers - #33
Open
Maher-Reven wants to merge 1 commit into
Open
Maher-Reven wants to merge 1 commit into
Maher-Reven wants to merge 1 commit into
Conversation
`(?i)(google.*ads|GADMobileAds|admob)` is unanchored, so `ads` matched inside `loadSdk`, `downloads`, `uploads` and `threads`. Any app that used a non-ad Google SDK and had one of those words on the same line got a CRITICAL §5.1.2 finding, which `--exit-code` turns into a failed build, and the suggested fix was to add an ATT prompt the app does not need. Require an ad-specific token instead. `\badmob` is anchored only at the start so it still covers `AdMobBanner` and `expo-ads-admob` while rejecting words that merely end in those letters. Fixes RevylAI#30
This was referenced Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #30.
Problem
internal/privacy/scanner.gomatched Google Ads/AdMob with:{regexp.MustCompile(`(?i)(google.*ads|GADMobileAds|admob)`), "Google Ads/AdMob"},google.*adsis case-insensitive and unanchored, soadsmatches inside ordinary identifiers —loadSdk,downloads,uploads,threads. One line of Google Sign-In is enough:Google…loadSdk→ theadSinloadSdkcompletes the match.I reproduced it with a fixture containing that single line plus a
PrivacyInfo.xcprivacywithNSPrivacyTracking = false, and no ad SDK anywhere:This is the top severity, so
preflight --exit-codereturnsErrThresholdand fails the build for an app that would pass review — and the attached fix tells the developer to addrequestTrackingAuthorization(), which is itself a §5.1.2 risk in an app that does not track.Fix
Require an ad-specific token:
{regexp.MustCompile(`(?i)(googlemobileads|google-mobile-ads|GADMobileAds|GADApplicationIdentifier|\badmob)`), "Google Ads/AdMob"},\badmobis anchored at the start only, deliberately:\badmob\bwould missAdMobBannerandAdMobInterstitial, which is whatexpo-ads-admobactually exports. Anchoring only the front still rejects any word that merely ends in those letters.After the fix the same fixture reports
GREENLIT — privacy compliance looks good.Testing
Two tests in
internal/privacy/scanner_test.go, in both directions:TestGoogleAdsPatternIgnoresOrdinaryIdentifiers— the four identifier shapes above. All four fail against the old pattern, which I verified by reverting it.TestGoogleAdsPatternStillDetectsRealIntegrations— six real integrations that must keep matching:import GoogleMobileAds,GADMobileAds.sharedInstance(),GADApplicationIdentifier,react-native-google-mobile-ads,expo-ads-admob, and a bareadmobrequire.The second test caught a mistake while I was writing this. My first version also asserted detection in
Info.plist,Podfile,package.jsonandbuild.gradle, and those cases failed —detectLangonly returns a language for.swift,.m,.h,.ts,.tsx,.js,.jsx, so manifest and Gradle files are never scanned for tracking SDKs at all. That is pre-existing behaviour and out of scope here, but it means an AdMob integration declared only inpackage.jsonor aPodfilegoes undetected today. Worth a separate issue if you would like one. I dropped the Android-only alternations I had added for the same reason —.java/.kt/.gradleare never read, so they could never match.go build ./...andgo test ./...are clean.Scope note
The two neighbouring patterns have the same shape and the same defect —
adjust.*sdkmatchesadjustsFontSizeToFitWidthandadjustedContentInsetwheneversdkappears on the line, andunity.*adsmatchesunityWebView.loadThreads(). I have kept this PR to the reported issue; those are in a follow-up so each can be reviewed on its own.Note
Low Risk
Scoped regex change in privacy SDK detection with bidirectional tests; reduces false CRITICAL findings without touching auth or data paths.
Overview
Tightens the privacy scanner’s Google Ads/AdMob detection so apps without ad SDKs no longer get false §5.1.2 ATT findings (and
preflight --exit-codefailures).The old
google.*adsalternation is replaced with ad-specific tokens (googlemobileads,google-mobile-ads,GADMobileAds,GADApplicationIdentifier, and\badmobwith a leading word boundary only soAdMobBannerstill matches). Two regression tests cover benign Google Sign-In /loadSdk-style lines and common real AdMob integration shapes in scanned Swift, ObjC, and JS/TS files.Reviewed by Cursor Bugbot for commit 9d61ff0. Bugbot is set up for automated code reviews on this repo. Configure here.