Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/remove header based logger #301

Merged
merged 8 commits into from
Jan 17, 2024
3 changes: 0 additions & 3 deletions lib/pxconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class PxConfig {
['JWT_HEADER_USER_ID_FIELD_NAME', 'px_jwt_header_user_id_field_name'],
['JWT_HEADER_ADDITIONAL_FIELD_NAMES', 'px_jwt_header_additional_field_names'],
['CUSTOM_IS_SENSITIVE_REQUEST', 'px_custom_is_sensitive_request'],
['LOGGER_AUTH_TOKEN', 'px_logger_auth_token'],
['FIRST_PARTY_TIMEOUT_MS', 'px_first_party_timeout_ms'],
['URL_DECODE_RESERVED_CHARACTERS', 'px_url_decode_reserved_characters']
];
Expand Down Expand Up @@ -365,7 +364,6 @@ function pxDefaultConfig() {
JWT_HEADER_USER_ID_FIELD_NAME: '',
JWT_HEADER_ADDITIONAL_FIELD_NAMES: [],
CUSTOM_IS_SENSITIVE_REQUEST: '',
LOGGER_AUTH_TOKEN: '',
FIRST_PARTY_TIMEOUT_MS: 4000,
URL_DECODE_RESERVED_CHARACTERS: false
};
Expand Down Expand Up @@ -441,7 +439,6 @@ const allowedConfigKeys = [
'px_jwt_header_user_id_field_name',
'px_jwt_header_additional_field_names',
'px_custom_is_sensitive_request',
'px_logger_auth_token',
'px_first_party_timeout_ms'
];

Expand Down
11 changes: 0 additions & 11 deletions lib/pxenforcer.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const {
CI_CREDENTIALS_COMPROMISED_FIELD,
} = require('./utils/constants');
const pxCors = require('./pxcors');
const { LogServiceClient } = require('./pxlogserviceclient');

class PxEnforcer {
constructor(params, client) {
Expand All @@ -48,8 +47,6 @@ class PxEnforcer {

this.reversePrefix = this.pxConfig.conf.PX_APP_ID.substring(2);
this.initializeCredentialsIntelligence(this.logger, this._config);

this.logServiceClient = new LogServiceClient(this._config, this.pxClient);
}

initializeCredentialsIntelligence(logger, config) {
Expand Down Expand Up @@ -642,14 +639,6 @@ class PxEnforcer {
cb(htmlTemplate);
});
}

sendHeaderBasedLogs(pxCtx, config, req) {
const headerValue = pxCtx ? pxCtx.headers[Constants.X_PX_ENFORCER_LOG_HEADER] : req.headers[Constants.X_PX_ENFORCER_LOG_HEADER];
if (headerValue && headerValue === config.LOGGER_AUTH_TOKEN) {
this.logServiceClient.sendLogs(pxCtx, config.logger.logs, req);
}
config.logger.logs = [];
}
}

module.exports = PxEnforcer;
8 changes: 0 additions & 8 deletions lib/pxlogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,18 @@ class PxLogger {
}

debug(msg) {
this.recordLog(msg, LoggerSeverity.DEBUG);
if (this.debugMode && typeof msg === 'string') {
this.internalLogger.info(`[PerimeterX - DEBUG][${this.appId}] - ${msg}`);
}
}

error(msg) {
this.recordLog(msg, LoggerSeverity.ERROR);
if (this.loggerSeverity !== LoggerSeverity.NONE && typeof msg === 'string') {
this.internalLogger.error(
new Error(`[PerimeterX - ERROR][${this.appId}] - ${msg}`).stack
);
}
}

recordLog(message, loggerSeverity) {
const logRecord = { message: message, severity: loggerSeverity, messageTimestamp: Date.now() };
this.logs.push(logRecord);
}

}

module.exports = PxLogger;
41 changes: 0 additions & 41 deletions lib/pxlogserviceclient.js

This file was deleted.

5 changes: 0 additions & 5 deletions lib/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ const JWT_ADDITIONAL_FIELDS_FIELD_NAME = 'jwt_additional_fields';
const CROSS_TAB_SESSION = 'cross_tab_session';
const COOKIE_SEPARATOR = ';';

const X_PX_ENFORCER_LOG_HEADER = 'x-px-enforcer-log';
const EXTERNAL_LOGGER_SERVICE_PATH = '/enforcer-logs/';

module.exports = {
MILLISECONDS_IN_SECOND,
SECONDS_IN_MINUTE,
Expand Down Expand Up @@ -69,6 +66,4 @@ module.exports = {
JWT_ADDITIONAL_FIELDS_FIELD_NAME,
CROSS_TAB_SESSION,
COOKIE_SEPARATOR,
X_PX_ENFORCER_LOG_HEADER,
EXTERNAL_LOGGER_SERVICE_PATH
};
Loading