Skip to content

Commit 74f73f8

Browse files
fix(rsc-demo): address remaining CodeQL format string alerts
Use console.log/warn %s formatting instead of template literals to avoid format string injection with user-provided values. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent e55c0b2 commit 74f73f8

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

apps/rsc-demo/packages/app1/server/api.server.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ async function forwardActionToRemote(
100100
) {
101101
const targetUrl = `${remoteConfig.url}/react${req.url.includes('?') ? req.url.substring(req.url.indexOf('?')) : ''}`;
102102

103+
// Log federation forwarding (use %s to avoid format string injection)
103104
console.log(
104-
`[Federation] Forwarding action ${forwardedActionId} to ${targetUrl}`
105+
'[Federation] Forwarding action %s to %s',
106+
forwardedActionId,
107+
targetUrl
105108
);
106109

107110
// Collect request body
@@ -504,9 +507,11 @@ app.post(
504507
if (!actionFn) {
505508
const remoteApp = getRemoteAppForAction(actionId);
506509
if (remoteApp) {
510+
// Use %s to avoid format string injection
507511
console.log(
508-
`[Federation] Action ${actionId} belongs to ${remoteApp.app}, ` +
509-
'no MF-registered handler found, forwarding via HTTP...'
512+
'[Federation] Action %s belongs to %s, no MF-registered handler found, forwarding via HTTP...',
513+
actionId,
514+
remoteApp.app
510515
);
511516
await forwardActionToRemote(
512517
req,
@@ -521,8 +526,10 @@ app.post(
521526
if (!actionFn && actionEntry) {
522527
// For bundled server actions, they should be in the registry
523528
// File-level actions are also bundled into server.rsc.js
529+
// Use %s to avoid format string injection
524530
console.warn(
525-
`Action ${actionId} not in registry, manifest entry:`,
531+
'Action %s not in registry, manifest entry:',
532+
actionId,
526533
actionEntry
527534
);
528535
}

apps/rsc-demo/packages/app2/server/api.server.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,18 @@ app.post(
368368
} = require('react-server-dom-webpack/server');
369369
registerServerReference(candidate, actionEntry.id, actionEntry.name);
370370
actionFn = candidate;
371+
// Use %s to avoid format string injection
371372
console.warn(
372-
`[RSC] Lazily registered action ${actionId} from ${filePath} after cache miss`
373+
'[RSC] Lazily registered action %s from %s after cache miss',
374+
actionId,
375+
filePath
373376
);
374377
}
375378
} catch (e) {
379+
// Use %s to avoid format string injection
376380
console.warn(
377-
`[RSC] Failed lazy-register for action ${actionId}:`,
381+
'[RSC] Failed lazy-register for action %s:',
382+
actionId,
378383
e.message
379384
);
380385
}

0 commit comments

Comments
 (0)