@abaplint/cli 2.120.31 → 2.120.32

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.
Files changed (2) hide show
  1. package/build/cli.js +314 -2
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -27700,7 +27700,10 @@ class TypeUtils {
27700
27700
  || source instanceof basic_1.DataType
27701
27701
  || source instanceof basic_1.UnknownType;
27702
27702
  }
27703
- if (source instanceof basic_1.CharacterType) {
27703
+ if (source instanceof cgeneric_type_1.CGenericType && target instanceof basic_1.StringType) {
27704
+ return false;
27705
+ }
27706
+ else if (source instanceof basic_1.CharacterType) {
27704
27707
  if (target instanceof basic_1.CharacterType) {
27705
27708
  if (((_b = source.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true) {
27706
27709
  return source.getLength() <= target.getLength();
@@ -70050,7 +70053,7 @@ class Registry {
70050
70053
  }
70051
70054
  static abaplintVersion() {
70052
70055
  // magic, see build script "version.js"
70053
- return "2.120.31";
70056
+ return "2.120.32";
70054
70057
  }
70055
70058
  getDDICReferences() {
70056
70059
  return this.ddicReferences;
@@ -84278,6 +84281,7 @@ __exportStar(__webpack_require__(/*! ./newline_between_methods */ "../core/build
84278
84281
  __exportStar(__webpack_require__(/*! ./no_aliases */ "../core/build/src/rules/no_aliases.js"), exports);
84279
84282
  __exportStar(__webpack_require__(/*! ./no_chained_assignment */ "../core/build/src/rules/no_chained_assignment.js"), exports);
84280
84283
  __exportStar(__webpack_require__(/*! ./no_comments_between_methods */ "../core/build/src/rules/no_comments_between_methods.js"), exports);
84284
+ __exportStar(__webpack_require__(/*! ./no_dynamic_stuff */ "../core/build/src/rules/no_dynamic_stuff.js"), exports);
84281
84285
  __exportStar(__webpack_require__(/*! ./no_external_form_calls */ "../core/build/src/rules/no_external_form_calls.js"), exports);
84282
84286
  __exportStar(__webpack_require__(/*! ./no_inline_in_optional_branches */ "../core/build/src/rules/no_inline_in_optional_branches.js"), exports);
84283
84287
  __exportStar(__webpack_require__(/*! ./no_macros */ "../core/build/src/rules/no_macros.js"), exports);
@@ -84357,6 +84361,7 @@ __exportStar(__webpack_require__(/*! ./when_others_last */ "../core/build/src/ru
84357
84361
  __exportStar(__webpack_require__(/*! ./whitespace_end */ "../core/build/src/rules/whitespace_end.js"), exports);
84358
84362
  __exportStar(__webpack_require__(/*! ./xml_consistency */ "../core/build/src/rules/xml_consistency.js"), exports);
84359
84363
  __exportStar(__webpack_require__(/*! ./no_exclamation_escape */ "../core/build/src/rules/no_exclamation_escape.js"), exports);
84364
+ __exportStar(__webpack_require__(/*! ./xml_bom */ "../core/build/src/rules/xml_bom.js"), exports);
84360
84365
  __exportStar(__webpack_require__(/*! ./no_exclamation_escape */ "../core/build/src/rules/no_exclamation_escape.js"), exports);
84361
84366
  //# sourceMappingURL=index.js.map
84362
84367
 
@@ -88390,6 +88395,255 @@ exports.NoCommentsBetweenMethods = NoCommentsBetweenMethods;
88390
88395
 
88391
88396
  /***/ },
88392
88397
 
88398
+ /***/ "../core/build/src/rules/no_dynamic_stuff.js"
88399
+ /*!***************************************************!*\
88400
+ !*** ../core/build/src/rules/no_dynamic_stuff.js ***!
88401
+ \***************************************************/
88402
+ (__unused_webpack_module, exports, __webpack_require__) {
88403
+
88404
+ "use strict";
88405
+
88406
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
88407
+ if (k2 === undefined) k2 = k;
88408
+ var desc = Object.getOwnPropertyDescriptor(m, k);
88409
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
88410
+ desc = { enumerable: true, get: function() { return m[k]; } };
88411
+ }
88412
+ Object.defineProperty(o, k2, desc);
88413
+ }) : (function(o, m, k, k2) {
88414
+ if (k2 === undefined) k2 = k;
88415
+ o[k2] = m[k];
88416
+ }));
88417
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
88418
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
88419
+ }) : function(o, v) {
88420
+ o["default"] = v;
88421
+ });
88422
+ var __importStar = (this && this.__importStar) || (function () {
88423
+ var ownKeys = function(o) {
88424
+ ownKeys = Object.getOwnPropertyNames || function (o) {
88425
+ var ar = [];
88426
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
88427
+ return ar;
88428
+ };
88429
+ return ownKeys(o);
88430
+ };
88431
+ return function (mod) {
88432
+ if (mod && mod.__esModule) return mod;
88433
+ var result = {};
88434
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
88435
+ __setModuleDefault(result, mod);
88436
+ return result;
88437
+ };
88438
+ })();
88439
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
88440
+ exports.NoDynamicStuff = exports.NoDynamicStuffConf = void 0;
88441
+ const Statements = __importStar(__webpack_require__(/*! ../abap/2_statements/statements */ "../core/build/src/abap/2_statements/statements/index.js"));
88442
+ const Expressions = __importStar(__webpack_require__(/*! ../abap/2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
88443
+ const _abap_rule_1 = __webpack_require__(/*! ./_abap_rule */ "../core/build/src/rules/_abap_rule.js");
88444
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
88445
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
88446
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
88447
+ class NoDynamicStuffConf extends _basic_rule_config_1.BasicRuleConfig {
88448
+ constructor() {
88449
+ super(...arguments);
88450
+ /** Detects dynamic method calls, ie. CALL METHOD (name), SET HANDLER and CALL BADI */
88451
+ this.callMethod = true;
88452
+ /** Detects dynamic CALL FUNCTION, ie. the function module name is not a literal */
88453
+ this.callFunction = true;
88454
+ /** Detects CALL DATABASE PROCEDURE, the procedure name is always dynamic */
88455
+ this.callDatabaseProcedure = true;
88456
+ /** Detects dynamic CALL TRANSFORMATION */
88457
+ this.callTransformation = true;
88458
+ /** Detects dynamic CALL TRANSACTION, ie. the transaction code is not a literal */
88459
+ this.callTransaction = true;
88460
+ /** Detects dynamic PERFORM */
88461
+ this.perform = true;
88462
+ /** Detects dynamic SUBMIT */
88463
+ this.submit = true;
88464
+ /** Detects dynamic CREATE OBJECT */
88465
+ this.createObject = true;
88466
+ /** Detects dynamic CREATE DATA */
88467
+ this.createData = true;
88468
+ /** Detects dynamic GET BADI */
88469
+ this.getBadi = true;
88470
+ /** Detects dynamic ASSIGN, including ASSIGN COMPONENT */
88471
+ this.assign = true;
88472
+ /** Detects dynamic internal table access, ie. dynamic WHERE, keys, SORT BY and TRANSPORTING */
88473
+ this.internalTable = true;
88474
+ /** Detects dynamic EXPORT and IMPORT */
88475
+ this.exportImport = true;
88476
+ }
88477
+ }
88478
+ exports.NoDynamicStuffConf = NoDynamicStuffConf;
88479
+ class NoDynamicStuff extends _abap_rule_1.ABAPRule {
88480
+ constructor() {
88481
+ super(...arguments);
88482
+ this.conf = new NoDynamicStuffConf();
88483
+ }
88484
+ getMetadata() {
88485
+ return {
88486
+ key: "no_dynamic_stuff",
88487
+ title: "No dynamic stuff",
88488
+ shortDescription: `Detects dynamic calls and other dynamic language constructs`,
88489
+ extendedInformation: `Dynamic constructs cannot be checked statically, they are not found by
88490
+ where-used lists and refactorings, and they can introduce injection vulnerabilities.
88491
+
88492
+ Dynamic tokens containing a literal, eg. CALL METHOD ('CL_FOO')=>('BAR'), are not reported,
88493
+ as these are equivalent to the static variant.
88494
+
88495
+ Dynamic SQL is reported by rule dangerous_statement.`,
88496
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Security],
88497
+ badExample: `CALL METHOD (lv_class)=>(lv_method).
88498
+ CALL FUNCTION lv_function_module.
88499
+ CREATE OBJECT ref TYPE (lv_class).
88500
+ ASSIGN (lv_name) TO <fs>.
88501
+ SORT tab BY (lv_field).`,
88502
+ goodExample: `cl_class=>method( ).
88503
+ CALL FUNCTION 'ZFOO'.
88504
+ CREATE OBJECT ref TYPE cl_class.
88505
+ ASSIGN foo TO <fs>.
88506
+ SORT tab BY field.`,
88507
+ };
88508
+ }
88509
+ getConfig() {
88510
+ return this.conf;
88511
+ }
88512
+ setConfig(conf) {
88513
+ this.conf = conf;
88514
+ }
88515
+ runParsed(file) {
88516
+ const issues = [];
88517
+ for (const statementNode of file.getStatements()) {
88518
+ const found = this.check(statementNode);
88519
+ if (found !== undefined) {
88520
+ issues.push(issue_1.Issue.atStatement(file, statementNode, "Dynamic " + found, this.getMetadata().key, this.conf.severity));
88521
+ }
88522
+ }
88523
+ return issues;
88524
+ }
88525
+ check(node) {
88526
+ const statement = node.get();
88527
+ // note that MethodSource is also used by SET HANDLER and CALL BADI
88528
+ if (this.conf.callMethod === true && this.dynamicMethodSource(node) === true) {
88529
+ return "method call";
88530
+ }
88531
+ if (statement instanceof Statements.CallFunction) {
88532
+ if (this.conf.callFunction === true
88533
+ && this.notLiteral(node.findDirectExpression(Expressions.FunctionName))) {
88534
+ return "CALL FUNCTION";
88535
+ }
88536
+ }
88537
+ else if (statement instanceof Statements.CallDatabase) {
88538
+ if (this.conf.callDatabaseProcedure === true) {
88539
+ return "CALL DATABASE PROCEDURE";
88540
+ }
88541
+ }
88542
+ else if (statement instanceof Statements.CallTransformation) {
88543
+ if (this.conf.callTransformation === true && this.hasDynamic(node)) {
88544
+ return "CALL TRANSFORMATION";
88545
+ }
88546
+ }
88547
+ else if (statement instanceof Statements.CallTransaction) {
88548
+ // the transaction code is a Source, ie. there is no parenthesized dynamic variant
88549
+ if (this.conf.callTransaction === true
88550
+ && this.notLiteral(node.findDirectExpression(Expressions.Source))) {
88551
+ return "CALL TRANSACTION";
88552
+ }
88553
+ }
88554
+ else if (statement instanceof Statements.Perform) {
88555
+ if (this.conf.perform === true && this.hasDynamic(node)) {
88556
+ return "PERFORM";
88557
+ }
88558
+ }
88559
+ else if (statement instanceof Statements.Submit) {
88560
+ if (this.conf.submit === true && this.hasDynamic(node)) {
88561
+ return "SUBMIT";
88562
+ }
88563
+ }
88564
+ else if (statement instanceof Statements.CreateObject) {
88565
+ if (this.conf.createObject === true && this.hasDynamic(node)) {
88566
+ return "CREATE OBJECT";
88567
+ }
88568
+ }
88569
+ else if (statement instanceof Statements.CreateData) {
88570
+ if (this.conf.createData === true && this.hasDynamic(node)) {
88571
+ return "CREATE DATA";
88572
+ }
88573
+ }
88574
+ else if (statement instanceof Statements.GetBadi) {
88575
+ if (this.conf.getBadi === true && this.hasDynamic(node)) {
88576
+ return "GET BADI";
88577
+ }
88578
+ }
88579
+ else if (statement instanceof Statements.Assign
88580
+ || statement instanceof Statements.AssignLocalCopy) {
88581
+ if (this.conf.assign === true
88582
+ && (this.hasDynamic(node) || this.dynamicAssignComponent(node))) {
88583
+ return "ASSIGN";
88584
+ }
88585
+ }
88586
+ else if (statement instanceof Statements.Export) {
88587
+ if (this.conf.exportImport === true && this.hasDynamic(node)) {
88588
+ return "EXPORT";
88589
+ }
88590
+ }
88591
+ else if (statement instanceof Statements.Import) {
88592
+ if (this.conf.exportImport === true && this.hasDynamic(node)) {
88593
+ return "IMPORT";
88594
+ }
88595
+ }
88596
+ else if (statement instanceof Statements.At
88597
+ || statement instanceof Statements.DeleteInternal
88598
+ || statement instanceof Statements.InsertInternal
88599
+ || statement instanceof Statements.Loop
88600
+ || statement instanceof Statements.ModifyInternal
88601
+ || statement instanceof Statements.ReadTable
88602
+ || statement instanceof Statements.Sort
88603
+ || statement instanceof Statements.SortDataset) {
88604
+ if (this.conf.internalTable === true && this.hasDynamic(node)) {
88605
+ return "internal table access";
88606
+ }
88607
+ }
88608
+ return undefined;
88609
+ }
88610
+ dynamicMethodSource(node) {
88611
+ for (const source of node.findAllExpressions(Expressions.MethodSource)) {
88612
+ // Dynamic is always a direct child of MethodSource, dynamics further down
88613
+ // are parameters of the method call and not part of the method name
88614
+ for (const dynamic of source.findDirectExpressions(Expressions.Dynamic)) {
88615
+ if (this.isLiteral(dynamic) === false) {
88616
+ return true;
88617
+ }
88618
+ }
88619
+ }
88620
+ return false;
88621
+ }
88622
+ dynamicAssignComponent(node) {
88623
+ var _a;
88624
+ const component = (_a = node.findDirectExpression(Expressions.AssignSource)) === null || _a === void 0 ? void 0 : _a.findExpressionAfterToken("COMPONENT");
88625
+ return component !== undefined && this.isLiteral(component) === false;
88626
+ }
88627
+ hasDynamic(node) {
88628
+ for (const dynamic of node.findAllExpressions(Expressions.Dynamic)) {
88629
+ if (this.isLiteral(dynamic) === false) {
88630
+ return true;
88631
+ }
88632
+ }
88633
+ return false;
88634
+ }
88635
+ notLiteral(node) {
88636
+ return node !== undefined && this.isLiteral(node) === false;
88637
+ }
88638
+ isLiteral(node) {
88639
+ return node.findDirectExpression(Expressions.Constant) !== undefined;
88640
+ }
88641
+ }
88642
+ exports.NoDynamicStuff = NoDynamicStuff;
88643
+ //# sourceMappingURL=no_dynamic_stuff.js.map
88644
+
88645
+ /***/ },
88646
+
88393
88647
  /***/ "../core/build/src/rules/no_exclamation_escape.js"
88394
88648
  /*!********************************************************!*\
88395
88649
  !*** ../core/build/src/rules/no_exclamation_escape.js ***!
@@ -99583,6 +99837,64 @@ exports.WhitespaceEnd = WhitespaceEnd;
99583
99837
 
99584
99838
  /***/ },
99585
99839
 
99840
+ /***/ "../core/build/src/rules/xml_bom.js"
99841
+ /*!******************************************!*\
99842
+ !*** ../core/build/src/rules/xml_bom.js ***!
99843
+ \******************************************/
99844
+ (__unused_webpack_module, exports, __webpack_require__) {
99845
+
99846
+ "use strict";
99847
+
99848
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
99849
+ exports.XMLBOM = exports.XMLBOMConf = void 0;
99850
+ const edit_helper_1 = __webpack_require__(/*! ../edit_helper */ "../core/build/src/edit_helper.js");
99851
+ const issue_1 = __webpack_require__(/*! ../issue */ "../core/build/src/issue.js");
99852
+ const position_1 = __webpack_require__(/*! ../position */ "../core/build/src/position.js");
99853
+ const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "../core/build/src/rules/_basic_rule_config.js");
99854
+ const _irule_1 = __webpack_require__(/*! ./_irule */ "../core/build/src/rules/_irule.js");
99855
+ class XMLBOMConf extends _basic_rule_config_1.BasicRuleConfig {
99856
+ }
99857
+ exports.XMLBOMConf = XMLBOMConf;
99858
+ class XMLBOM {
99859
+ constructor() {
99860
+ this.conf = new XMLBOMConf();
99861
+ }
99862
+ getMetadata() {
99863
+ return {
99864
+ key: "xml_bom",
99865
+ title: "XML UTF-8 byte order mark",
99866
+ shortDescription: "Checks that XML files start with a UTF-8 byte order mark",
99867
+ extendedInformation: "Checks that each XML file has a UTF-8 byte order mark (BOM) at its beginning.",
99868
+ tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.Quickfix],
99869
+ };
99870
+ }
99871
+ getConfig() {
99872
+ return this.conf;
99873
+ }
99874
+ setConfig(conf) {
99875
+ this.conf = conf;
99876
+ }
99877
+ initialize(_reg) {
99878
+ return this;
99879
+ }
99880
+ run(obj) {
99881
+ const file = obj.getXMLFile();
99882
+ if (file === undefined || file.getRaw().startsWith("\uFEFF")) {
99883
+ return [];
99884
+ }
99885
+ return [this.createIssue(file)];
99886
+ }
99887
+ createIssue(file) {
99888
+ const start = new position_1.Position(1, 1);
99889
+ const fix = edit_helper_1.EditHelper.insertAt(file, start, "\uFEFF");
99890
+ return issue_1.Issue.atRange(file, start, start, "XML file must start with a UTF-8 byte order mark", this.getMetadata().key, this.conf.severity, fix);
99891
+ }
99892
+ }
99893
+ exports.XMLBOM = XMLBOM;
99894
+ //# sourceMappingURL=xml_bom.js.map
99895
+
99896
+ /***/ },
99897
+
99586
99898
  /***/ "../core/build/src/rules/xml_consistency.js"
99587
99899
  /*!**************************************************!*\
99588
99900
  !*** ../core/build/src/rules/xml_consistency.js ***!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.31",
3
+ "version": "2.120.32",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.31",
42
+ "@abaplint/core": "^2.120.32",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",