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.
circular-dependency-scanner
Advanced tools
Out-of-box and zero configuration circular dependencies detector, with both JavaScript API and Command Line Tool.
Out-of-box circular dependencies detector, with both JavaScript API and Command Line Tool built in, support all file types we used in common like .js,.jsx,.ts,.tsx,.mjs,.cjs,.vue
.
Pull out import/require/export
path from files and revert it into to real path (if aliased) with path alias configurations, then calculate the circles among and print which with colors.
English | 中文
Here the running example for the ds -o circles.json
execution:
The ts,js,vue
files will be printed directly into console as blue,yellow,green
as follows if you didn't pass an output filename param:
On one hand there are few tools, on the other hand there are too many annoyed problems among the exist tools on the market:
But now, you just run ds
, all of the (.js,.jsx,.ts,.tsx,.mjs,.cjs,.vue) files under current directory will be parsed directly and fast with TypeScript API, which almost include all file types we used. And then the circles among these files will be printed.
The ds
command which means depscan
will be available after you installed this package globally.
pnpm i -g circular-dependency-scanner # or npm/yarn
cd path/to/execute # change directory
ds # run `ds` command
There are detailed documentations built in, you can use -h
option to print help information anytime.
ds [options] [path] # Automatically detect circular dependencies under the current directory and print the circles.
ds -h # print help info
ds -V/--version # print cli version
ds # current dir by default
ds src # detect src directory...and so on.
ds --filter 'src/router/*.ts' # only print the circles matched the pattern.
ds --absolute # print absolute path.
ds --ignore output dist node_modules # path to ignore.
ds --output circles.json # output analysis into specified file.
ds --alias @:src @components:src/components # path alias, follows `<from>:<to>` convention
Sometime you may want to manually write script and make an analysis, just use JavaScript API as follows:
import { circularDepsDetect } from 'circular-dependency-scanner';
const results = circularDepsDetect({
/**
* Base path to execute command.
* @default process.cwd()
*/
cwd: string;
/**
* Whether to use absolute path.
* @default false
*/
absolute: boolean;
/**
* Glob patterns to exclude from matches.
* @default ['node_modules']
*/
ignore: string[];
/**
* Path alias to resolve.
* @default { '@': 'src' }
*/
alias: Record<string, string>;
});
This source code is here src/ast.ts. In a short, it find reference like:
import test from './test'; // got './test'
import './test'; // got './test'
import('./test'); // got './test'
require('./test'); // got './test'
export * from './test'; // got './test'
export { test }; // got no export source
If some of the circles it found make no sense, you can use --filter
option to screen out.
The analysis of file reference depend on the alias
configurations you have supplied. So if you run this command at your monorepo root directory, you may find that some of the different projects under may include same alias configurations, which cause the results unreliable.
If you want to analyze multiple projects, please execute one by one.
No tool is perfect, and if you run into problems with it, welcome to file an issue, I’ll respond as soon as possible.
1.1.3
FAQs
Out-of-box and zero configuration circular dependencies detector, with both JavaScript API and Command Line Tool.
The npm package circular-dependency-scanner receives a total of 4,235 weekly downloads. As such, circular-dependency-scanner popularity was classified as popular.
We found that circular-dependency-scanner demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
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.