@appland/scanner 1.81.1 → 1.82.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # [@appland/scanner-v1.82.1](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.82.0...@appland/scanner-v1.82.1) (2023-08-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Ensure that AppMaps are un-marked as being scanned ([e051d8d](https://github.com/getappmap/appmap-js/commit/e051d8db4e7d7b6b8ad8420573f0f02939d9e3bc))
7
+
8
+ # [@appland/scanner-v1.82.0](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.81.1...@appland/scanner-v1.82.0) (2023-08-11)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Fix caching of unparseable SQL ([e81db08](https://github.com/getappmap/appmap-js/commit/e81db08d6f6a7b661f77aa3aead5e800e15a7358))
14
+
15
+
16
+ ### Features
17
+
18
+ * Analyze in worker threads ([612da06](https://github.com/getappmap/appmap-js/commit/612da06532e765469094aaeaaf614a52e75e46d2))
19
+
1
20
  # [@appland/scanner-v1.81.1](https://github.com/getappmap/appmap-js/compare/@appland/scanner-v1.81.0...@appland/scanner-v1.81.1) (2023-08-11)
2
21
 
3
22
 
@@ -15,12 +15,19 @@ class AppMapIndex {
15
15
  if (!event.sql)
16
16
  throw new Error(`${event.fqid} is not a SQL query`);
17
17
  const sql = this.sqlNormalized(event);
18
- let ast = ASTBySQLString.get(sql);
19
- if (!ast) {
20
- ast = (0, models_1.parseSQL)(sql);
21
- ast ? ASTBySQLString.set(sql, ast) : ASTBySQLString.set(sql, null);
18
+ let result;
19
+ const cachedAST = ASTBySQLString.get(sql);
20
+ if (cachedAST === 'parse-error') {
21
+ result = undefined;
22
22
  }
23
- return ast;
23
+ else if (cachedAST) {
24
+ result = cachedAST;
25
+ }
26
+ else {
27
+ result = (0, models_1.parseSQL)(sql);
28
+ ASTBySQLString.set(sql, result ? result : 'parse-error');
29
+ }
30
+ return result;
24
31
  }
25
32
  sqlNormalized(event) {
26
33
  if (!event.sql)
@@ -50,6 +50,7 @@ const events_1 = __importDefault(require("events"));
50
50
  const watchScanTelemetry_1 = require("./watchScanTelemetry");
51
51
  const isAncestorPath_1 = __importDefault(require("../../util/isAncestorPath"));
52
52
  const util_1 = require("util");
53
+ const console_1 = require("console");
53
54
  const debug = (0, util_1.debuglog)('scanner:watch');
54
55
  function isDir(targetPath) {
55
56
  return __awaiter(this, void 0, void 0, function* () {
@@ -176,25 +177,37 @@ class Watcher {
176
177
  scan(mtimePath) {
177
178
  return __awaiter(this, void 0, void 0, function* () {
178
179
  (0, assert_1.default)(this.config, `config should always be loaded before appmapWatcher triggers a scan`);
179
- const appmapFile = [path_1.default.dirname(mtimePath), 'appmap.json'].join('.');
180
- const reportFile = mtimePath.replace(/mtime$/, 'appmap-findings.json');
181
- const [appmapStats, reportStats] = yield Promise.all([appmapFile, reportFile].map((f) => (0, promises_1.stat)(f).catch(() => null)));
182
- if (!appmapStats)
183
- return;
184
- const cut = (str) => str.substring(str.length - 8);
185
- debug('%s: %s, findings: %s, config: %s', appmapFile, cut(appmapStats.mtimeMs.toFixed(3)), reportStats && cut(reportStats.mtimeMs.toFixed(3)), cut(this.config.timestampMs.toFixed(3)));
186
- if (reportStats &&
187
- reportStats.mtimeMs > appmapStats.mtimeMs - 1000 &&
188
- reportStats.mtimeMs > this.config.timestampMs - 1000)
189
- return; // report is up to date
190
- const startTime = Date.now();
191
- const scanner = yield (0, scanner_1.default)(true, this.config, [appmapFile]);
192
- const rawScanResults = yield scanner.scan();
193
- const elapsed = Date.now() - startTime;
194
- this.scanEventEmitter.emit('scan', { scanResults: rawScanResults, elapsed });
195
- // Always report the raw data
196
- yield (0, promises_1.writeFile)(reportFile, (0, formatReport_1.formatReport)(rawScanResults));
197
- this.processing.delete(mtimePath);
180
+ const perform = () => __awaiter(this, void 0, void 0, function* () {
181
+ const appmapFile = [path_1.default.dirname(mtimePath), 'appmap.json'].join('.');
182
+ const reportFile = mtimePath.replace(/mtime$/, 'appmap-findings.json');
183
+ const [appmapStats, reportStats] = yield Promise.all([appmapFile, reportFile].map((f) => (0, promises_1.stat)(f).catch(() => null)));
184
+ if (!appmapStats) {
185
+ (0, console_1.warn)(`[scan] AppMap file ${appmapFile} does not exist`);
186
+ return;
187
+ }
188
+ const cut = (str) => str.substring(str.length - 8);
189
+ (0, assert_1.default)(this.config);
190
+ debug('%s: %s, findings: %s, config: %s', appmapFile, cut(appmapStats.mtimeMs.toFixed(3)), reportStats && cut(reportStats.mtimeMs.toFixed(3)), cut(this.config.timestampMs.toFixed(3)));
191
+ if (reportStats &&
192
+ reportStats.mtimeMs > appmapStats.mtimeMs - 1000 &&
193
+ reportStats.mtimeMs > this.config.timestampMs - 1000) {
194
+ (0, console_1.warn)(`[scan] Report file ${reportFile} is already up to date`);
195
+ return;
196
+ }
197
+ const startTime = Date.now();
198
+ const scanner = yield (0, scanner_1.default)(true, this.config, [appmapFile]);
199
+ const rawScanResults = yield scanner.scan();
200
+ const elapsed = Date.now() - startTime;
201
+ this.scanEventEmitter.emit('scan', { scanResults: rawScanResults, elapsed });
202
+ // Always report the raw data
203
+ yield (0, promises_1.writeFile)(reportFile, (0, formatReport_1.formatReport)(rawScanResults));
204
+ });
205
+ try {
206
+ yield perform();
207
+ }
208
+ finally {
209
+ this.processing.delete(mtimePath);
210
+ }
198
211
  });
199
212
  }
200
213
  reloadConfig() {
@@ -271,7 +271,7 @@ class GitProperties {
271
271
  return __awaiter(this, void 0, void 0, function* () {
272
272
  return new Promise((resolve) => {
273
273
  try {
274
- const commandProcess = (0, child_process_1.spawn)('git', ['status'], {
274
+ const commandProcess = (0, child_process_1.spawn)('git', ['status', '--porcelain'], {
275
275
  shell: true,
276
276
  cwd: cwd === null || cwd === void 0 ? void 0 : cwd.toString(),
277
277
  stdio: 'ignore',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appland/scanner",
3
- "version": "1.81.1",
3
+ "version": "1.82.1",
4
4
  "description": "Analyze AppMaps for code flaws",
5
5
  "bin": "built/cli.js",
6
6
  "main": "built/index.js",