UNPKG

@appsensorlike/appsensorlike

Version:

A port of OWASP AppSensor reference implementation

131 lines (130 loc) 6.01 kB
import { AppSensorEvent, ClientApplication, DetectionPoint, DetectionSystem, IValidateInitialize } from "../../core.js"; import { CorrelationSet } from "../../correlation/correlation.js"; import { Rule } from "../../rule/rule.js"; /** * Client/custom detection points (override some aspects for a client or brand new detection points). */ interface IClient { clientName: string; detectionPoints: DetectionPoint[]; } /** * Client/custom detection points and regular detection points */ interface IDetectionPoints { clients?: IClient[]; detectionPoints: DetectionPoint[]; } /** * Represents the configuration for server-side components. */ interface IServerConfiguration extends IValidateInitialize { configurationFile?: string; rules?: Rule[]; detectionPoints: IDetectionPoints; correlationSets?: CorrelationSet[]; clientApplicationIdentificationHeaderName?: string; clientApplications?: ClientApplication[]; serverHostName?: string; serverPort?: number; serverSocketTimeout?: number; geolocateIpAddresses?: boolean; geolocationDatabasePath?: string; } /** * Represents the configuration for server-side components. Additionally, * contains various helper methods for common configuration-related * actions. */ declare abstract class ServerConfiguration implements IServerConfiguration { static DEFAULT_HEADER_NAME: string; configurationFile: string | undefined; rules: Rule[]; detectionPoints: IDetectionPoints; correlationSets: CorrelationSet[]; clientApplicationIdentificationHeaderName: string; clientApplications: ClientApplication[]; serverHostName: string; serverPort: number; serverSocketTimeout: number; customDetectionPoints: Map<string, DetectionPoint[]>; static clientApplicationCache: Map<string, ClientApplication>; checkValidInitialize(): void; getCustomDetectionPoints(): Map<string, DetectionPoint[]>; setCustomDetectionPoints(customPoints: Map<string, DetectionPoint[]>): ServerConfiguration; getConfigurationFile(): string | undefined; setConfigurationFile(configurationFile: string): ServerConfiguration; getRules(): Rule[]; setRules(rules: Rule[]): ServerConfiguration; getDetectionPoints(): DetectionPoint[]; setDetectionPoints(detectionPoints: DetectionPoint[]): ServerConfiguration; getCorrelationSets(): CorrelationSet[]; setCorrelationSets(correlationSets: CorrelationSet[]): ServerConfiguration; getClientApplicationIdentificationHeaderName(): string; getClientApplicationIdentificationHeaderNameOrDefault(): string; setClientApplicationIdentificationHeaderName(clientApplicationIdentificationHeaderName: string): ServerConfiguration; getClientApplications(): ClientApplication[]; setClientApplications(clientApplications: ClientApplication[]): ServerConfiguration; getServerHostName(): string; setServerHostName(serverHostName: string): ServerConfiguration; getServerPort(): number; setServerPort(serverPort: number): ServerConfiguration; getServerSocketTimeout(): number; setServerSocketTimeout(serverSocketTimeout: number): ServerConfiguration; /** * Find related detection systems based on a given detection system. * This simply means those systems that have been configured along with the * specified system id as part of a correlation set. * * @param detectionSystem system ID to evaluate and find correlated systems * @return collection of strings representing correlation set, INCLUDING specified system ID */ getRelatedDetectionSystems(detectionSystem: DetectionSystem | null): string[]; /** * Locate matching detection points configuration from server-side config file. * * @param search detection point that has been added to the system * @return DetectionPoint populated with configuration information from server-side config */ findDetectionPoints(search: DetectionPoint | null, clientApplicationName?: string | null): DetectionPoint[]; /** * Finds all {@link Rule}s that could have been triggered by the {@link AppSensorEvent}. * A trigger {@link AppSensorEvent} must be the final {@link AppSensorEvent} so * if the corresponding {@link MonitorPoint} is in the {@link Rule}'s final {@link Expression} * it should be evaluated. * * @param triggerEvent the {@link AppSensorEvent} that triggered the {@link Rule} * @return a list of {@link Rule}s applicable to triggerEvent */ findRules(triggerEvent: AppSensorEvent): Rule[]; findClientApplication(clientApplicationName: string): ClientApplication | undefined; equals(obj: Object): boolean; } /** * This interface is to be fulfilled by implementations that load a configuration * file and provide an object representation of it. * * The current implementation only consists of an XML configuration that utilizes a * standardized XSD schema. However, there is nothing in the interface requiring the * XML implementation. Most standard users will likely stick to the standard implementation. * * TODO: may update this interface is we move to something other than "reading" * the config, ie. supporting configs from data stores/cloud, etc. */ interface ServerConfigurationReader { /** * Read content using default locations * @return populated configuration object * @throws ConfigurationException */ read(): ServerConfiguration | null; /** * * @param configurationLocation specify configuration location (ie. file location of XML file) * @param validatorLocation specify validator location (ie. file location of XSD file) * @return populated configuration object * @throws ConfigurationException */ read(configurationLocation: string, validatorLocation: string | null, reload: boolean): ServerConfiguration | null; } export { IClient, IServerConfiguration, ServerConfiguration, ServerConfigurationReader };