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