@appland/scanner 1.63.0 → 1.64.0

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,10 @@
1
+ # [@appland/scanner-v1.64.0](https://github.com/applandinc/appmap-js/compare/@appland/scanner-v1.63.0...@appland/scanner-v1.64.0) (2022-08-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * Command scope falls back on root events ([3823a1f](https://github.com/applandinc/appmap-js/commit/3823a1f686212db49b87f2995baa2103a4e007d1))
7
+
1
8
  # [@appland/scanner-v1.63.0](https://github.com/applandinc/appmap-js/compare/@appland/scanner-v1.62.2...@appland/scanner-v1.63.0) (2022-07-28)
2
9
 
3
10
 
package/built/check.js CHANGED
@@ -9,7 +9,7 @@ class Check {
9
9
  }
10
10
  this.id = rule.id;
11
11
  this.options = options || makeOptions();
12
- this.scope = rule.scope || 'root';
12
+ this.scope = rule.scope || 'command';
13
13
  this.includeScope = [];
14
14
  this.excludeScope = [];
15
15
  this.includeEvent = [];
@@ -35,14 +35,7 @@ class RuleChecker {
35
35
  }
36
36
  check(appMapFile, appMapIndex, check, findings) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- const numScopesChecked = yield this.checkScope(appMapFile, appMapIndex, check, check.scope, findings);
39
- if (numScopesChecked === 0 && check.scope === 'command') {
40
- yield this.checkScope(appMapFile, appMapIndex, check, 'root', findings);
41
- }
42
- });
43
- }
44
- checkScope(appMapFile, appMapIndex, check, scope, findings) {
45
- return __awaiter(this, void 0, void 0, function* () {
38
+ const scope = check.scope;
46
39
  if ((0, util_1.verbose)()) {
47
40
  console.warn(`Checking AppMap ${appMapIndex.appMap.name} with scope ${scope}`);
48
41
  }
@@ -56,9 +49,7 @@ class RuleChecker {
56
49
  yield events[i];
57
50
  }
58
51
  };
59
- let numScopes = 0;
60
52
  for (const scope of scopeIterator.scopes(callEvents())) {
61
- numScopes += 1;
62
53
  if ((0, util_1.verbose)()) {
63
54
  console.warn(`Scope ${scope.scope}`);
64
55
  }
@@ -75,7 +66,6 @@ class RuleChecker {
75
66
  yield this.checkEvent(scope.scope, scope.scope, appMapFile, appMapIndex, checkInstance, findings);
76
67
  }
77
68
  }
78
- return numScopes;
79
69
  });
80
70
  }
81
71
  checkEvent(event, scope, appMapFile, appMapIndex, checkInstance, findings) {
@@ -101,6 +101,7 @@ exports.default = {
101
101
  id: 'secret-in-log',
102
102
  title: 'Secret in log',
103
103
  labels: [Secret, Log],
104
+ scope: 'root',
104
105
  impactDomain: 'Security',
105
106
  enumerateScope: true,
106
107
  references: {
@@ -30,7 +30,6 @@ function build(options) {
30
30
  exports.default = {
31
31
  id: 'slow-function-call',
32
32
  title: 'Slow function call',
33
- scope: 'root',
34
33
  impactDomain: 'Performance',
35
34
  enumerateScope: true,
36
35
  description: (0, parseRuleDescription_1.default)('slowFunctionCall'),
@@ -21,15 +21,28 @@ const Command = 'command.perform';
21
21
  const Job = 'job.perform';
22
22
  class CommandScope extends scopeIterator_1.default {
23
23
  *scopes(events) {
24
+ let found = false;
25
+ const roots = [];
24
26
  for (const event of events) {
27
+ if (event.isCall() && !event.parent) {
28
+ roots.push(event);
29
+ }
25
30
  if (event.isCall() &&
26
31
  (event.codeObject.labels.has(Command) ||
27
32
  event.codeObject.labels.has(Job) ||
28
33
  event.httpServerRequest)) {
34
+ found = true;
29
35
  yield new ScopeImpl(event);
30
36
  this.advanceToReturnEvent(event, events);
31
37
  }
32
38
  }
39
+ // If no true command is found, yield all root events.
40
+ if (!found) {
41
+ for (let index = 0; index < roots.length; index++) {
42
+ const event = roots[index];
43
+ yield new ScopeImpl(event);
44
+ }
45
+ }
33
46
  }
34
47
  }
35
48
  exports.default = CommandScope;
@@ -8,6 +8,7 @@ impactDomain: Security
8
8
  labels:
9
9
  - secret
10
10
  - log
11
+ scope: root
11
12
  ---
12
13
 
13
14
  Identifies when a known or assumed secret is written to a log. Logs are often transported into other
@@ -3,7 +3,6 @@ rule: slow-function-call
3
3
  name: Slow function call
4
4
  title: Slow function call
5
5
  impactDomain: Performance
6
- scope: root
7
6
  ---
8
7
 
9
8
  Ensures that function elapsed time does not exceed a threshold.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appland/scanner",
3
- "version": "1.63.0",
3
+ "version": "1.64.0",
4
4
  "description": "",
5
5
  "bin": "built/cli.js",
6
6
  "files": [
@@ -61,7 +61,6 @@
61
61
  "@appland/sql-parser": "^1.5.0",
62
62
  "@types/cli-progress": "^3.9.2",
63
63
  "ajv": "^8.8.2",
64
- "ansi-escapes": "^5.0.0",
65
64
  "applicationinsights": "^2.1.4",
66
65
  "async": "^3.2.3",
67
66
  "chalk": "^4.1.2",
@@ -86,16 +85,20 @@
86
85
  },
87
86
  "pkg": {
88
87
  "targets": [
89
- "node14-linux-x64",
90
- "node14-win-x64",
91
- "node14-macos-x64"
88
+ "node16-linux-x64",
89
+ "node16-win-x64",
90
+ "node16-macos-x64",
91
+ "node16-macos-arm64"
92
92
  ],
93
93
  "scripts": [
94
- "built/scanner/*.js"
94
+ "built/scanner/*.js",
95
+ "built/rules/**/*.js"
95
96
  ],
96
97
  "assets": [
97
98
  "built/sampleConfig/*.yml",
98
- "built/**/*.json"
99
+ "built/**/*.json",
100
+ "package.json",
101
+ "doc/**/*.md"
99
102
  ],
100
103
  "outputPath": "dist"
101
104
  }