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.
@coolgk/string
Advanced tools
a javascript / typescript module
npm install @coolgk/string
string utility functions
import { stripTags, escapeHtml, unescapeHtml, prepad0 } from '@coolgk/string';
// OR
// const { stripTags, escapeHtml, unescapeHtml, prepad0 } = require('@coolgk/string');
const str = '<h1>test</h1><script>alert(1)</script>'
console.log(stripTags(str)); // test alert(1)
console.log(escapeHtml(str)); // <h1>test</h1><script>alert(1)</script>
console.log(unescapeHtml(escapeHtml(str))); // <h1>test</h1><script>alert(1)</script>
console.log(prepad0(7, 2)); // 07
console.log(prepad0(70, 3)); // 070
console.log(prepad0(70, 4)); // 0070
console.log(prepad0(1, 4)); // 0001
console.log(prepad0(1000, 2)); // 1000
string
strip html tags e.g. "<h1>header</h1><p>message</p>" becomes "header message"
string
escaping user input e.g. html code in a message box
string
unescaping strings escaped by escapeHtml()
string
use padStart instead
string
strip html tags e.g. "<h1>header</h1><p>message</p>" becomes "header message"
Kind: global function
Returns: string
- - string with tags stripped
Param | Type | Description |
---|---|---|
a | string | string |
string
escaping user input e.g. html code in a message box
Kind: global function
Param | Type | Description |
---|---|---|
value | string | string to escape |
string
unescaping strings escaped by escapeHtml()
Kind: global function
Param | Type | Description |
---|---|---|
string | string | string to unescape |
string
use padStart instead
Kind: global function
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
Param | Type | Default | Description |
---|---|---|---|
value | number | an integer in string or number format | |
length | number | 2 | length of the output e.g. length = 2, 8 becomes 08. length = 3, 70 = 070. |
FAQs
string utility functions
The npm package @coolgk/string receives a total of 2 weekly downloads. As such, @coolgk/string popularity was classified as not popular.
We found that @coolgk/string 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.