Remove sensitive data from the error message of Sercret_Property (#104)

Co-authored-by: FAREAST\renhel <renhel@microsoft.com>
This commit is contained in:
Renhe Li 2020-08-17 13:20:29 +08:00 коммит произвёл GitHub
Родитель 087dcd07bd
Коммит 101eae537f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 86 добавлений и 50 удалений

Просмотреть файл

@ -224,13 +224,8 @@ function checkSecretPropertyInResponse (validateOptions, schema, json, report) {
var isXmsSecretTrue = xMsSecret && typeof xMsSecret === 'boolean' && xMsSecret === true
if (isResponse && schema && isXmsSecretTrue && json !== undefined) {
let errorMessage = 'Secret property `"{0}": ';
let errorMessage = 'Secret property `"{0}"';
if (schema && schema.type === 'string' && typeof json === 'string') {
errorMessage += '"{1}"';
} else {
errorMessage += '{1}';
}
let propertyName = '';
if (schema.title && typeof schema.title === 'string') {
@ -245,7 +240,7 @@ function checkSecretPropertyInResponse (validateOptions, schema, json, report) {
}
}
errorMessage += '`, cannot be sent in the response.';
report.addCustomError('SECRET_PROPERTY', errorMessage, [propertyName, json], null, schema);
report.addCustomError('SECRET_PROPERTY', errorMessage, [propertyName, ''], null, schema);
}
}

109
package-lock.json сгенерированный
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "yasway",
"version": "1.10.1",
"version": "1.10.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -463,9 +463,9 @@
},
"dependencies": {
"acorn": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.0.0.tgz",
"integrity": "sha512-PaF/MduxijYYt7unVGRuds1vBC9bFxbNf+VWqhOClfdgy7RlVkQqt610ig1/yxTgsDIfW1cWDel5EBbOy3jdtQ==",
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
"dev": true
}
}
@ -3566,9 +3566,9 @@
},
"dependencies": {
"minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
}
}
@ -3724,9 +3724,9 @@
"dev": true
},
"elliptic": {
"version": "6.5.1",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.1.tgz",
"integrity": "sha512-xvJINNLbTeWQjrl6X+7eQCrIy/YPv5XCpKW6kB5mKvtnGILoLDcySuwomfdzt0BMdLNVnuRNTuzKNHj0bva1Cg==",
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.3.tgz",
"integrity": "sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==",
"dev": true,
"requires": {
"bn.js": "^4.4.0",
@ -4516,6 +4516,15 @@
"ms": "2.0.0"
}
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
@ -4536,21 +4545,27 @@
"integrity": "sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8="
},
"falafel": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/falafel/-/falafel-2.1.0.tgz",
"integrity": "sha1-lrsXdh2rqU9G0AFzizzt86Z/4Gw=",
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/falafel/-/falafel-2.2.4.tgz",
"integrity": "sha512-0HXjo8XASWRmsS0X1EkhwEMZaD3Qvp7FfURwjLKjG1ghfRm/MGZl2r4cWUTv41KdNghTw4OUMmVtdGQp3+H+uQ==",
"dev": true,
"requires": {
"acorn": "^5.0.0",
"acorn": "^7.1.1",
"foreach": "^2.0.5",
"isarray": "0.0.1",
"isarray": "^2.0.1",
"object-keys": "^1.0.6"
},
"dependencies": {
"acorn": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
"integrity": "sha512-+G7P8jJmCHr+S+cLfQxygbWhXy+8YTVGzAkpEbcLo2mLoL7tij/VG41QSHACSf5QgYRhMZYHuNc6drJaO0Da+w==",
"dev": true
},
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
"integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==",
"dev": true
}
}
@ -6270,6 +6285,15 @@
"path-is-absolute": "^1.0.0"
}
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
}
},
"mocha": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz",
@ -6773,9 +6797,9 @@
}
},
"http-proxy": {
"version": "1.18.0",
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.0.tgz",
"integrity": "sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ==",
"version": "1.18.1",
"resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz",
"integrity": "sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ==",
"dev": true,
"requires": {
"eventemitter3": "^4.0.0",
@ -8380,9 +8404,9 @@
}
},
"lodash": {
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
"version": "4.17.20",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz",
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA=="
},
"lodash._basecopy": {
"version": "3.0.1",
@ -9139,12 +9163,20 @@
}
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"version": "0.5.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dev": true,
"requires": {
"minimist": "0.0.8"
"minimist": "^1.2.5"
},
"dependencies": {
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
}
}
},
"mkdirp2": {
@ -9224,6 +9256,15 @@
"integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
@ -10872,9 +10913,9 @@
},
"dependencies": {
"minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
}
}
@ -12445,9 +12486,9 @@
},
"dependencies": {
"minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
}
}

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "yasway",
"version": "1.10.1",
"version": "1.10.2",
"description": "A library that simplifies Swagger integrations.",
"main": "index.js",
"types": "index.d.ts",
@ -76,7 +76,7 @@
"js-yaml": "^3.13.1",
"json-refs": "^3.0.13",
"json-schema-faker": "^0.5.0-rc16",
"lodash": "^4.17.11",
"lodash": "^4.17.20",
"native-promise-only": "^0.8.1",
"nyc": "^15.0.1",
"path-to-regexp": "^1.7.0",

Просмотреть файл

@ -349,14 +349,14 @@ describe('Response', function () {
title: '{\"path\":[\"toy\"]}'
}, {
code: 'SECRET_PROPERTY',
message: 'Secret property `"toy": `, cannot be sent in the response.',
params: ['toy', []],
message: 'Secret property `"toy"`, cannot be sent in the response.',
params: ['toy', ''],
path: ['photoUrls'],
title: '{\"path\":[\"toy\"]}'
}, {
code: 'SECRET_PROPERTY',
message: 'Secret property `"": "Test Toy"`, cannot be sent in the response.',
params: ['', 'Test Toy'],
message: 'Secret property `""`, cannot be sent in the response.',
params: ['', ''],
path: ['name'],
},
]);
@ -731,12 +731,12 @@ describe('Response', function () {
errors: [
{
code: 'SECRET_PROPERTY',
message: 'Secret property `"": "password"`, cannot be sent in the response.',
params: ['', 'password'],
message: 'Secret property `""`, cannot be sent in the response.',
params: ['', ''],
path: ['secret']
}
],
message: 'Invalid body: Secret property `"": "password"`, cannot be sent in the response.',
message: 'Invalid body: Secret property `""`, cannot be sent in the response.',
path: []
}
]);