bpmnlint-plugin-camunda-compat 2.60.1 → 2.60.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmnlint-plugin-camunda-compat",
3
- "version": "2.60.1",
3
+ "version": "2.60.2",
4
4
  "description": "A bpmnlint plug-in for Camunda compatibility",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,7 +15,13 @@ const { reportErrors } = require('../utils/reporter');
15
15
 
16
16
  const { skipInNonExecutableProcess } = require('../utils/rule');
17
17
 
18
- module.exports = skipInNonExecutableProcess(function() {
18
+ const { greaterOrEqual } = require('../utils/version');
19
+
20
+ // `camunda.secrets.<name>` only resolves on engines with this version or newer;
21
+ // before that, `{{secrets.<name>}}` remains the only working format
22
+ const CAMUNDA_SECRETS_FORMAT_ALLOWED_VERSION = '8.10';
23
+
24
+ module.exports = skipInNonExecutableProcess(function({ version }) {
19
25
  function check(node, reporter) {
20
26
  const errors = [
21
27
  validateIoMapping,
@@ -33,66 +39,85 @@ module.exports = skipInNonExecutableProcess(function() {
33
39
  }
34
40
  }
35
41
 
36
- return {
37
- check
38
- };
39
- });
42
+ function validateIoMapping(node) {
43
+ const ioMapping = findExtensionElement(node, 'zeebe:IoMapping');
40
44
 
41
- function validateIoMapping(node) {
42
- const ioMapping = findExtensionElement(node, 'zeebe:IoMapping');
45
+ if (!ioMapping) {
46
+ return [];
47
+ }
43
48
 
44
- if (!ioMapping) {
45
- return [];
49
+ return ioMapping.get('inputParameters')
50
+ .filter(inputParameter => !isValidSecret(inputParameter.get('source')))
51
+ .map(inputParameter => getReport('source', inputParameter, node));
46
52
  }
47
53
 
48
- return ioMapping.get('inputParameters')
49
- .filter(inputParameter => !isValidSecret(inputParameter.get('source')))
50
- .map(inputParameter => getReport('source', inputParameter, node));
51
- }
54
+ function validateProperties(node) {
55
+ const properties = findExtensionElement(node, 'zeebe:Properties');
52
56
 
53
- function validateProperties(node) {
54
- const properties = findExtensionElement(node, 'zeebe:Properties');
57
+ if (!properties) {
58
+ return [];
59
+ }
55
60
 
56
- if (!properties) {
57
- return [];
61
+ return (properties.get('properties'))
62
+ .filter(property => !isValidSecret(property.get('value')))
63
+ .map(property => getReport('value', property, node));
58
64
  }
59
65
 
60
- return (properties.get('properties'))
61
- .filter(property => !isValidSecret(property.get('value')))
62
- .map(property => getReport('value', property, node));
63
- }
66
+ function validateSubscription(node) {
67
+ let message;
64
68
 
65
- function validateSubscription(node) {
66
- let message;
69
+ if (is(node, 'bpmn:ReceiveTask')) {
70
+ message = node.get('messageRef');
71
+ } else {
72
+ const messageEventDefinition = getEventDefinition(node, 'bpmn:MessageEventDefinition');
67
73
 
68
- if (is(node, 'bpmn:ReceiveTask')) {
69
- message = node.get('messageRef');
70
- } else {
71
- const messageEventDefinition = getEventDefinition(node, 'bpmn:MessageEventDefinition');
74
+ if (!messageEventDefinition) {
75
+ return [];
76
+ }
72
77
 
73
- if (!messageEventDefinition) {
78
+ message = messageEventDefinition.get('messageRef');
79
+ }
80
+
81
+ if (!message) {
74
82
  return [];
75
83
  }
76
84
 
77
- message = messageEventDefinition.get('messageRef');
78
- }
85
+ const subscription = findExtensionElement(message, 'zeebe:Subscription');
79
86
 
80
- if (!message) {
81
- return [];
82
- }
87
+ if (!subscription) {
88
+ return [];
89
+ }
83
90
 
84
- const subscription = findExtensionElement(message, 'zeebe:Subscription');
91
+ const correlationKey = subscription.get('correlationKey');
85
92
 
86
- if (!subscription) {
87
- return [];
93
+ return isValidSecret(correlationKey)
94
+ ? []
95
+ : [ getReport('correlationKey', subscription, node) ];
88
96
  }
89
97
 
90
- const correlationKey = subscription.get('correlationKey');
98
+ function isValidSecret(value) {
99
+ if (!value || !isString(value) || !value.includes('secrets.')) {
100
+ return true;
101
+ }
91
102
 
92
- return isValidSecret(correlationKey)
93
- ? []
94
- : [ getReport('correlationKey', subscription, node) ];
95
- }
103
+ // the current, opt-in `camunda.secrets.<name>` format is always accepted
104
+ if (/camunda\.secrets\.[\w-]+/.test(value)) {
105
+ return true;
106
+ }
107
+
108
+ // once the engine supports `camunda.secrets.<name>`, any remaining
109
+ // `secrets.<name>` reference (wrapped or not) is considered outdated
110
+ if (greaterOrEqual(version, CAMUNDA_SECRETS_FORMAT_ALLOWED_VERSION)) {
111
+ return false;
112
+ }
113
+
114
+ return /{{\s*secrets\.[\w-]+\s*}}/.test(value);
115
+ }
116
+
117
+ return {
118
+ check
119
+ };
120
+ });
96
121
 
97
122
  function getReport(propertyName, node, parentNode) {
98
123
  const path = getPath(node, parentNode);
@@ -104,14 +129,8 @@ function getReport(propertyName, node, parentNode) {
104
129
  type: ERROR_TYPES.SECRET_EXPRESSION_FORMAT_DEPRECATED,
105
130
  node,
106
131
  parentNode: parentNode,
107
- property: propertyName
132
+ property: propertyName,
133
+ allowedVersion: CAMUNDA_SECRETS_FORMAT_ALLOWED_VERSION
108
134
  }
109
135
  };
110
136
  }
111
-
112
- function isValidSecret(value) {
113
- return !value
114
- || !isString(value)
115
- || !value.includes('secrets.')
116
- || /{{\s*secrets\.[\w-]+\s*}}/.test(value);
117
- }