Skip to content

Commit

Permalink
Block web browser requests to export endpoint (#6944)
Browse files Browse the repository at this point in the history
* Block web  browser requests to export endpoint

* Update src/emulator/hub.ts

Co-authored-by: Yuchen Shi <yuchenshi@google.com>

---------

Co-authored-by: Yuchen Shi <yuchenshi@google.com>
  • Loading branch information
joehan and yuchenshi committed Apr 2, 2024
1 parent dbb8573 commit 068a2b0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/emulator/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ export class EmulatorHub extends ExpressBasedEmulator {
});

app.post(EmulatorHub.PATH_EXPORT, async (req, res) => {
if (req.headers.origin) {
res.status(403).json({
message: `Export cannot be triggered by external callers.`,
});
}
const path: string = req.body.path;
const initiatedBy: string = req.body.initiatedBy || "unknown";
utils.logLabeledBullet("emulators", `Received export request. Exporting data to ${path}.`);
Expand Down

0 comments on commit 068a2b0

Please sign in to comment.