Repository navigation
[FSSDK-13489] Fix Arnica findings: artipacked workflows, LGPL dependency, TLS context, manifest - #544
Conversation
…ncy, 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 <[email protected]>
Alex Yong (alexjoeyyong)
left a comment
There was a problem hiding this comment.
Verdict: approve (with non-blocking nits). Posted as a comment review.
CI: all checks pass (lint, build, integration, the 28/33/36 emulator tests, compat suite). The Arnica check is NEUTRAL, so I can't see from it whether each finding cleared.
Checked myself:
persist-credentials: falseis safe. The onlygitin the Gradle build is the SCM URLs in the POM (build.gradle:344-346). The publish step uses Maven credentials from env vars.integration_testspassed with theci-helper-toolscheckout hardened.- The findbugs removal is exercised. The
buildjob runs:test-app:minifyDebugWithR8and:test-app:minifyReleaseWithR8and both pass. The only remaining references are the ProGuard-dontwarnand the twoexcludelines. - The new unit test runs in CI.
./gradlew buildruns:shared:testDebugUnitTest(testAllModulesonly runs:shared:connectedAndroidTest, so thebuildjob is the one that covers it). - "TLS" to "TLSv1.2" is equivalent here. Every socket is already pinned to TLSv1.2 by
enableTLSOnSocket.
Nits
TLSSocketFactoryTestprobably can't fail for the reason it names. It runs on the host JVM (CI uses Temurin 17), where anSSLContextof"TLSv1.2"likely already yields[TLSv1.2]as enabled protocols. The test would then pass even ifenableTLSOnSocketwere deleted. I couldn't run it. Please delete thesetEnabledProtocolscall and re-run: if it still passes, assert something the factory alone guarantees.- Bare
<!-- nosemgrep -->suppresses every rule on that element, and the PR is unsure Arnica honors it. Confirm the finding clears; otherwise dismiss it in Arnica with the launcher-activity reason. - Stale comment in
test-app/build.gradle:// required by API-16now sits over gson alone, andminSdkVersionis 21. - The description says the factory is "used on API 21 and 22".
Client.javagates it onSDK_INT <= LOLLIPOP(21), so it's API 21 only. - Follow-up, not this PR:
build.ymlinterpolates${{ inputs.github_tag }}straight into arun:line. The callers pass constants, so it's low risk, but it is the template-injection pattern a hardening pass looks for.Client.java:72-73also builds anSSLContextand discards it.
…, 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 <[email protected]>
Empty commit to rerun the checks after the previous build was cancelled. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Alex Yong (alexjoeyyong)
left a comment
There was a problem hiding this comment.
Re-review at af892b8. Verdict: approve the code. Two required checks are red, so it can't merge until someone re-runs them, and neither failure comes from this PR's code.
TL;DR
- Both of my earlier asks are done, and I verified them. I ran
TLSSocketFactoryTeston JDK 17: 2 pass. With thesetEnabledProtocolspin removed fromenableTLSOnSocket, the new test fails ("expectedTLSv1.2but wasTLSv1.3") while the old-style test still passes. So the first version really couldn't fail, and the new one can, for the right reason. The staletest-app/build.gradlecomment is fixed, and the description now says "only used on API 21" and admits the first test was vacuous. test (28, x86, google_apis)is red because the job hung, not because a test failed. Gradle printedBUILD SUCCESSFUL in 9m 17swith every connected-test task run and 0 failures. The job then stalled in the emulator teardown and sat there until GitHub's 6-hour limit cancelled it at 03:32. The previous commit did the same thing:BUILD SUCCESSFUL in 11m 43s, then stalled until someone cancelled it after 5h12m.- The compatibility suite (android) is red, but the same code passed it. Phase A failed all 1,078 of 1,078 scenarios at their first
activatecall (the test app returned nothing), while Phase B (925 scenarios) and Phase C (26) passed in full.af892b8is an empty commit on top of5ee1968(0 files), and5ee1968passed this suite. All three runs used the same test app (48fd295) and suite (8ee35cf), the APK builds all succeeded, and the SDK's dependencies are pinned (java_core_ver = "4.7.0"). It failed twice (attempts 1 and 2), so I'd treat it as a test-environment problem, but I can't prove the exact cause. - What it needs: someone with the rights to re-run both checks. Both are required (
optimizely/fullstack-sdk-compatibility-suite (android)andtest (28, x86, google_apis)), and the PR showsREVIEW_REQUIRED/BLOCKED. I haven't re-run CI (and shouldn't). - Not tested: behaviour on a real API 21 device (these are JVM unit tests, as the description says).
What I ran
| Check | Result |
|---|---|
TLSSocketFactoryTest at the head, JDK 17 (temurin) + JUnit 4.13.2 |
OK (2 tests) |
Same, setEnabledProtocols(new String[] {"TLSv1.2"}) removed |
1 failure: socketsArePinnedToTLSv12EvenWhenTheContextAllowsMore (expected:<TLSv1.[2]> but was:<TLSv1.[3]>); defaultFactoryOnlyEnablesTLSv12 still passes |
git compare 5ee1968...af892b8 |
0 files changed (empty "Retrigger CI" commit) |
| Compat suite status history per commit | 3e7c959 success, 5ee1968 success, af892b8 failure (attempt 1) and failure (attempt 2) |
| API-28 job logs, both red runs | BUILD SUCCESSFUL first, then stalled after "Terminate Emulator" / removeAll |
Ponytail (what to delete or simplify)
Lean already. Ship. The package-private TLSSocketFactory(SSLContext) constructor exists only so a test can pass a permissive context. It's the smallest way to make the pin testable, and the public constructor just delegates to it.
net: no lines left to cut.
Nits
- Give the
testjob a timeout (.github/workflows/android.yml). It has notimeout-minutes, so a hung emulator teardown holds a runner for the full 6 hours, and it has happened on this PR twice (5h12m and 6h). The tests take 11-14 minutes, sotimeout-minutes: 30on thetestjob would turn this into a failure within half an hour. That line is outside this PR's diff, so I can't attach it as a suggestion; it's a follow-up. - The bare
<!-- nosemgrep -->in the manifest is unchanged. The description is upfront that it may not clear the finding. The Arnica check now reports "skipping", so I can't see whether it did; please confirm in Arnica, and dismiss the finding there with the launcher-activity reason if it didn't. - Pre-existing, optional follow-up:
Client.java:72-73builds anSSLContext, thennew TLSSocketFactory()builds another, and the first is discarded.
Proof: test output and CI evidence (verbatim, trimmed)
# TLSSocketFactoryTest at af892b8 (eclipse-temurin:17-jdk, openjdk 17.0.21, JUnit 4.13.2)
JUnit version 4.13.2
..
OK (2 tests)
# Same, `setEnabledProtocols(new String[] {"TLSv1.2"})` removed from enableTLSOnSocket
..E
There was 1 failure:
1) socketsArePinnedToTLSv12EvenWhenTheContextAllowsMore(com.optimizely.ab.android.shared.TLSSocketFactoryTest)
array lengths differed, expected.length=1 actual.length=2; arrays first differed at element [0]; expected:<TLSv1.[2]> but was:<TLSv1.[3]>
Tests run: 2, Failures: 1
# API-28 job, run 45705309671 (head af892b8)
21:44:21 > Task :user-profile:connectedAndroidTest
21:44:21 BUILD SUCCESSFUL in 9m 17s (369 actionable tasks: 369 executed; "Finished 20 tests ... (0 failed)")
21:44:22 OK: killing emulator, bye bye
21:44:23 INFO | removeAll <- last line of output
03:32:43 ##[error]The operation was canceled. (6 h later)
# previous commit 5ee1968, run 45651361679
16:22:12 BUILD SUCCESSFUL in 11m 43s
16:22:13 INFO | removeAll
21:20:43 ##[error]The operation was canceled.
# compat suite (android), same test app 48fd295 / suite 8ee35cf in all three runs
3e7c959 success (Nov 23)
5ee1968 success (Nov 25 16:35)
af892b8 failure attempt 1 (21:59), failure attempt 2 (22:28) -- af892b8 is an empty commit on 5ee1968
failing run: Phase A 1078 scenarios (1078 failed) [TypeError at hooks.js:273 "activate" returned no result]
Phase B 925 passed Phase C 26 passed
…mulator test job - Use the exact rule id in the manifest nosemgrep comment, so it only silences the exported-activity rule (java.android.security.exported_activity.exported_activity). - Add timeout-minutes: 30 to the test job. The tests take 9-16 minutes, but a hung emulator shutdown kept the job running until GitHub's 6 hour limit. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Muzahidul Islam (muzahidul-opti)
left a comment
There was a problem hiding this comment.
Thanks for addressing the comments
Summary
persist-credentials: falseto all 4actions/checkoutsteps:build.yml(1) andandroid.yml(3). This stops the GitHub token being left in.git/config(Arnica artipacked findings). No later step needs git credentials: the integration step runs scripts fromoptimizely/ci-helper-toolsthat only usecurlwith a token passed through env vars, and the Gradle publish step uses Maven credentials from env vars.com.google.code.findbugs:annotations:3.0.0(LGPL-2.1) fromtest-app/build.gradle. It was added for API-16, buttest-appnow hasminSdkVersion 21. The published modules already excludecom.google.code.findbugs, so the test app now builds the way a real consumer app does. Nothing else in the repo uses it except a harmless ProGuard-dontwarnline. The stale// required by API-16comment abovegsonnow says whatgsonis for.TLSSocketFactory: useSSLContext.getInstance("TLSv1.2")instead of"TLS"(Arnica weak SSL context finding). Behavior is unchanged, because every socket the factory creates is already limited toTLSv1.2byenableTLSOnSocket, andClient.javaalready requests"TLSv1.2". The factory is only used on API 21:Client.javagates it onSDK_INT <= LOLLIPOP.TLSSocketFactory(SSLContext)constructor (the public constructor calls it). It is only there so a test can pass a context that allows more than TLSv1.2 and check thatenableTLSOnSocketpins the sockets by itself.test-app/src/main/AndroidManifest.xml: document and suppress the "Exported activity" finding.SplashScreenActivityis the launcher activity, and launcher activities must beexported="true"on Android 12+. It is a false positive. The comment names the rule (java.android.security.exported_activity.exported_activity) and sits directly above the<activitytag, where the finding anchors. If Arnica does not honor it, dismiss the finding there with that reason.android.yml: addtimeout-minutes: 30to the emulatortestjob. The tests take 9 to 16 minutes, but twice on this PR a hung emulator shutdown kept the job running until GitHub's 6 hour limit (afterBUILD SUCCESSFULwith 0 test failures), so the job ended as cancelled.Test plan
TLSSocketFactoryTesthas two tests. One checks the default factory only enablesTLSv1.2. The other builds the factory from a plain"TLS"context, which allows several protocols, and checks the sockets are still limited toTLSv1.2. The second test fails if thesetEnabledProtocolscall inenableTLSOnSocketis removed (checked by deleting that call and re-running). The first version of this test passed even without that call.buildjob runs them through:shared:testDebugUnitTest.exported_activityon the manifest: the original reports the finding at the<activitytag, and the PR version reports none. A comment with a different rule id does not suppress it.test-appis covered by the CIbuildjob, which builds the test app.test (28, x86, google_apis)hung afterBUILD SUCCESSFUL(see the timeout above), and the compatibility suite (android) failed on an empty commit while the commit before it passed.Issues
🤖 Generated with Claude Code