Skip to content

Commit

Permalink
Uplift of #17179 (squashed) to release
Browse files Browse the repository at this point in the history
  • Loading branch information
goodov committed Jan 12, 2024
1 parent 1713666 commit 0ffcc37
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 316 deletions.
2 changes: 0 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ vars = {
}

deps = {
"vendor/requests": "https://github.com/kennethreitz/requests@e4d59bedfd3c7f4f254f4f5d036587bcd8152458",
"vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b",
"vendor/python-patch": "https://github.com/brave/python-patch@d8880110be6554686bc08261766538c2926d4e82",
"vendor/omaha": {
"url": "https://github.com/brave/omaha.git@138c95d58f9c41113f7e0dd5acdbcaab8be20df9",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/mojo/public/tools/bindings/generators/mojom_ts_generator.py b/mojo/public/tools/bindings/generators/mojom_ts_generator.py
index d8e0cf30486690b5aa33906985642dc8f7f762f5..1c43796152811d020370aa0a42bc4fddf8b05c06 100644
--- a/mojo/public/tools/bindings/generators/mojom_ts_generator.py
+++ b/mojo/public/tools/bindings/generators/mojom_ts_generator.py
@@ -175,8 +175,10 @@ def _GetWebUiModulePath(module):
path. Otherwise, returned paths always end in a '/' and begin with either
`chrome://resources/` or a '/'."""
path = module.metadata.get('webui_module_path')
- if path is None or path == '/':
- return path
+ if path is None:
+ return None
+ if path == '' or path == '/':
+ return '/'
if _IsAbsoluteChromeResourcesPath(path):
return path.rstrip('/') + '/'
return '/{}/'.format(path.strip('/'))
51 changes: 23 additions & 28 deletions script/audit_deps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
#!/usr/bin/env vpython3
# pylint: disable=line-too-long

"""This script runs `npm audit' and `cargo audit' on relevant paths in the
repo."""

Expand All @@ -14,26 +13,25 @@
import os
import subprocess
import sys
import urllib.request

import requests

def get_remote_audit_config(
url = "https://raw.githubusercontent.com/brave/audit-config/main/config.json",
retry = 3):
"""Fetch additional audit configuration"""
s = requests.Session()
s.mount(url, requests.adapters.HTTPAdapter(max_retries=retry))
return s.get(url).json()
url="https://raw.githubusercontent.com/brave/audit-config/main/config.json"
):
return json.loads(urllib.request.urlopen(url).read().decode("utf-8"))


REMOTE_AUDIT_CONFIG = get_remote_audit_config()
IGNORED_CARGO_ADVISORIES = [e["advisory"] for e in REMOTE_AUDIT_CONFIG["ignore"]["cargo"]]
IGNORED_NPM_ADVISORIES = [e["advisory"] for e in REMOTE_AUDIT_CONFIG["ignore"]["npm"]]
IGNORED_CARGO_ADVISORIES = [
e["advisory"] for e in REMOTE_AUDIT_CONFIG["ignore"]["cargo"]
]
IGNORED_NPM_ADVISORIES = [
e["advisory"] for e in REMOTE_AUDIT_CONFIG["ignore"]["npm"]
]

# Use all (sub)paths except these for npm audit.
NPM_EXCLUDE_PATHS = [
'build',
os.path.join('node_modules')
]
NPM_EXCLUDE_PATHS = ['build', os.path.join('node_modules')]

# Only check Cargo.lock for this path.
CARGO_INCLUDE_PATH = os.path.join('third_party', 'rust')
Expand All @@ -43,24 +41,21 @@ def main():
"""Audit a specified path, or the whole project."""

if len(IGNORED_NPM_ADVISORIES) > 0:
print(
f"Ignoring NPM advisories "
f"{', '.join(map(str, IGNORED_NPM_ADVISORIES))}"
)
print(f"Ignoring NPM advisories "
f"{', '.join(map(str, IGNORED_NPM_ADVISORIES))}")
if len(IGNORED_CARGO_ADVISORIES) > 0:
print(
f"Ignoring Cargo advisories "
f"{', '.join(map(str, IGNORED_CARGO_ADVISORIES))}"
)
print(f"Ignoring Cargo advisories "
f"{', '.join(map(str, IGNORED_CARGO_ADVISORIES))}")

args = parse_args()
errors = 0

if args.input_dir:
return audit_path(os.path.abspath(args.input_dir), args)

for path in [os.path.dirname(os.path.dirname(args.source_root)),
args.source_root]:
for path in [
os.path.dirname(os.path.dirname(args.source_root)), args.source_root
]:
errors += audit_path(path, args)

for dir_path, dirs, _ in os.walk(args.source_root):
Expand Down Expand Up @@ -101,8 +96,7 @@ def npm_audit_deps(path, args):
# Don't support npm audit --production until dev dependencies are
# correctly identified in package.json
print('npm audit --production not supported; auditing dev dependencies')
audit_process = subprocess.Popen(
npm_args, stdout=subprocess.PIPE, cwd=path)
audit_process = subprocess.Popen(npm_args, stdout=subprocess.PIPE, cwd=path)
output, _ = audit_process.communicate()

try:
Expand Down Expand Up @@ -172,7 +166,8 @@ def parse_args():

parser = argparse.ArgumentParser(description='Audit brave-core npm deps')
parser.add_argument('input_dir', nargs='?', help='Directory to check')
parser.add_argument('--source_root', required=True,
parser.add_argument('--source_root',
required=True,
help='Full path of the src/brave directory')
parser.add_argument('--cargo_audit_exe', required=True)
parser.add_argument('--audit_dev_deps',
Expand Down
28 changes: 1 addition & 27 deletions script/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,20 @@
import os
import sys

from lib.config import PLATFORM, SOURCE_ROOT, \
enable_verbose_mode, is_verbose_mode
from lib.config import PLATFORM, enable_verbose_mode, is_verbose_mode
from lib.util import execute_stdout, scoped_cwd


VENDOR_DIR = os.path.join(SOURCE_ROOT, 'vendor')
PYTHON_26_URL = 'https://chromium.googlesource.com/chromium/deps/python_26'

NPM = 'npm'
if sys.platform in ['win32', 'cygwin']:
NPM += '.cmd'


def main():
os.chdir(SOURCE_ROOT)

args = parse_args()
if not args.yes and PLATFORM != 'win32':
check_root()
if args.verbose:
enable_verbose_mode()
if sys.platform == 'cygwin':
update_win32_python()

setup_python_libs()
update_node_modules('.')


Expand All @@ -45,24 +34,15 @@ def parse_args():
action='store_true',
help='Run non-interactively by assuming "yes" to all '
'prompts.')

return parser.parse_args()


def check_root():
if os.geteuid() == 0: # pylint: disable=no-member
print("We suggest not running this as root, unless you're really sure.")
choice = input("Do you want to continue? [y/N]: ")
if choice not in ('y', 'Y'):
sys.exit(0)


def setup_python_libs():
for lib in ('requests', 'boto'):
with scoped_cwd(os.path.join(VENDOR_DIR, lib)):
execute_stdout([sys.executable, 'setup.py', 'build'])


def update_node_modules(dirname, env=None):
if env is None:
env = os.environ.copy()
Expand All @@ -73,11 +53,5 @@ def update_node_modules(dirname, env=None):
execute_stdout(args, env)


def update_win32_python():
with scoped_cwd(VENDOR_DIR):
if not os.path.exists('python_26'):
execute_stdout(['git', 'clone', PYTHON_26_URL])


if __name__ == '__main__':
sys.exit(main())
10 changes: 0 additions & 10 deletions script/brave_license_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ def AddBraveCredits(root, prune_paths, special_cases, prune_dirs,
"URL": "https://github.com/brave-intl/bat-native-bip39wally-core",
"License": "MIT",
},
os.path.join('brave', 'vendor', 'boto'): {
"Name": "boto",
"URL": "https://github.com/boto/boto",
"License": "MIT",
},
os.path.join('brave', 'vendor', 'brave-extension'): {
"Name": "Brave Only Extension",
"URL": "https://github.com/brave/brave-extension",
Expand Down Expand Up @@ -135,11 +130,6 @@ def AddBraveCredits(root, prune_paths, special_cases, prune_dirs,
"License": "MIT",
"License File": ["/brave/vendor/python-patch/doc/LICENSE"],
},
os.path.join('brave', 'vendor', 'requests'): {
"Name": "Requests",
"URL": "https://github.com/psf/requests",
"License": "Apache-2.0",
},
os.path.join('brave', 'vendor', 'sparkle'): {
"Name": "Sparkle",
"URL": "https://github.com/brave/Sparkle",
Expand Down
61 changes: 0 additions & 61 deletions script/bump-version.py

This file was deleted.

22 changes: 0 additions & 22 deletions script/lib/connect.py

This file was deleted.

Loading

0 comments on commit 0ffcc37

Please sign in to comment.