Skip to content

[FSSDK-13489] Fix Arnica findings: artipacked workflows, LGPL dependency, TLS context, manifest - #544

Merged
Esra Kartal (esrakartalOpt) merged 4 commits into
masterfrom
esra/fssdk-13489-fix-arnica-findings
Nov 30, 2026
Merged

Esra Kartal (esrakartalOpt) merged 4 commits into
masterfrom
esra/fssdk-13489-fix-arnica-findings

Conversation

@esrakartalOpt

@esrakartalOpt Esra Kartal (esrakartalOpt) commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add persist-credentials: false to all 4 actions/checkout steps: build.yml (1) and android.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 from optimizely/ci-helper-tools that only use curl with a token passed through env vars, and the Gradle publish step uses Maven credentials from env vars.
  • Remove com.google.code.findbugs:annotations:3.0.0 (LGPL-2.1) from test-app/build.gradle. It was added for API-16, but test-app now has minSdkVersion 21. The published modules already exclude com.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 -dontwarn line. The stale // required by API-16 comment above gson now says what gson is for.
  • TLSSocketFactory: use SSLContext.getInstance("TLSv1.2") instead of "TLS" (Arnica weak SSL context finding). Behavior is unchanged, because every socket the factory creates is already limited to TLSv1.2 by enableTLSOnSocket, and Client.java already requests "TLSv1.2". The factory is only used on API 21: Client.java gates it on SDK_INT <= LOLLIPOP.
  • Add a package-private 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 that enableTLSOnSocket pins the sockets by itself.
  • test-app/src/main/AndroidManifest.xml: document and suppress the "Exported activity" finding. SplashScreenActivity is the launcher activity, and launcher activities must be exported="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 <activity tag, where the finding anchors. If Arnica does not honor it, dismiss the finding there with that reason.
  • android.yml: add timeout-minutes: 30 to the emulator test job. 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 (after BUILD SUCCESSFUL with 0 test failures), so the job ended as cancelled.

Test plan

  • TLSSocketFactoryTest has two tests. One checks the default factory only enables TLSv1.2. The other builds the factory from a plain "TLS" context, which allows several protocols, and checks the sockets are still limited to TLSv1.2. The second test fails if the setEnabledProtocols call in enableTLSOnSocket is removed (checked by deleting that call and re-running). The first version of this test passed even without that call.
  • The tests run on a JVM (JDK 17), so they check the pinning logic and not behavior on a real API 21 device. The CI build job runs them through :shared:testDebugUnitTest.
  • Ran the real Semgrep rule exported_activity on the manifest: the original reports the finding at the <activity tag, and the PR version reports none. A comment with a different rule id does not suppress it.
  • Both workflow files and the manifest parse as valid YAML/XML.
  • The removal of the findbugs dependency in test-app is covered by the CI build job, which builds the test app.
  • Two required checks were red on the previous commit and need a re-run, not a code change: test (28, x86, google_apis) hung after BUILD SUCCESSFUL (see the timeout above), and the compatibility suite (android) failed on an empty commit while the commit before it passed.

Issues

  • FSSDK-13489

🤖 Generated with Claude Code

…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]>

@alexjoeyyong Alex Yong (alexjoeyyong) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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: false is safe. The only git in the Gradle build is the SCM URLs in the POM (build.gradle:344-346). The publish step uses Maven credentials from env vars. integration_tests passed with the ci-helper-tools checkout hardened.
  • The findbugs removal is exercised. The build job runs :test-app:minifyDebugWithR8 and :test-app:minifyReleaseWithR8 and both pass. The only remaining references are the ProGuard -dontwarn and the two exclude lines.
  • The new unit test runs in CI. ./gradlew build runs :shared:testDebugUnitTest (testAllModules only runs :shared:connectedAndroidTest, so the build job is the one that covers it).
  • "TLS" to "TLSv1.2" is equivalent here. Every socket is already pinned to TLSv1.2 by enableTLSOnSocket.

Nits

  • TLSSocketFactoryTest probably can't fail for the reason it names. It runs on the host JVM (CI uses Temurin 17), where an SSLContext of "TLSv1.2" likely already yields [TLSv1.2] as enabled protocols. The test would then pass even if enableTLSOnSocket were deleted. I couldn't run it. Please delete the setEnabledProtocols call 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-16 now sits over gson alone, and minSdkVersion is 21.
  • The description says the factory is "used on API 21 and 22". Client.java gates it on SDK_INT <= LOLLIPOP (21), so it's API 21 only.
  • Follow-up, not this PR: build.yml interpolates ${{ inputs.github_tag }} straight into a run: 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-73 also builds an SSLContext and 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]>

@alexjoeyyong Alex Yong (alexjoeyyong) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TLSSocketFactoryTest on JDK 17: 2 pass. With the setEnabledProtocols pin removed from enableTLSOnSocket, the new test fails ("expected TLSv1.2 but was TLSv1.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 stale test-app/build.gradle comment 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 printed BUILD SUCCESSFUL in 9m 17s with 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 activate call (the test app returned nothing), while Phase B (925 scenarios) and Phase C (26) passed in full. af892b8 is an empty commit on top of 5ee1968 (0 files), and 5ee1968 passed 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) and test (28, x86, google_apis)), and the PR shows REVIEW_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 test job a timeout (.github/workflows/android.yml). It has no timeout-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, so timeout-minutes: 30 on the test job 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-73 builds an SSLContext, then new 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]>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the comments

@esrakartalOpt
Esra Kartal (esrakartalOpt) merged commit 4456350 into master Nov 30, 2026
12 checks passed
@esrakartalOpt
Esra Kartal (esrakartalOpt) deleted the esra/fssdk-13489-fix-arnica-findings branch November 30, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants