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 +1 -1
- package/rules/camunda-cloud/secrets.js +68 -49
package/package.json
CHANGED
|
@@ -15,7 +15,13 @@ const { reportErrors } = require('../utils/reporter');
|
|
|
15
15
|
|
|
16
16
|
const { skipInNonExecutableProcess } = require('../utils/rule');
|
|
17
17
|
|
|
18
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
});
|
|
42
|
+
function validateIoMapping(node) {
|
|
43
|
+
const ioMapping = findExtensionElement(node, 'zeebe:IoMapping');
|
|
40
44
|
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
if (!ioMapping) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
43
48
|
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
return ioMapping.get('inputParameters')
|
|
50
|
+
.filter(inputParameter => !isValidSecret(inputParameter.get('source')))
|
|
51
|
+
.map(inputParameter => getReport('source', inputParameter, node));
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.map(inputParameter => getReport('source', inputParameter, node));
|
|
51
|
-
}
|
|
54
|
+
function validateProperties(node) {
|
|
55
|
+
const properties = findExtensionElement(node, 'zeebe:Properties');
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
if (!properties) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
55
60
|
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
return (properties.get('properties'))
|
|
62
|
+
.filter(property => !isValidSecret(property.get('value')))
|
|
63
|
+
.map(property => getReport('value', property, node));
|
|
58
64
|
}
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.map(property => getReport('value', property, node));
|
|
63
|
-
}
|
|
66
|
+
function validateSubscription(node) {
|
|
67
|
+
let message;
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
if (is(node, 'bpmn:ReceiveTask')) {
|
|
70
|
+
message = node.get('messageRef');
|
|
71
|
+
} else {
|
|
72
|
+
const messageEventDefinition = getEventDefinition(node, 'bpmn:MessageEventDefinition');
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const messageEventDefinition = getEventDefinition(node, 'bpmn:MessageEventDefinition');
|
|
74
|
+
if (!messageEventDefinition) {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
72
77
|
|
|
73
|
-
|
|
78
|
+
message = messageEventDefinition.get('messageRef');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!message) {
|
|
74
82
|
return [];
|
|
75
83
|
}
|
|
76
84
|
|
|
77
|
-
|
|
78
|
-
}
|
|
85
|
+
const subscription = findExtensionElement(message, 'zeebe:Subscription');
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
if (!subscription) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
83
90
|
|
|
84
|
-
|
|
91
|
+
const correlationKey = subscription.get('correlationKey');
|
|
85
92
|
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
return isValidSecret(correlationKey)
|
|
94
|
+
? []
|
|
95
|
+
: [ getReport('correlationKey', subscription, node) ];
|
|
88
96
|
}
|
|
89
97
|
|
|
90
|
-
|
|
98
|
+
function isValidSecret(value) {
|
|
99
|
+
if (!value || !isString(value) || !value.includes('secrets.')) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
91
102
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
}
|