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

Add warning about Brave's "referral code" system #2271

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

foxt
Copy link
Contributor

@foxt foxt commented Sep 2, 2023

Changes proposed in this PR:

Add a warning mentioning Brave's promo code system.

  • I have disclosed any relevant conflicts of interest in my post.
  • I agree to grant Privacy Guides a perpetual, worldwide, non-exclusive, transferable, royalty-free, irrevocable license with the right to sublicense such rights through multiple tiers of sublicensees, to reproduce, modify, display, perform, relicense, and distribute my contribution as part of this project.
  • I am the sole author of this work.
  • I agree to the Community Code of Conduct.

@netlify
Copy link

netlify bot commented Sep 2, 2023

Deploy Preview for privacyguides ready!

Name Link
🔨 Latest commit aa9fed4
🔍 Latest deploy log https://app.netlify.com/sites/privacyguides/deploys/65378ea7b5980a00081ac10b
😎 Deploy Preview https://deploy-preview-2271.preview.privacyguides.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
4 paths audited
Performance: 84
Accessibility: 91
Best Practices: 98
SEO: 88
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@foxt
Copy link
Contributor Author

foxt commented Sep 2, 2023

For reference, here's a copy of the postinstall script from the current macOS installer.

#!/bin/bash
# This postinstall script is run on macOS pkg installers

# Extract a referral / promo code from the installer path of the format /dir/path/Setup-Brave-Anything-xxx001.pkg
# where the promo code would be xxx001
installerPath=$1
installationPath=$2

promoCode=""

# Detect if installer contained a referral promotion code within the filename
standardPromoCodeRegex='[a-zA-Z0-9]{3}[0-9]{3}'
installerPathPromoCodeRegex=".+-((${standardPromoCodeRegex})|([a-zA-Z]{1,}-[a-zA-Z]{1,}))([[:blank:]]?\([0-9]+\))?\.pkg$"
if [[ $installerPath =~ $installerPathPromoCodeRegex ]]; then
  n=${#BASH_REMATCH[*]}
  rematch=${BASH_REMATCH[1]}
  if [[ $n -ge 1 && ! ${rematch} =~ ^Browser-.*$ ]]; then
    promoCode=${rematch}
    if [[ $promoCode =~ $standardPromoCodeRegex ]]; then
      promoCode=$(tr a-z A-Z <<< $promoCode)
    fi
    echo "Got promo code: $promoCode"
  fi
fi

# Get a channel-safe version of the application name (based on the
# .pkg file name)
if [ "$promoCode" == "" ]; then
  appName=$(basename "$1" | sed "s/.pkg//" | sed "s/ /\-/g")
else
  appName=$(basename "$1" | sed "s/.pkg//" | sed "s/ /\-/g" | perl -ple "s/-${promoCode}//i")
fi

appNameNoDash=$(echo $appName | sed "s/-/ /g")
installationAppPath="$installationPath/${appNameNoDash}.app"
userDataDir="$HOME/Library/Application Support/BraveSoftware"
appDataDir="$userDataDir/${appName}"
promoCodePath="$appDataDir/promoCode"

# pkg runs this script as root so we need to get current username
userName="$USER"

echo "Installer path is: $installerPath"
echo "Username is: $userName"
echo "Installation app path is: $installationAppPath"

# Fix the permissions on installed .app so that updater has permissions to write new contents.
# By default pkg will install the .app with root:wheel owner and 'drwxr-xr-x' permission.
# We'll allow all admin users of the machine permissions to update the app, as well as the installing-user
# (who may not be an admin).
sudo chmod -R 775 "$installationAppPath"
sudo chown -R $userName "$installationAppPath"
sudo chgrp -R admin "$installationAppPath"

# handle promoCode specific logic (if promoCode was found)
if [ "$promoCode" != "" ]; then
  echo "Writing to user data directory at: $promoCodePath"
  mkdir -p "$appDataDir"
  echo "$promoCode" > "$promoCodePath"
  # fix permissions
  sudo chown -R "$userName" "$userDataDir"
fi

exit 0

I noticed that Brave on macOS is distributed as pkg file, rather than a plain .app in a disk image. This is uncommon. As far as I know the other browser to do this is Microsoft Edge, which used a pkg installer to register its telemetry agent to launch at boot without even opening the browser.

@dngray dngray added the c:browsers browsers, add-ons, and related topics label Sep 11, 2023
@dngray
Copy link
Member

dngray commented Sep 11, 2023

Hmm, I wasn't aware of this. I wonder if this is a bit like what Mozilla do if you download from the website and not the ftp

@freddy-m freddy-m requested a review from dngray September 26, 2023 22:20
@jonaharagon jonaharagon changed the title include warning about brave's promocode system Add warning for Brave's "promo code" system Oct 6, 2023
@jonaharagon jonaharagon added this to the v3.17 milestone Oct 14, 2023
@jonaharagon jonaharagon changed the title Add warning for Brave's "promo code" system Add warning about Brave's "referral code" system Oct 24, 2023
Copy link
Member

@jonaharagon jonaharagon left a comment

Choose a reason for hiding this comment

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

Approving this now with or without the suggestion in #2271 (comment) (I'll let @dngray decide if he wants to add that note on macOS downloads)

Copy link
Member

@freddy-m freddy-m left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Jonah Aragon <jonah@triplebit.net>
Signed-off-by: Daniel Gray <dngray@privacyguides.org>
Signed-off-by: blacklight447 <github.ef27z@simplelogin.com>
@dngray dngray merged commit aa9fed4 into privacyguides:main Oct 24, 2023
@privacyguides-bot
Copy link
Collaborator

This pull request has been mentioned on Privacy Guides. There might be relevant details there:

https://discuss.privacyguides.net/t/v3-17/15136/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c:browsers browsers, add-ons, and related topics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants