Socket
Socket
Sign inDemoInstall

@appland/scanner

Package Overview
Dependencies
278
Maintainers
4
Versions
119
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.71.2 to 1.71.3

4

built/cli/scan/command.js

@@ -72,7 +72,7 @@ "use strict";

}
if (appmapDir)
yield (0, validateFile_1.default)('directory', appmapDir);
if (!appmapFile && !appmapDir) {
appmapDir = (yield (0, appmapDirFromConfig_1.appmapDirFromConfig)()) || '.';
}
if (appmapDir)
yield (0, validateFile_1.default)('directory', appmapDir);
let appId = appIdArg;

@@ -79,0 +79,0 @@ if (!watch && !reportAllFindings)

@@ -47,2 +47,25 @@ "use strict";

const async_1 = require("async");
function isDir(targetPath) {
return __awaiter(this, void 0, void 0, function* () {
try {
return (yield (0, promises_1.stat)(targetPath)).isDirectory();
}
catch (_a) {
return false;
}
});
}
function existingParent(targetPath) {
return __awaiter(this, void 0, void 0, function* () {
while (targetPath.length > 1) {
if (yield isDir(targetPath))
break;
targetPath = path_1.default.dirname(targetPath);
}
return targetPath;
});
}
function isAncestorPath(ancestor, descendant) {
return !path_1.default.relative(ancestor, descendant).startsWith('..');
}
class Watcher {

@@ -62,11 +85,25 @@ constructor(options) {

.on('change', this.reloadConfig.bind(this));
// Chokidar struggles with relative paths. Make sure the watch pattern is absolute.
const watchPattern = path_1.default.resolve(this.options.appmapDir, '**', 'mtime');
this.appmapWatcher = chokidar.watch(watchPattern, {
const appmapDir = path_1.default.resolve(this.options.appmapDir);
// If the appmap directory is a descendant of cwd, watch cwd (presumably project directory).
// This ensures the watch will survive even if the appmap dir is removed and recreated.
// Otherwise, make sure to use an existing directory. Chokidar struggles with missing directories.
const watchDir = isAncestorPath(process.cwd(), appmapDir)
? process.cwd()
: yield existingParent(appmapDir);
// Custom ignore function needed to cut down the watch tree to just what we need.
const ignored = (targetPath) => {
// Ignore anything that isn't an ancestor or descendant of the appmap dir.
if (!(isAncestorPath(targetPath, appmapDir) || isAncestorPath(appmapDir, targetPath)))
return true;
// Also make sure to not try to recurse down node_modules or .git
const basename = path_1.default.basename(targetPath);
return basename === 'node_modules' || basename === '.git';
};
this.appmapWatcher = chokidar.watch(watchDir, {
ignoreInitial: true,
ignored: ['**/node_modules/**', '**/.git/**'],
ignored,
});
this.appmapPoller = chokidar.watch(watchPattern, {
this.appmapPoller = chokidar.watch(watchDir, {
ignoreInitial: false,
ignored: ['**/node_modules/**', '**/.git/**'],
ignored,
usePolling: true,

@@ -76,3 +113,3 @@ interval: 1000,

});
const enqueue = this.enqueue.bind(this);
const enqueue = (filePath) => path_1.default.basename(filePath) === 'mtime' && this.enqueue(filePath);
for (const ch of [this.appmapWatcher, this.appmapPoller])

@@ -100,3 +137,3 @@ ch.on('add', enqueue).on('change', enqueue);

(0, assert_1.default)(this.config, `config should always be loaded before appmapWatcher triggers a scan`);
const appmapFile = mtimePath.replace(/\/mtime$/, '.appmap.json');
const appmapFile = [path_1.default.dirname(mtimePath), 'appmap.json'].join('.');
const reportFile = mtimePath.replace(/mtime$/, 'appmap-findings.json');

@@ -103,0 +140,0 @@ const [appmapStats, reportStats] = yield Promise.all([appmapFile, reportFile].map((f) => (0, promises_1.stat)(f).catch(() => null)));

@@ -0,1 +1,9 @@

# [@appland/scanner-v1.71.3](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.71.2...@appland/scanner-v1.71.3) (2022-10-11)
### Bug Fixes
* Handle appmap paths in an OS-agnostic manner in scan --watch ([cc473a8](https://github.com/getappmap/appmap-js/commit/cc473a89c60130b4b518a56b7e50f8617d88dd59))
* scan --watch works even if the appmap dir doesn't initially exist ([938bb76](https://github.com/getappmap/appmap-js/commit/938bb76d8fd827874731f4cd3258c4b9e0988a35))
# [@appland/scanner-v1.71.2](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.71.1...@appland/scanner-v1.71.2) (2022-10-04)

@@ -2,0 +10,0 @@

{
"name": "@appland/scanner",
"version": "1.71.2",
"version": "1.71.3",
"description": "",

@@ -5,0 +5,0 @@ "bin": "built/cli.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc