@appsignal/nodejs
Advanced tools
Comparing version
import { HashMap } from "@appsignal/types"; | ||
export declare class Diagnose { | ||
#private; | ||
constructor(); | ||
run(): Promise<void>; | ||
sendReport(data: object): void; | ||
printAgentDiagnose(report: HashMap<any>): void; | ||
printAgentTest(definition: HashMap<any>, test: HashMap<any>): void; | ||
agentDiagnosticTestDefinition(): HashMap<any>; | ||
send_report(data: object): void; | ||
print_newline(): void; | ||
colorize(value: string): string; | ||
} |
"use strict"; | ||
var _diagnose; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Diagnose = void 0; | ||
const tslib_1 = require("tslib"); | ||
const { DiagnoseTool } = require("../diagnose"); | ||
@@ -11,4 +13,8 @@ const fs = require("fs"); | ||
class Diagnose { | ||
constructor() { | ||
_diagnose.set(this, void 0); | ||
tslib_1.__classPrivateFieldSet(this, _diagnose, new DiagnoseTool({})); | ||
} | ||
async run() { | ||
const data = await new DiagnoseTool({}).generate(); | ||
const data = await tslib_1.__classPrivateFieldGet(this, _diagnose).generate(); | ||
console.log(`AppSignal diagnose`); | ||
@@ -115,3 +121,3 @@ console.log(`=`.repeat(80)); | ||
else if (process.argv.includes("--send-report")) { | ||
this.send_report(data); | ||
this.sendReport(data); | ||
} | ||
@@ -127,3 +133,3 @@ else { | ||
case "y": | ||
self.send_report(data); | ||
self.sendReport(data); | ||
break; | ||
@@ -137,2 +143,7 @@ default: | ||
} | ||
sendReport(data) { | ||
console.log(" Transmitting diagnostics report"); | ||
console.log(""); | ||
tslib_1.__classPrivateFieldGet(this, _diagnose).sendReport(data); | ||
} | ||
printAgentDiagnose(report) { | ||
@@ -239,30 +250,2 @@ if (report["error"]) { | ||
} | ||
send_report(data) { | ||
const json = JSON.stringify(data); | ||
const opts = { | ||
port: 443, | ||
method: "POST", | ||
host: "appsignal.com", | ||
path: "/diag", | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": json.length | ||
}, | ||
cert: fs.readFileSync(path.resolve(__dirname, "../../cert/cacert.pem"), "utf-8") | ||
}; | ||
const req = https.request(opts, (res) => { | ||
res.setEncoding("utf8"); | ||
// print token to the console | ||
res.on("data", (chunk) => { | ||
const { token } = JSON.parse(chunk.toString()); | ||
console.log(` Your support token:`, token); | ||
console.log(` View this report: https://appsignal.com/diagnose/${token}`); | ||
}); | ||
}); | ||
req.on("error", (e) => { | ||
console.error(`Problem with diagnose request: ${e.message}`); | ||
}); | ||
req.write(json); | ||
req.end(); | ||
} | ||
print_newline() { | ||
@@ -283,4 +266,5 @@ console.log(``); | ||
exports.Diagnose = Diagnose; | ||
_diagnose = new WeakMap(); | ||
function format_value(value) { | ||
return util.inspect(value); | ||
} |
@@ -15,3 +15,3 @@ import { Client, Metrics, Plugin, Tracer, AppsignalOptions } from "./interfaces"; | ||
#private; | ||
readonly VERSION = "2.2.2"; | ||
readonly VERSION = "2.2.3"; | ||
config: Configuration; | ||
@@ -18,0 +18,0 @@ extension: Extension; |
@@ -6,29 +6,29 @@ "use strict"; | ||
APPSIGNAL_ACTIVE: "active", | ||
APPSIGNAL_PUSH_API_KEY: "apiKey", | ||
APPSIGNAL_APP_ENV: "environment", | ||
APPSIGNAL_APP_NAME: "name", | ||
APPSIGNAL_APP_ENV: "environment", | ||
APPSIGNAL_CA_FILE_PATH: "caFilePath", | ||
APPSIGNAL_PUSH_API_ENDPOINT: "endpoint", | ||
APPSIGNAL_HOSTNAME: "hostname", | ||
APPSIGNAL_SEND_PARAMS: "sendParams", | ||
APPSIGNAL_DEBUG: "debug", | ||
APPSIGNAL_DNS_SERVERS: "dnsServers", | ||
APPSIGNAL_ENABLE_HOST_METRICS: "enableHostMetrics", | ||
APPSIGNAL_ENABLE_MINUTELY_PROBES: "enableMinutelyProbes", | ||
APPSIGNAL_ENABLE_STATSD: "enableStatsd", | ||
APPSIGNAL_FILES_WORLD_ACCESSIBLE: "filesWorldAccessible", | ||
APPSIGNAL_FILTER_DATA_KEYS: "filterDataKeys", | ||
APPSIGNAL_FILTER_PARAMETERS: "filterParameters", | ||
APPSIGNAL_FILTER_SESSION_DATA: "filterSessionData", | ||
APPSIGNAL_FILTER_DATA_KEYS: "filterDataKeys", | ||
APPSIGNAL_DEBUG: "debug", | ||
APPSIGNAL_DNS_SERVERS: "dnsServers", | ||
APPSIGNAL_LOG: "log", | ||
APPSIGNAL_LOG_PATH: "logPath", | ||
APPSIGNAL_HOSTNAME: "hostname", | ||
APPSIGNAL_HTTP_PROXY: "httpProxy", | ||
APPSIGNAL_IGNORE_ACTIONS: "ignoreActions", | ||
APPSIGNAL_IGNORE_ERRORS: "ignoreErrors", | ||
APPSIGNAL_IGNORE_NAMESPACES: "ignoreNamespaces", | ||
APPSIGNAL_HTTP_PROXY: "httpProxy", | ||
APPSIGNAL_LOG: "log", | ||
APPSIGNAL_LOG_PATH: "logPath", | ||
APPSIGNAL_PUSH_API_ENDPOINT: "endpoint", | ||
APPSIGNAL_PUSH_API_KEY: "apiKey", | ||
APPSIGNAL_REQUEST_HEADERS: "requestHeaders", | ||
APPSIGNAL_RUNNING_IN_CONTAINER: "runningInContainer", | ||
APPSIGNAL_SEND_PARAMS: "sendParams", | ||
APPSIGNAL_SKIP_SESSION_DATA: "skipSessionData", | ||
APPSIGNAL_WORKING_DIRECTORY_PATH: "workingDirectoryPath", | ||
APPSIGNAL_WORKING_DIR_PATH: "workingDirPath", | ||
APPSIGNAL_WORKING_DIRECTORY_PATH: "workingDirectoryPath", | ||
APPSIGNAL_ENABLE_HOST_METRICS: "enableHostMetrics", | ||
APPSIGNAL_ENABLE_MINUTELY_PROBES: "enableMinutelyProbes", | ||
APPSIGNAL_ENABLE_STATSD: "enableStatsd", | ||
APPSIGNAL_SKIP_SESSION_DATA: "skipSessionData", | ||
APPSIGNAL_FILES_WORLD_ACCESSIBLE: "filesWorldAccessible", | ||
APPSIGNAL_REQUEST_HEADERS: "requestHeaders", | ||
APP_REVISION: "revision" | ||
@@ -38,5 +38,16 @@ }; | ||
_APPSIGNAL_ACTIVE: "active", | ||
_APPSIGNAL_APP_NAME: "name", | ||
_APPSIGNAL_CA_FILE_PATH: "caFilePath", | ||
_APPSIGNAL_DEBUG_LOGGING: "debug", | ||
_APPSIGNAL_DNS_SERVERS: "dnsServers", | ||
_APPSIGNAL_ENABLE_HOST_METRICS: "enableHostMetrics", | ||
_APPSIGNAL_ENABLE_STATSD: "enableStatsd", | ||
_APPSIGNAL_ENVIRONMENT: "environment", | ||
_APPSIGNAL_DEBUG_LOGGING: "debug", | ||
_APPSIGNAL_TRANSACTION_DEBUG_MODE: "debug", | ||
_APPSIGNAL_FILES_WORLD_ACCESSIBLE: "filesWorldAccessible", | ||
_APPSIGNAL_FILTER_DATA_KEYS: "filterDataKeys", | ||
_APPSIGNAL_HOSTNAME: "hostname", | ||
_APPSIGNAL_HTTP_PROXY: "httpProxy", | ||
_APPSIGNAL_IGNORE_ACTIONS: "ignoreActions", | ||
_APPSIGNAL_IGNORE_ERRORS: "ignoreErrors", | ||
_APPSIGNAL_IGNORE_NAMESPACES: "ignoreNamespaces", | ||
_APPSIGNAL_LOG: "log", | ||
@@ -46,17 +57,6 @@ _APPSIGNAL_LOG_FILE_PATH: "logFilePath", | ||
_APPSIGNAL_PUSH_API_KEY: "apiKey", | ||
_APPSIGNAL_APP_NAME: "name", | ||
_APPSIGNAL_HTTP_PROXY: "httpProxy", | ||
_APPSIGNAL_IGNORE_ACTIONS: "ignoreActions", | ||
_APPSIGNAL_IGNORE_ERRORS: "ignoreErrors", | ||
_APPSIGNAL_IGNORE_NAMESPACES: "ignoreNamespaces", | ||
_APPSIGNAL_RUNNING_IN_CONTAINER: "runningInContainer", | ||
_APPSIGNAL_TRANSACTION_DEBUG_MODE: "debug", | ||
_APPSIGNAL_WORKING_DIRECTORY_PATH: "workingDirectoryPath", | ||
_APPSIGNAL_WORKING_DIR_PATH: "workingDirPath", | ||
_APPSIGNAL_WORKING_DIRECTORY_PATH: "workingDirectoryPath", | ||
_APPSIGNAL_ENABLE_HOST_METRICS: "enableHostMetrics", | ||
_APPSIGNAL_ENABLE_STATSD: "enableStatsd", | ||
_APPSIGNAL_HOSTNAME: "hostname", | ||
_APPSIGNAL_CA_FILE_PATH: "caFilePath", | ||
_APPSIGNAL_DNS_SERVERS: "dnsServers", | ||
_APPSIGNAL_FILES_WORLD_ACCESSIBLE: "filesWorldAccessible", | ||
_APPSIGNAL_FILTER_DATA_KEYS: "filterDataKeys", | ||
_APP_REVISION: "revision" | ||
@@ -66,23 +66,23 @@ }; | ||
active: "active", | ||
environment: "env", | ||
apiKey: "push_api_key", | ||
caFilePath: "ca_file_path", | ||
debug: "debug", | ||
log: "log", | ||
logPath: "log_path", | ||
dnsServers: "dns_servers", | ||
enableHostMetrics: "enable_host_metrics", | ||
enableStatsd: "enable_statsd", | ||
endpoint: "endpoint", | ||
apiKey: "push_api_key", | ||
name: "name", | ||
environment: "env", | ||
filesWorldAccessible: "files_world_accessible", | ||
filterDataKeys: "filter_data_keys", | ||
hostname: "hostname", | ||
ignoreActions: "ignore_actions", | ||
ignoreErrors: "ignore_errors", | ||
ignoreNamespaces: "ignore_namespaces", | ||
log: "log", | ||
logPath: "log_path", | ||
name: "name", | ||
revision: "revision", | ||
runningInContainer: "running_in_container", | ||
workingDirPath: "working_dir_path", | ||
workingDirectoryPath: "working_directory_path", | ||
enableHostMetrics: "enable_host_metrics", | ||
enableStatsd: "enable_statsd", | ||
hostname: "hostname", | ||
caFilePath: "ca_file_path", | ||
dnsServers: "dns_servers", | ||
filesWorldAccessible: "files_world_accessible", | ||
revision: "revision", | ||
filterDataKeys: "filter_data_keys" | ||
workingDirectoryPath: "working_directory_path" | ||
}; |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
exists: boolean; | ||
mode?: number; | ||
mode?: string; | ||
ownership?: { | ||
@@ -40,3 +40,2 @@ gid: number; | ||
}; | ||
app: {}; | ||
agent: object; | ||
@@ -69,3 +68,4 @@ config: { | ||
private getConfigData; | ||
sendReport(data: object): void; | ||
} | ||
export {}; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const https_1 = tslib_1.__importDefault(require("https")); | ||
const http_1 = tslib_1.__importDefault(require("http")); | ||
const url_1 = require("url"); | ||
@@ -36,3 +37,2 @@ const crypto_1 = require("crypto"); | ||
host: this.getHostData(), | ||
app: {}, | ||
agent: tslib_1.__classPrivateFieldGet(this, _extension).diagnose(), | ||
@@ -139,3 +139,3 @@ config: { | ||
exists: true, | ||
mode, | ||
mode: mode.toString(8), | ||
ownership: { | ||
@@ -170,2 +170,40 @@ gid, | ||
} | ||
sendReport(data) { | ||
const json = JSON.stringify({ diagnose: data }); | ||
const config = tslib_1.__classPrivateFieldGet(this, _config).data; | ||
const params = new url_1.URLSearchParams({ api_key: config["apiKey"] || "" }); | ||
const diagnoseEndpoint = process.env.APPSIGNAL_DIAGNOSE_ENDPOINT || "https://appsignal.com/diag"; | ||
const url = new url_1.URL(diagnoseEndpoint); | ||
const opts = { | ||
method: "POST", | ||
protocol: url.protocol, | ||
host: url.hostname, | ||
port: url.port, | ||
path: `${url.pathname}?${params.toString()}`, | ||
headers: { | ||
"Content-Type": "application/json", | ||
"Content-Length": json.length | ||
}, | ||
cert: fs_1.default.readFileSync(path_1.default.resolve(__dirname, "../cert/cacert.pem"), "utf-8") | ||
}; | ||
const requestModule = url.protocol == "http:" ? http_1.default : https_1.default; | ||
const request = requestModule.request(opts, (response) => { | ||
const responseStatus = response.statusCode; | ||
response.setEncoding("utf8"); | ||
response.on("data", (responseData) => { | ||
if (responseStatus === 200) { | ||
const { token } = JSON.parse(responseData.toString()); | ||
console.log(` Your support token:`, token); | ||
console.log(` View this report: https://appsignal.com/diagnose/${token}`); | ||
} | ||
else { | ||
console.error(" Error: Something went wrong while submitting the report to AppSignal."); | ||
console.error(` Response code: ${responseStatus}`); | ||
console.error(` Response body:\n${responseData}`); | ||
} | ||
}); | ||
}); | ||
request.write(json); | ||
request.end(); | ||
} | ||
} | ||
@@ -172,0 +210,0 @@ exports.DiagnoseTool = DiagnoseTool; |
export interface AppsignalOptions { | ||
name: string; | ||
active: boolean; | ||
apiKey: string; | ||
active: boolean; | ||
caFilePath: string; | ||
debug: boolean; | ||
logPath: string; | ||
log: string; | ||
dnsServers: string[]; | ||
enableHostMetrics: boolean; | ||
enableMinutelyProbes: boolean; | ||
enableStatsd: boolean; | ||
endpoint: string; | ||
caFilePath: string; | ||
hostname: string; | ||
sendParams: string[]; | ||
environment: string; | ||
filesWorldAccessible: boolean; | ||
filterParameters: string[]; | ||
filterSessionData: string[]; | ||
dnsServers: string[]; | ||
hostname: string; | ||
httpProxy: string; | ||
ignoreActions: string[]; | ||
ignoreErrors: string[]; | ||
ignoreInstrumentation: string[]; | ||
ignoreNamespaces: string[]; | ||
ignoreInstrumentation: string[]; | ||
httpProxy: string; | ||
log: string; | ||
logPath: string; | ||
name: string; | ||
requestHeaders: string[]; | ||
revision: string; | ||
runningInContainer: boolean; | ||
sendParams: string[]; | ||
skipSessionData: boolean; | ||
workingDirPath: string; | ||
workingDirectoryPath: string; | ||
enableHostMetrics: boolean; | ||
enableMinutelyProbes: boolean; | ||
enableStatsd: boolean; | ||
skipSessionData: boolean; | ||
filesWorldAccessible: boolean; | ||
requestHeaders: string[]; | ||
revision: string; | ||
environment: string; | ||
[key: string]: string | string[] | boolean; | ||
} |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "2.2.2"; | ||
export declare const AGENT_VERSION = "7376537"; | ||
export declare const VERSION = "2.2.3"; | ||
export declare const AGENT_VERSION = "09308fb"; |
@@ -5,3 +5,3 @@ "use strict"; | ||
// Do not touch this file, auto-generated by scripts/create-versionfile | ||
exports.VERSION = "2.2.2"; | ||
exports.AGENT_VERSION = "7376537"; | ||
exports.VERSION = "2.2.3"; | ||
exports.AGENT_VERSION = "09308fb"; |
{ | ||
"name": "@appsignal/nodejs", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"main": "dist/index", | ||
@@ -19,3 +19,3 @@ "types": "dist/index", | ||
"optionalDependencies": { | ||
"@appsignal/nodejs-ext": "=2.0.2" | ||
"@appsignal/nodejs-ext": "=2.0.3" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance 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
361831
0.89%94
2.17%3743
2.69%16
6.67%4
33.33%