Repository navigation
[FSSDK-13477] Fix Arnica findings: checkout credentials, SDK key in URL, CMAB hash, demo app - #425
Esra Kartal (esrakartalOpt) wants to merge 1 commit into
Conversation
…RL, CMAB hash, demo app jquery-validation 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 comments. Both code fixes are correct and each is pinned by a test that fails without it; I built and ran them under Mono and reproduced that. The vendored demo-app scripts match the official release byte for byte. Two comments: one wording nit (inline suggestion) and a note that part of the workflow change isn't exercised by this PR's CI.
TL;DR
- Tests: built the SDK and tests with Mono msbuild (signed, as CI does) and ran NUnit 2.6.4:
DefaultCmabServiceTest22 of 22,HttpProjectConfigManagerTest25 of 25 (the description saw 24 of 25, one timing-dependent test; it passed for me). - Both fixes are load-bearing. I put each production change back and re-ran: SHA256 -> MD5 fails
HashAttributesIsSha256OfAttributesSortedByKey(Expected string length 64 but was 32); removingUri.EscapeDataStringfailsTestHttpConfigManagerEscapesSdkKeyInDatafileUrl(the request URI gains a query). I also recomputed the test's expected value independently: SHA256 of{"a":1,"b":"x"}isecf9e98ec064..., matching the test. - The hash change is safe to ship.
AttributesHashis only compared with the stored value in the cache lookup (DefaultCmabService.cs:179); it is never sent to the CMAB service. An entry written by an older version is simply a miss. - The key escape doesn't change real keys. SDK keys are alphanumeric, so
Uri.EscapeDataStringleaves them as they are;WithUrlcallers never reach that line. - Demo app scripts are the real thing:
jquery.validate.jsandjquery.validate.min.jsare byte-identical (ignoring line endings) to[email protected]from npm. persist-credentials: falsecovers all nine checkouts and the jobs that ran in CI show it working (the unit-test job logspersist-credentials: falsethenRemoving auth).
CI: 9 pass, 1 skipped (Arnica), 1 failing: optimizely/fullstack-prod-suite (csharp). That check fails on master's last three commits and on the last three merged PRs (#421, #423, #424) too, so it isn't from this change.
Not covered by this PR's CI
integration_test.yml:csharp.ymlcalls it asoptimizely/csharp-sdk/.github/workflows/integration_test.yml@master, i.e. master's copy. In the PR run the integration job's checkout loggedpersist-credentials: true. That file's change takes effect after merge. I read its trigger step: it only passes the token through env.csharp_release.yml(4 checkouts) only runs on a release. I checked that nothing in it runsgit,ghor reads.git/config, so I don't expect a change, but nothing has run it.
Proof
Results
Mono 6.12 / msbuild Release, SignAssembly with keypair.snk, NUnit 2.6.4 console
PR as pushed: DefaultCmabServiceTest 22 run, 0 fail HttpProjectConfigManagerTest 25 run, 0 fail
M1 SHA256->MD5: 1 failure: HashAttributesIsSha256OfAttributesSortedByKey
Expected: "ecf9e98ec0641e23113ff3ce8bdc78d0ddd249886517fd4a7f68cc83d4e65667"
But was: "75a6ce4be04f5075316047b75a98d8eb"
M2 no EscapeDataString: 1 error: TestHttpConfigManagerEscapesSdkKeyInDatafileUrl
(mock SendAsync with Host == cdn.optimizely.com and empty Query/Fragment never performed)
sha256 of {"a":1,"b":"x"} (python hashlib) = ecf9e98ec0641e23113ff3ce8bdc78d0ddd249886517fd4a7f68cc83d4e65667
jquery.validate.js vendored 9112fcdb7ef6babe official 1.21.0 9112fcdb7ef6babe IDENTICAL
jquery.validate.min.js vendored ba66d3685c4fdf51 official 1.21.0 ba66d3685c4fdf51 IDENTICAL
fullstack-prod-suite (csharp): failure on master c30fa1a, 6ecaa2b, 800a355 and on merged PRs #424, #423, #421
actionlint on the three changed workflows: the same findings on this head and on master
(setup-dotnet@v2 / checkout@v2 runner "too old", SC2086 info notes). None from this PR.
Environment note: only the two fixtures touched by this PR were run (not the whole suite), under Mono and NUnit 2.6.4, not Windows msbuild and NUnit 3.18.1 as CI does. The demo app (ASP.NET) was not built.
Findings
Blockers: none. Should-fix: none.
Nits
- Comment wording (
HttpProjectConfigManager.cs:380-381, inline suggestion, principles check CODE-1.S1): "stays an empty value, as before" describes how the code used to behave. Say what it does now. - Bare
nosemgrep(TestData.cs:99,102,HttpClientEventDispatcher45.cs:88,WebRequestEventDispatcher35.cs:60): without a rule id it suppresses every current and future rule on that line. The description is upfront that the Arnica rule ids weren't available; once Arnica shows them after the rescan, scope each one (// nosemgrep: <rule-id>). Not a suggestion block, because I don't know the ids. - Pre-existing and identical on
master, so not asked here:integration_test.ymlstill usesactions/checkout@v2, which actionlint flags as too old.
Ponytail
Lean already: the fixes are one-line each, the two tests are the minimum that pin them, and the nosemgrep blocks carry the reasons the scanner can't. Nothing to cut.
net: 0 lines possible.
Principles (installed principles plugin v0.5.0, org layer; no repo-level checks)
Applied by hand, not the full recorded run. FUN-1.S1 pass (each fix has a test that fails without it; M1 and M2). FUN-2.S1 pass (the two fixtures pass; CI green apart from the pre-existing external check). SEC-4.S1 pass (the key is escaped before it reaches the URL). SEC-6.S1 pass (clears the artipacked, MD5 and path-traversal findings). CODE-1.S1: one nit ("as before", above).
| // "#" cannot change which URL is requested. A null key stays an empty value, | ||
| // as before, because the error handler above may not throw. |
There was a problem hiding this comment.
Nit (principles CODE-1.S1). "stays an empty value, as before" describes what the code used to do. State what it does now:
| // "#" cannot change which URL is requested. A null key stays an empty value, | |
| // as before, because the error handler above may not throw. | |
| // "#" cannot change which URL is requested. A null key becomes an empty value, | |
| // because the error handler above may not throw. |
|
|
||
| // This is test code. The names passed to LoadJsonData are fixed strings in this class, | ||
| // and they select embedded resources of this assembly, not files on disk. | ||
| // nosemgrep |
There was a problem hiding this comment.
Nit (not a suggestion block: I don't know the rule ids). A bare nosemgrep suppresses every current and future rule on this line. The description says the Arnica rule ids weren't available. Once the rescan shows them, scope each suppression (// nosemgrep: <rule-id>). Same for line 102 here, HttpClientEventDispatcher45.cs:88 and WebRequestEventDispatcher35.cs:60.
Summary
Fixes the Arnica findings in FSSDK-13477 that can be fixed in code, and documents the rest.
Fixed
persist-credentials: falseon everyactions/checkout. No later step uses git.HttpProjectConfigManager(1): the SDK key is now escaped (Uri.EscapeDataString) before it goes into the datafile URL.jQuery.Validation1.19.5 to 1.21.0, and the unusedOptimizely.SDK3.2.0 entry removed frompackages.config.Suppressed with a reason above each
nosemgrep: the 2 event dispatchers (the URL comes from the SDK's own region list) and the test data loader (embedded resources, not files).Not changed (dismiss in Arnica): 7 findings in vendored demo app scripts (third-party code, not part of the published package). The
log4netfinding is fixed in #426.Test plan
HttpProjectConfigManagerTest24/25. The one failure,TestSettingIfModifiedSinceInRequestHeader, fails the same way on a cleanmaster(a timing race in the test).nosemgrepcomments.Issues
🤖 Generated with Claude Code