UNPKG

2.28 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 }
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16var ts = require("typescript");
17var Lint = require("tslint");
18var tsutils = require("tsutils");
19var AstUtils_1 = require("./utils/AstUtils");
20var Rule = (function (_super) {
21 __extends(Rule, _super);
22 function Rule() {
23 return _super !== null && _super.apply(this, arguments) || this;
24 }
25 Rule.prototype.apply = function (sourceFile) {
26 return this.applyWithFunction(sourceFile, walk);
27 };
28 Rule.metadata = {
29 ruleName: 'no-exec-script',
30 type: 'maintainability',
31 description: 'Do not use the execScript functions',
32 options: null,
33 optionsDescription: '',
34 typescriptOnly: true,
35 issueClass: 'SDL',
36 issueType: 'Error',
37 severity: 'Critical',
38 level: 'Mandatory',
39 group: 'Security',
40 commonWeaknessEnumeration: '95, 676'
41 };
42 Rule.FAILURE_STRING = 'forbidden execScript: ';
43 return Rule;
44}(Lint.Rules.AbstractRule));
45exports.Rule = Rule;
46function walk(ctx) {
47 function cb(node) {
48 if (tsutils.isCallExpression(node)) {
49 var expression = node.expression;
50 var functionName = AstUtils_1.AstUtils.getFunctionName(node);
51 if (functionName === 'execScript') {
52 var msg = Rule.FAILURE_STRING + expression.getFullText().trim();
53 ctx.addFailureAt(expression.getStart(), expression.getWidth(), msg);
54 }
55 }
56 return ts.forEachChild(node, cb);
57 }
58 return ts.forEachChild(ctx.sourceFile, cb);
59}
60//# sourceMappingURL=noExecScriptRule.js.map
\No newline at end of file