Skip to content

Commit

Permalink
Fixes for null conditions to backend server utils and apiregistry
Browse files Browse the repository at this point in the history
  • Loading branch information
TekMonksGitHub committed Jan 16, 2024
1 parent 537a204 commit c2a5b9c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions backend/server/lib/apiregistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ async function checkSecurity(url, req, headers, servObject, reason) {
const allSecurityCheckers = [...securitycheckers];
if (apiregentry.query.customSecurity) for (const securityCheckerCustom of utils.escapedSplit(apiregentry.query.customSecurity, ","))
allSecurityCheckers.push(global.APIREGISTRY.ENV.CUSTOM_SECURITY_CHECKERS[securityCheckerCustom]);
for (const securitycheckerThis of allSecurityCheckers) if (!(await securitycheckerThis.checkSecurity(apiregentry, endPoint,
req, headers, servObject, reason))) {
reason.reason += ` ---- Failed on: ${securitycheckerThis.__org_monkshu_apiregistry_conf_modulename}`;
return false;
for (const securitycheckerThis of allSecurityCheckers) if (securitycheckerThis &&
(!(await securitycheckerThis.checkSecurity(apiregentry, endPoint, req, headers, servObject, reason)))) {
reason.reason += ` ---- Failed on: ${securitycheckerThis.__org_monkshu_apiregistry_conf_modulename}`;
return false;
}

return true;
Expand Down
3 changes: 2 additions & 1 deletion backend/server/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ function generateUUID(useDashes=true) { // Public Domain/MIT: from https://stack
*/
function createAsyncFunction(code) {
const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
const newFunction = context => new AsyncFunction(Object.keys(context).join(","), code)(...Object.values(context));
const newFunction = context => new AsyncFunction(Object.keys(context||{}).join(","), code)(...Object.values(context||{}));
return newFunction;
}

Expand Down Expand Up @@ -516,6 +516,7 @@ function isObject(obj) {
* @returns The MD5 hash.
*/
function hashObject(obj) {
if (!obj) return undefined;
const combinedString = typeof obj !== "object" ? obj.toString() :
Object.entries(obj).reduce((accumulator, [key, value]) => accumulator += `${key}:${value.toString()}`, "");
return crypto.createHash("md5").update(combinedString).digest("hex");
Expand Down
2 changes: 1 addition & 1 deletion build_number
Original file line number Diff line number Diff line change
@@ -1 +1 @@
775
776
2 changes: 1 addition & 1 deletion frontend/framework/js/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function generateUUID(useDashes=true) { // Public Domain/MIT: from https://stack
*/
const createAsyncFunction = code => {
const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;
const newFunction = context => new AsyncFunction(Object.keys(context).join(","), code)(...Object.values(context));
const newFunction = context => new AsyncFunction(Object.keys(context||{}).join(","), code)(...Object.values(context||{}));
return newFunction;
}

Expand Down

0 comments on commit c2a5b9c

Please sign in to comment.