Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
The is-subdir npm package is a utility that helps determine if a given directory is a subdirectory of another directory. This can be useful in various scenarios such as validating file paths, ensuring security by restricting access to certain directories, and more.
Check if a directory is a subdirectory
This feature allows you to check if a given directory is a subdirectory of another directory. In this example, '/home/user/projects/my-app' is a subdirectory of '/home/user/projects', so the function returns true.
const isSubdir = require('is-subdir');
const parentDir = '/home/user/projects';
const subDir = '/home/user/projects/my-app';
console.log(isSubdir(parentDir, subDir)); // true
Check if a directory is not a subdirectory
This feature allows you to check if a given directory is not a subdirectory of another directory. In this example, '/home/user/other-projects' is not a subdirectory of '/home/user/projects', so the function returns false.
const isSubdir = require('is-subdir');
const parentDir = '/home/user/projects';
const notSubDir = '/home/user/other-projects';
console.log(isSubdir(parentDir, notSubDir)); // false
The path-is-inside package provides similar functionality by checking if one path is inside another path. It is useful for validating file paths and ensuring that a given path is within a certain directory. Compared to is-subdir, path-is-inside offers a more general approach to path validation.
The is-path-inside package checks if a path is inside another path. It is similar to is-subdir but focuses on paths rather than directories specifically. This package is useful for ensuring that a file or directory is within a certain path, providing a broader use case compared to is-subdir.
Return whether a directory is a subdirectory of another directory
Cross-platform. Works correctly on Windows, where directory paths can start with disk drive letters in different casings. Like c:\foo
and C:\foo\bar
.
npm i -S is-subdir
'use strict'
const path = require('path')
const isSubdir = require('is-subdir')
console.log(isSubdir(process.cwd(), path.resolve('node_modules')))
//> true
FAQs
Return whether a directory is a subdirectory of another directory
The npm package is-subdir receives a total of 1,175,471 weekly downloads. As such, is-subdir popularity was classified as popular.
We found that is-subdir 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.