0.20.6 • Published 1 year ago

@appsensorlike/appsensorlike_storage_mysql v0.20.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

This is @appsensorlike/appsensorlike MySQL storage implementation.

Installation


npm i @appsensorlike/appsensorlike_storage_mysql

Preparation


Create tables in the db using module's dist/storage-providers/appsensor-storage-mysql/sql/tables.sql script.

Copy from the module's dist/storage-providers/appsensor-storage-mysql/appsensor-storage-mysql-config.json in your working directory and set "database", "user" and "password" under "poolConfig".

Usage

Considering example under @appsensorlike/appsensorlike, now you just have to pass instances of MySQLAttackStore, MySQLEventStore, MySQLResponseStore to AppSensorLocal constructor

import { AppSensorLocal } from '@appsensorlike/appsensorlike/execution-modes/appsensor-local/appsensor_local.js';
import { AppSensorEvent, Category, DetectionPoint, DetectionSystem, User } from "@appsensorlike/appsensorlike/core/core.js";
import { MySQLAttackStore, MySQLEventStore, MySQLResponseStore } from "@appsensorlike/appsensorlike_storage_mysql";


const appSensorLocal = new AppSensorLocal('appsensor-server-config.json',
                                         new MySQLAttackStore(),
                                         new MySQLEventStore(),
                                         new MySQLResponseStore());
const eventManager = appSensorLocal.getAppSensorClient().getEventManager();

//following lines are added just for purpose of demonstration
//
const user1 = new User("user1");
const detectionPoint = new DetectionPoint(Category.REQUEST, "RE7");
const detectionSystem = new DetectionSystem("localhostme");

if (eventManager) {
   await eventManager.addEvent(new AppSensorEvent(user1, detectionPoint, detectionSystem)); 
   await eventManager.addEvent(new AppSensorEvent(user1, detectionPoint, detectionSystem)); //new instance every time to set timestamp
}

Check your db tables.

TypeScript support

You need TypeScript version >= 4.7 in order the paths exported by the module to be resolved.

0.20.6

1 year ago

0.18.3

2 years ago

0.18.2

2 years ago

0.18.1

2 years ago

0.18.0

2 years ago

0.17.0

2 years ago

0.16.0

2 years ago

0.15.0

2 years ago

1.0.0

2 years ago