New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-range-tracker

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-range-tracker - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

37

index.js
const defaultStorage = {};
const prop = (key) => (obj) => obj[key];
module.exports = (

@@ -12,2 +14,3 @@ {

onDeadlineReached,
onSimilarTimestamp,
timestampFunction,

@@ -103,2 +106,36 @@ bannedTraits = [],

if (typeof onSimilarTimestamp === "function") {
const reducer =
(ip) =>
(acc, { timestamp }, index, arr) => {
if (index) {
acc.push({
ip,
window: timestamp - arr[index - 1].timestamp,
});
}
return acc;
};
const timestampWindows = Object.keys(storage)
.filter((key) => storage[key].ip !== ip)
.map((key) => storage[key].reduce(reducer(key), []));
const currentTimestampWindow = storage[ip]
.reduce(reducer(ip), [])
.map(prop("window"))
.join();
const similarTimestampWindows = timestampWindows.filter(
(chunks) =>
chunks.map(prop("window")).join() === currentTimestampWindow &&
chunks[0]?.ip !== ip
);
if (currentTimestampWindow && similarTimestampWindows.length) {
onSimilarTimestamp(req, similarTimestampWindows.flat().map(prop("ip")));
}
}
if (typeof onSimilarTrait === "function") {

@@ -105,0 +142,0 @@ const reducer = (acc, { from, to }) => (acc += `${from},${to};`);

2

package.json
{
"name": "express-range-tracker",
"version": "1.0.7",
"version": "1.0.8",
"description": "Detects bots by tracking the timings of range header",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -73,2 +73,8 @@ # express-range-tracker

`onSimilarTimestamp` - function that fires on clients with same range request timestamp windows
```js
onSimilarTimestamp(req, ips);
```
# Test

@@ -75,0 +81,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc