From 3e7c9594a7dacced6c218e8cd16c3feaa802d35a Mon Sep 17 00:00:00 2001 From: esrakartalOpt Date: Mon, 23 Nov 2026 11:55:16 -0600 Subject: [PATCH 1/3] [FSSDK-13489] Fix Arnica findings: artipacked workflows, LGPL dependency, TLS context, manifest - Add persist-credentials: false to all actions/checkout steps in build.yml and android.yml so the GitHub token is not left in .git/config. - Remove com.google.code.findbugs:annotations (LGPL-2.1) from test-app. It was added for API-16 and test-app now has minSdk 21; published modules already exclude it. - Use SSLContext.getInstance("TLSv1.2") in TLSSocketFactory and add a unit test that sockets only enable TLSv1.2. - Document and suppress the exported launcher activity finding in the test-app manifest (false positive: launcher activities must be exported on Android 12+). Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/android.yml | 7 +++ .github/workflows/build.yml | 2 + .../ab/android/shared/TLSSocketFactory.java | 2 +- .../android/shared/TLSSocketFactoryTest.java | 43 +++++++++++++++++++ test-app/build.gradle | 1 - test-app/src/main/AndroidManifest.xml | 3 ++ 6 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 shared/src/test/java/com/optimizely/ab/android/shared/TLSSocketFactoryTest.java diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 16312c5a..4d94e947 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -17,6 +17,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -35,6 +37,9 @@ jobs: with: # You should create a personal access token and store it in your repository token: ${{ secrets.CI_USER_TOKEN }} + # The token is only needed for this checkout. Later steps pass it explicitly via env + # and do not use git, so do not leave it in .git/config. + persist-credentials: false repository: 'optimizely/ci-helper-tools' path: 'home/runner/ci-helper-tools' ref: 'master' @@ -97,6 +102,8 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 + with: + persist-credentials: false - name: set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 659a2b5b..dd4611aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,6 +23,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/shared/src/main/java/com/optimizely/ab/android/shared/TLSSocketFactory.java b/shared/src/main/java/com/optimizely/ab/android/shared/TLSSocketFactory.java index d458bde0..14d00b44 100644 --- a/shared/src/main/java/com/optimizely/ab/android/shared/TLSSocketFactory.java +++ b/shared/src/main/java/com/optimizely/ab/android/shared/TLSSocketFactory.java @@ -34,7 +34,7 @@ public class TLSSocketFactory extends SSLSocketFactory { private SSLSocketFactory sslSocketFactory; public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException { - SSLContext context = SSLContext.getInstance("TLS"); + SSLContext context = SSLContext.getInstance("TLSv1.2"); context.init(null, null, null); sslSocketFactory = context.getSocketFactory(); } diff --git a/shared/src/test/java/com/optimizely/ab/android/shared/TLSSocketFactoryTest.java b/shared/src/test/java/com/optimizely/ab/android/shared/TLSSocketFactoryTest.java new file mode 100644 index 00000000..c7d6e927 --- /dev/null +++ b/shared/src/test/java/com/optimizely/ab/android/shared/TLSSocketFactoryTest.java @@ -0,0 +1,43 @@ +/**************************************************************************** + * Copyright 2026, Optimizely, Inc. and contributors * + * * + * Licensed under the Apache License, Version 2.0 (the "License"); * + * you may not use this file except in compliance with the License. * + * You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, software * + * distributed under the License is distributed on an "AS IS" BASIS, * + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * + * See the License for the specific language governing permissions and * + * limitations under the License. * + ***************************************************************************/ + +package com.optimizely.ab.android.shared; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import java.net.Socket; + +import javax.net.ssl.SSLSocket; + +public class TLSSocketFactoryTest { + + @Test + public void createdSocketsOnlyEnableTLSv12() throws Exception { + TLSSocketFactory factory = new TLSSocketFactory(); + + // An unconnected socket is enough to check which protocols are enabled. + Socket socket = factory.createSocket(); + try { + assertTrue(socket instanceof SSLSocket); + assertArrayEquals(new String[] {"TLSv1.2"}, ((SSLSocket) socket).getEnabledProtocols()); + } finally { + socket.close(); + } + } +} diff --git a/test-app/build.gradle b/test-app/build.gradle index f242fc60..31bccf7c 100644 --- a/test-app/build.gradle +++ b/test-app/build.gradle @@ -73,7 +73,6 @@ dependencies { // required by API-16 implementation "com.google.code.gson:gson:$gson_ver" - implementation 'com.google.code.findbugs:annotations:3.0.0' testImplementation "junit:junit:$junit_ver" testImplementation "org.mockito:mockito-core:$mockito_ver" diff --git a/test-app/src/main/AndroidManifest.xml b/test-app/src/main/AndroidManifest.xml index 0fe3f090..13c1c4a1 100644 --- a/test-app/src/main/AndroidManifest.xml +++ b/test-app/src/main/AndroidManifest.xml @@ -38,6 +38,9 @@ android:name=".NotificationService" android:exported="false" /> + + Date: Wed, 25 Nov 2026 10:08:45 -0600 Subject: [PATCH 2/3] [FSSDK-13489] Address review: make TLSSocketFactory test able to fail, fix stale comment - Add a package-private TLSSocketFactory(SSLContext) constructor so a test can pass a context that allows more than TLSv1.2. The new test fails if enableTLSOnSocket stops pinning sockets to TLSv1.2 (the old test passed even without it). - Fix the stale "required by API-16" comment on gson in test-app/build.gradle. Co-Authored-By: Claude Sonnet 5.5 --- .../ab/android/shared/TLSSocketFactory.java | 7 +++++- .../android/shared/TLSSocketFactoryTest.java | 23 +++++++++++++++++-- test-app/build.gradle | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/shared/src/main/java/com/optimizely/ab/android/shared/TLSSocketFactory.java b/shared/src/main/java/com/optimizely/ab/android/shared/TLSSocketFactory.java index 14d00b44..47146c91 100644 --- a/shared/src/main/java/com/optimizely/ab/android/shared/TLSSocketFactory.java +++ b/shared/src/main/java/com/optimizely/ab/android/shared/TLSSocketFactory.java @@ -34,7 +34,12 @@ public class TLSSocketFactory extends SSLSocketFactory { private SSLSocketFactory sslSocketFactory; public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException { - SSLContext context = SSLContext.getInstance("TLSv1.2"); + this(SSLContext.getInstance("TLSv1.2")); + } + + // Visible for testing: lets a test pass a context that allows more than TLSv1.2, to check that + // enableTLSOnSocket pins the sockets on its own. + TLSSocketFactory(SSLContext context) throws KeyManagementException { context.init(null, null, null); sslSocketFactory = context.getSocketFactory(); } diff --git a/shared/src/test/java/com/optimizely/ab/android/shared/TLSSocketFactoryTest.java b/shared/src/test/java/com/optimizely/ab/android/shared/TLSSocketFactoryTest.java index c7d6e927..b274a6b8 100644 --- a/shared/src/test/java/com/optimizely/ab/android/shared/TLSSocketFactoryTest.java +++ b/shared/src/test/java/com/optimizely/ab/android/shared/TLSSocketFactoryTest.java @@ -23,14 +23,33 @@ import java.net.Socket; +import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; public class TLSSocketFactoryTest { @Test - public void createdSocketsOnlyEnableTLSv12() throws Exception { - TLSSocketFactory factory = new TLSSocketFactory(); + public void defaultFactoryOnlyEnablesTLSv12() throws Exception { + assertOnlyTLSv12(new TLSSocketFactory()); + } + + @Test + public void socketsArePinnedToTLSv12EvenWhenTheContextAllowsMore() throws Exception { + // "TLS" allows several protocol versions (TLSv1.3 and TLSv1.2 on the JVM running this test), so this + // only passes if enableTLSOnSocket itself limits the sockets to TLSv1.2. + SSLContext permissive = SSLContext.getInstance("TLS"); + permissive.init(null, null, null); + SSLSocket unpinned = (SSLSocket) permissive.getSocketFactory().createSocket(); + try { + assertTrue(unpinned.getEnabledProtocols().length > 1); + } finally { + unpinned.close(); + } + + assertOnlyTLSv12(new TLSSocketFactory(SSLContext.getInstance("TLS"))); + } + private static void assertOnlyTLSv12(TLSSocketFactory factory) throws Exception { // An unconnected socket is enough to check which protocols are enabled. Socket socket = factory.createSocket(); try { diff --git a/test-app/build.gradle b/test-app/build.gradle index 31bccf7c..86d264f1 100644 --- a/test-app/build.gradle +++ b/test-app/build.gradle @@ -71,7 +71,7 @@ dependencies { implementation "androidx.appcompat:appcompat:1.2.0" implementation "com.google.android.material:material:1.2.1" - // required by API-16 + // JSON library for the SDK (it picks one from the classpath) implementation "com.google.code.gson:gson:$gson_ver" testImplementation "junit:junit:$junit_ver" From af892b85415c94a39a6af87178252bea92064bf7 Mon Sep 17 00:00:00 2001 From: esrakartalOpt Date: Wed, 25 Nov 2026 15:32:32 -0600 Subject: [PATCH 3/3] [FSSDK-13489] Retrigger CI Empty commit to rerun the checks after the previous build was cancelled. Co-Authored-By: Claude Sonnet 5.5