UNPKG

@abaplint/core

Version:
62 lines 2.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CallTransactionAuthorityCheck = exports.CallTransactionAuthorityCheckConf = void 0; const _basic_rule_config_1 = require("./_basic_rule_config"); const _abap_rule_1 = require("./_abap_rule"); const _irule_1 = require("./_irule"); const Statements = require("../abap/2_statements/statements"); const issue_1 = require("../issue"); const version_1 = require("../version"); class CallTransactionAuthorityCheckConf extends _basic_rule_config_1.BasicRuleConfig { } exports.CallTransactionAuthorityCheckConf = CallTransactionAuthorityCheckConf; class CallTransactionAuthorityCheck extends _abap_rule_1.ABAPRule { constructor() { super(...arguments); this.conf = new CallTransactionAuthorityCheckConf(); this.MINIMUM_VERSION = version_1.Version.v740sp02; } getMetadata() { return { key: "call_transaction_authority_check", title: "Call Transaction Authority-Check", shortDescription: `Checks that usages of CALL TRANSACTION contain an authority-check.`, extendedInformation: `https://docs.abapopenchecks.org/checks/54/`, tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Security], badExample: `CALL TRANSACTION 'FOO'.`, goodExample: `TRY. CALL TRANSACTION 'FOO' WITH AUTHORITY-CHECK. CATCH cx_sy_authorization_error. ENDTRY.`, }; } getMessage() { return "Add an authority check to CALL TRANSACTION"; } getConfig() { return this.conf; } setConfig(conf) { this.conf = conf; } runParsed(file, obj) { const currentVersion = this.reg.getConfig().getVersion(); // Cloud version does not support CALL TRANSACTION if (currentVersion < this.MINIMUM_VERSION || currentVersion === version_1.Version.Cloud) { return []; } const issues = []; if (obj.getType() === "INTF") { return []; } for (const statNode of file.getStatements()) { const statement = statNode.get(); if (statement instanceof Statements.CallTransaction && !statNode.concatTokensWithoutStringsAndComments().toUpperCase().includes("WITH AUTHORITY-CHECK")) { issues.push(issue_1.Issue.atStatement(file, statNode, this.getMessage(), this.getMetadata().key)); } } return issues; } } exports.CallTransactionAuthorityCheck = CallTransactionAuthorityCheck; //# sourceMappingURL=call_transaction_authority_check.js.map