@abaplint/cli 2.120.31 → 2.120.33

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