New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mythx-report-helper

Package Overview
Dependencies
Maintainers
3
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mythx-report-helper - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

build/src/Properties.js

42

build/src/Issue.js

@@ -12,5 +12,8 @@ "use strict";

this.swcID = issue.swcID;
if (this.description.head.indexOf("Analysis depth is limited in this mode so some issues might not be detected") >= 0) {
this.severity = "info";
if (issue.uuid) {
this.uuid = issue.uuid;
}
if (this.description.head.indexOf('Analysis depth is limited in this mode so some issues might not be detected') >= 0) {
this.severity = 'info';
}
this.id = this.generateId();

@@ -20,20 +23,25 @@ this.setupIssue();

generateId() {
const timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, () => {
return (Math.random() * 16 | 0).toString(16);
}).toLowerCase();
const timestamp = ((new Date().getTime() / 1000) | 0).toString(16);
return (timestamp +
'xxxxxxxxxxxxxxxx'
.replace(/[x]/g, () => {
return ((Math.random() * 16) | 0).toString(16);
})
.toLowerCase());
}
;
setupIssue() {
this.isTypeSolidity = this.location.sourceType !== 'raw-bytecode';
this.hasDecodedLocation = (this.decodedLocation !== undefined)
&& (this.decodedLocation !== null)
&& this.decodedLocation.length
&& this.decodedLocation.length > 0
&& this.decodedLocation[0].line !== undefined
&& this.decodedLocation[0].column !== undefined
&& this.decodedLocation[1].line !== undefined
&& this.decodedLocation[1].column !== undefined;
this.hasValidSourceMap = this.location.sourceMap && this.location.sourceMap.split(":").length === 3;
this.ignored = (this.hasDecodedLocation && this.decodedLocation[2]) ? true : false;
this.hasDecodedLocation =
this.decodedLocation !== undefined &&
this.decodedLocation !== null &&
this.decodedLocation.length &&
this.decodedLocation.length > 0 &&
this.decodedLocation[0].line !== undefined &&
this.decodedLocation[0].column !== undefined &&
this.decodedLocation[1].line !== undefined &&
this.decodedLocation[1].column !== undefined;
this.hasValidSourceMap =
this.location.sourceMap && this.location.sourceMap.split(':').length === 3;
this.ignored =
this.hasDecodedLocation && this.decodedLocation[2] ? true : false;
}

@@ -40,0 +48,0 @@ getStartingLine() {

@@ -44,12 +44,28 @@ "use strict";

if (InstructionCoverageOverTime.length === 2) {
issues.meta = Object.assign({}, issues.meta, { InstructionCoverageOverTime: InstructionCoverageOverTime[0], InstructionCoverageOverTimeUnit: InstructionCoverageOverTime[1] });
issues.meta = {
...issues.meta,
InstructionCoverageOverTime: InstructionCoverageOverTime[0],
InstructionCoverageOverTimeUnit: InstructionCoverageOverTime[1],
};
}
if (PercentageCoverageOverTime.length === 2) {
issues.meta = Object.assign({}, issues.meta, { PercentageCoverageOverTime: PercentageCoverageOverTime[0], PercentageCoverageOverTimeUnit: PercentageCoverageOverTime[1] });
issues.meta = {
...issues.meta,
PercentageCoverageOverTime: PercentageCoverageOverTime[0],
PercentageCoverageOverTimeUnit: PercentageCoverageOverTime[1],
};
}
if (BranchCoverageOverTime.length === 2) {
issues.meta = Object.assign({}, issues.meta, { BranchCoverageOverTime: BranchCoverageOverTime[0], BranchCoverageOverTimeUnit: BranchCoverageOverTime[1] });
issues.meta = {
...issues.meta,
BranchCoverageOverTime: BranchCoverageOverTime[0],
BranchCoverageOverTimeUnit: BranchCoverageOverTime[1],
};
}
if (PathCoverageOverTime.length === 2) {
issues.meta = Object.assign({}, issues.meta, { PathCoverageOverTime: PathCoverageOverTime[0], PathCoverageOverTimeUnit: PathCoverageOverTime[1] });
issues.meta = {
...issues.meta,
PathCoverageOverTime: PathCoverageOverTime[0],
PathCoverageOverTimeUnit: PathCoverageOverTime[1],
};
}

@@ -71,3 +87,3 @@ if (LineCoverage) {

}
issues.meta = Object.assign({}, issues.meta, { lineCoverage });
issues.meta = { ...issues.meta, lineCoverage };
}

@@ -74,0 +90,0 @@ return issues;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const Issue_1 = require("./Issue");

@@ -12,6 +11,33 @@ const util_1 = require("util");

}
static propertyIsValid(property) {
let isValid = true;
const expectedKeys = [
'id',
'name',
'sourceFile',
'annotationSource',
'contractName',
'covered',
'violated',
'correlatedIssues',
'location',
];
const actualKeys = Object.keys(property);
for (const expectedKey of expectedKeys) {
if (actualKeys.indexOf(expectedKey) < 0) {
isValid = false;
console.warn('Property ' + expectedKey + ' not found.');
}
}
return isValid;
}
init(issues, input, filter) {
this.propertiesAvailable = false;
this.issuesWithoutProperties = [];
this.properties = [];
this.updateIssues(issues, input, filter);
this.updateMetrics(issues);
this.processedIssues && this.applyFilters();
this.updateProperties();
this.indexIssuesByProperty();
}

