Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dazn/chaos-squirrel-attack-memory

Package Overview
Dependencies
Maintainers
7
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dazn/chaos-squirrel-attack-memory - npm Package Compare versions

Comparing version 0.10.0 to 0.10.1

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## 0.10.1 (2021-07-20)
**Note:** Version bump only for package @dazn/chaos-squirrel-attack-memory
# 0.10.0 (2021-03-12)

@@ -8,0 +16,0 @@

10

dist/index.d.ts
/// <reference types="node" />
export interface MemoryAttackOptions {
size?: number;
stepSize?: number;
stepTime?: number;
}

@@ -8,6 +10,12 @@ export default class MemoryAttack {

size: number;
stepSize: number;
stepTime: number;
buffers: Buffer[];
constructor({ size }?: MemoryAttackOptions);
private stepInterval?;
constructor({ size, stepSize, stepTime, }?: MemoryAttackOptions);
start(): void;
private stepAllocate;
private clearStep;
private allocate;
stop(): void;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const buffer_1 = __importDefault(require("buffer"));
const BUF_LENGTH = buffer_1.default.constants.MAX_LENGTH;
const buffer = __importStar(require("buffer"));
class MemoryAttack {
constructor({ size = BUF_LENGTH } = {}) {
constructor({ size = buffer.constants.MAX_LENGTH, stepSize = 0, stepTime = 0, } = {}) {
this.buffers = [];
this.size = size;
this.stepSize = stepSize;
this.stepTime = stepTime;
}

@@ -20,5 +37,28 @@ static configure(opts) {

start() {
let toFill = this.size;
if (this.stepTime && this.stepSize) {
this.allocate(this.stepSize);
this.stepInterval = setInterval(this.stepAllocate.bind(this), this.stepTime);
}
else {
this.allocate(this.size);
}
}
stepAllocate() {
if (this.buffers.length * this.stepSize >= this.size) {
this.clearStep();
}
else {
this.allocate(this.stepSize);
}
}
clearStep() {
if (typeof this.stepInterval !== 'undefined') {
clearInterval(this.stepInterval);
this.stepInterval = undefined;
}
}
allocate(size) {
let toFill = size;
while (toFill > 0) {
const bufSize = Math.min(toFill, BUF_LENGTH);
const bufSize = Math.min(toFill, buffer.constants.MAX_LENGTH);
this.buffers.push(Buffer.alloc(bufSize, 'chaos-squirrel'));

@@ -31,4 +71,5 @@ toFill -= bufSize;

this.buffers = [];
this.clearStep();
}
}
exports.default = MemoryAttack;

4

package.json
{
"name": "@dazn/chaos-squirrel-attack-memory",
"version": "0.10.0",
"version": "0.10.1",
"description": "Chaos Squirrel attack to fill memory",

@@ -28,3 +28,3 @@ "main": "dist/index.js",

},
"gitHead": "676058c0054b819ad27edc1adeadcc589ca56848"
"gitHead": "09fa010cf3ea9afb1550147f1222203c87feea6a"
}
# @dazn/chaos-squirrel-attack-memory
Chaos Squirrel attack to fill memory
Chaos Squirrel attack to fill memory instantly, or increasing memory usage over time.
## Usage
Basic memory attack.
```ts

@@ -11,4 +13,3 @@ import MemoryAttack from '@dazn/chaos-squirrel-attack-memory';

const createMemoryAttack = MemoryAttack.configure({
// 2gb
size: 2000000000,
size: 2e9 // ~2gb
});

@@ -19,5 +20,24 @@

// 2gb of memory will be used
// ~2gb of memory will be used
memoryAttack.stop(); // removes references to memory to allow GC to collect it
```
Progressive memory attack.
```ts
import MemoryAttack from '@dazn/chaos-squirrel-attack-memory';
const createMemoryAttack = MemoryAttack.configure({
size: 2e9, // ~2gb
stepSize: 2e8, // ~200mb
stepTime: 1e3 // 1s
});
const memoryAttack = createMemoryAttack();
memoryAttack.start();
// ~2gb of memory will be used, starting from 0gb & increasing by ~200mb every 1s
memoryAttack.stop(); // removes references to memory to allow GC to collect it
```
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