@abaplint/core 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.
@@ -377,7 +377,10 @@ class TypeUtils {
377
377
  || source instanceof basic_1.DataType
378
378
  || source instanceof basic_1.UnknownType;
379
379
  }
380
- if (source instanceof basic_1.CharacterType) {
380
+ if (source instanceof cgeneric_type_1.CGenericType && target instanceof basic_1.StringType) {
381
+ return false;
382
+ }
383
+ else if (source instanceof basic_1.CharacterType) {
381
384
  if (target instanceof basic_1.CharacterType) {
382
385
  if (((_b = source.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true) {
383
386
  return source.getLength() <= target.getLength();
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.31";
78
+ return "2.120.32";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -124,6 +124,7 @@ __exportStar(require("./newline_between_methods"), exports);
124
124
  __exportStar(require("./no_aliases"), exports);
125
125
  __exportStar(require("./no_chained_assignment"), exports);
126
126
  __exportStar(require("./no_comments_between_methods"), exports);
127
+ __exportStar(require("./no_dynamic_stuff"), exports);
127
128
  __exportStar(require("./no_external_form_calls"), exports);
128
129
  __exportStar(require("./no_inline_in_optional_branches"), exports);
129
130
  __exportStar(require("./no_macros"), exports);
@@ -203,5 +204,6 @@ __exportStar(require("./when_others_last"), exports);
203
204
  __exportStar(require("./whitespace_end"), exports);
204
205
  __exportStar(require("./xml_consistency"), exports);
205
206
  __exportStar(require("./no_exclamation_escape"), exports);
207
+ __exportStar(require("./xml_bom"), exports);
206
208
  __exportStar(require("./no_exclamation_escape"), exports);
207
209
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.NoDynamicStuff = exports.NoDynamicStuffConf = void 0;
37
+ const Statements = __importStar(require("../abap/2_statements/statements"));
38
+ const Expressions = __importStar(require("../abap/2_statements/expressions"));
39
+ const _abap_rule_1 = require("./_abap_rule");
40
+ const _basic_rule_config_1 = require("./_basic_rule_config");
41
+ const issue_1 = require("../issue");
42
+ const _irule_1 = require("./_irule");
43
+ class NoDynamicStuffConf extends _basic_rule_config_1.BasicRuleConfig {
44
+ constructor() {
45
+ super(...arguments);
46
+ /** Detects dynamic method calls, ie. CALL METHOD (name), SET HANDLER and CALL BADI */
47
+ this.callMethod = true;
48
+ /** Detects dynamic CALL FUNCTION, ie. the function module name is not a literal */
49
+ this.callFunction = true;
50
+ /** Detects CALL DATABASE PROCEDURE, the procedure name is always dynamic */
51
+ this.callDatabaseProcedure = true;
52
+ /** Detects dynamic CALL TRANSFORMATION */
53
+ this.callTransformation = true;
54
+ /** Detects dynamic CALL TRANSACTION, ie. the transaction code is not a literal */
55
+ this.callTransaction = true;
56
+ /** Detects dynamic PERFORM */
57
+ this.perform = true;
58
+ /** Detects dynamic SUBMIT */
59
+ this.submit = true;
60
+ /** Detects dynamic CREATE OBJECT */
61
+ this.createObject = true;
62
+ /** Detects dynamic CREATE DATA */
63
+ this.createData = true;
64
+ /** Detects dynamic GET BADI */
65
+ this.getBadi = true;
66
+ /** Detects dynamic ASSIGN, including ASSIGN COMPONENT */
67
+ this.assign = true;
68
+ /** Detects dynamic internal table access, ie. dynamic WHERE, keys, SORT BY and TRANSPORTING */
69
+ this.internalTable = true;
70
+ /** Detects dynamic EXPORT and IMPORT */
71
+ this.exportImport = true;
72
+ }
73
+ }
74
+ exports.NoDynamicStuffConf = NoDynamicStuffConf;
75
+ class NoDynamicStuff extends _abap_rule_1.ABAPRule {
76
+ constructor() {
77
+ super(...arguments);
78
+ this.conf = new NoDynamicStuffConf();
79
+ }
80
+ getMetadata() {
81
+ return {
82
+ key: "no_dynamic_stuff",
83
+ title: "No dynamic stuff",
84
+ shortDescription: `Detects dynamic calls and other dynamic language constructs`,
85
+ extendedInformation: `Dynamic constructs cannot be checked statically, they are not found by
86
+ where-used lists and refactorings, and they can introduce injection vulnerabilities.
87
+
88
+ Dynamic tokens containing a literal, eg. CALL METHOD ('CL_FOO')=>('BAR'), are not reported,
89
+ as these are equivalent to the static variant.
90
+
91
+ Dynamic SQL is reported by rule dangerous_statement.`,
92
+ tags: [_irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Security],
93
+ badExample: `CALL METHOD (lv_class)=>(lv_method).
94
+ CALL FUNCTION lv_function_module.
95
+ CREATE OBJECT ref TYPE (lv_class).
96
+ ASSIGN (lv_name) TO <fs>.
97
+ SORT tab BY (lv_field).`,
98
+ goodExample: `cl_class=>method( ).
99
+ CALL FUNCTION 'ZFOO'.
100
+ CREATE OBJECT ref TYPE cl_class.
101
+ ASSIGN foo TO <fs>.
102
+ SORT tab BY field.`,
103
+ };
104
+ }
105
+ getConfig() {
106
+ return this.conf;
107
+ }
108
+ setConfig(conf) {
109
+ this.conf = conf;
110
+ }
111
+ runParsed(file) {
112
+ const issues = [];
113
+ for (const statementNode of file.getStatements()) {
114
+ const found = this.check(statementNode);
115
+ if (found !== undefined) {
116
+ issues.push(issue_1.Issue.atStatement(file, statementNode, "Dynamic " + found, this.getMetadata().key, this.conf.severity));
117
+ }
118
+ }
119
+ return issues;
120
+ }
121
+ check(node) {
122
+ const statement = node.get();
123
+ // note that MethodSource is also used by SET HANDLER and CALL BADI
124
+ if (this.conf.callMethod === true && this.dynamicMethodSource(node) === true) {
125
+ return "method call";
126
+ }
127
+ if (statement instanceof Statements.CallFunction) {
128
+ if (this.conf.callFunction === true
129
+ && this.notLiteral(node.findDirectExpression(Expressions.FunctionName))) {
130
+ return "CALL FUNCTION";
131
+ }
132
+ }
133
+ else if (statement instanceof Statements.CallDatabase) {
134
+ if (this.conf.callDatabaseProcedure === true) {
135
+ return "CALL DATABASE PROCEDURE";
136
+ }
137
+ }
138
+ else if (statement instanceof Statements.CallTransformation) {
139
+ if (this.conf.callTransformation === true && this.hasDynamic(node)) {
140
+ return "CALL TRANSFORMATION";
141
+ }
142
+ }
143
+ else if (statement instanceof Statements.CallTransaction) {
144
+ // the transaction code is a Source, ie. there is no parenthesized dynamic variant
145
+ if (this.conf.callTransaction === true
146
+ && this.notLiteral(node.findDirectExpression(Expressions.Source))) {
147
+ return "CALL TRANSACTION";
148
+ }
149
+ }
150
+ else if (statement instanceof Statements.Perform) {
151
+ if (this.conf.perform === true && this.hasDynamic(node)) {
152
+ return "PERFORM";
153
+ }
154
+ }
155
+ else if (statement instanceof Statements.Submit) {
156
+ if (this.conf.submit === true && this.hasDynamic(node)) {
157
+ return "SUBMIT";
158
+ }
159
+ }
160
+ else if (statement instanceof Statements.CreateObject) {
161
+ if (this.conf.createObject === true && this.hasDynamic(node)) {
162
+ return "CREATE OBJECT";
163
+ }
164
+ }
165
+ else if (statement instanceof Statements.CreateData) {
166
+ if (this.conf.createData === true && this.hasDynamic(node)) {
167
+ return "CREATE DATA";
168
+ }
169
+ }
170
+ else if (statement instanceof Statements.GetBadi) {
171
+ if (this.conf.getBadi === true && this.hasDynamic(node)) {
172
+ return "GET BADI";
173
+ }
174
+ }
175
+ else if (statement instanceof Statements.Assign
176
+ || statement instanceof Statements.AssignLocalCopy) {
177
+ if (this.conf.assign === true
178
+ && (this.hasDynamic(node) || this.dynamicAssignComponent(node))) {
179
+ return "ASSIGN";
180
+ }
181
+ }
182
+ else if (statement instanceof Statements.Export) {
183
+ if (this.conf.exportImport === true && this.hasDynamic(node)) {
184
+ return "EXPORT";
185
+ }
186
+ }
187
+ else if (statement instanceof Statements.Import) {
188
+ if (this.conf.exportImport === true && this.hasDynamic(node)) {
189
+ return "IMPORT";
190
+ }
191
+ }
192
+ else if (statement instanceof Statements.At
193
+ || statement instanceof Statements.DeleteInternal
194
+ || statement instanceof Statements.InsertInternal
195
+ || statement instanceof Statements.Loop
196
+ || statement instanceof Statements.ModifyInternal
197
+ || statement instanceof Statements.ReadTable
198
+ || statement instanceof Statements.Sort
199
+ || statement instanceof Statements.SortDataset) {
200
+ if (this.conf.internalTable === true && this.hasDynamic(node)) {
201
+ return "internal table access";
202
+ }
203
+ }
204
+ return undefined;
205
+ }
206
+ dynamicMethodSource(node) {
207
+ for (const source of node.findAllExpressions(Expressions.MethodSource)) {
208
+ // Dynamic is always a direct child of MethodSource, dynamics further down
209
+ // are parameters of the method call and not part of the method name
210
+ for (const dynamic of source.findDirectExpressions(Expressions.Dynamic)) {
211
+ if (this.isLiteral(dynamic) === false) {
212
+ return true;
213
+ }
214
+ }
215
+ }
216
+ return false;
217
+ }
218
+ dynamicAssignComponent(node) {
219
+ var _a;
220
+ const component = (_a = node.findDirectExpression(Expressions.AssignSource)) === null || _a === void 0 ? void 0 : _a.findExpressionAfterToken("COMPONENT");
221
+ return component !== undefined && this.isLiteral(component) === false;
222
+ }
223
+ hasDynamic(node) {
224
+ for (const dynamic of node.findAllExpressions(Expressions.Dynamic)) {
225
+ if (this.isLiteral(dynamic) === false) {
226
+ return true;
227
+ }
228
+ }
229
+ return false;
230
+ }
231
+ notLiteral(node) {
232
+ return node !== undefined && this.isLiteral(node) === false;
233
+ }
234
+ isLiteral(node) {
235
+ return node.findDirectExpression(Expressions.Constant) !== undefined;
236
+ }
237
+ }
238
+ exports.NoDynamicStuff = NoDynamicStuff;
239
+ //# sourceMappingURL=no_dynamic_stuff.js.map
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XMLBOM = exports.XMLBOMConf = void 0;
4
+ const edit_helper_1 = require("../edit_helper");
5
+ const issue_1 = require("../issue");
6
+ const position_1 = require("../position");
7
+ const _basic_rule_config_1 = require("./_basic_rule_config");
8
+ const _irule_1 = require("./_irule");
9
+ class XMLBOMConf extends _basic_rule_config_1.BasicRuleConfig {
10
+ }
11
+ exports.XMLBOMConf = XMLBOMConf;
12
+ class XMLBOM {
13
+ constructor() {
14
+ this.conf = new XMLBOMConf();
15
+ }
16
+ getMetadata() {
17
+ return {
18
+ key: "xml_bom",
19
+ title: "XML UTF-8 byte order mark",
20
+ shortDescription: "Checks that XML files start with a UTF-8 byte order mark",
21
+ extendedInformation: "Checks that each XML file has a UTF-8 byte order mark (BOM) at its beginning.",
22
+ tags: [_irule_1.RuleTag.Syntax, _irule_1.RuleTag.Quickfix],
23
+ };
24
+ }
25
+ getConfig() {
26
+ return this.conf;
27
+ }
28
+ setConfig(conf) {
29
+ this.conf = conf;
30
+ }
31
+ initialize(_reg) {
32
+ return this;
33
+ }
34
+ run(obj) {
35
+ const file = obj.getXMLFile();
36
+ if (file === undefined || file.getRaw().startsWith("\uFEFF")) {
37
+ return [];
38
+ }
39
+ return [this.createIssue(file)];
40
+ }
41
+ createIssue(file) {
42
+ const start = new position_1.Position(1, 1);
43
+ const fix = edit_helper_1.EditHelper.insertAt(file, start, "\uFEFF");
44
+ 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);
45
+ }
46
+ }
47
+ exports.XMLBOM = XMLBOM;
48
+ //# sourceMappingURL=xml_bom.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.31",
3
+ "version": "2.120.32",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",