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.
@asamuzakjp/nwsapi
Advanced tools
Fast CSS Selectors API Engine
NWSAPI is the development progress of NWMATCHER aiming at Selectors Level 4 conformance. It has been completely reworked to be easily extended and maintained. It is a right-to-left selector parser and compiler written in pure Javascript with no external dependencies. It was initially thought as a cross browser library to improve event delegation and web page scraping in various frameworks but it has become a popular replacement of the native CSS selection and matching functionality in newer browsers and headless environments.
It uses regular expressions to parse CSS selector strings and metaprogramming to transforms these selector strings into Javascript function resolvers. This process is executed only once for each selector string allowing memoization of the function resolvers and achieving unmatched performances.
To include NWSAPI in a standard web page:
<script type="text/javascript" src="nwsapi.js"></script>
To include NWSAPI in a standard web page and automatically replace the native QSA:
<script type="text/javascript" src="nwsapi.js" onload="NW.Dom.install()"></script>
To use NWSAPI with Node.js:
$ npm install nwsapi
NWSAPI currently supports browsers (as a global, NW.Dom
) and headless environments (as a CommonJS module).
Here is a list of all the CSS2/CSS3/CSS4 Supported selectors.
You can read more about NWSAPI features and compliance on the wiki.
ancestor( selector, context, callback )
Returns a reference to the nearest ancestor element matching selector
, starting at context
. Returns null
if no element is found. If callback
is provided, it is invoked for the matched element.
first( selector, context, callback )
Returns a reference to the first element matching selector
, starting at context
. Returns null
if no element matches. If callback
is provided, it is invoked for the matched element.
match( selector, element, callback )
Returns true
if element
matches selector
, starting at context
; returns false
otherwise. If callback
is provided, it is invoked for the matched element.
select( selector, context, callback )
Returns an array of all the elements matching selector
, starting at context
; returns empty Array
otherwise. If callback
is provided, it is invoked for each matching element.
byId( id, from )
Returns a reference to the first element with ID id
, optionally filtered to descendants of the element from
.
byTag( tag, from )
Returns an array of elements having the specified tag name tag
, optionally filtered to descendants of the element from
.
byClass( class, from )
Returns an array of elements having the specified class name class
, optionally filtered to descendants of the element from
.
configure( options )
The following is the list of currently available configuration options, their default values and descriptions, they are boolean flags that can be set to true
or false
:
IDS_DUPES
: true - true to allow using multiple elements having the same id, false to disallowLIVECACHE
: true - true for caching both results and resolvers, false for caching only resolversMIXEDCASE
: true - true to match tag names case insensitive, false to match using case sensitiveLOGERRORS
: true - true to print errors and warnings to the console, false to mute both of themconfigure( { <configuration-flag>: [ true | false ] } )
Disable logging errors/warnings to console, disallow duplicate ids. Example:
NW.Dom.configure( { LOGERRORS: false, IDS_DUPES: false } );
NOTE: NW.Dom.configure() without parameters return the current configuration.
registerCombinator( symbol, resolver )
Registers a new symbol and its matching resolver in the combinators table. Example:
NW.Dom.registerCombinator( '^', 'e.parentElement' );
registerOperator( symbol, resolver )
Registers a new symbol and its matching resolver in the attribute operators table. Example:
NW.Dom.registerOperator( '!=', { p1: '^', p2: '$', p3: 'false' } );
registerSelector( name, rexp, func )
Registers a new selector, the matching RE and the resolver function, in the selectors table. Example:
NW.Dom.registerSelector('Controls', /^\:(control)(.*)/i,
(function(global) {
return function(match, source, mode, callback) {
var status = true;
source = 'if(/^(button|input|select|textarea)/i.test(e.nodeName)){' + source + '}';
return { 'source': source, 'status': status };
};
})(this));
FAQs
Fast CSS Selectors API Engine
The npm package @asamuzakjp/nwsapi receives a total of 391 weekly downloads. As such, @asamuzakjp/nwsapi popularity was classified as not popular.
We found that @asamuzakjp/nwsapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.