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.
redis-sessions
Advanced tools
There is a need to maintain a universal session across different application server platforms.
This is a NodeJS module to keep sessions in a Redis datastore and add some useful methods.
npm install redis-sessions
webapp
, app_cust123
).lastactivity
, ip
which were active within the last n seconds.RedisSessions = require("redis-sessions");
rs = new RedisSessions();
app = "myapp";
// Set a session for `user1001`
rs.create({
app: app,
id: "user1001"},
function(err, resp) {
// resp should be something like
// {token: "r30kKwv3sA6ExrJ9OmLSm4Wo3nt9MQA1yG94wn6ByFbNrVWhcwAyOM7Zhfxqh8fe"}
});
rs.set({
app: app,
token: "r30kKwv3sA6ExrJ9OmLSm4Wo3nt9MQA1yG94wn6ByFbNrVWhcwAyOM7Zhfxqh8fe",
d: {
"unread_msgs": 12,
"last_action": "/read/news",
"birthday": "2013-08-13"
}},
function(err, resp) {
/*
resp contains the session with the new values:
{
"id":"user1001",
"r": 1,
"w": 2,
"idle": 1,
"ttl": 7200,
"d":
{
"unread_msgs": 12,
"last_action": "/read/news",
"birthday": "2013-08-13"
}
}
*/
});
rs.get({
app: app,
token: "r30kKwv3sA6ExrJ9OmLSm4Wo3nt9MQA1yG94wn6ByFbNrVWhcwAyOM7Zhfxqh8fe"},
function(err, resp) {
/*
resp contains the session:
{
"id":"user1001",
"r": 1, // The number of reads on this token
"w": 1, // The number of writes on this token
"idle": 21, // The idle time in seconds.
"ttl": 7200, // Timeout after 7200 idle time
"d":
{
"unread_msgs": 12,
"last_action": "/read/news",
"birthday": "2013-08-13"
}
}
*/
});
Set/Update/Delete parameters by supplying app, token and some data d
.
The d
object contains a simple key/value list where values
can be string, number, boolean or null.
To remove keys set them to null
, keys that are not supplied will not be touched.
rs.set({
app: app,
token: "r30kKwv3sA6ExrJ9OmLSm4Wo3nt9MQA1yG94wn6ByFbNrVWhcwAyOM7Zhfxqh8fe",
d: {
"unread_msgs": null
"last_action": "/read/msg/2121"
}},
function(err, resp) {
/*
resp contains the session with modified values:
{
"id":"user1001",
"r": 1,
"w": 2,
"idle": 1,
"ttl": 7200,
"d":
{
"last_action": "/read/msg/2121",
"birthday": "2013-08-13"
}
}
*/
});
Kill a single session by supplying app and token:
rs.kill({
app: app,
token: "r30kKwv3sA6ExrJ9OmLSm4Wo3nt9MQA1yG94wn6ByFbNrVWhcwAyOM7Zhfxqh8fe"},
function(err, resp) {
/*
resp contains the result:
{kill: 1}
*/
});
Note: If {kill: 0} is returned the session was not found.
Query the amount of active session within the last 10 minutes (600 seconds).
rs.activity({
app: app,
dt: 600},
function(err, resp) {
/*
resp contains the activity:
{activity: 12}
*/
});
Kill all sessions of an app:
rs.killall({app: app},
function(err, resp) {
/*
resp contains the result:
{kill: 12} // The amount of sessions that were killed
*/
});
FAQs
An advanced session store for Redis
The npm package redis-sessions receives a total of 859 weekly downloads. As such, redis-sessions popularity was classified as not popular.
We found that redis-sessions demonstrated a healthy version release cadence and project activity because the last version was released less than 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.