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.
About single ascii characters.
install with npm:
npm install --save chars.js
Chars.ASCII_RANGE_...
Chars.ASCII_RANGE_... are
static const
arrays with only two indices: [bottomOfRange, topOfRange]. These ranges are directly related to the ordinal values of the ascii-table.
The following ranges are defined in chars.js:
Range | Ordinal range | Characters found in range |
---|---|---|
Chars.ASCII_RANGE_UPPERCASE | [65,90] | ABCDEFGHIJKLMNOPQRSTUVWXYZ |
Chars.ASCII_RANGE_LOWERCASE | [97,122] | abcdefghijklmnopqrstuvwxyz |
Chars.ASCII_RANGE_NUMBERS | [48,57] | 0123456789 |
Chars.ASCII_RANGE_SPECIAL_1 | [32,47] | (white space) !"#$%&'()*+,-./ |
Chars.ASCII_RANGE_SPECIAL_2 | [58,64] | :;<=>?@ |
Chars.ASCII_RANGE_SPECIAL_3 | [91,96] | [\]^_` |
Chars.ASCII_RANGE_SPECIAL_4 | [123,126] | {|}~ |
Chars.ASCII_RANGE_ALL(printable) | [32,126] | (white space) !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_abcdefghijklmnopqrstuvwxyz{|}~` |
Chars.REGEXP_SPECIAL_CHARS
<array> REGEXP_SPECIAL_CHARS
Returns an array (like a set) with all special characters used in regular expressions.
I use this for one of my other libraries, strings.js, for escaping a string to prepare for making a new RegExp.
Chars.ascii
<string> Chars.ascii( <string>/<number> ordinal )
Returns the ascii character found at ordinal.
var space= Chars.ascii( 32 );
// ' '
Chars.ordinal
<number> Chars.ordinal( <string>/<number> char )
Returns the ordinal for char.
var ordSpace= Chars.ordinal( ' ' );
// 32
Chars.isUpper
<boolean> Chars.isUpper( <string>/<number> char )
Returns true if char is uppercase.
var test= Chars.isUpper( 'z' );
// false
Chars.isLower
<boolean> Chars.isLower( <string>/<number> char )
Returns true if char is lowercase.
var test= Chars.isLower( 'z' );
// true
Chars.isAlpha
<boolean> Chars.isAlpha( <string>/<number> char )
Returns true if char is uppercase or lowercase alpha.
var test= Chars.isAlpha( 'a' );
// true
Chars.isNumeric
<boolean> Chars.isNumeric( <string>/<number> char )
Returns true if char is a number.
var test= Chars.isNumeric( '0' );
// true
var test= Chars.isNumeric( 0 );
// true
Chars.isSpecial
<boolean> Chars.isSpecial( <string>/<number> char )
Returns true if char is a special character from the SPECIAL_1,2,3 or 4 range.
var test= Chars.isSpecial( '.' );
// true
Chars.isAlphaNumeric
<boolean> Chars.isAlphaNumeric( <string>/<number> char )
Returns true if char is a uppercase, lowercase or number.
var test= Chars.isAlphaNumeric( 'A' );
// true
var test= Chars.isAlphaNumeric( 1 );
// true
Chars.random
<string> Chars.random( range )
Returns a random character in range range. range defaults to the Chars.ASCII_RANGE_ALL range
var test= Chars.random( Chars.ASCII_RANGE_UPPERCASE );
// returns a single random character between 'A' and 'Z'
Chars.prototype.constructor
<this> constructor( <string>/<number> char, <array> range )
char can be a number character or ordinal, range has the format of ASCII_RANGE
var char= new Chars( '?' );
// I will be using this char instance for the following examples.
Chars.prototype.get
<string> get()
Returns this.char
console.log( char.get() );
// '?'
Chars.prototype.set
<string> set( <string>/<number> char )
char can be a number character or ordinal. If char is an ordinal, the character represented by ordinal will be set.
console.log( char.set('!') );
// '!'
Chars.prototype.next
<string> next( <string>/<number> amount )
Proceed this.char to the following ascii character and returns it, if no arguments are given. Proceed to amount ascii characters ahead, limited by this.range, if amount is set.
console.log( char.next() );
// '@'
Chars.prototype.prev
<this> prev( <string>/<number> amount )
Sets and returns this.char to the predecessor of the current ascii character in the ascii-table, if no arguments are given. If amount is given, it will decrease and set to the amount characters back in the ascii table.
prev is limited to the current active range. So, casting a prev on the bounds of the range will keep returning this bound.
console.log( char.prev() );
// '!'
The remaining methods are similar in working as the static versions by the same name, they only do not require a string argument, they use the objects string instead.
Chars.prototype.isUpper
<boolean> isUpper()
Chars.prototype.isLower
<boolean> isLower()
Chars.prototype.isAlpha
<boolean> isAlpha()
Chars.prototype.isNumeric
<boolean> isNumeric()
Chars.prototype.isSpecial
<boolean> isSpecial()
Chars.prototype.isAlphaNumeric
<boolean> isAlphaNumeric()
Chars.prototype.random
<string> random()
0.2.0
0.1.5
###license MIT
FAQs
A single-ascii-character utility
The npm package chars.js receives a total of 1 weekly downloads. As such, chars.js popularity was classified as not popular.
We found that chars.js 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.