Skip to content

Commit

Permalink
Merge pull request #34 from snyk-tech-services/develop
Browse files Browse the repository at this point in the history
release
  • Loading branch information
aarlaud authored May 6, 2021
2 parents 013440c + 12df192 commit cc47289
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 30 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
],
"homepage": "https://github.com/snyk-tech-services/snyk-api-ts-client#readme",
"dependencies": {
"@manifoldco/swagger-to-ts": "^2.0.0",
"@snyk/configstore": "^3.2.0-rc1",
"@snyk/dep-graph": "^1.23.0",
"@types/lodash": "^4.14.155",
Expand All @@ -64,6 +63,7 @@
"utility-types": "^3.10.0"
},
"devDependencies": {
"@manifoldco/swagger-to-ts": "^2.0.0",
"@types/jest": "^25.1.1",
"@types/lodash": "^4.14.149",
"@types/node": "^12.12.26",
Expand All @@ -80,6 +80,7 @@
"ts-jest": "^25.1.0",
"ts-node": "8.6.2",
"tsc-watch": "^4.1.0",
"typedoc": "^0.20.29",
"typescript": "^3.7.5"
},
"pkg": {
Expand Down
16 changes: 7 additions & 9 deletions src/lib/client/abstraction/org/aggregatedissues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createFromJSON, DepGraph, DepGraphData } from '@snyk/dep-graph';

interface IssuesWithVulnsPaths {
issues: {
pkgVersions: { [key: string]: Array<Array<string>> };
pkgVersionsWithPaths: { [key: string]: Array<Array<string>> }[];
}[];
}

Expand Down Expand Up @@ -31,28 +31,26 @@ export const getAggregatedIssuesWithVulnPaths = async (
issues: [],
};

