Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

compact-yarn-audit

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compact-yarn-audit - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

4

package.json
{
"name": "compact-yarn-audit",
"version": "1.1.0",
"version": "1.1.1",
"description": "Presents output from yarn audit in a compact table",

@@ -35,4 +35,4 @@ "engines": {

"chalk": "^2.4.0",
"get-stream": "^6.0.1",
"lodash.uniqby": "^4.7.0",
"ndjson": "^2.0.0",
"strip-ansi": "^7.0.0",

@@ -39,0 +39,0 @@ "text-table": "^0.2.0"

@@ -8,5 +8,9 @@ ## What's this?

```sh
yarn audit --json | npx tersify-yarn-audit
yarn audit --json | npx compact-yarn-audit
```
> Note: yarn's audit output can be quite large (gigabytes for a sizeable
> monorepo that hasn't had updates for a while), so it can take
> some time to process all that data.
## Sample output

@@ -13,0 +17,0 @@

#!/usr/bin/env node
import getStream from "get-stream";
import { terseLog } from "./log-to-terse-object.js";
import ndjson from "ndjson";
import { sortLog, extractUsefulAttributes } from "./log-to-terse-object.js";
import { terseLog2Table } from "./terse-object-to-table.js";
getStream(process.stdin)
.then((pLog) => {
const lTerseLog = terseLog(pLog);
console.log(terseLog2Table(lTerseLog));
let lLog = [];
process.stdin
.pipe(ndjson.parse())
.on("data", (pLogEntry) => {
if (pLogEntry.type === "auditAdvisory") {
lLog.push(extractUsefulAttributes(pLogEntry));
}
})
.catch((pError) => {
.on("error", (pError) => {
console.error(pError);
process.exitCode = 1;
process.exit();
})
.on("end", () => {
console.log(terseLog2Table(sortLog(lLog)));
});
import uniqBy from "lodash.uniqby";
function auditLog2Object(pAuditLog) {
return JSON.parse(`[${pAuditLog.split("\n").join(",")}]`.replace(",]", "]"));
}
function extractUsefulAttributesFromLogEntry(pLogEntry) {
const lFixable = pLogEntry.data.advisory.patched_versions !== "<0.0.0";
const lVia = pLogEntry.data.resolution.path.split(">").shift();
return {
severity: pLogEntry.data.advisory.severity,
title: pLogEntry.data.advisory.title,
fixable: lFixable,
fixString: lFixable
? `"${pLogEntry.data.advisory.module_name}": "${pLogEntry.data.advisory.patched_versions}"`
: "no fix available",
module_name: pLogEntry.data.advisory.module_name,
via: lVia === pLogEntry.data.advisory.module_name ? "." : lVia,
};
}
function severity2Order(pSeverity) {

@@ -34,4 +14,2 @@ const lSeverity2Order = {

function unique(pTerseEntries) {}
function sortEntry(pEntryLeft, pEntryRight) {

@@ -47,10 +25,21 @@ return `${severity2Order(pEntryLeft.severity)}|${pEntryLeft.module_name}` >

}
export function terseLog(pLog) {
return uniqBy(
auditLog2Object(pLog)
.filter((pLogEntry) => pLogEntry.type === "auditAdvisory")
.map(extractUsefulAttributesFromLogEntry)
.sort(sortEntry),
wholeRecordAsString
);
export function sortLog(pLog) {
return uniqBy(pLog.sort(sortEntry), wholeRecordAsString);
}
export function extractUsefulAttributes(pLogEntry) {
const lFixable = pLogEntry.data.advisory.patched_versions !== "<0.0.0";
const lVia = pLogEntry.data.resolution.path.split(">").shift();
return {
severity: pLogEntry.data.advisory.severity,
title: pLogEntry.data.advisory.title,
fixable: lFixable,
fixString: lFixable
? `"${pLogEntry.data.advisory.module_name}": "${pLogEntry.data.advisory.patched_versions}"`
: "no fix available",
module_name: pLogEntry.data.advisory.module_name,
via: lVia === pLogEntry.data.advisory.module_name ? "." : lVia,
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc