Skip to content

Commit

Permalink
fix: fixed allowlisting when denylist requests processed, removed arb…
Browse files Browse the repository at this point in the history
…itrary code comment from redis cache fix, added silentSymbol to suppress console output for incredibly verbose/repeating messages (e.g. duplicate log error messages from mongoose), suppressed calendar gregorian scale migration output
  • Loading branch information
titanism committed Apr 19, 2024
1 parent b894528 commit 94c38a8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
22 changes: 18 additions & 4 deletions app/controllers/web/denylist.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Boom = require('@hapi/boom');
const dayjs = require('dayjs-with-plugins');
const isFQDN = require('is-fqdn');
const isSANB = require('is-string-and-not-blank');
const ms = require('ms');
const { boolean } = require('boolean');
const { isEmail, isIP } = require('validator');

Expand Down Expand Up @@ -264,24 +265,37 @@ async function remove(ctx) {
// del ip
await ctx.client.del(`denylist:${ctx.state.q}`);
// add ip
await ctx.client.set(`allowlist:${ctx.state.q}`, true);
await ctx.client.set(`allowlist:${ctx.state.q}`, 'true', 'PX', ms('30d'));
} else {
// del email and/or domain
await ctx.client.del(`denylist:${ctx.state.q}`);
await ctx.client.set(`allowlist:${ctx.state.q}`, 'true', 'PX', ms('30d'));
// del root domain
if (ctx.state.rootDomain && ctx.state.q !== ctx.state.rootDomain) {
await ctx.client.del(`denylist:${ctx.state.rootDomain}`);
await ctx.client.set(`allowlist:${ctx.state.rootDomain}`, true);
await ctx.client.set(
`allowlist:${ctx.state.rootDomain}`,
'true',
'PX',
ms('30d')
);
}

// if it was an email then delete the combo
if (isEmail(ctx.state.q) && ctx.state.rootDomain) {
await ctx.client.del(`denylist:${ctx.state.q}`);
await ctx.client.del(`denylist:${ctx.state.rootDomain}:${ctx.state.q}`);
await ctx.client.set(`allowlist:${ctx.state.q}`);
await ctx.client.set(
`allowlist:${ctx.state.q}`,
'true',
'PX',
ms('30d')
);
await ctx.client.set(
`allowlist:${ctx.state.rootDomain}:${ctx.state.q}`,
true
'true',
'PX',
ms('30d')
);
}
}
Expand Down
3 changes: 0 additions & 3 deletions assets/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ function toArrayBuffer(buffer) {
);
}

// arbitrary comment to trigger re-cache
(() => {})();

// load jQuery and Bootstrap
// <https://stackoverflow.com/a/34340392>
// <https://github.com/FezVrasta/popper.js/issues/287#issuecomment-321887784>
Expand Down
7 changes: 7 additions & 0 deletions helpers/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ for (const level of logger.config.levels) {

if (hash) meta.app.hash = hash;

if (
meta?.ignore_hook === true ||
err?.is_duplicate_log === true ||
err?.ignoreHook === true
)
meta[silentSymbol] = true;

if (
meta.is_http &&
meta.response &&
Expand Down
9 changes: 6 additions & 3 deletions helpers/migrate-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,12 @@ async function migrateSchema(db, session, tables) {
//
// NOTE: for now in the interim we're going to simply log it as a code bug
//
errors.push(
`Column "${key}" in table "${table}" has property "${prop}" with definition "${column[prop]}" when it needs to be "${tables[table].mapping[key][prop]}" to match the current schema`
);
const message = `Column "${key}" in table "${table}" has property "${prop}" with definition "${column[prop]}" when it needs to be "${tables[table].mapping[key][prop]}" to match the current schema`;
if (
message !==
'Column "scale" in table "Calendars" has property "default_value" with definition "null" when it needs to be "Gregorian" to match the current schema'
)
errors.push(message);
}
}
}
Expand Down

0 comments on commit 94c38a8

Please sign in to comment.