Here's how you could create custom error classes in Node.js using latest ES6 / ES2015 syntax.
I've tried to make it as lean and unobtrusive as possible.
errors/AppError.js
| title: Suspicious msdt.exe execution - Office Exploit | |
| id: 97a80ed7-1f3f-4d05-9ef4-65760e634f6b | |
| status: experimental | |
| description: This rule will monitor suspicious arguments passed to the msdt.exe process. These arguments are an indicator of recent Office/Msdt exploitation. | |
| references: | |
| - https://doublepulsar.com/follina-a-microsoft-office-code-execution-vulnerability-1a47fce5629e | |
| - https://twitter.com/MalwareJake/status/1531019243411623939 | |
| author: 'Matthew Brennan' | |
| tags: | |
| - attack.execution |
| class CustomTableCalendar extends StatefulWidget { | |
| const CustomTableCalendar({Key? key}) : super(key: key); | |
| @override | |
| _CustomTableCalendarState createState() => _CustomTableCalendarState(); | |
| } | |
| class _CustomTableCalendarState extends State<CustomTableCalendar> { | |
| final todaysDate = DateTime.now(); | |
| var _focusedCalendarDate = DateTime.now(); |
| // Author: Renat Tuktarov (renat@sourcerer.io) | |
| const retry = function(fn, prev) { | |
| return new Promise((current, reject) => { | |
| const resolve = _ => (prev && prev()) || current(); | |
| fn(resolve, delay => { | |
| setTimeout(_ => { | |
| retry(fn, resolve); | |
| }, delay); |
| var debug = process.env.NODE_ENV !== "production"; | |
| var webpack = require('webpack'); | |
| module.exports = { | |
| context: __dirname, | |
| devtool: debug ? "inline-sourcemap" : null, | |
| entry: "./js/scripts.js", | |
| output: { | |
| path: __dirname + "/js", | |
| filename: "scripts.min.js" |
| var Db = require('mongodb').Db; | |
| var Connection = require('mongodb').Connection; | |
| var Server = require('mongodb').Server; | |
| //the MongoDB connection | |
| var connectionInstance; | |
| module.exports = function(callback) { | |
| //if already we have a connection, don't connect to database again | |
| if (connectionInstance) { | |
| callback(connectionInstance); |
| /** | |
| * Module dependencies | |
| */ | |
| var express = require('express'); | |
| var fs = require('fs'); | |
| var mongoose = require('mongoose'); | |
| var Schema = mongoose.Schema; | |
| // img path |
| function keepTrying(otherArgs, promise) { | |
| promise = promise||new Promise(); | |
| // try doing the important thing | |
| if(success) { | |
| promise.resolve(result); | |
| } else { | |
| setTimeout(function() { | |
| keepTrying(otherArgs, promise); |