Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@statoscope/cli
Advanced tools
This package supplies Statoscope as CLI tool
npm i @statoscope/cli -g
statoscope [command] [...args]
Validate one or more webpack stats.
This is an experimental feature. Please provide some feedback
validate validator input [...args]
--validator
(-v
) - path to validator-script (see validator API below)--input
(-i
) - path to one or more webpack stats--warn-as-error
(-w
) - treat warnings as errorsAs jora-query:
Validator-script may provide plain jora-query.
A query must return TestEntry[]
:
type TestEntry = {
type?: 'error' | 'warn' | 'info'; // 'error' by default
assert?: boolean; // false by default
messsage: string;
filename?: string;
};
Example:
rules.jora:
[
{
assert: compilations.nodeModules.[name="lodash"].size() = 0,
message: 'Lodash usage detected. Please do not use lodash in this project',
filename: name
},
{
message: 'Just info message',
filename: name
}
]
statoscope validate rules.jora stats.json
Output:
stats.json
info: Just info message
error: Lodash usage detected. Please do not use lodash in this project
Info: 1
Errors: 1
In this example validation will fail if bundle uses lodash
library.
You can inspect stats-file structure and test your rules at statoscope-sandbox by clicking to
Make report
button.
You may also validate multiple stats (e.g. in CI):
rules.jora:
$master: .[name="master.json"];
$branch: .[name="branch.json"];
$branchRXJS: $branch.compilations.nodeModules.[name="rxjs"].instances.reasons.data.resolvedModule;
$masterRXJS: $master.compilations.nodeModules.[name="rxjs"].instances.reasons.data.resolvedModule;
[
{
assert: $branch.compilations.nodeModules.[name="lodash"].size() = 0,
message: 'Lodash usage detected. Please do not use lodash in this project',
filename: $branch.name
},
{
type: 'warn',
assert: $branchRXJS.size() <= $masterRXJS.size(),
message: 'More rxjs usage detected. Try not to increase rxjs-usage',
filename: $branch.name
}
]
statoscope validate rules.jora --input master.json --input branch.json
Output:
branch.json
error: Lodash usage detected. Please do not use lodash in this project
warn: More rxjs usage detected. Try not to increase rxjs-usage
Errors: 1
Warnings: 1
Also, there are a lot of jora-helpers that you can use in your rules:
For example:
rules.jora:
$master: .[name="astexp-1.json"];
$branch: .[name="astexp-2.json"];
$masterInitialSize: $master.compilations.chunks.[initial].reduce(=> size + $$, 0);
$branchInitialSize: $branch.compilations.chunks.[initial].reduce(=> size + $$, 0);
$initialSizeDiff: $branchInitialSize - $masterInitialSize;
$initialSizeDiffPercent: $branchInitialSize.percentFrom($masterInitialSize, 2);
[
{
assert: $initialSizeDiff <= 0,
message: `Initial assets size increased by ${$initialSizeDiff.formatSize()} (${$initialSizeDiffPercent}%)`,
filename: $branch.name
}
]
statoscope validate rules.jora --input master.json --input branch.json
Output:
branch.json
error: Initial assets size increased at 249.57 kb (9.16%)"
Errors: 1
As function:
Validator-script may export ValidatorFn
that will be called to validate stats from input
.
type Data = {
files: Object[];
compilations: Object[];
query: (query: string, data?: any) => any; // query-parameter is jora-syntax query
};
type API = {
error(message: string, filename?: string): void;
warn(message: string, filename?: string): void;
info(message: string, filename?: string): void;
};
type ValidatorFn = (data: Data, api: API) => Promise<string | void>;
Example:
module.exports = (data, api) => {
const lodash = data.query('compilations.nodeModules.[name="lodash"]');
if (lodash.length) {
api.error(
'Lodash usage detected. Please do not use lodash in this project',
data.files[0].name
);
}
};
statoscope validate rules.js stats.json
Output:
stats.json
error: Lodash usage detected. Please do not use lodash in this project
Errors: 1
Start HTTP-server and serve JSON-stats as HTML report
serve input [...args]
--input
(-i
) - path to one or more webpack stats--host
(-h
) - server host--port
(-p
) - server port--open
(-o
) - open browser after server startExample:
statoscope serve path/to/stats.json -o
Start server and open browser.
Generate HTML report from JSON-stats.
generate input output [...args]
--input
(-i
) - path to one or more webpack stats--output
(-t
) - path to generated HTML--open
(-o
) - open browser after generateExample:
statoscope generate path/to/stats.json path/to/report.html -o
Create statoscope report, save it to path/to/report.html
and open
If you are an engineer or a company that is interested in Statoscope improvements, you may support Statoscope by financial contribution at OpenCollective.
5.6.1 (16 July 2021)
[helpers]
fix handling max
-property in Graph.findPaths
FAQs
Statoscope CLI tools
The npm package @statoscope/cli receives a total of 9,229 weekly downloads. As such, @statoscope/cli popularity was classified as popular.
We found that @statoscope/cli demonstrated a healthy version release cadence and project activity because the last version was released less than 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.