Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A NodeJS Server for LokiJS
Sloki is a nodejs server which embed LokiJS, a blazing fast in-memory documents database. Sloki help to make LokiJS scalable : you can now have multiple processes speaking with LokiJS through Sloki.
A possible architecture using sloki :
+----------------------------+ TCP / Binary +-----------------------------------+
| NodeJS app worker #1 |<------------------->| |
+----------------------------+ | Sloki |
| |
+----------------------------+ TCP / Binary | +-------------------------+ |
| NodeJS app worker #2 |<------------------->| | | |
+----------------------------+ | | | |
| | LokiJS | |
+----------------------------+ TCP / JSONRPC | | fast in-memory database | |
| go/php/python/C/whatever |<------------------->| | | |
+----------------------------+ | | | |
| | | |
+----------------------------+ TCP / Binary | +-------------------------+ |
| sloki-cli |<------------------->| |
+----------------------------+ +-----------------------------------+
For moment, only TCP transport is supported. The advantage of TCP vs HTTP API is that the connection is persistent.
By default, Sloki listens on the following ports:
Port | Transport | TLS | Protocol | ops/sec/client |
---|---|---|---|---|
6370 | TCP | NO | Binary (fastest) | avg 18K ops/sec |
6371 | TCP | YES | Binary (fastest) | avg 25K ops/sec (??) |
6372 | TCP | NO | JSONRPC | avg 17K ops/sec |
6373 | TCP | YES | JSONRPC | avg 24K ops/sec (??) |
If somebody have an idea why TLS is fastest than TCP, i'd like to know .. :)
You will need a client to speak with sloki.
The binary protocol has been made with performance in mind. Payloads looks like JSONRPC, but it's not.
REQUEST | RESPONSE
------------------------------------------- | --------------------------------------
{ | {
"m":"myMethod", | "r":true,
"p":["foo","bar"], | "id":"operation-uniq-id"
"id":"operation-uniq-id" | }
} |
jsonrpc
version attribute, method
become m
, params
become p
, result
become r
)The JSONRPC protocol has been chosen for interoperability.
REQUEST | RESPONSE
------------------------------------------- | --------------------------------------
{ | {
"jsonrpc":"2.0", | "jsonrpc":"2.0"
"method":"myMethod", | "result":true,
"params":["foo","bar"], | "id":"operation-uniq-id"
"id":"operation-uniq-id" | }
} |
npm install -g sloki
sloki
sloki --help
See https://github.com/sloki-project/sloki-node-client
The client will load every methods that sloki server have, so, the client documentation is not really usefull
See https://github.com/sloki-project/sloki-benchs
Icon | Description |
---|---|
:heavy_check_mark: | implemented |
:heavy_plus_sign: | in progress/MUST be implemented |
:red_circle: | does NOT make sens in sloki, will NOT be implemented |
:question: | MAY be implemented |
Status | Transport | Notes |
---|---|---|
:heavy_check_mark: | TCP | Persistant connection |
:heavy_plus_sign: | TLS | Persistant connection |
:question: | HTTP | |
:question: | HTTPS |
Status | Method | Parameter | Description |
---|---|---|---|
:heavy_check_mark: | clients | return TCP/TLS connected clients | |
:heavy_check_mark: | gc | invoke gc(), for testing purpose | |
:heavy_check_mark: | maxClients | return TCP/TLS maxClients | |
:heavy_check_mark: | maxClients | maxClients | set TCP/TLS maxClients |
:heavy_check_mark: | memory | return sloki memory usage | |
:heavy_check_mark: | methods | return sloki methods | |
:heavy_check_mark: | quit | disconnect (TCP/TLS clients only) | |
:heavy_check_mark: | shutdown | shutdown sloki | |
:heavy_check_mark: | version | return versions (sloki, lokijs, sloki-node-client) | |
:heavy_check_mark: | wait | wait for one second, for testing purpose |
Loki Class (Database) documentation
Status | Command | Parameter(s) | Description |
---|---|---|---|
:heavy_check_mark: | loadDatabase | databaseName,[options] | select (and load if needed) a database |
:heavy_check_mark: | db | return current database name (sloki specific) | |
:heavy_check_mark: | listDatabases | return available databases | |
:heavy_check_mark: | saveDatabase | trigger manual saving of the selected database | |
:heavy_check_mark: | listCollections | return available collections in selected database | |
:heavy_check_mark: | addCollection | options | add a collection in selected database |
:heavy_check_mark: | getCollection | collectionName | return collection properties in selected database |
:heavy_plus_sign: | removeCollection | collectionName | removes a collection from the selected database |
:heavy_plus_sign: | renameCollection | oldName, newName | renames an existing collection in the selected database |
:question: | clearChanges | clears all the changes in all collections of selected database | |
:question: | close | close selected database | |
:question: | configureOptions | options | reconfigure selected database options |
:question: | copy | options | copy selected database into a new Loky instance |
:question: | deleteDatabase | delete selected database | |
:question: | getCollection | collectionName | Retrieves reference to a collection by name |
:red_circle: | deserializeCollection | see LokiJS Class documentation | |
:red_circle: | deserializeDestructured | see LokiJS Class documentation | |
:red_circle: | generateChangesNotification | see LokiJS Class documentation | |
:red_circle: | loadDatabase | see "use" command | |
:red_circle: | loadJSON | see LokiJS Class documentation | |
:red_circle: | loadJSONObject | see LokiJS Class documentation | |
:red_circle: | serialize | see LokiJS Class documentation | |
:red_circle: | serializeChanges | see LokiJS Class documentation | |
:red_circle: | serializeCollection | options | see LokiJS Class documentation |
:red_circle: | serializeDestructured | options | see LokiJS Class documentation |
:red_circle: | throttledSaveDrain | see LokiJS Class documentation |
Status | Command | Parameter(s) | Description |
---|---|---|---|
:heavy_check_mark: | find | collectionName, filter | find document(s) |
:heavy_check_mark: | get | collectionName, lokiId | return a document by his id |
:heavy_check_mark: | insert | collectionName, document | insert one or more document(s) |
:heavy_check_mark: | remove | collectionName, document or id | remove one or more document(s) |
:heavy_check_mark: | update | collectionName, document | update a document |
Status | Transport | Notes |
---|---|---|
:heavy_plus_sign: | TCP | Persistant connection |
:heavy_plus_sign: | TLS | Persistant connection |
:question: | HTTP | |
:question: | HTTPS |
Status | Tool | Notes |
---|---|---|
:heavy_plus_sign: | CLI | CLI using TCP transport |
Status | Improvement | Notes |
---|---|---|
:heavy_plus_sign: | Authentication | Optional authentication layer (all transports) |
$ sloki --help
=======================================================================
Sloki - a NodeJS Server for LokyJS
=======================================================================
Environnement variable Default
SLOKI_TCP_BINARY_ENABLE true
SLOKI_TCP_BINARY_PORT 6370
SLOKI_TCP_BINARY_HOST localhost
SLOKI_TCP_BINARY_MAX_CLIENTS 64
SLOKI_TLS_BINARY_ENABLE true
SLOKI_TLS_BINARY_PORT 6371
SLOKI_TLS_BINARY_HOST localhost
SLOKI_TLS_BINARY_MAX_CLIENTS 64
SLOKI_TCP_JSONRPC_ENABLE true
SLOKI_TCP_JSONRPC_PORT 6372
SLOKI_TCP_JSONRPC_HOST localhost
SLOKI_TCP_JSONRPC_MAX_CLIENTS 64
SLOKI_TLS_JSONRPC_ENABLE true
SLOKI_TLS_JSONRPC_PORT 6373
SLOKI_TLS_JSONRPC_HOST localhost
SLOKI_TLS_JSONRPC_MAX_CLIENTS 64
SLOKI_DIR /home/franck/.sloki
SLOKI_SHOW_OPS_INTERVAL 0
SLOKI_GC_INTERVAL 3600000
SLOKI_MEM_LIMIT 26094 Mb
-----------------------------------------------------------------------
Command Line Options Default
--tcp-binary-enable true
--tcp-binary-port 6370
--tcp-binary-host localhost
--tcp-binary-max-clients 64
--tls-binary-enable true
--tls-binary-port 6371
--tls-binary-host localhost
--tls-binary-max-clients 64
--tcp-jsonrpc-enable true
--tcp-jsonrpc-port 6372
--tcp-jsonrpc-host localhost
--tcp-jsonrpc-max-clients 64
--tls-jsonrpc-enable true
--tls-jsonrpc-port 6373
--tls-jsonrpc-host localhost
--tls-jsonrpc-max-clients 64
--dir /home/franck/.sloki
--show-ops-interval 0
--gc-interval 3600000
--mem-limit 26094 Mb
-----------------------------------------------------------------------
Examples:
$ sloki # will use defaults
$ sloki --tcp-binary-port=6370 --tcp-binary-host=localhost
The default values can be overridden first with those of the environment variables, and then those of the command line options.
SLOKI_DIR /path/to/sloki
dbs
contains lokijs databasescerts
contains SSL Certificates for TLSSLOKI_MEM_LIMIT
SLOKI_GC_INTERVAL
FAQs
A NodeJS server for LokiJS
The npm package sloki receives a total of 0 weekly downloads. As such, sloki popularity was classified as not popular.
We found that sloki demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.