UNPKG

@appsensorlike/appsensorlike

Version:

A port of OWASP AppSensor reference implementation

63 lines (62 loc) 3.4 kB
import { AppSensorEvent, Attack, DetectionPoint, IPAddress, Response, IValidateInitialize } from '../core/core.js'; import { Rule } from '../core/rule/rule.js'; declare class JSONConfigManager { static CONFIGURATION_CHANGED_EVENT: string; private eventEmitter; protected configReader: JSONConfigReadValidate; protected configFile: string | null; protected configSchemaFile: string | null; protected watchConfigFile: boolean; protected currentConfig: any; constructor(configReader: JSONConfigReadValidate, configFile?: string | null, configSchemaFile?: string | null, watchConfigFile?: boolean); getConfiguration(): any; protected reloadConfiguration(): void; listenForConfigurationChange(cb: (newConfig: any) => void): void; private watch; private unwatch; } declare class JSONConfigReadValidate { protected defaultConfigFile: string; protected defaultConfigSchemaFile: string | null; protected prototypeOfConfigObj: Object | null | undefined; constructor(defaultRelativeTo: string, defaultConfigFile: string, defaultConfigSchemaFile?: string | null, prototypeOfConfigObj?: Object | null); getDefaultConfigFile(): string; getDefaultConfigSchemaFile(): string | null; getConfigLocation(configLocation?: string | null): string; getValidatorLocation(validatorLocation?: string | null): string | null; /** * Read configuration file and validate. * If a configuration file is not provided, default is taken * If a validator(schema) is not provided, default is taken. * If default schema is not set, loaded configuration is not validated * @param configLocation a configuration file path relative to the working directory or an absolute path * @param validatorLocation a validator(schema) * @param reload true when configuration file has been changed since loaded in memory * @returns a configuration object */ read(configLocation?: string | null, validatorLocation?: string | null, reload?: boolean): any; /** * Read configuration from a string and validate. * @param configAsString a string containing the configuration in JSON format * @param validatorLocation a validator(schema); if it is null, doesn't validate * @returns a configuration object */ readFromString(configAsString: string, validatorLocation?: string | null): any; protected validateConfig(config: any, validatorLocation: string, reload: boolean): boolean; } declare class Utils { static ipAddressSample: IPAddress; static detectionPointSample: DetectionPoint; static ruleSample: Rule; static appSensorEventPrototypeSample: AppSensorEvent; static attackPrototypeSample: Attack; static responsePrototypeSample: Response; static resolvePath(relativeToFileURL: string, fileLocation: string): string; static sleep(timeOutInMilis: number): Promise<null>; static setPrototypeInDepth(target: Object, source: Object): void; static isIValidateInitialize(obj: any): obj is IValidateInitialize; static setTimestampFromJSONParsedObject(target: AppSensorEvent | Attack | Response, obj: Object): void; static setPrototypeInDepthByClassName(target: Object, className: string): void; static copyPropertyValues<T1 extends Object>(srcObj: T1, trgObj: T1): void; } export { JSONConfigManager, JSONConfigReadValidate, Utils };