1
0
Fork 0
mirror of synced 2024-05-16 18:32:41 +12:00

Disable searching for existing chrome user profiles by default

This commit is contained in:
Nick Sweeting 2024-03-14 00:58:45 -07:00 committed by GitHub
parent 62183b4c85
commit 3512dc7e60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -500,7 +500,7 @@ DYNAMIC_CONFIG_SCHEMA: ConfigDefaultDict = {
'LOGS_DIR': {'default': lambda c: c['OUTPUT_DIR'] / LOGS_DIR_NAME}, 'LOGS_DIR': {'default': lambda c: c['OUTPUT_DIR'] / LOGS_DIR_NAME},
'CONFIG_FILE': {'default': lambda c: Path(c['CONFIG_FILE']).resolve() if c['CONFIG_FILE'] else c['OUTPUT_DIR'] / CONFIG_FILENAME}, 'CONFIG_FILE': {'default': lambda c: Path(c['CONFIG_FILE']).resolve() if c['CONFIG_FILE'] else c['OUTPUT_DIR'] / CONFIG_FILENAME},
'COOKIES_FILE': {'default': lambda c: c['COOKIES_FILE'] and Path(c['COOKIES_FILE']).resolve()}, 'COOKIES_FILE': {'default': lambda c: c['COOKIES_FILE'] and Path(c['COOKIES_FILE']).resolve()},
'CHROME_USER_DATA_DIR': {'default': lambda c: find_chrome_data_dir() if c['CHROME_USER_DATA_DIR'] is None else (Path(c['CHROME_USER_DATA_DIR']).resolve() if c['CHROME_USER_DATA_DIR'] else None)}, # None means unset, so we autodetect it with find_chrome_Data_dir(), but emptystring '' means user manually set it to '', and we should store it as None 'CHROME_USER_DATA_DIR': {'default': lambda c: Path(c['CHROME_USER_DATA_DIR']).resolve() if c['CHROME_USER_DATA_DIR'] else None},
'URL_DENYLIST_PTN': {'default': lambda c: c['URL_DENYLIST'] and re.compile(c['URL_DENYLIST'] or '', ALLOWDENYLIST_REGEX_FLAGS)}, 'URL_DENYLIST_PTN': {'default': lambda c: c['URL_DENYLIST'] and re.compile(c['URL_DENYLIST'] or '', ALLOWDENYLIST_REGEX_FLAGS)},
'URL_ALLOWLIST_PTN': {'default': lambda c: c['URL_ALLOWLIST'] and re.compile(c['URL_ALLOWLIST'] or '', ALLOWDENYLIST_REGEX_FLAGS)}, 'URL_ALLOWLIST_PTN': {'default': lambda c: c['URL_ALLOWLIST'] and re.compile(c['URL_ALLOWLIST'] or '', ALLOWDENYLIST_REGEX_FLAGS)},
'DIR_OUTPUT_PERMISSIONS': {'default': lambda c: c['OUTPUT_PERMISSIONS'].replace('6', '7').replace('4', '5')}, # exec is always needed to list directories 'DIR_OUTPUT_PERMISSIONS': {'default': lambda c: c['OUTPUT_PERMISSIONS'].replace('6', '7').replace('4', '5')}, # exec is always needed to list directories
@ -910,27 +910,36 @@ def find_chrome_binary() -> Optional[str]:
def find_chrome_data_dir() -> Optional[str]: def find_chrome_data_dir() -> Optional[str]:
"""find any installed chrome user data directories in the default locations""" """find any installed chrome user data directories in the default locations"""
# Precedence: Chromium, Chrome, Beta, Canary, Unstable, Dev # deprecated because this is DANGEROUS, do not re-implement/uncomment this behavior.
# make sure data dir finding precedence order always matches binary finding order
default_profile_paths = ( # Going forward we want to discourage people from using their main chrome profile for archiving.
'~/.config/chromium', # Session tokens, personal data, and cookies are often returned in server responses,
'~/Library/Application Support/Chromium', # when they get archived, they are essentially burned as anyone who can view the archive
'~/AppData/Local/Chromium/User Data', # can use that data to masquerade as the logged-in user that did the archiving.
'~/.config/chrome', # For this reason users should always create dedicated burner profiles for archiving and not use
'~/.config/google-chrome', # their daily driver main accounts.
'~/Library/Application Support/Google/Chrome',
'~/AppData/Local/Google/Chrome/User Data', # # Precedence: Chromium, Chrome, Beta, Canary, Unstable, Dev
'~/.config/google-chrome-stable', # # make sure data dir finding precedence order always matches binary finding order
'~/.config/google-chrome-beta', # default_profile_paths = (
'~/Library/Application Support/Google/Chrome Canary', # '~/.config/chromium',
'~/AppData/Local/Google/Chrome SxS/User Data', # '~/Library/Application Support/Chromium',
'~/.config/google-chrome-unstable', # '~/AppData/Local/Chromium/User Data',
'~/.config/google-chrome-dev', # '~/.config/chrome',
) # '~/.config/google-chrome',
for path in default_profile_paths: # '~/Library/Application Support/Google/Chrome',
full_path = Path(path).resolve() # '~/AppData/Local/Google/Chrome/User Data',
if full_path.exists(): # '~/.config/google-chrome-stable',
return full_path # '~/.config/google-chrome-beta',
# '~/Library/Application Support/Google/Chrome Canary',
# '~/AppData/Local/Google/Chrome SxS/User Data',
# '~/.config/google-chrome-unstable',
# '~/.config/google-chrome-dev',
# )
# for path in default_profile_paths:
# full_path = Path(path).resolve()
# if full_path.exists():
# return full_path
return None return None
def wget_supports_compression(config): def wget_supports_compression(config):