bito-code-review[bot] commented on code in PR #43397:
URL: https://github.com/apache/superset/pull/43397#discussion_r3831869433


##########
superset-frontend/plugins/plugin-chart-cartodiagram/test/util/layerUtil.test.ts:
##########
@@ -17,22 +17,51 @@
  * under the License.
  */
 
-import { WfsLayerConf } from '../../src/types';
+import { WfsLayerConf, XyzLayerConf } from '../../src/types';
 import {
   createLayer,
   createWfsLayer,
   createWmsLayer,
   createXyzLayer,
+  escapeAttribution,
 } from '../../src/util/layerUtil';
 
 describe('layerUtil', () => {
+  describe('escapeAttribution', () => {
+    test('escapes HTML markup in attribution strings', () => {
+      expect(escapeAttribution('(c) OSM <img src=x onerror=alert(1)>')).toBe(
+        '(c) OSM &lt;img src=x onerror=alert(1)&gt;',
+      );
+      expect(escapeAttribution('a & "b" \'c\'')).toBe(
+        'a &amp; &quot;b&quot; &#039;c&#039;',
+      );
+      expect(escapeAttribution(undefined)).toBeUndefined();
+    });
+  });
+
   describe('createWmsLayer', () => {
     test('exists', () => {
       // function is trivial
       expect(createWmsLayer).toBeDefined();
     });
   });

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing XSS test for createWmsLayer</b></div>
   <div id="fix">
   
   `createWmsLayer` calls `escapeAttribution` (line 73 in layerUtil.tsx) but 
the test only checks existence. Add an assertion verifying HTML in attribution 
is escaped, matching the `createXyzLayer` test pattern at lines 49-63.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #989afc</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to