Socket
Socket
Sign inDemoInstall

@contrast/reporter

Package Overview
Dependencies
Maintainers
14
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrast/reporter - npm Package Compare versions

Comparing version 1.12.0 to 1.13.0

lib/index.d.ts.map

1

lib/index.d.ts

@@ -9,1 +9,2 @@ import BaseReporter, { Core } from './reporters/base';

}): ReporterBus;
//# sourceMappingURL=index.d.ts.map

13

lib/reporters/base.d.ts

@@ -1,4 +0,2 @@

/// <reference types="node" />
import { EventEmitter } from 'events';
import { AppInfo, Messages, RequestStore } from '@contrast/common';
import { AppInfo, Event, Lifecycle, Messages, RequestStore } from '@contrast/common';
import { Config } from '@contrast/config';

@@ -15,11 +13,15 @@ import { Scopes } from '@contrast/scopes';

readonly messages: Messages;
readonly events: {
lifecycle: Lifecycle;
};
readonly protect: Protect;
readonly scopes: Scopes;
readonly getEffectiveConfig: any;
}
export default abstract class BaseReporter {
name: string;
messages: EventEmitter;
messages: Messages;
scopes: Scopes;
constructor(core: Core, name: string);
subscribeWithLock(event: string, cb: (msg: Record<string, any>) => void): void;
subscribeWithLock(event: Event, cb: (msg: any) => void, ee?: Lifecycle | Messages): void;
abstract install(): Promise<void>;

@@ -29,1 +31,2 @@ abstract handleAssessEvent(msg: RequestStore): void;

}
//# sourceMappingURL=base.d.ts.map

