Skip to content

Commit 13d51cf

Browse files
CodeQL cleanup for alerts #18, #19, #20 (#4153)
Small cleanup PR to close three CodeQL alerts, without changing app behavior. - [#18](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/18) in `js/loader.js` - [#19](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/19) in `js/socketclient.js` - [#20](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/20) in `tests/electron/modules/calendar_spec.js` For `Loader` and `MMSocket`, make the global export explicit via `globalThis` (instead of suppressing `no-unused-vars`). For calendar tests, remove the unused debug helper `logAllText`. Also includes a tiny e2e cleanup: `MM_PORT` is cleared in `afterAll`. Outcome: Three open CodeQL alerts are addressed with small, low-risk changes. The global intent for `Loader` and `MMSocket` is explicit, dead test helper code is removed, and e2e test state is cleaned up more reliably between runs. With this, all current [code scanning issues](https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning) should be resolved in the develop branch 🎈
1 parent 79ea263 commit 13d51cf

4 files changed

Lines changed: 5 additions & 16 deletions

File tree

js/loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global defaultModules, vendor */
22

3-
// eslint-disable-next-line no-unused-vars
43
const Loader = (function () {
54

65
/* Create helper variables */
@@ -295,3 +294,5 @@ const Loader = (function () {
295294
}
296295
};
297296
}());
297+
298+
globalThis.Loader = Loader;

js/socketclient.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* global io */
22

3-
// eslint-disable-next-line no-unused-vars
43
const MMSocket = function (moduleName) {
54
if (typeof moduleName !== "string") {
65
throw new Error("Please set the module name for the MMSocket.");
@@ -45,3 +44,5 @@ const MMSocket = function (moduleName) {
4544
this.socket.emit(notification, payload);
4645
};
4746
};
47+
48+
globalThis.MMSocket = MMSocket;

tests/e2e/port_spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe("port directive configuration", () => {
2424

2525
afterAll(async () => {
2626
await helpers.stopApplication();
27+
delete process.env.MM_PORT;
2728
});
2829

2930
it("should return 200", async () => {

tests/electron/modules/calendar_spec.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,6 @@ describe("Calendar module", () => {
2222
return await loc.count();
2323
};
2424

25-
/**
26-
* Use this for debugging broken tests, it will console log the text of the calendar module
27-
* @returns {Promise<void>}
28-
*/
29-
// eslint-disable-next-line no-unused-vars
30-
const logAllText = async () => {
31-
expect(global.page).not.toBeNull();
32-
const loc = await global.page.locator(".calendar .event");
33-
const elem = loc.first();
34-
await elem.waitFor();
35-
expect(elem).not.toBeNull();
36-
console.log(await loc.allInnerTexts());
37-
};
38-
3925
const first = 0;
4026
const second = 1;
4127
const third = 2;

0 commit comments

Comments
 (0)