brizental pushed to branch main at The Tor Project / Applications / tor-browser-build

Commits:

8 changed files:

Changes:

  • projects/application-services/README.md
    ... ... @@ -46,6 +46,15 @@ We keep the list of files to download in `gradle-dependencies-list.txt`.
    46 46
     A procedure to create this file is documented in
    
    47 47
     [tor-browser-build#40855](https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/issues/40855#note_2906041).
    
    48 48
     
    
    49
    +## Other dependencies
    
    50
    +
    
    51
    +Finally, Application Services depends on
    
    52
    +[NSS](https://firefox-source-docs.mozilla.org/security/nss/index.html).
    
    53
    +We used to have a separate tor-browser-build project for it, but it was
    
    54
    +almost an exact copy of the script included in this repository.
    
    55
    +Keeping it updated wasn't trivial, so we decided to run Mozilla's scripts
    
    56
    +instead.
    
    57
    +
    
    49 58
     # Caveats
    
    50 59
     
    
    51 60
     ## Git repository information
    

  • projects/application-services/a-s-noop.diff
    1 1
     diff --git a/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/Config.kt b/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/Config.kt
    
    2
    -index 78c16dd0..d2615fa7 100644
    
    2
    +index 78c16dd0a..d2615fa74 100644
    
    3 3
     --- a/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/Config.kt
    
    4 4
     +++ b/components/fxa-client/android/src/main/java/mozilla/appservices/fxaclient/Config.kt
    
    5 5
     @@ -13,4 +13,5 @@ fun FxaServer.contentUrl() = when (this) {
    
    ... ... @@ -9,7 +9,7 @@ index 78c16dd0..d2615fa7 100644
    9 9
     +    is FxaServer.__NOOP -> ""
    
    10 10
      }
    
    11 11
     diff --git a/components/nimbus/android/src/main/java/org/mozilla/experiments/nimbus/Nimbus.kt b/components/nimbus/android/src/main/java/org/mozilla/experiments/nimbus/Nimbus.kt
    
    12
    -index 8c05be9c..6bf2ec15 100644
    
    12
    +index 8c05be9cf..6bf2ec15d 100644
    
    13 13
     --- a/components/nimbus/android/src/main/java/org/mozilla/experiments/nimbus/Nimbus.kt
    
    14 14
     +++ b/components/nimbus/android/src/main/java/org/mozilla/experiments/nimbus/Nimbus.kt
    
    15 15
     @@ -532,6 +532,8 @@ open class Nimbus(
    
    ... ... @@ -21,41 +21,97 @@ index 8c05be9c..6bf2ec15 100644
    21 21
                  }
    
    22 22
              }
    
    23 23
          }
    
    24
    -diff --git a/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt b/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt
    
    25
    -index 282f4e90..db8b00a3 100644
    
    26
    ---- a/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt
    
    27
    -+++ b/components/places/android/src/main/java/mozilla/appservices/places/PlacesConnection.kt
    
    28
    -@@ -289,6 +289,7 @@ internal fun VisitType.toInt(): Int {
    
    29
    -         VisitType.FRAMED_LINK -> 8
    
    30
    -         VisitType.RELOAD -> 9
    
    31
    -         VisitType.UPDATE_PLACE -> 10
    
    32
    -+        VisitType.__NOOP -> -1
    
    33
    -     }
    
    34
    - }
    
    24
    +diff --git a/megazords/full/Cargo.toml b/megazords/full/Cargo.toml
    
    25
    +index 75f44a812..a51c0643b 100644
    
    26
    +--- a/megazords/full/Cargo.toml
    
    27
    ++++ b/megazords/full/Cargo.toml
    
    28
    +@@ -9,21 +9,21 @@ license = "MPL-2.0"9345a6ea
    
    29
    + crate-type = ["cdylib"]
    
    35 30
     
    
    36
    -diff --git a/megazords/full/android/build.gradle b/megazords/full/android/build.gradle
    
    37
    -index 822ce180..ccdc6c8a 100644
    
    38
    ---- a/megazords/full/android/build.gradle
    
    39
    -+++ b/megazords/full/android/build.gradle
    
    40
    -@@ -54,6 +54,8 @@ configurations {
    
    41
    - }
    
    31
    + [dependencies]
    
    32
    +-fxa-client = { path = "../../components/fxa-client" }
    
    33
    +-logins = { path = "../../components/logins" }
    
    34
    +-tabs = { path = "../../components/tabs/" }
    
    35
    +-sync_manager = { path = "../../components/sync_manager/" }
    
    36
    ++# fxa-client = { path = "../../components/fxa-client" }
    
    37
    ++# logins = { path = "../../components/logins" }
    
    38
    ++# tabs = { path = "../../components/tabs/" }
    
    39
    ++# sync_manager = { path = "../../components/sync_manager/" }
    
    40
    + # TODO: Uncomment this code when webext-storage component is integrated in android
    
    41
    + # webext-storage = { path = "../../components/webext-storage/" }
    
    42
    + places = { path = "../../components/places" }
    
    43
    +-push = { path = "../../components/push" }
    
    44
    +-remote_settings = { path = "../../components/remote_settings" }
    
    45
    +-rust-log-forwarder = { path = "../../components/support/rust-log-forwarder" }
    
    46
    +-viaduct = { path = "../../components/viaduct" }
    
    47
    +-nimbus-sdk = { path = "../../components/nimbus" }
    
    48
    +-autofill = { path = "../../components/autofill" }
    
    49
    +-crashtest = { path = "../../components/crashtest" }
    
    50
    +-error-support = { path = "../../components/support/error" }
    
    51
    +-suggest = { path = "../../components/suggest" }
    
    52
    ++# push = { path = "../../components/push" }
    
    53
    ++# remote_settings = { path = "../../components/remote_settings" }
    
    54
    ++# rust-log-forwarder = { path = "../../components/support/rust-log-forwarder" }
    
    55
    ++# viaduct = { path = "../../components/viaduct" }
    
    56
    ++# nimbus-sdk = { path = "../../components/nimbus" }
    
    57
    ++# autofill = { path = "../../components/autofill" }
    
    58
    ++# crashtest = { path = "../../components/crashtest" }
    
    59
    ++# error-support = { path = "../../components/support/error" }
    
    60
    ++# suggest = { path = "../../components/suggest" }
    
    42 61
     
    
    43
    - cargo {
    
    44
    -+    cargoCommand = "${rootDir}/megazords/full/android/cargo-no-build.sh"
    
    45
    -+
    
    46
    -     // The directory of the Cargo.toml to build.
    
    47
    -     module = '..'
    
    62
    + lazy_static = "1.4"
    
    63
    +diff --git a/megazords/full/src/lib.rs b/megazords/full/src/lib.rs
    
    64
    +index 01d1be98b..a68eb647f 100644
    
    65
    +--- a/megazords/full/src/lib.rs
    
    66
    ++++ b/megazords/full/src/lib.rs
    
    67
    +@@ -8,20 +8,20 @@
    
    68
    + use std::ffi::CString;
    
    69
    + use std::os::raw::c_char;
    
    70
    +
    
    71
    +-pub use autofill;
    
    72
    +-pub use crashtest;
    
    73
    +-pub use error_support;
    
    74
    +-pub use fxa_client;
    
    75
    +-pub use logins;
    
    76
    +-pub use nimbus;
    
    77
    ++// pub use autofill;
    
    78
    ++// pub use crashtest;
    
    79
    ++// pub use error_support;
    
    80
    ++// pub use fxa_client;
    
    81
    ++// pub use logins;
    
    82
    ++// pub use nimbus;
    
    83
    + pub use places;
    
    84
    +-pub use push;
    
    85
    +-pub use remote_settings;
    
    86
    +-pub use rust_log_forwarder;
    
    87
    +-pub use suggest;
    
    88
    +-pub use sync_manager;
    
    89
    +-pub use tabs;
    
    90
    +-pub use viaduct;
    
    91
    ++// pub use push;
    
    92
    ++// pub use remote_settings;
    
    93
    ++// pub use rust_log_forwarder;
    
    94
    ++// pub use suggest;
    
    95
    ++// pub use sync_manager;
    
    96
    ++// pub use tabs;
    
    97
    ++// pub use viaduct;
    
    98
    + // TODO: Uncomment this code when webext-storage component is integrated in android
    
    99
    + // pub use webext_storage;
    
    48 100
     
    
    49 101
     diff --git a/publish.gradle b/publish.gradle
    
    50
    -index 71f5d55b..027665ff 100644
    
    102
    +index 71f5d55b9..659e26489 100644
    
    51 103
     --- a/publish.gradle
    
    52 104
     +++ b/publish.gradle
    
    53
    -@@ -194,7 +194,7 @@ ext.configureUniFFIBindgen = { udlFilePath ->
    
    105
    +@@ -194,7 +194,11 @@ ext.configureUniFFIBindgen = { udlFilePath ->
    
    54 106
              def uniffiGeneratedPath = "generated/source/uniffi/${variant.name}/java"
    
    55 107
              def t = tasks.register("generate${variant.name.capitalize()}UniFFIBindings", Exec) {
    
    56 108
                  workingDir project.rootDir
    
    57 109
     -            commandLine '/usr/bin/env', 'cargo', 'uniffi-bindgen', 'generate', "${project.projectDir}/${udlFilePath}", '--language', 'kotlin', '--out-dir', "${buildDir}/${uniffiGeneratedPath}"
    
    58
    -+            commandLine '/usr/bin/env', "${rootProject.projectDir}/uniffi-rs/uniffi-bindgen", 'generate', "${project.projectDir}/${udlFilePath}", '--language', 'kotlin', '--out-dir', "${buildDir}/${uniffiGeneratedPath}"
    
    110
    ++            if (udlFilePath.contains("places")) {
    
    111
    ++                commandLine '/usr/bin/env', 'cargo', 'uniffi-bindgen', 'generate', "${project.projectDir}/${udlFilePath}", '--language', 'kotlin', '--out-dir', "${buildDir}/${uniffiGeneratedPath}"
    
    112
    ++            } else {
    
    113
    ++                commandLine '/usr/bin/env', "${rootProject.projectDir}/uniffi-rs/uniffi-bindgen", 'generate', "${project.projectDir}/${udlFilePath}", '--language', 'kotlin', '--out-dir', "${buildDir}/${uniffiGeneratedPath}"
    
    114
    ++            }
    
    59 115
                  outputs.dir "${buildDir}/${uniffiGeneratedPath}"
    
    60 116
                  // Re-generate if the interface definition changes.
    
    61 117
                  inputs.file "${project.projectDir}/${udlFilePath}"

  • projects/application-services/apply-bug-13028.diff
    1
    +diff --git a/libs/build-all.sh b/libs/build-all.sh
    
    2
    +index 650c1299..6c4e5404 100755
    
    3
    +--- a/libs/build-all.sh
    
    4
    ++++ b/libs/build-all.sh
    
    5
    +@@ -128,6 +128,15 @@ echo $'\
    
    6
    +      fi
    
    7
    + ' | patch "${NSS_SRC_PATH}/nspr/configure"
    
    8
    + 
    
    9
    ++rm -f python
    
    10
    ++ln -s /usr/bin/python3 python
    
    11
    ++export PATH=$(pwd):$PATH
    
    12
    ++patch_13028=$(realpath bug_13028.patch)
    
    13
    ++pushd $NSS_SRC_PATH
    
    14
    ++# Apply our proxy bypass defense-in-depth here as well to be on the safe side.
    
    15
    ++patch -p2 < $patch_13028
    
    16
    ++popd
    
    17
    ++
    
    18
    + if [[ "${PLATFORM}" == "ios" ]]
    
    19
    + then
    
    20
    +   ./build-all-ios.sh "${SQLCIPHER_SRC_PATH}" "${NSS_SRC_PATH}"

  • projects/application-services/bug_13028.patch
    1
    +From 2f0888c348561249d3083555db33c5619840dbfa Mon Sep 17 00:00:00 2001
    
    2
    +From: Mike Perry <mikeperry-git@torproject.org>
    
    3
    +Date: Mon, 29 Sep 2014 14:30:19 -0700
    
    4
    +Subject: [PATCH] Bug 13028: Prevent potential proxy bypass cases.
    
    5
    +
    
    6
    +It looks like these cases should only be invoked in the NSS command line
    
    7
    +tools, and not the browser, but I decided to patch them anyway because there
    
    8
    +literally is a maze of network function pointers being passed around, and it's
    
    9
    +very hard to tell if some random code might not pass in the proper proxied
    
    10
    +versions of the networking code here by accident.
    
    11
    +
    
    12
    +diff --git a/security/nss/lib/certhigh/ocsp.c b/security/nss/lib/certhigh/ocsp.c
    
    13
    +index cea8456606bf..86fa971cfbef 100644
    
    14
    +--- a/security/nss/lib/certhigh/ocsp.c
    
    15
    ++++ b/security/nss/lib/certhigh/ocsp.c
    
    16
    +@@ -2932,6 +2932,14 @@ ocsp_ConnectToHost(const char *host, PRUint16 port)
    
    17
    +     PRNetAddr addr;
    
    18
    +     char *netdbbuf = NULL;
    
    19
    + 
    
    20
    ++    // XXX: Do we need a unittest ifdef here? We don't want to break the tests, but
    
    21
    ++    // we want to ensure nothing can ever hit this code in production.
    
    22
    ++#if 1
    
    23
    ++    printf("Tor Browser BUG: Attempted OSCP direct connect to %s, port %u\n", host,
    
    24
    ++            port);
    
    25
    ++    goto loser;
    
    26
    ++#endif
    
    27
    ++
    
    28
    +     sock = PR_NewTCPSocket();
    
    29
    +     if (sock == NULL)
    
    30
    +         goto loser;
    
    31
    +diff --git a/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_socket.c b/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_socket.c
    
    32
    +index e8698376b5be..85791d84a932 100644
    
    33
    +--- a/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_socket.c
    
    34
    ++++ b/security/nss/lib/libpkix/pkix_pl_nss/module/pkix_pl_socket.c
    
    35
    +@@ -1334,6 +1334,13 @@ pkix_pl_Socket_Create(
    
    36
    +                     plContext),
    
    37
    +                     PKIX_COULDNOTCREATESOCKETOBJECT);
    
    38
    + 
    
    39
    ++        // XXX: Do we need a unittest ifdef here? We don't want to break the tests, but
    
    40
    ++        // we want to ensure nothing can ever hit this code in production.
    
    41
    ++#if 1
    
    42
    ++        printf("Tor Browser BUG: Attempted pkix direct socket connect\n");
    
    43
    ++        PKIX_ERROR(PKIX_PRNEWTCPSOCKETFAILED);
    
    44
    ++#endif
    
    45
    ++
    
    46
    +         socket->isServer = isServer;
    
    47
    +         socket->timeout = timeout;
    
    48
    +         socket->clientSock = NULL;
    
    49
    +@@ -1433,6 +1440,13 @@ pkix_pl_Socket_CreateByName(
    
    50
    + 
    
    51
    +         localCopyName = PL_strdup(serverName);
    
    52
    + 
    
    53
    ++        // XXX: Do we need a unittest ifdef here? We don't want to break the tests, but
    
    54
    ++        // we want to ensure nothing can ever hit this code in production.
    
    55
    ++#if 1
    
    56
    ++        printf("Tor Browser BUG: Attempted pkix direct connect to %s\n", serverName);
    
    57
    ++        PKIX_ERROR(PKIX_PRNEWTCPSOCKETFAILED);
    
    58
    ++#endif
    
    59
    ++
    
    60
    +         sepPtr = strchr(localCopyName, ':');
    
    61
    +         /* First strip off the portnum, if present, from the end of the name */
    
    62
    +         if (sepPtr) {
    
    63
    +@@ -1582,6 +1596,13 @@ pkix_pl_Socket_CreateByHostAndPort(
    
    64
    +         PKIX_ENTER(SOCKET, "pkix_pl_Socket_CreateByHostAndPort");
    
    65
    +         PKIX_NULLCHECK_THREE(hostname, pStatus, pSocket);
    
    66
    + 
    
    67
    ++        // XXX: Do we need a unittest ifdef here? We don't want to break the tests, but
    
    68
    ++        // we want to ensure nothing can ever hit this code in production.
    
    69
    ++#if 1
    
    70
    ++        printf("Tor Browser BUG: Attempted pkix direct connect to %s, port %u\n", hostname,
    
    71
    ++                portnum);
    
    72
    ++        PKIX_ERROR(PKIX_PRNEWTCPSOCKETFAILED);
    
    73
    ++#endif
    
    74
    + 
    
    75
    +         prstatus = PR_GetHostByName(hostname, buf, sizeof(buf), &hostent);
    
    76
    + 
    
    77
    +-- 
    
    78
    +2.27.0
    
    79
    +

  • projects/application-services/build
    ... ... @@ -83,6 +83,15 @@ cp $builddir/uniffi-rs/uniffi-bindgen glean-core/android-native/
    83 83
     patch -p1 < $rootdir/glean-noop.diff
    
    84 84
     popd
    
    85 85
     
    
    86
    +pushd libs
    
    87
    +ln -s $rootdir/[% c("input_files_by_name/nss") %] ./
    
    88
    +ln -s $rootdir/bug_13028.patch
    
    89
    +patch -p2 < $rootdir/apply-bug-13028.diff
    
    90
    +patch -p2 < $rootdir/no-ndk-lookup.diff
    
    91
    +./build-all.sh desktop
    
    92
    +./build-all.sh android
    
    93
    +popd
    
    94
    +
    
    86 95
     [% IF c('var/fetch_gradle_dependencies') %]
    
    87 96
       # XXX: `assemble` is still not enough to see all fetched dependencies via
    
    88 97
       # Gradle's --debug. See: tor-browser-build#40056.
    

  • projects/application-services/config
    ... ... @@ -11,8 +11,8 @@ var:
    11 11
       gradle_dependencies_version: 11
    
    12 12
       gradle_version: 8.8
    
    13 13
       glean_parser: 14.0.1
    
    14
    -  # This is the only project for which the rust lib will actually be built
    
    15
    -  cargo_vendor_subdir: components/support/nimbus-fml
    
    14
    +  nss_version: '3.101'
    
    15
    +  nspr_version: '4.35'
    
    16 16
     
    
    17 17
     steps:
    
    18 18
       build:
    
    ... ... @@ -22,6 +22,9 @@ steps:
    22 22
           # builds when build time differ a lot, we need to do periodic rebuilds:
    
    23 23
           # https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/merge_requests/937#note_3009480
    
    24 24
           rebuild_date: '2024-09-12'
    
    25
    +      arch_deps:
    
    26
    +        # Needed to build NSS
    
    27
    +        - gyp
    
    25 28
         input_files:
    
    26 29
           - project: container-image
    
    27 30
             pkg_type: build
    
    ... ... @@ -46,6 +49,10 @@ steps:
    46 49
           - URL: 'https://dl.google.com/android/repository/build-tools_r30.0.3-linux.zip'
    
    47 50
             name: build_tools_30
    
    48 51
             sha256sum: 24593500aa95d2f99fb4f10658aae7e65cb519be6cd33fa164f15f27f3c4a2d6
    
    52
    +      # NSS version ans sha256 are in libs/build-all.sh.
    
    53
    +      - URL: 'https://ftp.mozilla.org/pub/security/nss/releases/NSS_[% c("var/nss_version") | replace("\\.", "_") %]_RTM/src/nss-[% c("var/nss_version") %]-with-nspr-[% c("var/nspr_version") %].tar.gz'
    
    54
    +        name: nss
    
    55
    +        sha256sum: 566faa9283ff3d9a7d6c44272df6e4330e3e06ca4e841a68840d31b27c9161c4
    
    49 56
           - filename: 'gradle-dependencies-[% c("var/gradle_dependencies_version") %]'
    
    50 57
             name: gradle-dependencies
    
    51 58
             exec: '[% INCLUDE "fetch-gradle-dependencies" %]'
    
    ... ... @@ -63,10 +70,11 @@ steps:
    63 70
             enable: '[% !c("var/fetch_gradle_dependencies") %]'
    
    64 71
           - filename: gen_gradle_deps_file.sh
    
    65 72
             enable: '[% c("var/fetch_gradle_dependencies") %]'
    
    66
    -      # tor-browser-build#40485: Make sure the Kotlin output of nimbus-fml
    
    67
    -      # has deterministic order for reproducibility.
    
    68
    -      # Delete when this patch is included upstream.
    
    73
    +      - filename: bug_13028.patch
    
    74
    +      - filename: apply-bug-13028.diff
    
    75
    +      # Delete when this patch is included upstream
    
    69 76
           - filename: bug40485-nimbus-fml-reproducibility.diff
    
    77
    +      - filename: no-ndk-lookup.diff
    
    70 78
           # as-ohttp-client lists both the version for ohttp and a git repo + rev,
    
    71 79
           # but this breaks the vendoring for offline builds.
    
    72 80
           - filename: ohttp-no-git.diff
    

  • projects/application-services/list_toolchain_updates_checks
    ... ... @@ -36,6 +36,17 @@ current='[% c("var/gradle_version") %]'
    36 36
     check_update_needed gradle "$needed" "$current"
    
    37 37
     
    
    38 38
     
    
    39
    +# nss-nspr
    
    40
    +read -d '' p << 'EOF' || true
    
    41
    +if (m/NSS_ARCHIVE="nss-(.*-with-nspr-.*)\\.tar\\.gz"/) {
    
    42
    +  print $1;
    
    43
    +  exit;
    
    44
    +}
    
    45
    +EOF
    
    46
    +needed=$(cat libs/build-all.sh | perl -ne "$p")
    
    47
    +current='[% c("var/nss_version") %]-with-nspr-[% c("var/nspr_version") %]'
    
    48
    +check_update_needed nss-nspr "$needed" "$current"
    
    49
    +
    
    39 50
     # uniffi
    
    40 51
     read -d '' p << 'EOF' || true
    
    41 52
     if (m/^\\s*uniffi\\s*=\\s*"([^"]*)"/) {
    

  • projects/application-services/no-ndk-lookup.diff
    1
    +diff --git a/libs/android_defaults.sh b/libs/android_defaults.sh
    
    2
    +index 2cfcc4206..9e3d3de97 100755
    
    3
    +--- a/libs/android_defaults.sh
    
    4
    ++++ b/libs/android_defaults.sh
    
    5
    +@@ -1,11 +1,7 @@
    
    6
    + #!/usr/bin/env bash
    
    7
    + 
    
    8
    +-# Find the NDK.
    
    9
    +-pushd ..
    
    10
    +-NDK_VERSION=$(./gradlew -q printNdkVersion | tail -1)
    
    11
    +-export ANDROID_NDK_HOME="$ANDROID_HOME/ndk/$NDK_VERSION"
    
    12
    +-export ANDROID_NDK_ROOT="$ANDROID_NDK_HOME"
    
    13
    +-popd || exit
    
    14
    ++# Do not try to find the NDK, as it does not work offline.
    
    15
    ++# We already define the needed variables in our environment.
    
    16
    + 
    
    17
    + if [[ -z "${ANDROID_NDK_API_VERSION:-}" ]]; then
    
    18
    +     export ANDROID_NDK_API_VERSION=21