Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
aho-corasick-automaton
Advanced tools
A streaming Aho-Corasick automata for matching strings. This module is a low level interface, but can be used to construct more complex algorithms.
var createTrie = require("array-trie")
var createAC = require("aho-corasick-automaton")
var trie = createTrie()
//First build the trie data structure
trie.set([1,2,3], 1)
trie.set([2,3,4], 2)
trie.set([6,7,8], 3)
trie.set([1,2], 4)
trie.set([2,3], 5)
//Next construct the automata and use it to
var automata = createAC(trie)
//Now run it on some data
var data = [1,2,3,4,5,6,7,8,9]
for(var state=automata, i=0; i<data.length; ) {
//Process next symbol
state=state.push(data[i++])
//Print out all matches at position i
if(state.value !== undefined) {
console.log("matches at position", i, ":")
for(var cur = state; cur.value !== undefined; cur = cur.next) {
console.log(cur.value)
}
}
}
Here is some example output from the above program:
matches at position 2 :
4
matches at position 3 :
1
5
matches at position 4 :
2
matches at position 8 :
3
npm install aho-corasick-automata
var createAC = require("aho-corasick-automata")
var root = createAC(trie)
Creates an Aho-Corasick automata from the trie encoded as an array-trie
Returns A new Aho-Corasick automata
automata.push(symbol)
Returns the next state of the automata after processing symbol
symbol
is the next character in the stream to processReturns The next state of the automata
automata.value
A value representing the terminal of the automata. undefined
if there is no trie entry at this point
automata.next
A pointer to the next entry in the linked list of values at this automata state. If the value
is undefined, then this is the last node in this list.
(c) 2013 Mikola Lysenko. MIT License
FAQs
Stream Aho-Corasick automata
The npm package aho-corasick-automaton receives a total of 65 weekly downloads. As such, aho-corasick-automaton popularity was classified as not popular.
We found that aho-corasick-automaton 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.