New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@appsignal/nodejs

Package Overview
Dependencies
Maintainers
6
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appsignal/nodejs - npm Package Compare versions

Comparing version

to
1.3.0

dist/cli/diagnose.d.ts

2

dist/agent.js

@@ -26,3 +26,3 @@ "use strict";

if (e.message === "Extension module not loaded") {
console.warn("AppSignal extension not loaded. This could mean that your current environment isn't supported, or that another error has occured.");
console.warn("AppSignal extension not loaded. This could mean that your current environment isn't supported, or that another error has occurred.");
}

@@ -29,0 +29,0 @@ else {

import { Metrics } from "@appsignal/types";
import { Instrumentation } from "./instrument";
/**
* Initialises all the avaiable core instrumentation.
* Initialises all the available core instrumentation.
*

@@ -14,3 +14,3 @@ * "Core instrumentation" is things that we can hook into automatically

/**
* Initialises all the avaiable probes to attach automatically at runtime.
* Initialises all the available probes to attach automatically at runtime.
*/

@@ -17,0 +17,0 @@ export declare function initCoreProbes(meter: Metrics, { enableMinutelyProbes }: {

@@ -10,3 +10,3 @@ "use strict";

/**
* Initialises all the avaiable core instrumentation.
* Initialises all the available core instrumentation.
*

@@ -35,3 +35,3 @@ * "Core instrumentation" is things that we can hook into automatically

/**
* Initialises all the avaiable probes to attach automatically at runtime.
* Initialises all the available probes to attach automatically at runtime.
*/

@@ -38,0 +38,0 @@ function initCoreProbes(meter, { enableMinutelyProbes }) {

@@ -16,3 +16,3 @@ import { NodeClient, Metrics, Plugin, Tracer } from "@appsignal/types";

#private;
readonly VERSION = "1.2.6";
readonly VERSION = "1.3.0";
config: Configuration;

@@ -19,0 +19,0 @@ agent: Agent;

@@ -23,3 +23,3 @@ /// <reference types="node" />

*/
generate(): {
generate(): Promise<{
library: {

@@ -49,3 +49,3 @@ language: string;

validation: {
push_api_key: string;
push_api_key: undefined;
};

@@ -58,6 +58,7 @@ process: {

};
};
}>;
private getLibraryData;
private getHostData;
private getInstallationReport;
private validatePushApiKey;
private getPathsData;

@@ -64,0 +65,0 @@ /**

@@ -7,2 +7,6 @@ "use strict";

const fs_1 = tslib_1.__importDefault(require("fs"));
const path_1 = tslib_1.__importDefault(require("path"));
const https_1 = tslib_1.__importDefault(require("https"));
const url_1 = require("url");
const crypto_1 = require("crypto");
const agent_1 = require("./agent");

@@ -23,3 +27,7 @@ const config_1 = require("./config");

*/
generate() {
async generate() {
let pushApiKeyValidation;
await this.validatePushApiKey()
.then(result => (pushApiKeyValidation = result))
.catch(result => (pushApiKeyValidation = result));
return {

@@ -35,3 +43,3 @@ library: this.getLibraryData(),

},
validation: { push_api_key: "valid" },
validation: { push_api_key: pushApiKeyValidation },
process: {

@@ -67,4 +75,4 @@ uid: process.getuid()

try {
const report = fs_1.default.readFileSync("/tmp/appsignal-install-report.json", "utf8");
return report ? JSON.parse(report) : {};
const rawReport = fs_1.default.readFileSync(reportPath(), "utf8");
return rawReport ? JSON.parse(rawReport) : {};
}

@@ -75,2 +83,24 @@ catch (e) {

}
async validatePushApiKey() {
return new Promise((resolve, reject) => {
const config = tslib_1.__classPrivateFieldGet(this, _config).data;
const params = new url_1.URLSearchParams({ api_key: config["apiKey"] });
const url = new url_1.URL(`/1/auth?${params.toString()}`, config["endpoint"]);
const options = { method: "POST" };
const request = https_1.default.request(url, options, function (response) {
const status = response.statusCode;
if (status === 200) {
resolve("valid");
}
else if (status === 401) {
reject("invalid");
}
else {
reject(`Failed with status ${status}`);
}
});
request.write("{}"); // Send empty JSON body
request.end();
});
}
getPathsData() {

@@ -80,3 +110,3 @@ const paths = {};

// (it should be)
const logPath = tslib_1.__classPrivateFieldGet(this, _config).data.logPath;
const logFilePath = tslib_1.__classPrivateFieldGet(this, _config).data.logFilePath;
// add any paths we want to check to this object!

@@ -88,7 +118,7 @@ const files = {

log_dir_path: {
path: logPath.replace("/appsignal.log", "")
path: tslib_1.__classPrivateFieldGet(this, _config).data.logPath.replace("/appsignal.log", "")
},
"appsignal.log": {
path: logPath,
content: safeReadFromPath(logPath).split("\n")
path: logFilePath,
content: safeReadFromPath(logFilePath).trimEnd().split("\n")
}

@@ -137,2 +167,13 @@ };

_config = new WeakMap(), _agent = new WeakMap();
// This implementation should match the `packages/nodejs-ext/scripts/report.js`
// implementation to generate the same path.
function reportPath() {
// Navigate up to the app dir. Move up the src dir, package dir, @appsignal
// dir and node_modules dir.
const appPath = path_1.default.join(__dirname, "../../../../");
const hash = crypto_1.createHash("sha256");
hash.update(appPath);
const reportPathDigest = hash.digest("hex");
return path_1.default.join(`/tmp/appsignal-${reportPathDigest}-install.report`);
}
function isWriteableFile(path) {

@@ -158,2 +199,3 @@ try {

}
const BYTES_TO_READ_FOR_FILES = 2 * 1024 * 1024; // 2 Mebibytes
/**

@@ -165,3 +207,3 @@ * Attempts to read a UTF-8 from `path`, and either returns the result

try {
return fs_1.default.readFileSync(path, "utf8");
return readBytesFromPath(path, BYTES_TO_READ_FOR_FILES);
}

@@ -172,2 +214,34 @@ catch (_) {

}
function readBytesFromPath(path, bytesToRead) {
let fd;
try {
const { readLength, startPosition } = readFileOptions(path, bytesToRead);
fd = fs_1.default.openSync(path, "r");
const buffer = Buffer.alloc(readLength);
fs_1.default.readSync(fd, buffer, 0, readLength, startPosition);
return buffer.toString("utf8");
}
finally {
if (fd) {
fs_1.default.closeSync(fd);
}
}
}
function readFileOptions(path, bytesToRead) {
const stats = fs_1.default.statSync(path);
const fileSize = stats.size;
if (fileSize < bytesToRead) {
return {
readLength: fileSize,
startPosition: 0
};
}
else {
const startPosition = fileSize - bytesToRead;
return {
readLength: bytesToRead,
startPosition
};
}
}
/**

@@ -174,0 +248,0 @@ * the following lines are borrowed from https://github.com/sindresorhus/is-docker/

@@ -1,2 +0,2 @@

export declare const VERSION = "1.2.6";
export declare const AGENT_VERSION = "9f282f3";
export declare const VERSION = "1.3.0";
export declare const AGENT_VERSION = "271250f";

@@ -5,3 +5,3 @@ "use strict";

// Do not touch this file, auto-generated by scripts/create-versionfile
exports.VERSION = "1.2.6";
exports.AGENT_VERSION = "9f282f3";
exports.VERSION = "1.3.0";
exports.AGENT_VERSION = "271250f";
{
"name": "@appsignal/nodejs",
"version": "1.2.6",
"version": "1.3.0",
"main": "dist/index",

@@ -19,3 +19,3 @@ "types": "dist/index",

"optionalDependencies": {
"@appsignal/nodejs-ext": "=1.2.6"
"@appsignal/nodejs-ext": "=1.2.7"
},

@@ -22,0 +22,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet