Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
dir-glob
Advanced tools
Package description
The dir-glob npm package is designed to convert directory paths into glob patterns, which can then be used with other tools that work with globs, such as file system search utilities. This can be particularly useful for including or excluding entire directories when working with file patterns.
Convert directories to glob patterns
This feature allows you to convert an array of directory paths into glob patterns that match all files within those directories. The example demonstrates converting two directory paths into their corresponding glob patterns.
const dirGlob = require('dir-glob');
(async () => {
const paths = await dirGlob(['assets', 'uploads']);
console.log(paths);
//=> ['assets/**', 'uploads/**']
})();
Include file extensions in glob patterns
This feature extends the basic directory-to-glob conversion by allowing you to specify file extensions. This results in glob patterns that match only files with the specified extensions within the given directories. The example shows how to generate glob patterns for jpg and png files only.
const dirGlob = require('dir-glob');
(async () => {
const paths = await dirGlob(['assets', 'uploads'], {extensions: ['jpg', 'png']});
console.log(paths);
//=> ['assets/**/*.jpg', 'assets/**/*.png', 'uploads/**/*.jpg', 'uploads/**/*.png']
})();
The 'glob' package provides pattern matching functionality for file paths. While 'glob' itself focuses on matching patterns against existing file structures, 'dir-glob' specifically converts directory paths into glob patterns. 'glob' can be used in conjunction with 'dir-glob' to first generate glob patterns for directories and then match those patterns against files.
Similar to 'glob', 'fast-glob' is an optimized version that provides a faster and more efficient way to match glob patterns against file systems. It offers a similar functionality to 'dir-glob' in terms of working with glob patterns, but it does not specifically focus on converting directories to globs. Instead, it's more about performing the matching operation itself, potentially using patterns generated by 'dir-glob'.
Readme
Convert directories to glob compatible strings
$ npm install --save dir-glob
const dirGlob = require('dir-glob');
dirGlob(['index.js', 'test.js', 'fixtures']).then(files => {
console.log(files);
//=> ['index.js', 'test.js', 'fixtures/**']
});
dirGlob(['lib/**', 'fixtures'], {ext: 'js'}).then(files => {
console.log(files);
//=> ['lib/**', 'fixtures/**/*.js']
});
dirGlob(['lib/**', 'fixtures'], {ext: ['js', 'png']}).then(files => {
console.log(files);
//=> ['lib/**', 'fixtures/**/*.{js,png}']
});
Returns a promise for an array of glob strings.
Type: array
, string
A string
or an array
of paths.
Type: array
, string
Append extension to the end of your glob.
Returns an array of glob strings.
Type: array
, string
A string
or an array
of paths.
Type: array
, string
Append extension to the end of your glob.
MIT © Kevin Martensson
FAQs
Convert directories to glob compatible strings
We found that dir-glob demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.