@bug-catch/server
Advanced tools
Sorry, the diff of this file is not supported yet
+2
-1
| { | ||
| "name": "@bug-catch/server", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "main": "index.js", | ||
@@ -26,2 +26,3 @@ "homepage": "https://github.com/bug-catch/server#readme", | ||
| "debug": "^4.1.1", | ||
| "dotenv": "^8.2.0", | ||
| "eslint": "^7.8.1", | ||
@@ -28,0 +29,0 @@ "gulp": "^4.0.2", |
| const express = require("express"); | ||
| require("dotenv").config(); | ||
| const bugcatch = require("../index"); | ||
@@ -19,5 +21,4 @@ | ||
| mongodb: { | ||
| uri: | ||
| "mongodb+srv://root:kL0Y1MpD1927oPlg@cluster0.ks1d6.mongodb.net/test?authSource=admin&replicaSet=atlas-9yqfga-shard-0&readPreference=primary&appname=MongoDB%20Compass&ssl=true", | ||
| database: "appname-errortracking", | ||
| uri: process.env.BUGCATCH_MONGO_URI, | ||
| database: process.env.BUGCATCH_MONGO_DATABASE, | ||
| }, | ||
@@ -24,0 +25,0 @@ }) |
-128
| (function (root, factory) { | ||
| if (typeof define === "function" && define.amd) { | ||
| define([], factory); | ||
| } else if (typeof exports === "object") { | ||
| module.exports = factory(); | ||
| } else { | ||
| root.Bugcatch = factory(); | ||
| } | ||
| })(this, function () { | ||
| "use strict"; | ||
| const Bugcatch = (function () { | ||
| /* | ||
| * Default options object | ||
| */ | ||
| const options = { | ||
| base_url: "", | ||
| release: "0.0.0", | ||
| disableError: false, | ||
| disableUnhandledRejection: false, | ||
| }; | ||
| /* | ||
| * Set options object | ||
| * | ||
| * @param {object} user options | ||
| */ | ||
| const setOptions = (userOptions) => { | ||
| Object.assign(options, userOptions); | ||
| }; | ||
| /* | ||
| * Post request | ||
| * | ||
| * @param {string} url address to post to | ||
| * @param {object} data object to send | ||
| */ | ||
| const xhrPost = (url, data) => { | ||
| try { | ||
| const xhr = new XMLHttpRequest(); | ||
| xhr.open("POST", url, true); | ||
| xhr.setRequestHeader("Content-Type", "application/json"); | ||
| xhr.send(JSON.stringify(data)); | ||
| } catch (error) { | ||
| console.log(error); | ||
| } | ||
| }; | ||
| /* | ||
| * Handle error events | ||
| * | ||
| * @param {object} error event object | ||
| */ | ||
| const onError = (evt) => { | ||
| // Collect error data from event | ||
| const data = {}; | ||
| // Detect error event | ||
| // separate error and unhandledrejection | ||
| if (evt.error) { | ||
| // Error event | ||
| data.type = evt.type; | ||
| data.message = evt.message; | ||
| data.filename = evt.filename; | ||
| data.location = window.location.href; | ||
| data.line = evt.lineno || -1; | ||
| data.column = evt.colno || -1; | ||
| data.error = { | ||
| name: evt.error.name, | ||
| message: evt.error.message, | ||
| stack: evt.error.stack, | ||
| }; | ||
| } else { | ||
| // Promise rejection event | ||
| data.type = evt.type; | ||
| data.message = evt.reason.message; | ||
| data.filename = ""; | ||
| data.location = window.location.href; | ||
| data.line = -1; | ||
| data.column = -1; | ||
| data.error = { | ||
| name: evt.reason.name, | ||
| message: evt.reason.message, | ||
| stack: evt.reason.stack, | ||
| }; | ||
| // Extract line and column numbers | ||
| // from stack trace | ||
| const stackLinePosition = (/:[0-9]+:[0-9]+/.exec( | ||
| evt.reason.stack | ||
| ) || [""])[0].split(":"); | ||
| if (stackLinePosition.length === 3) { | ||
| data.line = Number(stackLinePosition[1]); | ||
| data.column = Number(stackLinePosition[2]); | ||
| } | ||
| } | ||
| console.log(data); | ||
| // Send incident data to server | ||
| xhrPost(`${options.base_url}/error`, { | ||
| data: data, | ||
| release: options.release, | ||
| }); | ||
| return true; | ||
| }; | ||
| return { | ||
| /* | ||
| * Initialise bug-catch to catch all errors | ||
| * | ||
| * @param {object} user options | ||
| */ | ||
| init: function (userOptions) { | ||
| setOptions(userOptions); | ||
| // Listen to uncaught errors | ||
| window.addEventListener("error", onError); | ||
| // Listen to uncaught promises rejections | ||
| window.addEventListener("unhandledrejection", onError); | ||
| }, | ||
| }; | ||
| })(); | ||
| return Bugcatch; | ||
| }); |
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <title>Bug-catch test</title> | ||
| </head> | ||
| <body id="body"> | ||
| <h1>Bug-Catch</h1> | ||
| <script src="bugcatch.js" type="text/javascript"></script> | ||
| <script> | ||
| Bugcatch.init({ | ||
| base_url: "http://localhost:8000", | ||
| release: "0.1.0", | ||
| }); | ||
| setTimeout(function () { | ||
| // notThere(); | ||
| var promise = new Promise(function (resolve, reject) { | ||
| if (false) { | ||
| resolve("Stuff worked!"); | ||
| } else { | ||
| notThere(); | ||
| reject(Error("It broke")); | ||
| } | ||
| }); | ||
| }, 500); | ||
| </script> | ||
| </body> | ||
| </html> |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
25048
-15.75%8
14.29%13
-7.14%327
-26.02%3
50%