@appland/scanner 1.71.0 → 1.71.2

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/README.md CHANGED
@@ -66,7 +66,7 @@ documentation for each rule to see it's pattern filters and other configurable p
66
66
  To enable de-duplication of findings, a hash is calculated for each finding. The hash is the
67
67
  `sha256` digest of a canonical content string for the finding. The canonical content string combines
68
68
  stable data from the finding, such as the rule id, normalized event, etc. See
69
- [appmap-js/packages/models/src/event/hash.js](https://github.com/applandinc/appmap-js/blob/959a8c93c9be37d40a8f4a0e7d44ee211730641e/packages/models/src/event/hash.js)
69
+ [appmap-js/packages/models/src/event/hash.js](https://github.com/getappmap/appmap-js/blob/959a8c93c9be37d40a8f4a0e7d44ee211730641e/packages/models/src/event/hash.js)
70
70
  for details.
71
71
 
72
72
  ## Findings output file
@@ -102,7 +102,7 @@ _Example_
102
102
  "clients": [
103
103
  {
104
104
  "name": "appmap",
105
- "url": "https://github.com/applandinc/appmap-ruby",
105
+ "url": "https://github.com/getappmap/appmap-ruby",
106
106
  "version": "0.70.2"
107
107
  }
108
108
  ],
@@ -118,12 +118,12 @@ _Example_
118
118
  ],
119
119
  "git": [
120
120
  {
121
- "repository": "git@github.com:applandinc/appmap-server.git",
121
+ "repository": "git@github.com:getappmap/appmap-server.git",
122
122
  "branch": "master",
123
123
  "commit": "3b028018ec1f84e2c351d01d1dac45aeeae887b6"
124
124
  },
125
125
  {
126
- "repository": "git@github.com:applandinc/appmap-server.git",
126
+ "repository": "git@github.com:getappmap/appmap-server.git",
127
127
  "branch": "master",
128
128
  "commit": "3b028018ec1f84e2c351d01d1dac45aeeae887b6",
129
129
  "status": [
@@ -200,11 +200,11 @@ _Example_
200
200
  "tmp/appmap/rspec/API_APIKeysController_create_a_new_api_key.appmap.json": {
201
201
  "client": {
202
202
  "name": "appmap",
203
- "url": "https://github.com/applandinc/appmap-ruby",
203
+ "url": "https://github.com/getappmap/appmap-ruby",
204
204
  "version": "0.70.1"
205
205
  },
206
206
  "git": {
207
- "repository": "git@github.com:applandinc/appmap-server.git",
207
+ "repository": "git@github.com:getappmap/appmap-server.git",
208
208
  "branch": "master",
209
209
  "commit": "3b028018ec1f84e2c351d01d1dac45aeeae887b6"
210
210
  },
@@ -40,14 +40,14 @@ const promises_1 = require("fs/promises");
40
40
  const chokidar = __importStar(require("chokidar"));
41
41
  const formatReport_1 = require("./formatReport");
42
42
  const scanner_1 = __importDefault(require("./scanner"));
43
- const fs_1 = require("fs");
44
- const util_1 = require("util");
45
43
  const configurationProvider_1 = require("../../configuration/configurationProvider");
46
44
  const assert_1 = __importDefault(require("assert"));
47
45
  const path_1 = __importDefault(require("path"));
46
+ const async_1 = require("async");
48
47
  class Watcher {
49
48
  constructor(options) {
50
49
  this.options = options;
50
+ this.queue = (0, async_1.queue)(this.scan.bind(this), 2);
51
51
  }
52
52
  watch() {
53
53
  return __awaiter(this, void 0, void 0, function* () {
@@ -71,10 +71,9 @@ class Watcher {
71
71
  interval: 1000,
72
72
  persistent: false,
73
73
  });
74
- for (const ch of [this.appmapWatcher, this.appmapPoller]) {
75
- ch.on('add', (filePath) => this.scan(filePath));
76
- ch.on('change', (filePath) => this.scan(filePath));
77
- }
74
+ const enqueue = this.enqueue.bind(this);
75
+ for (const ch of [this.appmapWatcher, this.appmapPoller])
76
+ ch.on('add', enqueue).on('change', enqueue);
78
77
  });
79
78
  }
80
79
  close() {
@@ -87,15 +86,23 @@ class Watcher {
87
86
  }));
88
87
  });
89
88
  }
90
- scan(fileName) {
89
+ enqueue(mtimePath) {
90
+ if ([...this.queue].includes(mtimePath))
91
+ return;
92
+ this.queue.push(mtimePath);
93
+ }
94
+ scan(mtimePath) {
91
95
  return __awaiter(this, void 0, void 0, function* () {
92
96
  (0, assert_1.default)(this.config, `config should always be loaded before appmapWatcher triggers a scan`);
93
- const pathTokens = fileName.split('/');
94
- const appmapDir = pathTokens.slice(0, pathTokens.length - 1).join('/');
95
- const appmapFile = [appmapDir, 'appmap.json'].join('.');
96
- const reportFile = [appmapDir, 'appmap-findings.json'].join('/');
97
- if (!(yield (0, util_1.promisify)(fs_1.exists)(appmapFile)))
97
+ const appmapFile = mtimePath.replace(/\/mtime$/, '.appmap.json');
98
+ const reportFile = mtimePath.replace(/mtime$/, 'appmap-findings.json');
99
+ const [appmapStats, reportStats] = yield Promise.all([appmapFile, reportFile].map((f) => (0, promises_1.stat)(f).catch(() => null)));
100
+ if (!appmapStats)
98
101
  return;
102
+ if (reportStats &&
103
+ reportStats.mtimeMs > appmapStats.mtimeMs &&
104
+ reportStats.mtimeMs > this.config.timestampMs)
105
+ return; // report is up to date
99
106
  const scanner = yield (0, scanner_1.default)(true, this.config, [appmapFile]);
100
107
  const rawScanResults = yield scanner.scan();
101
108
  // Always report the raw data
@@ -211,10 +211,12 @@ function parseConfigFile(configPath) {
211
211
  configPath = (0, path_1.join)(__dirname, '../sampleConfig/default.yml');
212
212
  }
213
213
  console.log(`Using scanner configuration file ${configPath}`);
214
+ const timestampMs = (yield fs_1.promises.stat(configPath)).mtimeMs;
214
215
  const yamlConfig = yield fs_1.promises.readFile(configPath, 'utf-8');
215
- return js_yaml_1.default.load(yamlConfig, {
216
+ const config = js_yaml_1.default.load(yamlConfig, {
216
217
  filename: configPath,
217
218
  });
219
+ return Object.assign(Object.assign({}, config), { timestampMs });
218
220
  });
219
221
  }
220
222
  exports.parseConfigFile = parseConfigFile;
@@ -13,7 +13,7 @@ function rule(options) {
13
13
  (0, assert_1.default)(table.variant === 'table');
14
14
  return !excludeTables.find((filter) => filter(table.name));
15
15
  }
16
- // TODO: clean up (https://github.com/applandinc/scanner/issues/43)
16
+ // TODO: clean up (https://github.com/getappmap/scanner/issues/43)
17
17
  function matcher(command, appMapIndex, eventFilter) {
18
18
  const joinCount = {};
19
19
  for (const sqlEvent of (0, database_1.sqlStrings)(command, appMapIndex, eventFilter)) {
@@ -1,6 +1,6 @@
1
1
  ## Scanner architecture
2
2
 
3
- See [@appland/models source code](https://github.com/applandinc/appmap-js/tree/main/packages/models)
3
+ See [@appland/models source code](https://github.com/getappmap/appmap-js/tree/main/packages/models)
4
4
  for the JS API to AppMap data.
5
5
 
6
6
  ## Assertions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appland/scanner",
3
- "version": "1.71.0",
3
+ "version": "1.71.2",
4
4
  "description": "",
5
5
  "bin": "built/cli.js",
6
6
  "files": [