Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
boundary-match
Advanced tools
Regex string match and replace that honors boundaries for targets prepended and/or appended with non-word characters.
Regex string match and replace that honors boundaries for targets prepended and/or appended with non-word characters.
$ npm install --save boundary-match
const boundaryMatch = require('boundary-match');
boundaryMatch('(HotDog)', '(hotdog)', 'i');
// => [ '(HotDog)', index: 0, input: '(HotDog)' ]
// Q. But Why?
// A. Because, these fail to work as expected:
'(HotDog)'.match(/\b\(hotdog\)\b/i);
// => null
'(HotDog)'.match(new RegExp('\\b\\(hotdog\\)\\b', 'i'));
// => null
// When matching isn't enough... `replace`
let matched = boundaryMatch('Gimme a (HotDog)', '(HOTDOG)', 'i');
boundaryMatch.replace(matched, 'Chili Dog!');
// => Gimme a Chili Dog!
boundaryMatch(string, target[, flags])
If the target
is found in the string
, it returns an Array
containing the entire matched target as the first element; an index
property for the start of the match; and an input
property that contains the entire string
. If there were no matches, null
is returned.
string
Required
: String
the string to be searched.target
Required
: String
the string to be found. Will be escaped using escape-string-regexp
.flags
Optional
: String
can have any combination of the following values:
i
: ignore caseboundaryMatch.replace(match, target)
Returns a String
that replaces the found match
results with target
match
Required
: Array
the result of previously calling boundaryMatch
target
Required
: String
the string that replaces the found matchRegExp
flags: g
,u
, m
, y
ISC © Buster Collings
FAQs
Regex string match and replace that honors boundaries for targets prepended and/or appended with non-word characters.
We found that boundary-match 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.