Skip to content

Normalize schema #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
gl-dependency-scanning-report.json
node_modules
dist/
Empty file added .npmignore
Empty file.
14 changes: 9 additions & 5 deletions lib/convert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var capitalize = require("./utils").capitalize;
var getCWEId = require("./utils").getCWEId;
var gitlabSchema = require("schema-merge/dist/dependency-scanning-report-format.json");

var convert = function (json) {
return JSON.stringify(convertReportForType(JSON.parse(json)), null, " ");
Expand All @@ -21,7 +22,9 @@ function getReportType(parsedData) {

function convertV2Report(parsedData) {
let report = {};
report.version = "2.0";
// The version of the schema to which the JSON report conforms.
report.version = gitlabSchema.self.version;
report.schema = `https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v${gitlabSchema.self.version}/dist/dependency-scanning-report-format.json`
report.vulnerabilities = [];
report.remediations = [];

Expand All @@ -45,7 +48,7 @@ function convertV2Report(parsedData) {
confidence: "High",
scanner: {
id: "npm_audit_advisories",
name: "NPM Audit",
name: `NPM Audit v${getReportType(parsedData)}`
},
location: {
file: "package-lock.json",
Expand Down Expand Up @@ -86,7 +89,9 @@ function convertV2Report(parsedData) {

function convertV1Report(parsedData) {
let report = {};
report.version = "1.0";
// The version of the schema to which the JSON report conforms.
report.version = gitlabSchema.self.version;
report.schema = `https://gitlab.com/gitlab-org/security-products/security-report-schemas/-/raw/v${gitlabSchema.self.version}/dist/dependency-scanning-report-format.json`
report.vulnerabilities = [];
report.remediations = [];

Expand All @@ -108,7 +113,7 @@ function convertV1Report(parsedData) {
confidence: "High",
scanner: {
id: "npm_audit_advisories",
name: "NPM Audit",
name: `NPM Audit v${getReportType(parsedData)}`
},
location: {
file: "package.json",
Expand All @@ -134,7 +139,6 @@ function convertV1Report(parsedData) {
},
],
solution: advisory.recommendation,
instances: advisory.findings[0].paths.map((value) => ({ method: value })),
links: [
{
url: `https://npmjs.com/advisories/${advisory.id}`,
Expand Down
Loading