From b4d5f6d038f4b88402d968a24c522786dd6d52ea Mon Sep 17 00:00:00 2001 From: sbenmoussati <51402489+sbenmoussati@users.noreply.github.com> Date: Wed, 14 Dec 2022 14:53:49 +0100 Subject: [PATCH] Static code analysis setup --- .semgrepignore | 2 ++ src/app/app-cache-handler.ts | 1 + src/common/i18n.ts | 9 +++------ src/common/logger.ts | 1 + src/renderer/components/message-banner.tsx | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 .semgrepignore diff --git a/.semgrepignore b/.semgrepignore new file mode 100644 index 000000000..c3f824af5 --- /dev/null +++ b/.semgrepignore @@ -0,0 +1,2 @@ +spec/ +Dockerfile \ No newline at end of file diff --git a/src/app/app-cache-handler.ts b/src/app/app-cache-handler.ts index 884e2e795..786250bc5 100644 --- a/src/app/app-cache-handler.ts +++ b/src/app/app-cache-handler.ts @@ -26,6 +26,7 @@ const cleanOldCache = (): void => { const files = fs.readdirSync(userDataPath); files.forEach((file) => { + // nosemgrep const filePath = path.join(userDataPath, file); if (!fileRemovalList.includes(file)) { return; diff --git a/src/common/i18n.ts b/src/common/i18n.ts index b41c86b42..e50c72ba6 100644 --- a/src/common/i18n.ts +++ b/src/common/i18n.ts @@ -105,12 +105,9 @@ class Translation { * @param locale */ private loadResource(locale: LocaleType): JSON | null { - const resourcePath = path.resolve( - __dirname, - '..', - 'locale', - `${locale}.json`, - ); + const filename = `${locale}.json`; + // nosemgrep + const resourcePath = path.resolve(__dirname, '..', 'locale', filename); if (!fs.existsSync(resourcePath)) { return null; diff --git a/src/common/logger.ts b/src/common/logger.ts index 566e36033..94a0696be 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -274,6 +274,7 @@ class Logger { const files = fs.readdirSync(this.logPath); const deleteTimeStamp = new Date().getTime() - 5 * 24 * 60 * 60 * 1000; files.forEach((file) => { + // nosemgrep const filePath = path.join(this.logPath, file); if (fs.existsSync(filePath)) { const stat = fs.statSync(filePath); diff --git a/src/renderer/components/message-banner.tsx b/src/renderer/components/message-banner.tsx index 00955df86..cd986c046 100644 --- a/src/renderer/components/message-banner.tsx +++ b/src/renderer/components/message-banner.tsx @@ -100,7 +100,7 @@ export default class MessageBanner { if (onlineStateIntervalId) { return; } - + // nosemgrep onlineStateIntervalId = setInterval(async () => { try { const response = await window.fetch(this.url || window.location.href, {