@@ -27,5 +27,5 @@ "use strict";

}
subscribeWithLock(event, cb) {
subscribeWithLock(event, cb, ee) {
const { instrumentation } = this.scopes;
this.messages.on(event, (msg) => {
(ee || this.messages).on(event, (msg) => {
if (!instrumentation.isLocked()) {

@@ -32,0 +32,0 @@ instrumentation.run({ lock: true, name: this.name }, cb, msg);

@@ -1,4 +0,3 @@

import { AxiosInstance } from 'axios';
import BaseReporter, { Core } from '../../base';
import { AttackModel } from '../types';
import { Core } from '../../base';
import { AttackModel, ContrastUIReporter } from '../types';
import NgEndpoint from './ng-endpoint';

@@ -9,6 +8,5 @@ export default class ApplicationActivity extends NgEndpoint {

userAgentSet: Set<string>;
constructor(core: Core, uiReporter: BaseReporter & {
ngClient: AxiosInstance;
});
constructor(core: Core, uiReporter: ContrastUIReporter);
put(): Promise<void>;
}
//# sourceMappingURL=application-activity.d.ts.map

@@ -1,10 +0,9 @@

import { AxiosInstance } from 'axios';
import BaseReporter, { Core } from '../../base';
import { Core } from '../../base';
import { ContrastUIReporter } from '../types';
import V1Endpoint from './v1-endpoint';
export default class ApplicationSettings extends V1Endpoint {
lastUpdate: string;
constructor(core: Core, uiReporter: BaseReporter & {
v1Client: AxiosInstance;
});
constructor(core: Core, uiReporter: ContrastUIReporter);
get(): Promise<void>;
}
//# sourceMappingURL=application-settings.d.ts.map

@@ -29,5 +29,5 @@ "use strict";

async get() {
const { client, core: { logger, messages }, url, hostName, path, type, language, appName } = this;
const { client, core: { logger, messages }, } = this;
try {
const resp = await client.get(`${url}/${hostName}/${path}/${type}/${language}/${appName}/settings`, {
const resp = await client.get(this.appUrl('/settings'), {
headers: {

@@ -43,6 +43,4 @@ 'If-Modified-Since': this.lastUpdate

catch (err) {
if (err.response?.status >= 400) {
logger.error({ err, url }, 'failure getting application-settings');
throw err;
}
logger.error({ err }, 'failure getting application-settings');
throw err;
}

@@ -49,0 +47,0 @@ }

@@ -1,9 +0,8 @@

import { AxiosInstance } from 'axios';
import BaseReporter, { Core } from '../../base';
import { Core } from '../../base';
import { ContrastUIReporter } from '../types';
import NgEndpoint from './ng-endpoint';
export default class ApplicationStartup extends NgEndpoint {
constructor(core: Core, uiReporter: BaseReporter & {
ngClient: AxiosInstance;
});
constructor(core: Core, uiReporter: ContrastUIReporter);
put(): Promise<void>;
}
//# sourceMappingURL=application-startup.d.ts.map

@@ -10,1 +10,2 @@ import { Core } from '../../base';

export default BaseEndpoint;
//# sourceMappingURL=base-endpoint.d.ts.map
import { AxiosInstance } from 'axios';
import { Core } from '../../base';
import BaseEndpoint from './base-endpoint';
export interface NgEndpointOpts {
ngClient: AxiosInstance;
url: string;
}
export declare class NgEndpoint extends BaseEndpoint {
client: AxiosInstance;
constructor(core: Core, opts: {
ngClient: AxiosInstance;
url: string;
});
constructor(core: Core, opts: NgEndpointOpts);
}
export default NgEndpoint;
//# sourceMappingURL=ng-endpoint.d.ts.map

@@ -1,10 +0,9 @@

import { AxiosInstance } from 'axios';
import BaseReporter, { Core } from '../../base';
import { Core } from '../../base';
import { ContrastUIReporter } from '../types';
import NgEndpoint from './ng-endpoint';
export default class ServerStartup extends NgEndpoint {
lastUpdate: number;
constructor(core: Core, uiReporter: BaseReporter & {
ngClient: AxiosInstance;
});
constructor(core: Core, uiReporter: ContrastUIReporter);
put(): Promise<void>;
}
//# sourceMappingURL=server-activity.d.ts.map

@@ -1,10 +0,9 @@

import { AxiosInstance } from 'axios';
import BaseReporter, { Core } from '../../base';
import { Core } from '../../base';
import { ContrastUIReporter } from '../types';
import V1Endpoint from './v1-endpoint';
export default class ServerSettings extends V1Endpoint {
lastUpdate: string;
constructor(core: Core, uiReporter: BaseReporter & {
v1Client: AxiosInstance;
});
constructor(core: Core, uiReporter: ContrastUIReporter);
get(): Promise<void>;
}
//# sourceMappingURL=server-settings.d.ts.map

@@ -29,5 +29,5 @@ "use strict";

async get() {
const { client, core: { logger, messages }, url, hostName, path, type } = this;
const { client, core: { logger, messages }, } = this;
try {
const resp = await client.get(`${url}/${hostName}/${path}/${type}/settings`, {
const resp = await client.get(this.serverUrl('/settings'), {
headers: {

@@ -43,6 +43,4 @@ 'If-Modified-Since': this.lastUpdate

catch (err) {
if (err.response?.status >= 400) {
logger.error({ err, url }, 'failure getting server-settings');
throw err;
}
logger.error({ err }, 'failure getting server-settings');
throw err;
}

@@ -49,0 +47,0 @@ }

@@ -1,9 +0,8 @@

import { AxiosInstance } from 'axios';
import BaseReporter, { Core } from '../../base';
import { Core } from '../../base';
import { ContrastUIReporter } from '../types';
import NgEndpoint from './ng-endpoint';
export default class ServerStartup extends NgEndpoint {
constructor(core: Core, uiReporter: BaseReporter & {
ngClient: AxiosInstance;
});
constructor(core: Core, uiReporter: ContrastUIReporter);
put(): Promise<void>;
}
//# sourceMappingURL=server-startup.d.ts.map

@@ -7,1 +7,2 @@ import { ProtectMessage } from '@contrast/common';

};
//# sourceMappingURL=translations.d.ts.map
import { AxiosInstance } from 'axios';
import { Core } from '../../base';
import BaseEndpoint from './base-endpoint';
export interface V1EndpointOpts {
v1Client: AxiosInstance;
url: string;
}
export declare class V1Endpoint extends BaseEndpoint {
client: AxiosInstance;
hostName: string;
path: string;
type: string;
language: string;
serverHostName: string;
serverPath: string;
serverType: string;
appLanguage: string;
appName: string;
constructor(core: Core, opts: {
v1Client: AxiosInstance;
url: string;
});
constructor(core: Core, opts: V1EndpointOpts);
appUrl(endpoint: string): string;
serverUrl(endpoint: string): string;
}
export default V1Endpoint;
//# sourceMappingURL=v1-endpoint.d.ts.map

@@ -21,12 +21,21 @@ "use strict";

exports.V1Endpoint = void 0;
const path_1 = __importDefault(require("path"));
const utils_1 = require("../utils");
const base_endpoint_1 = __importDefault(require("./base-endpoint"));
const utils_1 = require("../utils");
class V1Endpoint extends base_endpoint_1.default {
constructor(core, opts) {
super(core, opts);
const { serverName, app_dir, node_version, name } = core.appInfo;
const encoded = [serverName, app_dir, `node.js ${node_version}`, 'Node', name].map(utils_1.base64EncodeUnpadded);
this.client = opts.v1Client;
[this.hostName, this.path, this.type, this.language, this.appName] = encoded;
this.serverHostName = (0, utils_1.base64EncodeUnpadded)(core.appInfo.serverName);
this.serverPath = (0, utils_1.base64EncodeUnpadded)(core.appInfo.app_dir);
this.serverType = (0, utils_1.base64EncodeUnpadded)(`node.js ${core.appInfo.node_version}`);
this.appLanguage = (0, utils_1.base64EncodeUnpadded)('Node');
this.appName = (0, utils_1.base64EncodeUnpadded)(core.appInfo.name);
}
appUrl(endpoint) {
return path_1.default.posix.join(this.url, this.serverHostName, this.serverPath, this.serverType, this.appLanguage, this.appName, endpoint);
}
serverUrl(endpoint) {
return path_1.default.posix.join(this.url, this.serverHostName, this.serverPath, this.serverType, endpoint);
}
}

@@ -33,0 +42,0 @@ exports.V1Endpoint = V1Endpoint;

@@ -0,22 +1,35 @@

import { RequestStore } from '@contrast/common';
import { AxiosInstance } from 'axios';
import { RequestStore } from '@contrast/common';
import BaseReporter, { Core } from '../base';
import ApplicationActivity from './endpoints/application-activity';
import ApplicationInventory from './endpoints/application-inventory';
import ApplicationSettings from './endpoints/application-settings';
import ApplicationStartup from './endpoints/application-startup';
import ApplicationUpdate from './endpoints/application-update';
import EffectiveConfig from './endpoints/effective-config';
import LibraryUsage from './endpoints/library-usage';
import RoutesObserved from './endpoints/routes-observed';
import ServerActivity from './endpoints/server-activity';
import ServerSettings from './endpoints/server-settings';
import ServerStartup from './endpoints/server-startup';
import ServerSettings from './endpoints/server-settings';
import ApplicationSettings from './endpoints/application-settings';
import Traces from './endpoints/traces/';
export default class ContrastUIReporter extends BaseReporter {
ngClient: AxiosInstance;
v1Client: AxiosInstance;
appActivityInterval: number;
appSettingsInterval: number;
appUpdateInterval: number;
serverSettingsInterval: number;
applicationActivity: ApplicationActivity;
applicationInventory: ApplicationInventory;
applicationSettings: ApplicationSettings;
applicationStartup: ApplicationStartup;
applicationSettings: ApplicationSettings;
applicationUpdate: ApplicationUpdate;
effectiveConfig: EffectiveConfig;
libraryUsage: LibraryUsage;
routesObserved: RoutesObserved;
serverActivity: ServerActivity;
serverSettings: ServerSettings;
serverStartup: ServerStartup;
serverSettings: ServerSettings;
activityInterval: number;
appSettingsInterval: number;
serverSettingsInterval: number;
traces: Traces;
constructor(core: Core, name?: string);

@@ -27,1 +40,2 @@ install(): Promise<void>;

}
//# sourceMappingURL=index.d.ts.map

@@ -20,30 +20,45 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("@contrast/common");
const base_1 = __importDefault(require("../base"));
const utils_1 = require("./utils");
const application_activity_1 = __importDefault(require("./endpoints/application-activity"));
const application_inventory_1 = __importDefault(require("./endpoints/application-inventory"));
const application_settings_1 = __importDefault(require("./endpoints/application-settings"));
const application_startup_1 = __importDefault(require("./endpoints/application-startup"));
const application_update_1 = __importDefault(require("./endpoints/application-update"));
const effective_config_1 = __importDefault(require("./endpoints/effective-config"));
const library_usage_1 = __importDefault(require("./endpoints/library-usage"));
const routes_observed_1 = __importDefault(require("./endpoints/routes-observed"));
const server_activity_1 = __importDefault(require("./endpoints/server-activity"));
const server_settings_1 = __importDefault(require("./endpoints/server-settings"));
const server_startup_1 = __importDefault(require("./endpoints/server-startup"));
const server_settings_1 = __importDefault(require("./endpoints/server-settings"));
const application_settings_1 = __importDefault(require("./endpoints/application-settings"));
const traces_1 = __importDefault(require("./endpoints/traces/"));
const utils_1 = require("./utils");
class ContrastUIReporter extends base_1.default {
constructor(core, name = 'contrast-ui-reporter') {
const { polling } = core.config.agent;
super(core, name);
const { app_activity_ms, app_settings_ms, server_settings_ms } = core.config.agent.polling;
this.activityInterval = app_activity_ms;
this.appSettingsInterval = app_settings_ms;
this.serverSettingsInterval = server_settings_ms;
// state shared by endpoints
this.appActivityInterval = polling.app_activity_ms;
this.appSettingsInterval = polling.app_settings_ms;
this.appUpdateInterval = polling.app_update_ms;
this.serverSettingsInterval = polling.server_settings_ms;
this.ngClient = (0, utils_1.createNgClient)(core);
this.v1Client = (0, utils_1.createV1Client)(core);
// endpoints
this.applicationStartup = new application_startup_1.default(core, this);
this.applicationActivity = new application_activity_1.default(core, this);
this.applicationInventory = new application_inventory_1.default(core, this);
this.applicationSettings = new application_settings_1.default(core, this);
this.applicationStartup = new application_startup_1.default(core, this);
this.effectiveConfig = new effective_config_1.default(core, this);
this.applicationUpdate = new application_update_1.default(core, this);
this.effectiveConfig = new effective_config_1.default(core, this);
this.libraryUsage = new library_usage_1.default(core, this);
this.routesObserved = new routes_observed_1.default(core, this);
this.serverActivity = new server_activity_1.default(core, this);
this.serverSettings = new server_settings_1.default(core, this);
this.serverStartup = new server_startup_1.default(core, this);
this.serverSettings = new server_settings_1.default(core, this);
this.traces = new traces_1.default(core, this);
}
async install() {
const { activityInterval, appSettingsInterval, serverSettingsInterval } = this;
// don't catch any errors thrown in these "onboarding" requests - they'll be handled
// by agentify during install phase so the app will run without instrumentation
await this.serverStartup.put();

@@ -53,12 +68,80 @@ await this.applicationStartup.put();

await this.applicationSettings.get();
await this.effectiveConfig.put();
setInterval(async () => {
await this.serverActivity.put();
await this.applicationActivity.put();
}, activityInterval).unref();
try {
await this.applicationActivity.put();
}
catch (err) {
// [1] for now just swallow any errors; the endpoint methods will log them.
// we may need to uninstall in the future, depending on nature of the error.
}
try {
await this.serverActivity.put();
}
catch (err) {
// [1]
}
try {
await this.traces.put();
}
catch (err) {
// [1]
}
}, this.appActivityInterval).unref();
setInterval(async () => {
await this.serverSettings.get();
}, serverSettingsInterval).unref();
try {
await this.serverSettings.get();
}
catch (err) {
// [1]
}
}, this.serverSettingsInterval).unref();
setInterval(async () => {
await this.applicationSettings.get();
}, appSettingsInterval).unref();
try {
await this.applicationSettings.get();
}
catch (err) {
// [1]
}
}, this.appSettingsInterval).unref();
setInterval(async () => {
try {
await this.applicationUpdate.put();
}
catch (err) {
// [1]
}
}, this.appUpdateInterval).unref();
this.subscribeWithLock(common_1.Event.ROUTE_COVERAGE_DISCOVERY_FINISHED, async (routes) => {
try {
await this.applicationInventory.post(routes);
}
catch (err) {
// [1]
}
});
this.subscribeWithLock(common_1.Event.ROUTE_COVERAGE_OBSERVATION, async (route) => {
try {
await this.routesObserved.post(route);
}
catch (err) {
// [1]
}
});
this.subscribeWithLock(common_1.Event.LIBRARY_USAGE, async (libInfo) => {
try {
await this.libraryUsage.post(libInfo);
}
catch (err) {
// [1]
}
});
this.subscribeWithLock(common_1.Event.SERVER_SETTINGS_UPDATE, async () => {
try {
await this.effectiveConfig.put();
}
catch (err) {
// [1]
}
});
}

@@ -65,0 +148,0 @@ handleAssessEvent(msg) { }

@@ -1,2 +0,9 @@

import { Rule } from '@contrast/common';
import { Rule, InputType } from '@contrast/common';
import { AxiosInstance } from 'axios';
import BaseReporter from '../base';
export { InputType };
export interface ContrastUIReporter extends BaseReporter {
ngClient: AxiosInstance;
v1Client: AxiosInstance;
}
export interface Timestamp {

@@ -11,26 +18,2 @@ start: number;

}
export declare enum InputType {
UNDEFINED_TYPE = "UNDEFINED_TYPE",
BODY = "BODY",
COOKIE_NAME = "COOKIE_NAME",
COOKIE_VALUE = "COOKIE_VALUE",
HEADER = "HEADER",
PARAMETER_NAME = "PARAMETER_NAME",
PARAMETER_VALUE = "PARAMETER_VALUE",
QUERYSTRING = "QUERYSTRING",
URI = "URI",
SOCKET = "SOCKET",
JSON_VALUE = "JSON_VALUE",
JSON_ARRAYED_VALUE = "JSON_ARRAYED_VALUE",
MULTIPART_CONTENT_TYPE = "MULTIPART_CONTENT_TYPE",
MULTIPART_VALUE = "MULTIPART_VALUE",
MULTIPART_FIELD_NAME = "MULTIPART_FIELD_NAME",
MULTIPART_NAME = "MULTIPART_NAME",
XML_VALUE = "XML_VALUE",
DWR_VALUE = "DWR_VALUE",
METHOD = "METHOD",
REQUEST = "REQUEST",
URL_PARAMETER = "URL_PARAMETER",
UNKNOWN = "UNKNOWN"
}
export interface DefendInput {

@@ -223,1 +206,2 @@ name: string;

}
//# sourceMappingURL=types.d.ts.map

@@ -17,4 +17,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.InputType = exports.DocumentType = void 0;
exports.DocumentType = exports.InputType = void 0;
const common_1 = require("@contrast/common");
Object.defineProperty(exports, "InputType", { enumerable: true, get: function () { return common_1.InputType; } });
var DocumentType;

@@ -26,27 +27,2 @@ (function (DocumentType) {

})(DocumentType = exports.DocumentType || (exports.DocumentType = {}));
var InputType;
(function (InputType) {
InputType["UNDEFINED_TYPE"] = "UNDEFINED_TYPE";
InputType["BODY"] = "BODY";
InputType["COOKIE_NAME"] = "COOKIE_NAME";
InputType["COOKIE_VALUE"] = "COOKIE_VALUE";
InputType["HEADER"] = "HEADER";
InputType["PARAMETER_NAME"] = "PARAMETER_NAME";
InputType["PARAMETER_VALUE"] = "PARAMETER_VALUE";
InputType["QUERYSTRING"] = "QUERYSTRING";
InputType["URI"] = "URI";
InputType["SOCKET"] = "SOCKET";
InputType["JSON_VALUE"] = "JSON_VALUE";
InputType["JSON_ARRAYED_VALUE"] = "JSON_ARRAYED_VALUE";
InputType["MULTIPART_CONTENT_TYPE"] = "MULTIPART_CONTENT_TYPE";
InputType["MULTIPART_VALUE"] = "MULTIPART_VALUE";
InputType["MULTIPART_FIELD_NAME"] = "MULTIPART_FIELD_NAME";
InputType["MULTIPART_NAME"] = "MULTIPART_NAME";
InputType["XML_VALUE"] = "XML_VALUE";
InputType["DWR_VALUE"] = "DWR_VALUE";
InputType["METHOD"] = "METHOD";
InputType["REQUEST"] = "REQUEST";
InputType["URL_PARAMETER"] = "URL_PARAMETER";
InputType["UNKNOWN"] = "UNKNOWN";
})(InputType = exports.InputType || (exports.InputType = {}));
//# sourceMappingURL=types.js.map

@@ -7,1 +7,2 @@ import { AxiosInstance } from 'axios';

export declare function createV1Client(core: Core): AxiosInstance;
//# sourceMappingURL=utils.d.ts.map

@@ -65,12 +65,14 @@ "use strict";

function createV1Client(core) {
const opts = {
const client = axios_1.default.create({
baseURL: new URL(`${core.config.api.url}`).href,
headers: {
'Authorization': base64Encode(`${core.config.api.user_name}:${core.config.api.service_key}`),
'API-Key': core.config.api.api_key
}
};
return axios_1.default.create(opts);
'API-Key': core.config.api.api_key,
'User-Agent': `ContrastNodeAgent/${core.agentVersion}`,
},
validateStatus: (status) => status < 400,
});
return client;
}
exports.createV1Client = createV1Client;
//# sourceMappingURL=utils.js.map

@@ -7,3 +7,3 @@ import { RequestStore } from '@contrast/common';

constructor(core: Core, name?: string);
handle(event: string, msg: Record<string, any>): void;
handle(event: string, msg: any): void;
install(): Promise<void>;

@@ -13,1 +13,2 @@ handleAssessEvent(msg: RequestStore): void;

}
//# sourceMappingURL=file.d.ts.map

@@ -41,2 +41,3 @@ "use strict";

common_1.Event.ROUTE_COVERAGE_DISCOVERY,
common_1.Event.ROUTE_COVERAGE_DISCOVERY_FINISHED,
common_1.Event.ROUTE_COVERAGE_OBSERVATION

@@ -43,0 +44,0 @@ ].forEach(event => {

@@ -36,1 +36,2 @@ import { RequestStore } from '@contrast/common';

export {};
//# sourceMappingURL=index.d.ts.map

@@ -81,3 +81,3 @@ "use strict";

target._flat[name] = value;
target._sources[name] = 'ContrastUI';
target._sources[name] = 'CONTRAST_UI';
}

@@ -84,0 +84,0 @@ core.messages.on(common_1.Event.SERVER_SETTINGS_UPDATE, (msg) => {

@@ -9,1 +9,2 @@ import { Result, ServerFeaturePreliminaryResult } from '@contrast/common';

export type AttackFunction = typeof successfulAttack | typeof ineffectiveAttack | typeof suspiciousAttack;
//# sourceMappingURL=messages.d.ts.map
{
"name": "@contrast/reporter",
"version": "1.12.0",
"version": "1.13.0",
"description": "Subscribes to agent messages and reports them",

@@ -20,4 +20,5 @@ "license": "SEE LICENSE IN LICENSE",

"dependencies": {
"@contrast/common": "1.7.0",
"@contrast/common": "1.8.0",
"axios": "^0.27.2",
"crc-32": "^1.2.2",
"hpagent": "^1.2.0",

@@ -24,0 +25,0 @@ "safe-stable-stringify": "^2.4.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc