@infosupport/huddle-cli 0.0.0-experiment-98.74.1 → 0.0.0-experiment-108.77.1
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/dist/firewall.js +0 -20
- package/package.json +1 -1
package/dist/firewall.js
CHANGED
|
@@ -177,29 +177,9 @@ function readJsonFile(file) {
|
|
|
177
177
|
throw new Error(`${file} is not valid JSON`);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
// The name of the group a document describes, or null when it is a plain rules
|
|
181
|
-
// export. A group envelope carries it under `group`, or at the top level in the
|
|
182
|
-
// documented bare form.
|
|
183
|
-
function groupNameOf(doc) {
|
|
184
|
-
const meta = (doc['group'] && typeof doc['group'] === 'object' && !Array.isArray(doc['group']) ? doc['group'] : doc);
|
|
185
|
-
const name = typeof meta['name'] === 'string' ? meta['name'].trim() : '';
|
|
186
|
-
return name || null;
|
|
187
|
-
}
|
|
188
180
|
async function runFirewallImport(opts) {
|
|
189
181
|
const doc = readJsonFile(opts.file);
|
|
190
182
|
const mode = opts.replace ? 'replace' : 'merge';
|
|
191
|
-
// A group envelope handed to the flat importer used to import its rules and
|
|
192
|
-
// silently drop the group (#98). Send it where it belongs instead — unless
|
|
193
|
-
// --container asks for a scope remap, which only the flat importer does.
|
|
194
|
-
const groupName = groupNameOf(doc);
|
|
195
|
-
if (groupName && !opts.container) {
|
|
196
|
-
console.error((0, utils_1.dim)(`[i] ${opts.file} is the group "${groupName}" — importing it as a group.`));
|
|
197
|
-
await runFirewallGroup({ action: 'import', arg: opts.file, replace: opts.replace });
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
if (groupName) {
|
|
201
|
-
console.error((0, utils_1.dim)(`[i] ${opts.file} is the group "${groupName}"; --container imports its rules into that scope without the group.`));
|
|
202
|
-
}
|
|
203
183
|
const qs = new URLSearchParams();
|
|
204
184
|
if (opts.container)
|
|
205
185
|
qs.set('container', opts.container);
|
package/package.json
CHANGED