// @ts-ignore
projectAggregatedIssues.issues.map((issue) => {
// @ts-ignore
const versionsWithVulnPaths = issue.pkgVersions.map((version) => {
projectAggregatedIssues?.issues?.map((issue) => {
const returnVulnPathsData = issue.pkgVersions.map((version) => {
const pkg = {
name: issue.pkgName,
version: version as string,
};
const returnData = {
return {
[`${pkg.version}`]: getVulnPathsForPkgVersionFromGraph(
pkg.name,
pkg.version,
depGraph,
),
};
return returnData;
});

const newIssue = {
let newIssue = {
pkgVersionsWithPaths: returnVulnPathsData,
...issue,
};
newIssue.pkgVersions = versionsWithVulnPaths;

returnData.issues.push(newIssue);
});

Expand Down
12 changes: 10 additions & 2 deletions src/lib/generators/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,16 @@ const generateResponseInterfaces = (
const methodsArray = classToGenerateResponseInterfacesFor.methods;

methodsArray.forEach((method) => {
if (!_.isEmpty(method.response) && !codeToReturn.includes(`${
utils.formatClassName(classToGenerateResponseInterfacesFor.name) +_.capitalize(method.verb) + 'ResponseType'}`)) {
if (
!_.isEmpty(method.response) &&
!codeToReturn.includes(
`${
utils.formatClassName(classToGenerateResponseInterfacesFor.name) +
_.capitalize(method.verb) +
'ResponseType'
}`,
)
) {
switch (method.response?.type) {
case 'custom':
// codeToReturn += `export interface ${
Expand Down
2 changes: 2 additions & 0 deletions test/abstraction/org/aggregatedissues.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ describe('Testing org abstraction ', () => {
const result = await new Org({ orgId: '123' })
.project({ projectId: '123' })
.aggregatedissues.getAggregatedIssuesWithVulnPaths(body);

console.log(result);
expect(
_.isEqual(
result,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"id": "SNYK-JS-EXPRESSFILEUPLOAD-473997",
"issueType": "vuln",
"pkgName": "express-fileupload",
"pkgVersions": [{ "0.0.5": [["[email protected]"]] }],
"pkgVersions": ["0.0.5"],
"pkgVersionsWithPaths": [{ "0.0.5": [["[email protected]"]] }],
"priorityScore": 704,
"priority": {
"score": 704,
Expand Down Expand Up @@ -49,7 +50,8 @@
"id": "SNYK-JS-EXPRESSFILEUPLOAD-595969",
"issueType": "vuln",
"pkgName": "express-fileupload",
"pkgVersions": [{ "0.0.5": [["[email protected]"]] }],
"pkgVersions": ["0.0.5"],
"pkgVersionsWithPaths": [{ "0.0.5": [["[email protected]"]] }],
"priorityScore": 696,
"priority": {
"score": 696,
Expand Down Expand Up @@ -97,7 +99,8 @@
"id": "SNYK-JS-TREEKILL-536781",
"issueType": "vuln",
"pkgName": "tree-kill",
"pkgVersions": [
"pkgVersions": ["1.2.1"],
"pkgVersionsWithPaths": [
{
"1.2.1": [
["[email protected]", "[email protected]", "[email protected]"]
Expand Down Expand Up @@ -161,7 +164,8 @@
"id": "SNYK-JS-LODASH-567746",
"issueType": "vuln",
"pkgName": "lodash",
"pkgVersions": [
"pkgVersions": ["4.17.15"],
"pkgVersionsWithPaths": [
{
"4.17.15": [
["[email protected]", "[email protected]"],
Expand Down Expand Up @@ -266,7 +270,8 @@
"id": "SNYK-JS-HTTPSPROXYAGENT-469131",
"issueType": "vuln",
"pkgName": "https-proxy-agent",
"pkgVersions": [
"pkgVersions": ["2.2.2"],
"pkgVersionsWithPaths": [
{
"2.2.2": [
["[email protected]", "[email protected]", "[email protected]"],
Expand Down Expand Up @@ -341,7 +346,8 @@
"id": "snyk:lic:npm:goof:GPL-2.0",
"issueType": "license",
"pkgName": "goof",
"pkgVersions": [{ "0.0.3": [[]] }],
"pkgVersions": ["0.0.3"],
"pkgVersionsWithPaths": [{ "0.0.3": [[]] }],
"priorityScore": 625,
"priority": {
"score": 625,
Expand Down Expand Up @@ -376,7 +382,8 @@
"id": "SNYK-JS-LODASH-590103",
"issueType": "vuln",
"pkgName": "lodash",
"pkgVersions": [
"pkgVersions": ["4.17.15"],
"pkgVersionsWithPaths": [
{
"4.17.15": [
["[email protected]", "[email protected]"],
Expand Down Expand Up @@ -459,7 +466,8 @@
"id": "SNYK-JS-Y18N-1021887",
"issueType": "vuln",
"pkgName": "y18n",
"pkgVersions": [
"pkgVersions": ["3.2.1"],
"pkgVersionsWithPaths": [
{
"3.2.1": [
[
Expand Down Expand Up @@ -516,7 +524,8 @@
"id": "SNYK-JS-LODASH-608086",
"issueType": "vuln",
"pkgName": "lodash",
"pkgVersions": [
"pkgVersions": ["4.17.15"],
"pkgVersionsWithPaths": [
{
"4.17.15": [
["[email protected]", "[email protected]"],
Expand Down Expand Up @@ -605,7 +614,8 @@
"id": "SNYK-JS-INI-1048974",
"issueType": "vuln",
"pkgName": "ini",
"pkgVersions": [
"pkgVersions": ["1.3.5"],
"pkgVersionsWithPaths": [
{
"1.3.5": [
["[email protected]", "[email protected]"],
Expand Down Expand Up @@ -688,7 +698,8 @@
"id": "SNYK-JS-DOTPROP-543489",
"issueType": "vuln",
"pkgName": "dot-prop",
"pkgVersions": [
"pkgVersions": ["4.2.0"],
"pkgVersionsWithPaths": [
{
"4.2.0": [
["[email protected]", "[email protected]", "[email protected]"],
Expand Down Expand Up @@ -743,7 +754,8 @@
"id": "npm:ejs:20161128",
"issueType": "vuln",
"pkgName": "ejs",
"pkgVersions": [{ "0.8.8": [["[email protected]", "[email protected]"]] }],
"pkgVersions": ["0.8.8"],
"pkgVersionsWithPaths": [{ "0.8.8": [["[email protected]", "[email protected]"]] }],
"priorityScore": 405,
"priority": {
"score": 405,
Expand Down Expand Up @@ -794,7 +806,8 @@
"id": "SNYK-JS-MINIMIST-559764",
"issueType": "vuln",
"pkgName": "minimist",
"pkgVersions": [
"pkgVersions": ["1.2.0", "0.0.8", "0.0.10"],
"pkgVersionsWithPaths": [
{
"1.2.0": [
[
Expand Down Expand Up @@ -867,7 +880,8 @@
"id": "SNYK-JS-BL-608877",
"issueType": "vuln",
"pkgName": "bl",
"pkgVersions": [{ "1.2.2": [["[email protected]", "[email protected]"]] }],
"pkgVersions": ["1.2.2"],
"pkgVersionsWithPaths": [{ "1.2.2": [["[email protected]", "[email protected]"]] }],
"priorityScore": 385,
"priority": {
"score": 385,
Expand Down Expand Up @@ -916,7 +930,8 @@
"id": "SNYK-JS-EJS-1049328",
"issueType": "vuln",
"pkgName": "ejs",
"pkgVersions": [
"pkgVersions": ["0.8.8", "2.5.5"],
"pkgVersionsWithPaths": [
{ "0.8.8": [["[email protected]", "[email protected]"]] },
{ "2.5.5": [["[email protected]"]] }
],
Expand Down Expand Up @@ -963,7 +978,8 @@
"id": "SNYK-JS-ACORN-559469",
"issueType": "vuln",
"pkgName": "acorn",
"pkgVersions": [
"pkgVersions": ["5.7.3"],
"pkgVersionsWithPaths": [
{ "5.7.3": [["@snyk/[email protected]", "[email protected]"]] }
],
"priorityScore": 375,
Expand Down Expand Up @@ -1009,7 +1025,8 @@
"id": "npm:ejs:20161130-1",
"issueType": "vuln",
"pkgName": "ejs",
"pkgVersions": [{ "0.8.8": [["[email protected]", "[email protected]"]] }],
"pkgVersions": ["0.8.8"],
"pkgVersionsWithPaths": [{ "0.8.8": [["[email protected]", "[email protected]"]] }],
"priorityScore": 295,
"priority": {
"score": 295,
Expand Down Expand Up @@ -1050,7 +1067,8 @@
"id": "npm:ejs:20161130",
"issueType": "vuln",
"pkgName": "ejs",
"pkgVersions": [{ "0.8.8": [["[email protected]", "[email protected]"]] }],
"pkgVersions": ["0.8.8"],
"pkgVersionsWithPaths": [{ "0.8.8": [["[email protected]", "[email protected]"]] }],
"priorityScore": 295,
"priority": {
"score": 295,
Expand Down

0 comments on commit cc47289

Please sign in to comment.