From ba3cf52a7f1c318e9b56a625e89a305ee0781dbb Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Fri, 27 Aug 2021 20:41:43 +0200 Subject: [PATCH 1/4] add issue bot for prs --- .github/workflows/issue-bot.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index 18eb37ada1..4750fa403d 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -1,5 +1,8 @@ name: Issue Bot -on: [issues] +on: + issues: + pull_request: + types: [opened, reopened, edited] jobs: issue-bot: runs-on: ubuntu-latest From 2af63500e801739ce20bcd7767d93164591764e4 Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Fri, 27 Aug 2021 20:45:32 +0200 Subject: [PATCH 2/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b04fa45be0..ed242afc50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -146,6 +146,7 @@ ___ - Add ability to pass context of an object via a header, X-Parse-Cloud-Context, for Cloud Code triggers. The header addition allows client SDK's to add context without injecting _context in the body of JSON objects (Corey Baker) [#7437](https://github.com/parse-community/parse-server/pull/7437) - Add CI check to add changelog entry (Manuel Trezza) [#7512](https://github.com/parse-community/parse-server/pull/7512) - Refactor: uniform issue templates across repos (Manuel Trezza) [#7528](https://github.com/parse-community/parse-server/pull/7528) +- ci: add Issue Bot for PRs (Manuel Trezza) [#7530](https://github.com/parse-community/parse-server/pull/7530) ## 4.10.2 [Full Changelog](https://github.com/parse-community/parse-server/compare/4.10.1...4.10.2) From d7a34ceeb9d99c995643c5c2dd6d8d7cb4f791b3 Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Fri, 27 Aug 2021 20:50:41 +0200 Subject: [PATCH 3/4] Update issue-bot.yml --- .github/workflows/issue-bot.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/issue-bot.yml b/.github/workflows/issue-bot.yml index 4750fa403d..dd59371116 100644 --- a/.github/workflows/issue-bot.yml +++ b/.github/workflows/issue-bot.yml @@ -1,6 +1,7 @@ name: Issue Bot on: issues: + types: [opened, reopened, edited] pull_request: types: [opened, reopened, edited] jobs: From 795652953ac9f7f12293749b21ad83a966692f61 Mon Sep 17 00:00:00 2001 From: Manuel <5673677+mtrezza@users.noreply.github.com> Date: Fri, 3 Sep 2021 00:32:35 +0200 Subject: [PATCH 4/4] reformat code --- src/Routers/SecurityRouter.js | 6 ++++-- src/Security/Check.js | 6 +++--- src/Security/CheckRunner.js | 28 ++++++++++++++++------------ 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/Routers/SecurityRouter.js b/src/Routers/SecurityRouter.js index a9c50ecb8e..c7c217a048 100644 --- a/src/Routers/SecurityRouter.js +++ b/src/Routers/SecurityRouter.js @@ -4,10 +4,12 @@ import CheckRunner from '../Security/CheckRunner'; export class SecurityRouter extends PromiseRouter { mountRoutes() { - this.route('GET', '/security', + this.route( + 'GET', + '/security', middleware.promiseEnforceMasterKeyAccess, this._enforceSecurityCheckEnabled, - async (req) => { + async req => { const report = await new CheckRunner(req.config.security).run(); return { status: 200, diff --git a/src/Security/Check.js b/src/Security/Check.js index 7853fe7cce..dc57d63088 100644 --- a/src/Security/Check.js +++ b/src/Security/Check.js @@ -73,9 +73,9 @@ class Check { * The check state. */ const CheckState = Object.freeze({ - none: "none", - fail: "fail", - success: "success", + none: 'none', + fail: 'fail', + success: 'success', }); export default Check; diff --git a/src/Security/CheckRunner.js b/src/Security/CheckRunner.js index 2e522fefcb..a662ffbad4 100644 --- a/src/Security/CheckRunner.js +++ b/src/Security/CheckRunner.js @@ -46,7 +46,7 @@ class CheckRunner { // If report should be written to logs if (this.enableCheckLog) { - this._logReport(report) + this._logReport(report); } return report; } @@ -85,8 +85,8 @@ class CheckRunner { report: { version, state: CheckState.success, - groups: [] - } + groups: [], + }, }; // Identify report version @@ -95,13 +95,12 @@ class CheckRunner { default: // For each check group for (const group of groups) { - // Create group report const groupReport = { name: group.name(), state: CheckState.success, checks: [], - } + }; // Create check reports groupReport.checks = group.checks().map(check => { @@ -129,9 +128,9 @@ class CheckRunner { * @param {Object} report The report to log. */ _logReport(report) { - // Determine log level depending on whether any check failed - const log = report.report.state == CheckState.success ? (s) => logger.info(s) : (s) => logger.warn(s); + const log = + report.report.state == CheckState.success ? s => logger.info(s) : s => logger.warn(s); // Declare output const indent = ' '; @@ -142,7 +141,7 @@ class CheckRunner { // Traverse all groups and checks for compose output for (const group of report.report.groups) { - output += `\n- ${group.name}` + output += `\n- ${group.name}`; for (const check of group.checks) { checksCount++; @@ -166,7 +165,9 @@ class CheckRunner { `\n# #` + `\n###################################` + `\n` + - `\n${failedChecksCount > 0 ? 'Warning: ' : ''}${failedChecksCount} weak security setting(s) found${failedChecksCount > 0 ? '!' : ''}` + + `\n${ + failedChecksCount > 0 ? 'Warning: ' : '' + }${failedChecksCount} weak security setting(s) found${failedChecksCount > 0 ? '!' : ''}` + `\n${checksCount} check(s) executed` + `\n${skippedCheckCount} check(s) skipped` + `\n` + @@ -183,9 +184,12 @@ class CheckRunner { */ _getLogIconForState(state) { switch (state) { - case CheckState.success: return '✅'; - case CheckState.fail: return '❌'; - default: return 'ℹ️'; + case CheckState.success: + return '✅'; + case CheckState.fail: + return '❌'; + default: + return 'ℹ️'; } }