@@ -32,2 +58,45 @@ updateIssues(issues, input, filter) {

}
updateProperties() {
try {
const properties = this.meta.map((i) => i.Properties).flat();
if (!properties ||
properties.length == 0 ||
!Report.propertyIsValid(properties[0])) {
throw new Error('No properties available.');
}
this.properties = properties;
this.propertiesAvailable = true;
}
catch (e) {
console.warn('Properties unavailable, defaulting to Issues based report.');
}
}
indexIssuesByProperty() {
try {
for (const property of this.properties) {
const { correlatedIssues } = property;
for (const issueId of correlatedIssues) {
const targetIssue = this.getIssuesToDisplay().filter((issue) => issue.uuid === issueId)[0];
if (!property.issues) {
property.issues = [];
}
property.issues = [...property.issues, targetIssue];
}
}
const issuesWithProperties = this.properties
.map((property) => property.correlatedIssues)
.flat();
const issuesWithoutProperties = this.processedIssues.filter((issue) => issuesWithProperties.indexOf(issue.uuid) < 0);
this.issuesWithoutProperties = issuesWithoutProperties;
}
catch (e) {
console.warn('Properties unavailable, defaulting to Issues based report.');
}
}
getProperties() {
return this.properties;
}
getIssuesWithoutProperties() {
return this.issuesWithoutProperties;
}
updateMetrics(issues) {

@@ -44,2 +113,5 @@ this.issuesWithMetrics = issues && metrics_1.processMetrics(issues);

}
getIssuesByProperty() {
return [];
}
applyFilters() {

@@ -79,3 +151,6 @@ let filteredIssues = this.processedIssues;

if (!source || !source.length || source.length <= 1) {
sourcesIndexedByName = Object.assign({}, sourcesIndexedByName, { [fileName]: { id, name: fileName, sourceFileAvailable: false } });
sourcesIndexedByName = {
...sourcesIndexedByName,
[fileName]: { id, name: fileName, sourceFileAvailable: false },
};
return;

@@ -89,3 +164,6 @@ }

};
sourcesIndexedByName = Object.assign({}, sourcesIndexedByName, { [fileName]: sourceObject });
sourcesIndexedByName = {
...sourcesIndexedByName,
[fileName]: sourceObject,
};
return;

@@ -98,4 +176,4 @@ });

this.sourceFilesNames.forEach((srcName) => {
const _a = this.sourceFiles[srcName], { id, sourceFileAvailable } = _a, rest = tslib_1.__rest(_a, ["id", "sourceFileAvailable"]);
sourceFilesById = Object.assign({}, sourceFilesById, { [id]: Object.assign({ id }, rest) });
const { id, sourceFileAvailable, ...rest } = this.sourceFiles[srcName];
sourceFilesById = { ...sourceFilesById, [id]: { id, ...rest } };
});

@@ -127,3 +205,3 @@ this.sourceFilesById = sourceFilesById;

const issues = item.issues.map((issue) => {
return Object.assign({}, issue, { analysesSourceType: item.sourceType });
return { ...issue, analysesSourceType: item.sourceType };
});

@@ -139,7 +217,7 @@ issueItems = [...issueItems, issues];

flatIssues.map((issue) => {
const { locations } = issue, rest = tslib_1.__rest(issue, ["locations"]);
const { locations, ...rest } = issue;
if (!locations.length || locations.length < 1) {
const location = [];
const decodedLocation = [];
const processedIssue = new Issue_1.Issue(Object.assign({ location, decodedLocation }, rest));
const processedIssue = new Issue_1.Issue({ location, decodedLocation, ...rest });
if (processedIssue.hasDecodedLocation) {

@@ -161,3 +239,3 @@ processedIssues = [...processedIssues, processedIssue];

}
const processedIssue = new Issue_1.Issue(Object.assign({ location, decodedLocation }, rest));
const processedIssue = new Issue_1.Issue({ location, decodedLocation, ...rest });
processedIssues = [...processedIssues, processedIssue];

@@ -218,6 +296,12 @@ });

if (sourceLinesWithIssues[line] && sourceLinesWithIssues[line].issues) {
sourceLinesWithIssues[line] = Object.assign({}, sourceLinesWithIssues[line], { issues: [...sourceLinesWithIssues[line].issues, issue] });
sourceLinesWithIssues[line] = {
...sourceLinesWithIssues[line],
issues: [...sourceLinesWithIssues[line].issues, issue],
};
}
else {
sourceLinesWithIssues[line] = Object.assign({}, sourceLinesWithIssues[line], { issues: [issue] });
sourceLinesWithIssues[line] = {
...sourceLinesWithIssues[line],
issues: [issue],
};
}

@@ -224,0 +308,0 @@ });

{
"name": "mythx-report-helper",
"version": "1.4.1",
"version": "1.5.0",
"description": "TS helper to manage mythx reports",

@@ -35,4 +35,4 @@ "main": "./build/src/index.js",

"dependencies": {
"tslib": "~1.10.0"
"tslib": "^1.10.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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