snow-flow 1.3.24 → 1.3.25
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.
|
@@ -124,26 +124,47 @@ class XMLFirstFlowGenerator {
|
|
|
124
124
|
.replace(/\t/g, '	'); // Preserve tabs
|
|
125
125
|
return escaped;
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* 🛡️ Apply security defaults to flow definition - BUG-004 FIX
|
|
129
|
+
*/
|
|
130
|
+
applySecurityDefaults(flowDef) {
|
|
131
|
+
// 🔒 SECURITY GUARD: Never allow public access unless explicitly and safely configured
|
|
132
|
+
const secureFlowDef = {
|
|
133
|
+
...flowDef,
|
|
134
|
+
// Override with secure defaults - these CANNOT be accidentally public
|
|
135
|
+
accessible_from: 'package_private', // FORCE secure default
|
|
136
|
+
run_as: flowDef.run_as || 'user' // Default to user, not system
|
|
137
|
+
};
|
|
138
|
+
// 🚨 Log security override for audit trail
|
|
139
|
+
if (flowDef.accessible_from && flowDef.accessible_from !== 'package_private') {
|
|
140
|
+
console.log('🛡️ SECURITY OVERRIDE: Flow access forced to package_private for security');
|
|
141
|
+
console.log(` • Original: ${flowDef.accessible_from}`);
|
|
142
|
+
console.log(` • Applied: package_private (secure)`);
|
|
143
|
+
}
|
|
144
|
+
return secureFlowDef;
|
|
145
|
+
}
|
|
127
146
|
/**
|
|
128
147
|
* Generate complete Update Set XML for a flow
|
|
129
148
|
* Based on REAL ServiceNow XML structure research
|
|
130
149
|
*/
|
|
131
150
|
generateFlowUpdateSetXML(flowDef) {
|
|
151
|
+
// 🔒 BUG-004 FIX: Apply security defaults FIRST
|
|
152
|
+
const secureFlowDef = this.applySecurityDefaults(flowDef);
|
|
132
153
|
this.flowSysId = this.generateSysId();
|
|
133
154
|
const timestamp = new Date().toISOString();
|
|
134
|
-
const internalName =
|
|
155
|
+
const internalName = secureFlowDef.internal_name || this.generateInternalName(secureFlowDef.name);
|
|
135
156
|
// Generate all component sys_ids upfront
|
|
136
157
|
const updateSetSysId = this.generateSysId();
|
|
137
158
|
const snapshotSysId = this.generateSysId();
|
|
138
159
|
const triggerSysId = this.generateSysId();
|
|
139
|
-
const activitySysIds =
|
|
160
|
+
const activitySysIds = secureFlowDef.activities.map(() => this.generateSysId());
|
|
140
161
|
const logicSysIds = []; // For flow logic connections
|
|
141
162
|
// Calculate logic chain sys_ids
|
|
142
163
|
for (let i = 0; i < activitySysIds.length + 2; i++) {
|
|
143
164
|
logicSysIds.push(this.generateSysId());
|
|
144
165
|
}
|
|
145
166
|
// Build the complete flow definition JSON for snapshot
|
|
146
|
-
const flowDefinitionJson = this.buildFlowDefinitionJson(
|
|
167
|
+
const flowDefinitionJson = this.buildFlowDefinitionJson(secureFlowDef, triggerSysId, activitySysIds);
|
|
147
168
|
// Generate XML - MUST use sys_remote_update_set for imports!
|
|
148
169
|
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
149
170
|
<unload unload_date="${timestamp}">
|
|
@@ -151,7 +172,7 @@ class XMLFirstFlowGenerator {
|
|
|
151
172
|
<sys_remote_update_set action="INSERT_OR_UPDATE">
|
|
152
173
|
<sys_id>${updateSetSysId}</sys_id>
|
|
153
174
|
<name>${this.escapeXml(this.updateSetName)}</name>
|
|
154
|
-
<description>Flow import: ${this.escapeXml(
|
|
175
|
+
<description>Flow import: ${this.escapeXml(secureFlowDef.name)}</description>
|
|
155
176
|
<remote_sys_id>${updateSetSysId}</remote_sys_id>
|
|
156
177
|
<state>loaded</state>
|
|
157
178
|
<application>global</application>
|
|
@@ -165,7 +186,7 @@ class XMLFirstFlowGenerator {
|
|
|
165
186
|
<action>INSERT_OR_UPDATE</action>
|
|
166
187
|
<application>global</application>
|
|
167
188
|
<name>sys_hub_flow_${this.flowSysId}</name>
|
|
168
|
-
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_hub_flow"><sys_hub_flow action="INSERT_OR_UPDATE"><sys_id>${this.flowSysId}</sys_id><name>${this.escapeXml(
|
|
189
|
+
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_hub_flow"><sys_hub_flow action="INSERT_OR_UPDATE"><sys_id>${this.flowSysId}</sys_id><name>${this.escapeXml(secureFlowDef.name)}</name><internal_name>${this.escapeXml(internalName)}</internal_name><description>${this.escapeXml(secureFlowDef.description)}</description><active>true</active><type>flow</type><category>custom</category><sys_scope display_value="Global">global</sys_scope><sys_app display_value="Global">global</sys_app><sys_package display_value="Global" source="global">global</sys_package><access>${secureFlowDef.accessible_from}</access><run_as>${secureFlowDef.run_as}</run_as><sys_class_name>sys_hub_flow</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>${timestamp}</sys_created_on><sys_domain>global</sys_domain><sys_domain_path>/</sys_domain_path><sys_updated_by>admin</sys_updated_by><sys_updated_on>${timestamp}</sys_updated_on><latest_snapshot>${snapshotSysId}</latest_snapshot><master_snapshot>${snapshotSysId}</master_snapshot><natlang/><copied_from/><copied_from_name/><show_draft_actions>false</show_draft_actions><show_row_wfr_actions>false</show_row_wfr_actions><show_wf_actions>false</show_wf_actions><sys_overrides/><sys_policy/></sys_hub_flow></record_update>]]></payload>
|
|
169
190
|
<remote_update_set>${updateSetSysId}</remote_update_set>
|
|
170
191
|
<source_table>sys_hub_flow</source_table>
|
|
171
192
|
<sys_recorded_at>${timestamp}</sys_recorded_at>
|
|
@@ -179,7 +200,7 @@ class XMLFirstFlowGenerator {
|
|
|
179
200
|
<action>INSERT_OR_UPDATE</action>
|
|
180
201
|
<application>global</application>
|
|
181
202
|
<name>sys_hub_flow_snapshot_${snapshotSysId}</name>
|
|
182
|
-
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_hub_flow_snapshot"><sys_hub_flow_snapshot action="INSERT_OR_UPDATE"><sys_id>${snapshotSysId}</sys_id><name>${this.escapeXml(
|
|
203
|
+
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_hub_flow_snapshot"><sys_hub_flow_snapshot action="INSERT_OR_UPDATE"><sys_id>${snapshotSysId}</sys_id><name>${this.escapeXml(secureFlowDef.name)}</name><flow>${this.flowSysId}</flow><note>Initial version</note><snapshot>${this.escapeForXml(JSON.stringify(flowDefinitionJson, null, 2))}</snapshot><sys_created_by>admin</sys_created_by><sys_created_on>${timestamp}</sys_created_on></sys_hub_flow_snapshot></record_update>]]></payload>
|
|
183
204
|
<remote_update_set>${updateSetSysId}</remote_update_set>
|
|
184
205
|
<source_table>sys_hub_flow_snapshot</source_table>
|
|
185
206
|
<type>Flow Designer Snapshot</type>
|
|
@@ -191,13 +212,13 @@ class XMLFirstFlowGenerator {
|
|
|
191
212
|
<action>INSERT_OR_UPDATE</action>
|
|
192
213
|
<application>global</application>
|
|
193
214
|
<name>sys_hub_trigger_instance_${triggerSysId}</name>
|
|
194
|
-
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_hub_trigger_instance"><sys_hub_trigger_instance action="INSERT_OR_UPDATE"><sys_id>${triggerSysId}</sys_id><flow>${this.flowSysId}</flow><trigger_type>${this.getTriggerTypeId(
|
|
215
|
+
<payload><![CDATA[<?xml version="1.0" encoding="UTF-8"?><record_update table="sys_hub_trigger_instance"><sys_hub_trigger_instance action="INSERT_OR_UPDATE"><sys_id>${triggerSysId}</sys_id><flow>${this.flowSysId}</flow><trigger_type>${this.getTriggerTypeId(secureFlowDef.trigger_type)}</trigger_type><table>${secureFlowDef.table || ''}</table><condition>${this.escapeXml(secureFlowDef.trigger_condition || '')}</condition><order>100</order><active>true</active><sys_class_name>sys_hub_trigger_instance</sys_class_name><sys_created_by>admin</sys_created_by><sys_created_on>${timestamp}</sys_created_on><sys_domain>global</sys_domain><sys_domain_path>/</sys_domain_path></sys_hub_trigger_instance></record_update>]]></payload>
|
|
195
216
|
<remote_update_set>${updateSetSysId}</remote_update_set>
|
|
196
217
|
<source_table>sys_hub_trigger_instance</source_table>
|
|
197
218
|
<type>Flow Designer Trigger</type>
|
|
198
219
|
</sys_update_xml>
|
|
199
220
|
|
|
200
|
-
${this.generateActionInstancesXML(
|
|
221
|
+
${this.generateActionInstancesXML(secureFlowDef.activities, activitySysIds, timestamp, updateSetSysId)}
|
|
201
222
|
${this.generateFlowLogicXML(triggerSysId, activitySysIds, logicSysIds, timestamp, updateSetSysId)}
|
|
202
223
|
</unload>`;
|
|
203
224
|
return xml;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snow-flow",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.25",
|
|
4
4
|
"description": "ServiceNow Queen Agent - Hive-Mind Intelligence for ServiceNow Development inspired by claude-flow. Transform complex workflows into elegant one-command orchestration.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|