@appland/scanner 1.82.1 → 1.83.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 +14 -0
- package/built/algorithms/dataStructures/graph/Graph.d.ts +29 -0
- package/built/algorithms/dataStructures/graph/GraphEdge.d.ts +10 -0
- package/built/algorithms/dataStructures/graph/GraphVertex.d.ts +21 -0
- package/built/algorithms/dataStructures/linked-list/LinkedList.d.ts +16 -0
- package/built/algorithms/dataStructures/linked-list/LinkedListNode.d.ts +6 -0
- package/built/algorithms/graph/depth-first-search/index.d.ts +8 -0
- package/built/algorithms/graph/detect-cycle/index.d.ts +8 -0
- package/built/algorithms/hash/hashV1.d.ts +6 -0
- package/built/algorithms/hash/hashV2.d.ts +53 -0
- package/built/algorithms/utils/Comparator.d.ts +11 -0
- package/built/analyzer/recordSecrets.d.ts +6 -0
- package/built/analyzer/secretsRegexes.d.ts +5 -0
- package/built/appMapIndex.d.ts +8 -0
- package/built/check.d.ts +18 -0
- package/built/checkInstance.d.ts +16 -0
- package/built/cli/appmapDirFromConfig.d.ts +1 -0
- package/built/cli/ci/command.d.ts +8 -0
- package/built/cli/ci/options.d.ts +10 -0
- package/built/cli/codeVersionArgs.d.ts +2 -0
- package/built/cli/exitCode.d.ts +6 -0
- package/built/cli/fail.d.ts +1 -0
- package/built/cli/handleWorkingDirectory.d.ts +1 -0
- package/built/cli/merge/command.d.ts +8 -0
- package/built/cli/merge/options.d.ts +7 -0
- package/built/cli/reportUploadURL.d.ts +3 -0
- package/built/cli/resolveAppId.d.ts +1 -0
- package/built/cli/scan/breakpoint.d.ts +41 -0
- package/built/cli/scan/command.d.ts +8 -0
- package/built/cli/scan/formatReport.d.ts +2 -0
- package/built/cli/scan/interactiveScan.d.ts +8 -0
- package/built/cli/scan/options.d.ts +8 -0
- package/built/cli/scan/scanner.d.ts +9 -0
- package/built/cli/scan/singleScan.d.ts +12 -0
- package/built/cli/scan/singleScan.js +0 -15
- package/built/cli/scan/ui/interactiveProgess.d.ts +42 -0
- package/built/cli/scan/ui/scanContext.d.ts +17 -0
- package/built/cli/scan/ui/state/addBreakpoint.d.ts +3 -0
- package/built/cli/scan/ui/state/eval.d.ts +3 -0
- package/built/cli/scan/ui/state/hint.d.ts +3 -0
- package/built/cli/scan/ui/state/hitBreakpoint.d.ts +3 -0
- package/built/cli/scan/ui/state/initial.d.ts +3 -0
- package/built/cli/scan/ui/state/scan.d.ts +3 -0
- package/built/cli/scan/ui/state.d.ts +2 -0
- package/built/cli/scan/ui/userInteraction.d.ts +18 -0
- package/built/cli/scan/watchScan.d.ts +33 -0
- package/built/cli/scan/watchScan.js +0 -5
- package/built/cli/scan.d.ts +9 -0
- package/built/cli/scanArgs.d.ts +2 -0
- package/built/cli/scanOptions.d.ts +9 -0
- package/built/cli/updateCommitStatus.d.ts +1 -0
- package/built/cli/upload/command.d.ts +8 -0
- package/built/cli/upload/options.d.ts +11 -0
- package/built/cli/upload/pruneAppMap.d.ts +4 -0
- package/built/cli/upload.d.ts +5 -0
- package/built/cli/validateFile.d.ts +1 -0
- package/built/cli.d.ts +2 -0
- package/built/configuration/configurationProvider.d.ts +9 -0
- package/built/configuration/types/checkConfig.d.ts +18 -0
- package/built/configuration/types/configuration.d.ts +7 -0
- package/built/configuration/types/matchEventConfig.d.ts +7 -0
- package/built/configuration/types/matchPatternConfig.d.ts +6 -0
- package/built/database/index.d.ts +17 -0
- package/built/database/visit.d.ts +6 -0
- package/built/errors.d.ts +4 -0
- package/built/eventUtil.d.ts +3 -0
- package/built/findings.d.ts +3 -0
- package/built/index.d.ts +75 -0
- package/built/integration/appland/location.d.ts +5 -0
- package/built/integration/appland/retry.d.ts +5 -0
- package/built/integration/appland/retryOptions.d.ts +4 -0
- package/built/integration/appland/scannerJob/create.d.ts +11 -0
- package/built/integration/appland/scannerJob/merge.d.ts +5 -0
- package/built/integration/appland/scannerJob.d.ts +11 -0
- package/built/integration/github/commitStatus.d.ts +3 -0
- package/built/integration/vars.d.ts +12 -0
- package/built/lastGitOrFSModifiedDate.d.ts +6 -0
- package/built/openapi/index.d.ts +4 -0
- package/built/progressReporter.d.ts +16 -0
- package/built/report/appMapMetadata.d.ts +0 -0
- package/built/report/findingSummary.d.ts +11 -0
- package/built/report/findingsReport.d.ts +3 -0
- package/built/report/scanResults.d.ts +19 -0
- package/built/report/scanResults.js +1 -55
- package/built/report/scanSummary.d.ts +20 -0
- package/built/report/summaryReport.d.ts +2 -0
- package/built/ruleChecker.d.ts +13 -0
- package/built/ruleInstance.d.ts +6 -0
- package/built/rules/authzBeforeAuthn.d.ts +3 -0
- package/built/rules/circularDependency.d.ts +3 -0
- package/built/rules/deprecated-crypto-algorithm/metadata.d.ts +4 -0
- package/built/rules/deprecated-crypto-algorithm/rule.d.ts +3 -0
- package/built/rules/deserializationOfUntrustedData.d.ts +3 -0
- package/built/rules/execOfUntrustedCommand.d.ts +3 -0
- package/built/rules/http-500/metadata.d.ts +3 -0
- package/built/rules/http-500/rule.d.ts +2 -0
- package/built/rules/illegalPackageDependency.d.ts +3 -0
- package/built/rules/incompatibleHttpClientRequest.d.ts +3 -0
- package/built/rules/insecureCompare.d.ts +3 -0
- package/built/rules/jobNotCancelled.d.ts +3 -0
- package/built/rules/jwtAlgorithmNone.d.ts +24 -0
- package/built/rules/jwtUnverifiedSignature.d.ts +23 -0
- package/built/rules/lib/analyzeDataFlow.d.ts +23 -0
- package/built/rules/lib/hasParameterOrReceiver.d.ts +3 -0
- package/built/rules/lib/isCommand.d.ts +2 -0
- package/built/rules/lib/matchEvent.d.ts +4 -0
- package/built/rules/lib/matchPattern.d.ts +4 -0
- package/built/rules/lib/metadata.d.ts +9 -0
- package/built/rules/lib/openapiProvider.d.ts +3 -0
- package/built/rules/lib/parseRuleDescription.d.ts +1 -0
- package/built/rules/lib/precedingEvents.d.ts +2 -0
- package/built/rules/lib/rpcWithoutProtection.d.ts +6 -0
- package/built/rules/lib/sanitizesData.d.ts +2 -0
- package/built/rules/lib/util.d.ts +20 -0
- package/built/rules/logoutWithoutSessionReset.d.ts +3 -0
- package/built/rules/missingAuthentication.d.ts +3 -0
- package/built/rules/missingContentType.d.ts +3 -0
- package/built/rules/nPlusOneQuery.d.ts +3 -0
- package/built/rules/queryFromInvalidPackage.d.ts +3 -0
- package/built/rules/queryFromView.d.ts +3 -0
- package/built/rules/rpcWithoutCircuitBreaker.d.ts +3 -0
- package/built/rules/saveWithoutValidation.d.ts +3 -0
- package/built/rules/secretInLog.d.ts +3 -0
- package/built/rules/slowFunctionCall.d.ts +3 -0
- package/built/rules/slowHttpServerRequest.d.ts +3 -0
- package/built/rules/slowQuery.d.ts +3 -0
- package/built/rules/too-many-joins/metadata.d.ts +3 -0
- package/built/rules/too-many-joins/options.d.ts +6 -0
- package/built/rules/too-many-joins/rule.d.ts +7 -0
- package/built/rules/tooManyUpdates.d.ts +3 -0
- package/built/rules/unauthenticated-encryption/metadata.d.ts +3 -0
- package/built/rules/unauthenticated-encryption/rule.d.ts +2 -0
- package/built/rules/unbatchedMaterializedQuery.d.ts +3 -0
- package/built/rules/updateInGetRequest.d.ts +3 -0
- package/built/scan.d.ts +5 -0
- package/built/scope/commandScope.d.ts +6 -0
- package/built/scope/httpClientRequestScope.d.ts +6 -0
- package/built/scope/httpServerRequestScope.d.ts +6 -0
- package/built/scope/rootScope.d.ts +6 -0
- package/built/scope/scopeImpl.d.ts +8 -0
- package/built/scope/scopeIterator.d.ts +6 -0
- package/built/scope/sqlTransactionScope.d.ts +13 -0
- package/built/sqlWarning.d.ts +2 -0
- package/built/telemetry.d.ts +50 -0
- package/built/telemetry.js +72 -1
- package/built/util/eventAggregator.d.ts +20 -0
- package/built/util/isAncestorPath.d.ts +1 -0
- package/built/wellKnownLabels.d.ts +5 -0
- package/package.json +7 -8
- package/built/cli/scan/watchScanTelemetry.js +0 -44
- package/src/types.d.ts +0 -72
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Event, ValueBase } from '@appland/models';
|
|
2
|
+
/**
|
|
3
|
+
* Value tracked with data flow analysis, along with the information about
|
|
4
|
+
* its originating event and a list of any other such values that might have
|
|
5
|
+
* been used in its generation.
|
|
6
|
+
*/
|
|
7
|
+
export declare type TrackedValue = {
|
|
8
|
+
value: ValueBase;
|
|
9
|
+
origin: Event;
|
|
10
|
+
parents: ReadonlyArray<TrackedValue>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Tracks flow of data across the execution trace, identifying all function
|
|
14
|
+
* calls which have a tracked object as its receiver or one of the parameters.
|
|
15
|
+
* Any value such a function returns will also then become tracked.
|
|
16
|
+
* The origin chain of all values is recorded, so full provenience up to
|
|
17
|
+
* the starting set can be reconstructed.
|
|
18
|
+
* @param trackedData Initial data to track.
|
|
19
|
+
* @param startEvent The root event of the analysis.
|
|
20
|
+
* @returns Events which have a tracked piece of data as an input, each
|
|
21
|
+
* associated with the list of such inputs.
|
|
22
|
+
*/
|
|
23
|
+
export default function analyzeDataFlow(trackedData: ReadonlyArray<ValueBase>, startEvent: Event): Map<Event, ReadonlyArray<TrackedValue>>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import MatchEventConfig from '../../configuration/types/matchEventConfig';
|
|
2
|
+
import { EventFilter } from '../../types';
|
|
3
|
+
export declare function buildFilter(pattern: MatchEventConfig): EventFilter;
|
|
4
|
+
export declare function buildFilters(patterns: MatchEventConfig[]): EventFilter[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import MatchPatternConfig from '../../configuration/types/matchPatternConfig';
|
|
2
|
+
import { StringFilter } from '../../types';
|
|
3
|
+
export declare function buildFilter(pattern: MatchPatternConfig): StringFilter;
|
|
4
|
+
export declare function buildFilters(patterns: MatchPatternConfig[]): StringFilter[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function parseRuleDescription(id: string): string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Event, Label } from '@appland/models';
|
|
2
|
+
import { RuleLogic } from '../../types';
|
|
3
|
+
export interface RPCWithoutProtectionOptions {
|
|
4
|
+
get expectedLabel(): Label;
|
|
5
|
+
}
|
|
6
|
+
export declare function rpcWithoutProtection(candidateGenerator: (httpClientRequest: Event) => Generator<Event>, options: RPCWithoutProtectionOptions): RuleLogic;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Event, ReturnValueObject } from '@appland/models';
|
|
2
|
+
export declare function collectAppMapFiles(appmapFile?: string | string[], appmapDir?: string): Promise<string[]>;
|
|
3
|
+
declare function verbose(v?: boolean): boolean;
|
|
4
|
+
declare function capitalize(str: string): string;
|
|
5
|
+
declare function emptyValue(value: string): boolean;
|
|
6
|
+
declare function responseContentType(event: Event): string | undefined;
|
|
7
|
+
declare function appMapDir(appMapFileName: string): string;
|
|
8
|
+
declare function isFalsey(valueObj?: ReturnValueObject): boolean;
|
|
9
|
+
declare function parseValue(valueObj: ReturnValueObject): string[];
|
|
10
|
+
declare const isTruthy: (valueObj?: ReturnValueObject | undefined) => boolean;
|
|
11
|
+
declare function providesAuthentication(event: Event, label: string): boolean;
|
|
12
|
+
declare function ideLink(filePath: string, ide: string, eventId: number): string;
|
|
13
|
+
declare const toRegExp: (value: string | RegExp) => RegExp;
|
|
14
|
+
declare const toRegExpArray: (value: string[] | RegExp[]) => RegExp[];
|
|
15
|
+
declare const isRoot: (event: Event | undefined) => boolean;
|
|
16
|
+
declare function dasherize(str: string): string;
|
|
17
|
+
declare function camelize(text: string): string;
|
|
18
|
+
declare function pluralize(word: string, count: number): string;
|
|
19
|
+
declare function fileExists(file: string): Promise<boolean>;
|
|
20
|
+
export { appMapDir, capitalize, emptyValue, fileExists, isFalsey, isTruthy, ideLink, isRoot, parseValue, camelize, dasherize, pluralize, providesAuthentication, toRegExp, responseContentType, toRegExpArray, verbose, };
|
package/built/scan.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Event } from '@appland/models';
|
|
2
|
+
import { Scope } from '../types';
|
|
3
|
+
export default abstract class ScopeIterator {
|
|
4
|
+
abstract scopes(events: Iterable<Event>): Generator<Scope>;
|
|
5
|
+
protected advanceToReturnEvent(scopeEvent: Event, events: Iterator<Event>): void;
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Event } from '@appland/models';
|
|
2
|
+
import ScopeIterator from './scopeIterator';
|
|
3
|
+
import type { Scope } from '../types';
|
|
4
|
+
export interface TransactionDetails {
|
|
5
|
+
transaction: {
|
|
6
|
+
status: 'commit' | 'rollback';
|
|
7
|
+
events: Event[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare function hasTransactionDetails(event: Event & Partial<TransactionDetails>): event is Event & TransactionDetails;
|
|
11
|
+
export default class SQLTransactionScope extends ScopeIterator {
|
|
12
|
+
scopes(events: IterableIterator<Event>): Generator<Scope, void, void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { TelemetryClient } from 'applicationinsights';
|
|
3
|
+
import { PathLike } from 'fs';
|
|
4
|
+
declare class Session {
|
|
5
|
+
id: string;
|
|
6
|
+
expiration: number;
|
|
7
|
+
constructor();
|
|
8
|
+
static beyondExpiration(expiration: number): boolean;
|
|
9
|
+
static expirationFromNow(): number;
|
|
10
|
+
static newSessionId(): string;
|
|
11
|
+
touch(): void;
|
|
12
|
+
get valid(): boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface TelemetryData {
|
|
15
|
+
name: string;
|
|
16
|
+
properties?: Record<string, string | undefined>;
|
|
17
|
+
metrics?: Record<string, number | undefined>;
|
|
18
|
+
}
|
|
19
|
+
export interface TelemetryOptions {
|
|
20
|
+
includeEnvironment: boolean;
|
|
21
|
+
}
|
|
22
|
+
export default class Telemetry {
|
|
23
|
+
private static _session?;
|
|
24
|
+
private static _client?;
|
|
25
|
+
private static debug;
|
|
26
|
+
static readonly machineId: string;
|
|
27
|
+
static get enabled(): boolean;
|
|
28
|
+
static get session(): Session;
|
|
29
|
+
static get client(): TelemetryClient;
|
|
30
|
+
static sendEvent(data: TelemetryData, options?: TelemetryOptions): void;
|
|
31
|
+
static flush(exitCB: () => unknown): void;
|
|
32
|
+
}
|
|
33
|
+
export declare enum GitState {
|
|
34
|
+
NotInstalled = 0,
|
|
35
|
+
NoRepository = 1,
|
|
36
|
+
Ok = 2
|
|
37
|
+
}
|
|
38
|
+
export declare const GitRepositoryEnvKeys: readonly ["GITHUB_REPOSITORY", "CIRCLE_REPOSITORY_URL", "GIT_URL", "CI_REPOSITORY_URL"];
|
|
39
|
+
export declare const GitBranchEnvKeys: readonly ["GITHUB_REF_NAME", "CIRCLE_BRANCH", "GIT_BRANCH", "TRAVIS_BRANCH", "CI_COMMIT_REF_NAME"];
|
|
40
|
+
export declare const GitCommitEnvKeys: readonly ["GITHUB_SHA", "CIRCLE_SHA1", "GIT_COMMIT", "TRAVIS_COMMIT", "CI_COMMIT_SHA"];
|
|
41
|
+
declare class GitProperties {
|
|
42
|
+
static contributors(sinceDaysAgo: number, cwd?: PathLike): Promise<Array<string>>;
|
|
43
|
+
static repository(cwd?: PathLike): Promise<string | undefined>;
|
|
44
|
+
static branch(cwd?: PathLike): Promise<string | undefined>;
|
|
45
|
+
static commit(cwd?: PathLike): Promise<string | undefined>;
|
|
46
|
+
static state(cwd?: PathLike): Promise<GitState>;
|
|
47
|
+
static clearCache(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare const Git: typeof GitProperties;
|
|
50
|
+
export {};
|
package/built/telemetry.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.Git = exports.GitState = void 0;
|
|
38
|
+
exports.Git = exports.GitCommitEnvKeys = exports.GitBranchEnvKeys = exports.GitRepositoryEnvKeys = exports.GitState = void 0;
|
|
39
39
|
const os_1 = require("os");
|
|
40
40
|
const crypto_1 = require("crypto");
|
|
41
41
|
const os = __importStar(require("os"));
|
|
@@ -238,6 +238,26 @@ var GitState;
|
|
|
238
238
|
GitState[GitState["NoRepository"] = 1] = "NoRepository";
|
|
239
239
|
GitState[GitState["Ok"] = 2] = "Ok";
|
|
240
240
|
})(GitState = exports.GitState || (exports.GitState = {}));
|
|
241
|
+
exports.GitRepositoryEnvKeys = [
|
|
242
|
+
'GITHUB_REPOSITORY',
|
|
243
|
+
'CIRCLE_REPOSITORY_URL',
|
|
244
|
+
'GIT_URL',
|
|
245
|
+
'CI_REPOSITORY_URL', // GitLab
|
|
246
|
+
];
|
|
247
|
+
exports.GitBranchEnvKeys = [
|
|
248
|
+
'GITHUB_REF_NAME',
|
|
249
|
+
'CIRCLE_BRANCH',
|
|
250
|
+
'GIT_BRANCH',
|
|
251
|
+
'TRAVIS_BRANCH',
|
|
252
|
+
'CI_COMMIT_REF_NAME', // GitLab
|
|
253
|
+
];
|
|
254
|
+
exports.GitCommitEnvKeys = [
|
|
255
|
+
'GITHUB_SHA',
|
|
256
|
+
'CIRCLE_SHA1',
|
|
257
|
+
'GIT_COMMIT',
|
|
258
|
+
'TRAVIS_COMMIT',
|
|
259
|
+
'CI_COMMIT_SHA', // GitLab
|
|
260
|
+
];
|
|
241
261
|
class GitProperties {
|
|
242
262
|
static contributors(sinceDaysAgo, cwd) {
|
|
243
263
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -267,6 +287,54 @@ class GitProperties {
|
|
|
267
287
|
}
|
|
268
288
|
});
|
|
269
289
|
}
|
|
290
|
+
// Returns the repository URL, first by checking the environment, then by
|
|
291
|
+
// shelling out to git.
|
|
292
|
+
static repository(cwd) {
|
|
293
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
294
|
+
const envKey = exports.GitRepositoryEnvKeys.find((key) => process.env[key]);
|
|
295
|
+
if (envKey)
|
|
296
|
+
return process.env[envKey];
|
|
297
|
+
try {
|
|
298
|
+
const { stdout } = yield exec(['git', cwd && `-C ${cwd.toString()}`, 'config', '--get', 'remote.origin.url'].join(' '));
|
|
299
|
+
return stdout.trim();
|
|
300
|
+
}
|
|
301
|
+
catch (_a) {
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
// Returns the branch, first by checking the environment, then by
|
|
307
|
+
// shelling out to git.
|
|
308
|
+
static branch(cwd) {
|
|
309
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
310
|
+
const envKey = exports.GitBranchEnvKeys.find((key) => process.env[key]);
|
|
311
|
+
if (envKey)
|
|
312
|
+
return process.env[envKey];
|
|
313
|
+
try {
|
|
314
|
+
const { stdout } = yield exec(['git', cwd && `-C ${cwd.toString()}`, 'rev-parse', '--abbrev-ref', 'HEAD'].join(' '));
|
|
315
|
+
return stdout.trim();
|
|
316
|
+
}
|
|
317
|
+
catch (_a) {
|
|
318
|
+
return undefined;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
// Returns the commit SHA, first by checking the environment, then by
|
|
323
|
+
// shelling out to git.
|
|
324
|
+
static commit(cwd) {
|
|
325
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
326
|
+
const envKey = exports.GitCommitEnvKeys.find((key) => process.env[key]);
|
|
327
|
+
if (envKey)
|
|
328
|
+
return process.env[envKey];
|
|
329
|
+
try {
|
|
330
|
+
const { stdout } = yield exec(['git', cwd && `-C ${cwd.toString()}`, 'rev-parse', 'HEAD'].join(' '));
|
|
331
|
+
return stdout.trim();
|
|
332
|
+
}
|
|
333
|
+
catch (_a) {
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
270
338
|
static state(cwd) {
|
|
271
339
|
return __awaiter(this, void 0, void 0, function* () {
|
|
272
340
|
return new Promise((resolve) => {
|
|
@@ -295,6 +363,9 @@ class GitProperties {
|
|
|
295
363
|
});
|
|
296
364
|
});
|
|
297
365
|
}
|
|
366
|
+
static clearCache() {
|
|
367
|
+
gitCache.clear();
|
|
368
|
+
}
|
|
298
369
|
}
|
|
299
370
|
const gitCache = new Map();
|
|
300
371
|
// GitProperties is available externally as Git.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
export declare type PendingEvent<E> = {
|
|
4
|
+
emitter: EventEmitter;
|
|
5
|
+
event: string;
|
|
6
|
+
arg: E;
|
|
7
|
+
};
|
|
8
|
+
export declare const MaxMSBetween: number;
|
|
9
|
+
export declare type CancelFn = () => void;
|
|
10
|
+
export default class EventAggregator<E> {
|
|
11
|
+
private callback;
|
|
12
|
+
private maxMsBetween;
|
|
13
|
+
private pending;
|
|
14
|
+
private timeout?;
|
|
15
|
+
constructor(callback: (events: PendingEvent<E>[]) => void, maxMsBetween?: number);
|
|
16
|
+
private push;
|
|
17
|
+
private refresh;
|
|
18
|
+
private emitPending;
|
|
19
|
+
attach(emitter: EventEmitter, event: string): CancelFn;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isAncestorPath(ancestor: string, descendant: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appland/scanner",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.83.1",
|
|
4
4
|
"description": "Analyze AppMaps for code flaws",
|
|
5
5
|
"bin": "built/cli.js",
|
|
6
6
|
"main": "built/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"built",
|
|
9
|
-
"doc"
|
|
10
|
-
"src/types.d.ts"
|
|
9
|
+
"doc"
|
|
11
10
|
],
|
|
12
|
-
"types": "
|
|
11
|
+
"types": "built/index.d.ts",
|
|
13
12
|
"scripts": {
|
|
14
13
|
"build": "node bin/preBuild.js && tsc -p tsconfig.build.json && yarn schema && yarn doc",
|
|
15
14
|
"build-native": "yarn build && ./bin/build-native",
|
|
@@ -20,8 +19,8 @@
|
|
|
20
19
|
"doc-up-to-date": "git diff --exit-code doc/",
|
|
21
20
|
"lint": "eslint src --ext .ts",
|
|
22
21
|
"ci": "yarn lint && yarn build && yarn schema-up-to-date && yarn doc-up-to-date && yarn test",
|
|
23
|
-
"test": "jest --filter=./test/testFilter.js",
|
|
24
|
-
"jest": "jest --filter=./test/testFilter.js",
|
|
22
|
+
"test": "jest --filter=./test/testFilter.js --detectOpenHandles",
|
|
23
|
+
"jest": "jest --filter=./test/testFilter.js --detectOpenHandles",
|
|
25
24
|
"semantic-release": "semantic-release",
|
|
26
25
|
"watch": "node bin/preBuild.js && tsc -p tsconfig.build.json --watch"
|
|
27
26
|
},
|
|
@@ -65,7 +64,7 @@
|
|
|
65
64
|
"dependencies": {
|
|
66
65
|
"@appland/client": "^1.5.0",
|
|
67
66
|
"@appland/models": "^2.6.3",
|
|
68
|
-
"@appland/openapi": "1.6.
|
|
67
|
+
"@appland/openapi": "1.6.1",
|
|
69
68
|
"@appland/sql-parser": "^1.5.0",
|
|
70
69
|
"@types/cli-progress": "^3.9.2",
|
|
71
70
|
"ajv": "^8.8.2",
|
|
@@ -83,7 +82,7 @@
|
|
|
83
82
|
"lru-cache": "^6.0.0",
|
|
84
83
|
"minimatch": "^5.1.2",
|
|
85
84
|
"octokit": "^2.0.19",
|
|
86
|
-
"openapi-diff": "^0.23.
|
|
85
|
+
"openapi-diff": "^0.23.6",
|
|
87
86
|
"ora": "~5",
|
|
88
87
|
"pretty-format": "^27.4.6",
|
|
89
88
|
"read-pkg-up": "^7.0.1",
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WatchScanTelemetry = void 0;
|
|
7
|
-
const eventAggregator_1 = __importDefault(require("../../util/eventAggregator"));
|
|
8
|
-
const scanResults_1 = require("../../report/scanResults");
|
|
9
|
-
class WatchScanTelemetry {
|
|
10
|
-
constructor(scanEvents, appmapDir) {
|
|
11
|
-
this.appmapDir = appmapDir;
|
|
12
|
-
this.cancelFn = new eventAggregator_1.default((events) => {
|
|
13
|
-
const scanEvents = events.map((e) => e.arg);
|
|
14
|
-
this.sendTelemetry(scanEvents);
|
|
15
|
-
}).attach(scanEvents, 'scan');
|
|
16
|
-
}
|
|
17
|
-
cancel() {
|
|
18
|
-
if (this.cancelFn)
|
|
19
|
-
this.cancelFn();
|
|
20
|
-
this.cancelFn = undefined;
|
|
21
|
-
}
|
|
22
|
-
static watch(scanEvents, appmapDir) {
|
|
23
|
-
const telemetry = new WatchScanTelemetry(scanEvents, appmapDir);
|
|
24
|
-
return () => telemetry.cancel();
|
|
25
|
-
}
|
|
26
|
-
sendTelemetry(scanEvents) {
|
|
27
|
-
const ruleIds = new Set();
|
|
28
|
-
let elapsed = 0;
|
|
29
|
-
const telemetryScanResults = new scanResults_1.ScanResults();
|
|
30
|
-
for (const scanEvent of scanEvents) {
|
|
31
|
-
telemetryScanResults.aggregate(scanEvent.scanResults);
|
|
32
|
-
elapsed += scanEvent.elapsed;
|
|
33
|
-
}
|
|
34
|
-
telemetryScanResults.summary.rules.forEach((rule) => ruleIds.add(rule));
|
|
35
|
-
(0, scanResults_1.sendScanResultsTelemetry)({
|
|
36
|
-
ruleIds: [...ruleIds],
|
|
37
|
-
numAppMaps: telemetryScanResults.summary.numAppMaps,
|
|
38
|
-
numFindings: telemetryScanResults.summary.numFindings,
|
|
39
|
-
elapsedMs: elapsed,
|
|
40
|
-
appmapDir: this.appmapDir,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.WatchScanTelemetry = WatchScanTelemetry;
|
package/src/types.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { AppMap, Event } from '@appland/models';
|
|
2
|
-
import { SqliteParser } from '@appland/models/types/sqlite-parser';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Scope provides an Event at the root of the scope, and a Generator to iterate over its descendants.
|
|
6
|
-
*/
|
|
7
|
-
interface Scope {
|
|
8
|
-
scope: Event;
|
|
9
|
-
events: () => Generator<Event>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Level indicates the priority of a finding.
|
|
14
|
-
*/
|
|
15
|
-
export type Level = 'warning' | 'error';
|
|
16
|
-
|
|
17
|
-
type StringFilter = (value: string) => boolean;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* EventFilter is used by Rule to select Events that will be analyzed for findings.
|
|
21
|
-
* The event filter is always applied to the Scope.scope event. If enumerateScope is true,
|
|
22
|
-
* the filter is applied to all Scope.events as well.
|
|
23
|
-
*/
|
|
24
|
-
type EventFilter = (e: Event, appMapIndex: AppMapIndex) => boolean;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* MatchResult is created by a rule when it matches an Event.
|
|
28
|
-
*/
|
|
29
|
-
export interface MatchResult {
|
|
30
|
-
level?: Level;
|
|
31
|
-
event: Event;
|
|
32
|
-
message: string;
|
|
33
|
-
participatingEvents?: Record<string, Event>;
|
|
34
|
-
groupMessage?: string;
|
|
35
|
-
occurranceCount?: number;
|
|
36
|
-
relatedEvents?: Event[];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
type MatcherResult =
|
|
40
|
-
| Promise<boolean | string | MatchResult[]>
|
|
41
|
-
| boolean
|
|
42
|
-
| string
|
|
43
|
-
| MatchResult[]
|
|
44
|
-
| undefined;
|
|
45
|
-
|
|
46
|
-
type EventType = 'http_server_request' | 'http_client_request' | 'sql_query' | 'function';
|
|
47
|
-
|
|
48
|
-
export type QueryAST = SqliteParser.ListStatement | null;
|
|
49
|
-
|
|
50
|
-
interface AppMapIndex {
|
|
51
|
-
appMap: AppMap;
|
|
52
|
-
|
|
53
|
-
sqlAST(event: Event): QueryAST | undefined;
|
|
54
|
-
|
|
55
|
-
sqlNormalized(event: Event): string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Matcher function is part of a rule. It's applied to an Event to determine whether there is a finding
|
|
60
|
-
* on this event. If the Matcher returns true, a string, or a MatchResult[], then finding(s) are created.
|
|
61
|
-
*/
|
|
62
|
-
type Matcher = (e: Event, appMapIndex: AppMapIndex, eventFilter: EventFilter) => MatcherResult;
|
|
63
|
-
|
|
64
|
-
export interface RuleLogic {
|
|
65
|
-
// Tests an event in the scope see if it matches the rule conditions.
|
|
66
|
-
matcher: Matcher;
|
|
67
|
-
// When specified by the rule, only events which pass the where filter
|
|
68
|
-
// will be passed to the matcher.
|
|
69
|
-
where?: EventFilter;
|
|
70
|
-
// When specified by the rule, provides a detailed message for a finding on a specific event.
|
|
71
|
-
message?: (scope: Event, event: Event) => string;
|
|
72
|
-
}
|