Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
strip-outer
Advanced tools
The strip-outer npm package is designed to remove the outermost matching substring from a given string. It is particularly useful for trimming specific characters or patterns from the start and end of strings, allowing for more precise string manipulation than traditional trim methods.
Strip specific characters from the start and end of a string
This feature allows you to remove specific characters or patterns from both the start and end of a string. In the provided code sample, the 'strip-outer' package is used to remove the '---' characters from around the 'Hello World' string.
"use strict";\nconst stripOuter = require('strip-outer');\nconsole.log(stripOuter('---Hello World---', '---')); // 'Hello World'
Strip patterns using regular expressions
This feature demonstrates the ability to use regular expressions to define the pattern to be stripped from the string. In the example, all '#' characters are removed from the start and end of the 'Hello World' string.
"use strict";\nconst stripOuter = require('strip-outer');\nconsole.log(stripOuter('###Hello World###', /#+/)); // 'Hello World'
The 'trim' package offers functionality to remove whitespace from both ends of a string. While it is similar in its purpose of trimming strings, it does not offer the flexibility of removing specific characters or patterns like 'strip-outer'.
Although 'left-pad' is more focused on adding padding to the start of a string, it is mentioned here for its relevance in string manipulation. Unlike 'strip-outer', 'left-pad' does not remove characters but adds them, serving an opposite yet related purpose.
Strip a substring from the start/end of a string
$ npm install strip-outer
import stripOuter from 'strip-outer';
stripOuter('foobarfoo', 'foo');
//=> 'bar'
stripOuter('unicorncake', 'unicorn');
//=> 'cake'
FAQs
Strip a substring from the start/end of a string
The npm package strip-outer receives a total of 3,359,312 weekly downloads. As such, strip-outer popularity was classified as popular.
We found that strip-outer 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.