This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: redact fields that should not be stored in CouchDB (#10)
- Loading branch information
Showing
4 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// redact fields from package.json that should have been obfuscated. | ||
const redactSSORegex = /"sso":\s*"[^"]*"/g | ||
const replacement = '[SECRET]' | ||
|
||
module.exports = function (body) { | ||
if (isPackageJson(body)) { | ||
return body.replace(redactSSORegex, `"sso":"${replacement}"`) | ||
} | ||
} | ||
|
||
// detect whether or not this payload is | ||
// package meta information vs., as an example, | ||
// the login dance. | ||
function isPackageJson (body) { | ||
// checking for "name" and "versions", this should be sufficient. | ||
return body.indexOf('"name"') !== -1 && body.indexOf('"versions"') !== -1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"_id": "tiny-tarball", | ||
"_rev": "3-085759e977d42299e64a35aedc17d250", | ||
"name": "tiny-tarball", | ||
"description": "tiny tarball used for health checks", | ||
"dist-tags": { | ||
"latest": "1.0.0" | ||
}, | ||
"versions": { | ||
"1.0.0": { | ||
"name": "tiny-tarball", | ||
"version": "1.0.0", | ||
"description": "tiny tarball used for health checks", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": { | ||
"name": "Ben Coe", | ||
"email": "ben@npmjs.com" | ||
}, | ||
"license": "ISC", | ||
"_id": "tiny-tarball@1.0.0", | ||
"_shasum": "bbf102d5ae73afe2c553295e0fb02230216f65b1", | ||
"_from": ".", | ||
"_npmVersion": "2.7.0", | ||
"_nodeVersion": "1.5.0", | ||
"_npmUser": { | ||
"name": "bcoe", | ||
"email": "bencoe@gmail.com", | ||
"sso": "http://very-secret-url" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"sso": "http://very-secret-url", | ||
"name": "bcoe", | ||
"email": "bencoe@gmail.com" | ||
} | ||
], | ||
"dist": { | ||
"shasum": "bbf102d5ae73afe2c553295e0fb02230216f65b1", | ||
"tarball": "https://registry.npmjs.org/tiny-tarball/-/tiny-tarball-1.0.0.tgz" | ||
}, | ||
"directories": {} | ||
} | ||
}, | ||
"readme": "# TinyTarball\n\ntiny-tarball used for health checks\n\n**don't unpublish me!**\n", | ||
"maintainers": [ | ||
{ | ||
"sso": "http://very-secret-url", | ||
"name": "bcoe", | ||
"email": "ben@npmjs.com" | ||
} | ||
], | ||
"time": { | ||
"modified": "2015-05-16T22:27:54.741Z", | ||
"created": "2015-03-24T00:12:24.039Z", | ||
"1.0.0": "2015-03-24T00:12:24.039Z" | ||
}, | ||
"author": { | ||
"name": "Ben Coe", | ||
"email": "ben@npmjs.com" | ||
}, | ||
"license": "ISC", | ||
"readmeFilename": "README.md", | ||
"_attachments": {} | ||
} |