
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).
github.com/EddisonKing/autocomplete
A simple implementation of a prefix based auto-completer that is thread safe using a trie data structure.
go get github.com/EddisonKing/autocomplete
import "github.com/EddisonKing/autocomplete"
ac := autocomplete.New()
This will create a new AutoComplete
that you can then load string
entries into for later use in auto-completion.
// Single string
ac.Load("apples")
// Or multiple
ac.Load([]string{"apples", "bananas", "ewwwww_fruit"}...)
This will load entries into the AutoComplete
allowing them to be returned as entries during auto-completion.
Duplicate values will not change the underlying state, but the algorithm can't know an entry is a duplicate without walking the trie, so effectively, you will be wasting compute on duplicates.
results := ac.Complete("a") // Would return []string{"apples"} if the above Load data was used
Call Complete
and pass in a prefix string to get a slice containing entries that satisfy the auto-completion.
Calling Complete
with an empty prefix, ""
, will return all entries that were stored. Note that this requires a traversal of the full trie so the effort to return all entries is the same effort as what it took to store all the entries originally.
chan string
insteadThe underlying data structure is known as a "trie" which is a portion of the word "retrieval", the reason why the structure was initially designed.
Loading entries into the tree requires a traversal of the tree at a depth of however long the input is. Consider the performance is likely:
O(k) where `k` is the length of the input
Complete takes a traversal of the prefix, then a full traversal of the remainder of the trie past the prefix. Likely:
O(p + c) where `p` is the length of the prefix and `c` is how many entries there remaining in that sub-trie
A trie is fairly space efficient since overlapping words in the data (ex. "apple" and "app") are also stored utilising this overlap.
FAQs
Unknown package
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.