
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
point-in-region
Advanced tools
Quickly and robustly determines which region contains a given query point
Locates a point in a collection of regions. Point location is exact, takes O(log(n)) time, and the data structure has a space requirement of O(n log(n)).
//First create a list of vertices
var vertices = [
[0, 0],
[1, 0],
[1, 1],
[0, 1],
[2, 0],
[3, 0],
[3, 1],
[2, 1],
[2.25, 0.25],
[2.75, 0.25],
[2.75, 0.75],
[2.25, 0.75]
]
//Regions are defined by lists of loops of vertex indices
var regions = [
//First region, just a square, one loop
[
[0, 1, 2, 3]
],
//Second region, square with a hole in the middle
[
[4, 5, 6, 7],
[11, 10, 9, 8] //Note inner loop has opposite orientation
]
]
//Now we create the data structure
var classifyPoint = require("point-in-region")(vertices, regions)
//And we can use it to classify which region contains a given point
var assert = require("assert")
assert.equal(classifyPoint([0.5, 0.5]), 0)
assert.equal(classifyPoint([2.1, 0.1]), 1)
assert.equal(classifyPoint([100000, 10000]), -1) //Outside points return -1
assert.equal(classifyPoint([2.5, 0.5]), -1) //Point in center hole is outside region
Here is an in browser demo you can try out yourself:
npm install point-in-region
var classify = require("point-in-region")(positions, regions)
Preprocesses a collection of regions to answer point location queries efficiently.
positions
is a list of vertex positions for each of the regionsregions
is a list of regions encoded as lists of clockwise oriented loops of indicesReturns A point membership classification function for the region set
Note The regions must obey certain topological and geometric properties for this classification to be correct. Specifically:
classify(point)
Returns the index of the region containing point
point
is a 2D point encoded as a length 2 arrayReturns The index of the region containing point
or -1
if it is not in any region.
(c) 2014 Mikola Lysenko. MIT License
FAQs
Quickly and robustly determines which region contains a given query point
The npm package point-in-region receives a total of 188 weekly downloads. As such, point-in-region popularity was classified as not popular.
We found that point-in-region 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.