zsyp 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Readme.md +1 -1
- package/lib/event.js +21 -2
- package/lib/source-map.js +1 -1
- package/package.json +6 -7
package/Readme.md
CHANGED
|
@@ -75,7 +75,7 @@ MIT © [Damian Krzeminski](https://pirxpilot.me)
|
|
|
75
75
|
[npm-url]: https://npmjs.org/package/zsyp
|
|
76
76
|
|
|
77
77
|
[build-url]: https://github.com/pirxpilot/zsyp/actions/workflows/check.yaml
|
|
78
|
-
[build-image]: https://img.shields.io/github/workflow/status/pirxpilot/zsyp/check
|
|
78
|
+
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/zsyp/check.yaml?branch=main
|
|
79
79
|
|
|
80
80
|
[deps-image]: https://img.shields.io/librariesio/release/npm/zsyp
|
|
81
81
|
[deps-url]: https://libraries.io/npm/zsyp
|
package/lib/event.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const { ObjectId } = require('mongodb');
|
|
2
|
+
const { createHash } = require('node:crypto');
|
|
1
3
|
const stackParser = require('error-stack-parser');
|
|
2
4
|
const { resolve } = require('./source-map');
|
|
3
5
|
|
|
@@ -27,11 +29,15 @@ async function converter(event) {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
async function convertError(error) {
|
|
30
|
-
const { an, av } = error;
|
|
32
|
+
const { an, av, stack } = error;
|
|
31
33
|
const frames = safeParseStack(error).map(mapFrame);
|
|
32
34
|
error.stack = await Promise.all(frames);
|
|
33
35
|
delete error.type;
|
|
34
|
-
|
|
36
|
+
if (stack) {
|
|
37
|
+
// save original stack if present
|
|
38
|
+
error.org_stack = stack;
|
|
39
|
+
}
|
|
40
|
+
return addHash(error);
|
|
35
41
|
|
|
36
42
|
function safeParseStack(error) {
|
|
37
43
|
try {
|
|
@@ -54,3 +60,16 @@ function normalizeFilename(fileName) {
|
|
|
54
60
|
// strip hostname and leading slashes
|
|
55
61
|
return file.pathname.replace(/^\/+/, '');
|
|
56
62
|
}
|
|
63
|
+
|
|
64
|
+
function addHash(error) {
|
|
65
|
+
if (error.stack.length < 1) {
|
|
66
|
+
return error;
|
|
67
|
+
}
|
|
68
|
+
const hasher = createHash('shake128', { outputLength: 12 });
|
|
69
|
+
error.stack.some(([file, line], index) => {
|
|
70
|
+
hasher.update(`${file}:${line}`);
|
|
71
|
+
return index > 9; // only hash at most 10 stack lines
|
|
72
|
+
});
|
|
73
|
+
error._hash = new ObjectId(hasher.digest());
|
|
74
|
+
return error;
|
|
75
|
+
}
|
package/lib/source-map.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zsyp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "CSP violation reports logger.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Damian Krzeminski",
|
|
@@ -21,16 +21,15 @@
|
|
|
21
21
|
"debug": "~2 || ~3 || ~4",
|
|
22
22
|
"dotenv": "~16",
|
|
23
23
|
"error-stack-parser": "^2.1.4",
|
|
24
|
-
"lru-cache": "
|
|
25
|
-
"mniam": "
|
|
24
|
+
"lru-cache": "~10",
|
|
25
|
+
"mniam": "~4",
|
|
26
26
|
"router": "~1",
|
|
27
27
|
"source-map": "^0.7.4",
|
|
28
|
-
"supertest": "~6",
|
|
29
28
|
"useragent": "^2.3.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"jshint": "~
|
|
33
|
-
"
|
|
31
|
+
"@pirxpilot/jshint": "~3",
|
|
32
|
+
"supertest": "~6"
|
|
34
33
|
},
|
|
35
34
|
"scripts": {
|
|
36
35
|
"test": "make check"
|
|
@@ -39,4 +38,4 @@
|
|
|
39
38
|
"index.js",
|
|
40
39
|
"lib"
|
|
41
40
|
]
|
|
42
|
-
}
|
|
41
|
+
}
|