@sentriflow/cli 0.11.0-rc.2 → 0.11.0-rc.3
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/index.js +255 -47
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3801,7 +3801,7 @@ function detectionSample(configText) {
|
|
|
3801
3801
|
return `${configText.slice(0, DETECTION_SAMPLE)}
|
|
3802
3802
|
${configText.slice(start, start + DETECTION_SAMPLE)}`;
|
|
3803
3803
|
}
|
|
3804
|
-
function matchVendorPatterns(configText) {
|
|
3804
|
+
function matchVendorPatterns(configText, notes) {
|
|
3805
3805
|
const sampleText = detectionSample(configText);
|
|
3806
3806
|
const lines = sampleText.split("\n");
|
|
3807
3807
|
if (looksLikeXml(sampleText)) {
|
|
@@ -3976,7 +3976,9 @@ function matchVendorPatterns(configText) {
|
|
|
3976
3976
|
return JuniperJunOSSchema;
|
|
3977
3977
|
}
|
|
3978
3978
|
if (SHARED_SET_STATEMENT.test(sampleText)) {
|
|
3979
|
-
|
|
3979
|
+
const marked = setFormVendor(configText);
|
|
3980
|
+
if (!marked && notes) notes.sharedSetOnly = true;
|
|
3981
|
+
return marked ?? JuniperJunOSSchema;
|
|
3980
3982
|
}
|
|
3981
3983
|
if (/^\s*(ge|xe|et|ae|lo|irb|vlan|em|fxp)-[\d\/:.]+\s*\{/m.test(sampleText)) {
|
|
3982
3984
|
return JuniperJunOSSchema;
|
|
@@ -4374,7 +4376,15 @@ function detectVendorWithConfidence(configText) {
|
|
|
4374
4376
|
};
|
|
4375
4377
|
}
|
|
4376
4378
|
}
|
|
4377
|
-
const
|
|
4379
|
+
const notes = { sharedSetOnly: false };
|
|
4380
|
+
const matched = matchVendorPatterns(configText, notes);
|
|
4381
|
+
if (matched && notes.sharedSetOnly) {
|
|
4382
|
+
return {
|
|
4383
|
+
vendor: matched,
|
|
4384
|
+
confidence: "low",
|
|
4385
|
+
reason: "Set-form statements that both JunOS and VyOS/EdgeOS write, with no marker for either; assuming JunOS, but it may be VyOS"
|
|
4386
|
+
};
|
|
4387
|
+
}
|
|
4378
4388
|
if (matched) {
|
|
4379
4389
|
return {
|
|
4380
4390
|
vendor: matched,
|
|
@@ -7297,6 +7307,46 @@ var RuleEngine = class {
|
|
|
7297
7307
|
}
|
|
7298
7308
|
};
|
|
7299
7309
|
|
|
7310
|
+
// ../core/src/engine/ancestors.ts
|
|
7311
|
+
var parentsByAst = /* @__PURE__ */ new WeakMap();
|
|
7312
|
+
function readParents(ast) {
|
|
7313
|
+
const parents = /* @__PURE__ */ new Map();
|
|
7314
|
+
const stack = [];
|
|
7315
|
+
for (const root of ast) {
|
|
7316
|
+
parents.set(root, null);
|
|
7317
|
+
stack.push(root);
|
|
7318
|
+
}
|
|
7319
|
+
let node = stack.pop();
|
|
7320
|
+
while (node) {
|
|
7321
|
+
for (const child of node.children) {
|
|
7322
|
+
parents.set(child, node);
|
|
7323
|
+
stack.push(child);
|
|
7324
|
+
}
|
|
7325
|
+
node = stack.pop();
|
|
7326
|
+
}
|
|
7327
|
+
return parents;
|
|
7328
|
+
}
|
|
7329
|
+
function pathTo(ast, parents, node) {
|
|
7330
|
+
const path = [];
|
|
7331
|
+
let current = node;
|
|
7332
|
+
for (; ; ) {
|
|
7333
|
+
const parent = parents.get(current);
|
|
7334
|
+
if (parent === void 0) return void 0;
|
|
7335
|
+
if (parent === null) return ast.includes(current) ? path.reverse() : void 0;
|
|
7336
|
+
if (!parent.children.includes(current)) return void 0;
|
|
7337
|
+
path.push(parent);
|
|
7338
|
+
current = parent;
|
|
7339
|
+
}
|
|
7340
|
+
}
|
|
7341
|
+
function ancestorsOf(ast, node) {
|
|
7342
|
+
const known = parentsByAst.get(ast);
|
|
7343
|
+
const path = known ? pathTo(ast, known, node) : void 0;
|
|
7344
|
+
if (path) return path;
|
|
7345
|
+
const parents = readParents(ast);
|
|
7346
|
+
parentsByAst.set(ast, parents);
|
|
7347
|
+
return pathTo(ast, parents, node);
|
|
7348
|
+
}
|
|
7349
|
+
|
|
7300
7350
|
// ../core/src/helpers/index.ts
|
|
7301
7351
|
var helpers_exports = {};
|
|
7302
7352
|
__export(helpers_exports, {
|
|
@@ -14401,6 +14451,9 @@ function isJsonLocate(obj) {
|
|
|
14401
14451
|
if (!isSelector(locate.selector)) return false;
|
|
14402
14452
|
return locate.where === void 0 || isJsonCheck(locate.where);
|
|
14403
14453
|
}
|
|
14454
|
+
function isJsonNotUnder(obj) {
|
|
14455
|
+
return Array.isArray(obj) && obj.length > 0 && obj.every((name) => typeof name === "string" && name.length > 0 && name.trim() === name && !/[\r\n]/.test(name));
|
|
14456
|
+
}
|
|
14404
14457
|
function isJsonRule(obj) {
|
|
14405
14458
|
if (typeof obj !== "object" || obj === null) {
|
|
14406
14459
|
return false;
|
|
@@ -14441,6 +14494,12 @@ function isJsonRule(obj) {
|
|
|
14441
14494
|
if (rule.locate !== void 0 && !isJsonLocate(rule.locate)) {
|
|
14442
14495
|
return false;
|
|
14443
14496
|
}
|
|
14497
|
+
if (rule.topLevelOnly !== void 0 && typeof rule.topLevelOnly !== "boolean") {
|
|
14498
|
+
return false;
|
|
14499
|
+
}
|
|
14500
|
+
if (rule.notUnder !== void 0 && !isJsonNotUnder(rule.notUnder)) {
|
|
14501
|
+
return false;
|
|
14502
|
+
}
|
|
14444
14503
|
if (rule.failureMessage !== void 0 && typeof rule.failureMessage !== "string") {
|
|
14445
14504
|
return false;
|
|
14446
14505
|
}
|
|
@@ -14474,6 +14533,12 @@ function isJsonRuleFile(obj) {
|
|
|
14474
14533
|
}
|
|
14475
14534
|
|
|
14476
14535
|
// ../core/src/json-rules/JsonRuleCompiler.ts
|
|
14536
|
+
function nameMatchesBlock(names, id) {
|
|
14537
|
+
for (const name of names) {
|
|
14538
|
+
if (id === name || id.startsWith(name) && /\s/.test(id.charAt(name.length))) return true;
|
|
14539
|
+
}
|
|
14540
|
+
return false;
|
|
14541
|
+
}
|
|
14477
14542
|
var JsonRuleCompiler = class {
|
|
14478
14543
|
registry;
|
|
14479
14544
|
evaluator;
|
|
@@ -14531,13 +14596,15 @@ var JsonRuleCompiler = class {
|
|
|
14531
14596
|
compile(jsonRule) {
|
|
14532
14597
|
this.prepareCheck(jsonRule.check, jsonRule.id, "/check");
|
|
14533
14598
|
const locate = this.prepareLocate(jsonRule);
|
|
14599
|
+
const scope = this.prepareScope(jsonRule);
|
|
14534
14600
|
return {
|
|
14535
14601
|
id: jsonRule.id,
|
|
14536
14602
|
selector: jsonRule.selector,
|
|
14537
14603
|
vendor: jsonRule.vendor,
|
|
14538
14604
|
category: jsonRule.category,
|
|
14539
14605
|
metadata: jsonRule.metadata,
|
|
14540
|
-
check: (node,
|
|
14606
|
+
check: (node, ctx) => {
|
|
14607
|
+
if (scope && !this.inScope(node, scope, ctx)) return [];
|
|
14541
14608
|
let passed;
|
|
14542
14609
|
let reported = node;
|
|
14543
14610
|
try {
|
|
@@ -14593,6 +14660,42 @@ var JsonRuleCompiler = class {
|
|
|
14593
14660
|
}
|
|
14594
14661
|
return { selector: locate.selector.toLowerCase(), where: locate.where };
|
|
14595
14662
|
}
|
|
14663
|
+
/**
|
|
14664
|
+
* Validate and normalise a rule's `topLevelOnly` and `notUnder` fields.
|
|
14665
|
+
* @returns undefined when the rule runs on every matching node
|
|
14666
|
+
* @throws RuleCompileError for a malformed field
|
|
14667
|
+
*/
|
|
14668
|
+
prepareScope(jsonRule) {
|
|
14669
|
+
const topLevelOnly = jsonRule.topLevelOnly;
|
|
14670
|
+
const notUnder = jsonRule.notUnder;
|
|
14671
|
+
if (topLevelOnly !== void 0 && typeof topLevelOnly !== "boolean") {
|
|
14672
|
+
throw new RuleCompileError(jsonRule.id, "/topLevelOnly", "expected true or false");
|
|
14673
|
+
}
|
|
14674
|
+
if (notUnder !== void 0 && !isJsonNotUnder(notUnder)) {
|
|
14675
|
+
throw new RuleCompileError(
|
|
14676
|
+
jsonRule.id,
|
|
14677
|
+
"/notUnder",
|
|
14678
|
+
"expected a non-empty list of block ids, each a non-empty string without leading or trailing whitespace"
|
|
14679
|
+
);
|
|
14680
|
+
}
|
|
14681
|
+
if (!topLevelOnly && notUnder === void 0) return void 0;
|
|
14682
|
+
return {
|
|
14683
|
+
topLevelOnly: topLevelOnly === true,
|
|
14684
|
+
notUnder: new Set((notUnder ?? []).map((name) => name.toLowerCase()))
|
|
14685
|
+
};
|
|
14686
|
+
}
|
|
14687
|
+
/**
|
|
14688
|
+
* Whether a scoped rule judges `node`. Without the AST there is no way to
|
|
14689
|
+
* tell where the node lies, so a check called outside the engine judges
|
|
14690
|
+
* the node it is given.
|
|
14691
|
+
*/
|
|
14692
|
+
inScope(node, scope, ctx) {
|
|
14693
|
+
const ast = ctx?.getAst?.();
|
|
14694
|
+
if (!ast) return true;
|
|
14695
|
+
if (scope.topLevelOnly) return ast.includes(node);
|
|
14696
|
+
const enclosing = ancestorsOf(ast, node) ?? [];
|
|
14697
|
+
return !enclosing.some((block) => nameMatchesBlock(scope.notUnder, block.id.trim().toLowerCase()));
|
|
14698
|
+
}
|
|
14596
14699
|
/**
|
|
14597
14700
|
* Find the first descendant of `node` (depth-first, document order) whose
|
|
14598
14701
|
* id starts with the locate selector and, with `where`, satisfies it.
|
|
@@ -14819,6 +14922,7 @@ function validateJsonRuleFile(data, options = {}) {
|
|
|
14819
14922
|
} else {
|
|
14820
14923
|
obj.rules.forEach((rule, i) => {
|
|
14821
14924
|
pushLocateError(rule, `/rules/${i}`, errors);
|
|
14925
|
+
pushScopeErrors(rule, `/rules/${i}`, errors);
|
|
14822
14926
|
});
|
|
14823
14927
|
}
|
|
14824
14928
|
}
|
|
@@ -14867,6 +14971,24 @@ function pushLocateError(rule, path, errors) {
|
|
|
14867
14971
|
severity: "error"
|
|
14868
14972
|
});
|
|
14869
14973
|
}
|
|
14974
|
+
function pushScopeErrors(rule, path, errors) {
|
|
14975
|
+
if (typeof rule !== "object" || rule === null) return;
|
|
14976
|
+
const { topLevelOnly, notUnder } = rule;
|
|
14977
|
+
if (topLevelOnly !== void 0 && typeof topLevelOnly !== "boolean") {
|
|
14978
|
+
errors.push({
|
|
14979
|
+
path: `${path}/topLevelOnly`,
|
|
14980
|
+
message: 'Invalid "topLevelOnly": expected true or false',
|
|
14981
|
+
severity: "error"
|
|
14982
|
+
});
|
|
14983
|
+
}
|
|
14984
|
+
if (notUnder !== void 0 && !isJsonNotUnder(notUnder)) {
|
|
14985
|
+
errors.push({
|
|
14986
|
+
path: `${path}/notUnder`,
|
|
14987
|
+
message: 'Invalid "notUnder": expected a non-empty list of block ids, each a non-empty string without leading or trailing whitespace',
|
|
14988
|
+
severity: "error"
|
|
14989
|
+
});
|
|
14990
|
+
}
|
|
14991
|
+
}
|
|
14870
14992
|
function validateRule(rule, path, ctx) {
|
|
14871
14993
|
if (!RULE_ID_PATTERN.test(rule.id)) {
|
|
14872
14994
|
ctx.errors.push({
|
|
@@ -19098,6 +19220,18 @@ var isTopLevel = (node, context) => {
|
|
|
19098
19220
|
};
|
|
19099
19221
|
|
|
19100
19222
|
// ../rules-default/src/juniper/junos-rules.ts
|
|
19223
|
+
var idIs = (node, name) => node !== void 0 && equalsIgnoreCase(node.id.trim(), name);
|
|
19224
|
+
var enclosingBlocks = (node, context) => ancestorsOf(context?.getAst?.() ?? [], node) ?? [];
|
|
19225
|
+
var inGroup = (node, context) => idIs(enclosingBlocks(node, context)[0], "groups");
|
|
19226
|
+
var isRoutingProtocolsStanza = (node, context) => {
|
|
19227
|
+
if (isTopLevel(node, context)) return true;
|
|
19228
|
+
let path = enclosingBlocks(node, context);
|
|
19229
|
+
if ((idIs(path[0], "logical-systems") || idIs(path[0], "tenants")) && path.length >= 2) path = path.slice(2);
|
|
19230
|
+
return path.length === 0 || path.length === 2 && idIs(path[0], "routing-instances");
|
|
19231
|
+
};
|
|
19232
|
+
var NOT_TOP_LEVEL_SYSTEM = "Not the top-level system stanza.";
|
|
19233
|
+
var NOT_ROUTING_PROTOCOLS = "Not the protocols stanza of the device, a logical system, a tenant system or a routing instance.";
|
|
19234
|
+
var GROUP_CONTENT = "Configuration group content is not judged.";
|
|
19101
19235
|
var offenderResult2 = (ruleId, offender, message, level) => ({
|
|
19102
19236
|
passed: false,
|
|
19103
19237
|
message,
|
|
@@ -19126,7 +19260,10 @@ var RootAuthRequired = {
|
|
|
19126
19260
|
{ type: "general", label: "hardening" }
|
|
19127
19261
|
]
|
|
19128
19262
|
},
|
|
19129
|
-
check: (node) => {
|
|
19263
|
+
check: (node, context) => {
|
|
19264
|
+
if (!isTopLevel(node, context)) {
|
|
19265
|
+
return passResult2("JUN-SYS-001", node, NOT_TOP_LEVEL_SYSTEM);
|
|
19266
|
+
}
|
|
19130
19267
|
const rootAuth = findStanza4(node, "root-authentication");
|
|
19131
19268
|
if (!rootAuth) {
|
|
19132
19269
|
return {
|
|
@@ -19174,7 +19311,10 @@ var SshServiceRequired = {
|
|
|
19174
19311
|
cwe: ["CWE-319"]
|
|
19175
19312
|
}
|
|
19176
19313
|
},
|
|
19177
|
-
check: (node) => {
|
|
19314
|
+
check: (node, context) => {
|
|
19315
|
+
if (!isTopLevel(node, context)) {
|
|
19316
|
+
return passResult2("JUN-SYS-002", node, NOT_TOP_LEVEL_SYSTEM);
|
|
19317
|
+
}
|
|
19178
19318
|
const services = findStanza4(node, "services");
|
|
19179
19319
|
if (!services) {
|
|
19180
19320
|
return {
|
|
@@ -19218,7 +19358,10 @@ var SyslogRequired = {
|
|
|
19218
19358
|
owner: "NetOps",
|
|
19219
19359
|
remediation: 'Configure "syslog" under system stanza with appropriate log destinations.'
|
|
19220
19360
|
},
|
|
19221
|
-
check: (node) => {
|
|
19361
|
+
check: (node, context) => {
|
|
19362
|
+
if (!isTopLevel(node, context)) {
|
|
19363
|
+
return passResult2("JUN-SYS-003", node, NOT_TOP_LEVEL_SYSTEM);
|
|
19364
|
+
}
|
|
19222
19365
|
const syslog = findStanza4(node, "syslog");
|
|
19223
19366
|
if (!syslog) {
|
|
19224
19367
|
return {
|
|
@@ -19263,7 +19406,10 @@ var NtpRequired = {
|
|
|
19263
19406
|
owner: "NetOps",
|
|
19264
19407
|
remediation: 'Configure "ntp" under system stanza with at least one NTP server.'
|
|
19265
19408
|
},
|
|
19266
|
-
check: (node) => {
|
|
19409
|
+
check: (node, context) => {
|
|
19410
|
+
if (!isTopLevel(node, context)) {
|
|
19411
|
+
return passResult2("JUN-SYS-004", node, NOT_TOP_LEVEL_SYSTEM);
|
|
19412
|
+
}
|
|
19267
19413
|
const ntp = findStanza4(node, "ntp");
|
|
19268
19414
|
if (!ntp) {
|
|
19269
19415
|
return {
|
|
@@ -19348,7 +19494,10 @@ var JunosBgpRouterId = {
|
|
|
19348
19494
|
owner: "NetOps",
|
|
19349
19495
|
remediation: 'Configure "router-id" under routing-options stanza.'
|
|
19350
19496
|
},
|
|
19351
|
-
check: (node) => {
|
|
19497
|
+
check: (node, context) => {
|
|
19498
|
+
if (inGroup(node, context)) {
|
|
19499
|
+
return passResult2("JUN-BGP-001", node, GROUP_CONTENT);
|
|
19500
|
+
}
|
|
19352
19501
|
const hasRouterId = hasChildCommand(node, "router-id");
|
|
19353
19502
|
if (!hasRouterId) {
|
|
19354
19503
|
return {
|
|
@@ -19382,6 +19531,9 @@ var JunosBgpAsNumber = {
|
|
|
19382
19531
|
remediation: 'Configure "autonomous-system" under routing-options stanza.'
|
|
19383
19532
|
},
|
|
19384
19533
|
check: (node, context) => {
|
|
19534
|
+
if (inGroup(node, context)) {
|
|
19535
|
+
return passResult2("JUN-BGP-002", node, GROUP_CONTENT);
|
|
19536
|
+
}
|
|
19385
19537
|
const ast = context.getAst?.();
|
|
19386
19538
|
if (!ast) {
|
|
19387
19539
|
return { passed: true, message: "Cannot check without AST context.", ruleId: "JUN-BGP-002", nodeId: node.id, level: "info", loc: node.loc };
|
|
@@ -19436,7 +19588,10 @@ var JunosOspfAreaInterfaces = {
|
|
|
19436
19588
|
owner: "NetOps",
|
|
19437
19589
|
remediation: "Configure interfaces under each OSPF area."
|
|
19438
19590
|
},
|
|
19439
|
-
check: (node) => {
|
|
19591
|
+
check: (node, context) => {
|
|
19592
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
19593
|
+
return passResult2("JUN-OSPF-001", node, NOT_ROUTING_PROTOCOLS);
|
|
19594
|
+
}
|
|
19440
19595
|
const ospf = findStanza4(node, "ospf");
|
|
19441
19596
|
if (!ospf) {
|
|
19442
19597
|
return { passed: true, message: "OSPF not configured.", ruleId: "JUN-OSPF-001", nodeId: node.id, level: "info", loc: node.loc };
|
|
@@ -19481,7 +19636,10 @@ var JunosPolicyAction = {
|
|
|
19481
19636
|
owner: "NetOps",
|
|
19482
19637
|
remediation: 'Ensure all policy-statement terms have explicit "then accept" or "then reject" actions.'
|
|
19483
19638
|
},
|
|
19484
|
-
check: (node) => {
|
|
19639
|
+
check: (node, context) => {
|
|
19640
|
+
if (inGroup(node, context)) {
|
|
19641
|
+
return passResult2("JUN-POL-001", node, GROUP_CONTENT);
|
|
19642
|
+
}
|
|
19485
19643
|
const policyStatements = findStanzas3(node, /^policy-statement/i);
|
|
19486
19644
|
if (policyStatements.length === 0) {
|
|
19487
19645
|
return { passed: true, message: "No policy statements configured.", ruleId: "JUN-POL-001", nodeId: node.id, level: "info", loc: node.loc };
|
|
@@ -19544,7 +19702,10 @@ var JunosFirewallDefaultDeny = {
|
|
|
19544
19702
|
{ type: "general", label: "deny-by-default" }
|
|
19545
19703
|
]
|
|
19546
19704
|
},
|
|
19547
|
-
check: (node) => {
|
|
19705
|
+
check: (node, context) => {
|
|
19706
|
+
if (inGroup(node, context)) {
|
|
19707
|
+
return passResult2("JUN-FW-001", node, GROUP_CONTENT);
|
|
19708
|
+
}
|
|
19548
19709
|
const findFilters = (n) => {
|
|
19549
19710
|
const filters2 = [];
|
|
19550
19711
|
for (const child of n.children) {
|
|
@@ -20018,7 +20179,10 @@ var JunosIsisAuthentication = {
|
|
|
20018
20179
|
},
|
|
20019
20180
|
tags: generalTags("routing", "authentication", "isis")
|
|
20020
20181
|
},
|
|
20021
|
-
check: (node) => {
|
|
20182
|
+
check: (node, context) => {
|
|
20183
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20184
|
+
return passResult2("JUN-CTRL-002", node, NOT_ROUTING_PROTOCOLS);
|
|
20185
|
+
}
|
|
20022
20186
|
const isis = findStanza4(node, "isis");
|
|
20023
20187
|
if (!isis) {
|
|
20024
20188
|
return passResult2("JUN-CTRL-002", node, "IS-IS not configured.");
|
|
@@ -20049,7 +20213,10 @@ var JunosBfdRecommended = {
|
|
|
20049
20213
|
owner: "NetOps",
|
|
20050
20214
|
remediation: "Configure BFD (bfd-liveness-detection) for routing protocol adjacencies."
|
|
20051
20215
|
},
|
|
20052
|
-
check: (node) => {
|
|
20216
|
+
check: (node, context) => {
|
|
20217
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20218
|
+
return passResult2("JUN-CTRL-003", node, NOT_ROUTING_PROTOCOLS);
|
|
20219
|
+
}
|
|
20053
20220
|
const bgp = findStanza4(node, "bgp");
|
|
20054
20221
|
const ospf = findStanza4(node, "ospf");
|
|
20055
20222
|
const isis = findStanza4(node, "isis");
|
|
@@ -20179,7 +20346,10 @@ var JunosBgpAuthentication = {
|
|
|
20179
20346
|
},
|
|
20180
20347
|
tags: generalTags("bgp", "authentication", "routing")
|
|
20181
20348
|
},
|
|
20182
|
-
check: (node) => {
|
|
20349
|
+
check: (node, context) => {
|
|
20350
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20351
|
+
return passResult2("JUN-BGP-003", node, NOT_ROUTING_PROTOCOLS);
|
|
20352
|
+
}
|
|
20183
20353
|
const bgp = findStanza4(node, "bgp");
|
|
20184
20354
|
if (!bgp) {
|
|
20185
20355
|
return passResult2("JUN-BGP-003", node, "BGP not configured.");
|
|
@@ -20211,7 +20381,10 @@ var JunosBgpPrefixLimit = {
|
|
|
20211
20381
|
},
|
|
20212
20382
|
tags: generalTags("bgp", "dos", "routing")
|
|
20213
20383
|
},
|
|
20214
|
-
check: (node) => {
|
|
20384
|
+
check: (node, context) => {
|
|
20385
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20386
|
+
return passResult2("JUN-BGP-005", node, NOT_ROUTING_PROTOCOLS);
|
|
20387
|
+
}
|
|
20215
20388
|
const bgp = findStanza4(node, "bgp");
|
|
20216
20389
|
if (!bgp) {
|
|
20217
20390
|
return passResult2("JUN-BGP-005", node, "BGP not configured.");
|
|
@@ -20253,7 +20426,10 @@ var JunosBgpPolicies = {
|
|
|
20253
20426
|
},
|
|
20254
20427
|
tags: generalTags("bgp", "filtering", "routing")
|
|
20255
20428
|
},
|
|
20256
|
-
check: (node) => {
|
|
20429
|
+
check: (node, context) => {
|
|
20430
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20431
|
+
return passResult2("JUN-BGP-006", node, NOT_ROUTING_PROTOCOLS);
|
|
20432
|
+
}
|
|
20257
20433
|
const bgp = findStanza4(node, "bgp");
|
|
20258
20434
|
if (!bgp) {
|
|
20259
20435
|
return passResult2("JUN-BGP-006", node, "BGP not configured.");
|
|
@@ -20417,7 +20593,10 @@ var JunosZoneScreens = {
|
|
|
20417
20593
|
},
|
|
20418
20594
|
tags: generalTags("ids", "ddos", "screen")
|
|
20419
20595
|
},
|
|
20420
|
-
check: (node) => {
|
|
20596
|
+
check: (node, context) => {
|
|
20597
|
+
if (inGroup(node, context)) {
|
|
20598
|
+
return passResult2("JUN-ZONE-003", node, GROUP_CONTENT);
|
|
20599
|
+
}
|
|
20421
20600
|
const zones = findStanza4(node, "zones");
|
|
20422
20601
|
if (!zones) {
|
|
20423
20602
|
return passResult2("JUN-ZONE-003", node, "Security zones not configured.");
|
|
@@ -20607,7 +20786,10 @@ var JunosIkeDpd = {
|
|
|
20607
20786
|
owner: "NetOps",
|
|
20608
20787
|
remediation: "Enable dead-peer-detection on IKE gateways for tunnel health monitoring."
|
|
20609
20788
|
},
|
|
20610
|
-
check: (node) => {
|
|
20789
|
+
check: (node, context) => {
|
|
20790
|
+
if (inGroup(node, context)) {
|
|
20791
|
+
return passResult2("JUN-VPN-003", node, GROUP_CONTENT);
|
|
20792
|
+
}
|
|
20611
20793
|
const ike = findStanza4(node, "ike");
|
|
20612
20794
|
if (!ike) {
|
|
20613
20795
|
return passResult2("JUN-VPN-003", node, "IKE not configured.");
|
|
@@ -23975,16 +24157,9 @@ var descendantsOf2 = (nodes) => {
|
|
|
23975
24157
|
visit(nodes);
|
|
23976
24158
|
return out;
|
|
23977
24159
|
};
|
|
23978
|
-
var
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
if (node.children.includes(target)) return [node];
|
|
23982
|
-
const path = ancestorsOf(node.children, target);
|
|
23983
|
-
if (path.length > 0) return [node, ...path];
|
|
23984
|
-
}
|
|
23985
|
-
return [];
|
|
23986
|
-
};
|
|
23987
|
-
var inTemplate = (node, context) => ancestorsOf(context.getAst?.() ?? [], node).some((a) => ["template", "template-stack"].includes(keywordOf(a)));
|
|
24160
|
+
var enclosingBlocks2 = (node, context) => ancestorsOf(context?.getAst?.() ?? [], node) ?? [];
|
|
24161
|
+
var inTemplate = (node, context) => enclosingBlocks2(node, context).some((a) => ["template", "template-stack"].includes(keywordOf(a)));
|
|
24162
|
+
var TEMPLATE_CONTENT = "Panorama template content is not judged as the device configuration.";
|
|
23988
24163
|
var HostnameRequired = {
|
|
23989
24164
|
id: "PAN-SYS-001",
|
|
23990
24165
|
selector: "deviceconfig",
|
|
@@ -23996,7 +24171,10 @@ var HostnameRequired = {
|
|
|
23996
24171
|
owner: "NetOps",
|
|
23997
24172
|
remediation: "Configure hostname under deviceconfig > system."
|
|
23998
24173
|
},
|
|
23999
|
-
check: (node) => {
|
|
24174
|
+
check: (node, context) => {
|
|
24175
|
+
if (inTemplate(node, context)) {
|
|
24176
|
+
return passResult3("PAN-SYS-001", node, TEMPLATE_CONTENT);
|
|
24177
|
+
}
|
|
24000
24178
|
const system = findStanza6(node, "system");
|
|
24001
24179
|
if (!system) {
|
|
24002
24180
|
return {
|
|
@@ -24040,7 +24218,10 @@ var NtpRequired2 = {
|
|
|
24040
24218
|
owner: "SecOps",
|
|
24041
24219
|
remediation: "Configure NTP servers under deviceconfig > system > ntp-servers."
|
|
24042
24220
|
},
|
|
24043
|
-
check: (node) => {
|
|
24221
|
+
check: (node, context) => {
|
|
24222
|
+
if (inTemplate(node, context)) {
|
|
24223
|
+
return passResult3("PAN-SYS-002", node, TEMPLATE_CONTENT);
|
|
24224
|
+
}
|
|
24044
24225
|
const system = findStanza6(node, "system");
|
|
24045
24226
|
if (!system) {
|
|
24046
24227
|
return {
|
|
@@ -24084,7 +24265,10 @@ var DnsRequired = {
|
|
|
24084
24265
|
owner: "NetOps",
|
|
24085
24266
|
remediation: "Configure DNS servers under deviceconfig > system > dns-setting."
|
|
24086
24267
|
},
|
|
24087
|
-
check: (node) => {
|
|
24268
|
+
check: (node, context) => {
|
|
24269
|
+
if (inTemplate(node, context)) {
|
|
24270
|
+
return passResult3("PAN-SYS-003", node, TEMPLATE_CONTENT);
|
|
24271
|
+
}
|
|
24088
24272
|
const system = findStanza6(node, "system");
|
|
24089
24273
|
if (!system) {
|
|
24090
24274
|
return {
|
|
@@ -24142,7 +24326,10 @@ var ManagementAccessRestricted = {
|
|
|
24142
24326
|
cwe: ["CWE-284"]
|
|
24143
24327
|
}
|
|
24144
24328
|
},
|
|
24145
|
-
check: (node) => {
|
|
24329
|
+
check: (node, context) => {
|
|
24330
|
+
if (inTemplate(node, context)) {
|
|
24331
|
+
return passResult3("PAN-SYS-004", node, TEMPLATE_CONTENT);
|
|
24332
|
+
}
|
|
24146
24333
|
const system = findStanza6(node, "system");
|
|
24147
24334
|
if (!system) {
|
|
24148
24335
|
return {
|
|
@@ -24186,7 +24373,10 @@ var LoginBannerRequired = {
|
|
|
24186
24373
|
owner: "SecOps",
|
|
24187
24374
|
remediation: "Configure login-banner under deviceconfig > system."
|
|
24188
24375
|
},
|
|
24189
|
-
check: (node) => {
|
|
24376
|
+
check: (node, context) => {
|
|
24377
|
+
if (inTemplate(node, context)) {
|
|
24378
|
+
return passResult3("PAN-SYS-005", node, TEMPLATE_CONTENT);
|
|
24379
|
+
}
|
|
24190
24380
|
const system = findStanza6(node, "system");
|
|
24191
24381
|
if (!system) {
|
|
24192
24382
|
return {
|
|
@@ -24483,7 +24673,7 @@ var ZoneProtectionRequired = {
|
|
|
24483
24673
|
};
|
|
24484
24674
|
var NON_SECURITY_PROFILE_PARENTS = /* @__PURE__ */ new Set(["network", "log-settings", "profile-setting"]);
|
|
24485
24675
|
var isSecurityProfilesBlock = (ast, node) => {
|
|
24486
|
-
const parent = ancestorsOf(ast, node)
|
|
24676
|
+
const parent = ancestorsOf(ast, node)?.at(-1);
|
|
24487
24677
|
return !parent || !NON_SECURITY_PROFILE_PARENTS.has(keywordOf(parent));
|
|
24488
24678
|
};
|
|
24489
24679
|
var namesProfile = (node) => node !== void 0 && (node.children.length > 0 || valuesOf(node).length > 0);
|
|
@@ -24683,7 +24873,10 @@ var HARecommended = {
|
|
|
24683
24873
|
owner: "NetOps",
|
|
24684
24874
|
remediation: "Consider configuring High Availability (Active/Passive or Active/Active) for production environments."
|
|
24685
24875
|
},
|
|
24686
|
-
check: (node) => {
|
|
24876
|
+
check: (node, context) => {
|
|
24877
|
+
if (inTemplate(node, context)) {
|
|
24878
|
+
return passResult3("PAN-HA-001", node, TEMPLATE_CONTENT);
|
|
24879
|
+
}
|
|
24687
24880
|
const ha = findStanza6(node, "high-availability");
|
|
24688
24881
|
if (!ha || ha.children.length === 0) {
|
|
24689
24882
|
return {
|
|
@@ -25348,6 +25541,9 @@ var LogForwardingRequired = {
|
|
|
25348
25541
|
remediation: "Configure log forwarding to syslog server, Panorama, or SIEM for centralized logging."
|
|
25349
25542
|
},
|
|
25350
25543
|
check: (node, context) => {
|
|
25544
|
+
if (inTemplate(node, context)) {
|
|
25545
|
+
return passResult3("PAN-LOG-001", node, TEMPLATE_CONTENT);
|
|
25546
|
+
}
|
|
25351
25547
|
const logSettings = descendantsOf2(context.getAst?.() ?? [node]).filter(
|
|
25352
25548
|
(n) => n.children.length > 0 && keywordOf(n) === "log-settings"
|
|
25353
25549
|
);
|
|
@@ -27973,6 +28169,22 @@ var VyosInterfaceDescription = {
|
|
|
27973
28169
|
};
|
|
27974
28170
|
}
|
|
27975
28171
|
};
|
|
28172
|
+
var memberPortNames = (interfaces) => {
|
|
28173
|
+
const names = /* @__PURE__ */ new Set();
|
|
28174
|
+
const visit = (parent) => {
|
|
28175
|
+
const owner = parent.id.toLowerCase();
|
|
28176
|
+
const holdsMembers = owner === "member" || owner === "switch-port";
|
|
28177
|
+
for (const child of parent.children) {
|
|
28178
|
+
if (holdsMembers) {
|
|
28179
|
+
const name = /^interface\s+(\S+)/i.exec(child.id)?.[1];
|
|
28180
|
+
if (name) names.add(name.toLowerCase());
|
|
28181
|
+
}
|
|
28182
|
+
visit(child);
|
|
28183
|
+
}
|
|
28184
|
+
};
|
|
28185
|
+
visit(interfaces);
|
|
28186
|
+
return names;
|
|
28187
|
+
};
|
|
27976
28188
|
var VyosInterfaceAddress = {
|
|
27977
28189
|
id: "VYOS-IF-002",
|
|
27978
28190
|
selector: "interfaces",
|
|
@@ -27988,20 +28200,13 @@ var VyosInterfaceAddress = {
|
|
|
27988
28200
|
if (!isTopLevel(node, context)) return [];
|
|
27989
28201
|
const findings = [];
|
|
27990
28202
|
const ethernetInterfaces = getEthernetInterfaces(node);
|
|
27991
|
-
const members =
|
|
27992
|
-
for (const group of node.children) {
|
|
27993
|
-
const member = findStanza7(group, "member");
|
|
27994
|
-
for (const m of member?.children ?? []) {
|
|
27995
|
-
const name = /^interface\s+(\S+)/i.exec(m.id)?.[1];
|
|
27996
|
-
if (name) members.add(name.toLowerCase());
|
|
27997
|
-
}
|
|
27998
|
-
}
|
|
28203
|
+
const members = memberPortNames(node);
|
|
27999
28204
|
for (const iface of ethernetInterfaces) {
|
|
28000
28205
|
if (isDisabled2(iface)) {
|
|
28001
28206
|
continue;
|
|
28002
28207
|
}
|
|
28003
28208
|
const name = (iface.id.split(/\s+/).pop() ?? iface.id).toLowerCase();
|
|
28004
|
-
if (members.has(name) || hasChildCommand(iface, "bond-group") || iface.children.some((c) => /^vif(-s)?\s/i.test(c.id))) {
|
|
28209
|
+
if (members.has(name) || hasChildCommand(iface, "bond-group") || hasChildCommand(iface, "bridge-group") || iface.children.some((c) => /^vif(-s)?\s/i.test(c.id))) {
|
|
28005
28210
|
continue;
|
|
28006
28211
|
}
|
|
28007
28212
|
const hasAddress2 = hasChildCommand(iface, "address");
|
|
@@ -40629,6 +40834,7 @@ var juniper_json_rules_default = {
|
|
|
40629
40834
|
{
|
|
40630
40835
|
id: "JSON-JUNOS-003",
|
|
40631
40836
|
selector: "system",
|
|
40837
|
+
topLevelOnly: true,
|
|
40632
40838
|
vendor: "juniper-junos",
|
|
40633
40839
|
category: "Documentation",
|
|
40634
40840
|
metadata: {
|
|
@@ -40649,6 +40855,7 @@ var juniper_json_rules_default = {
|
|
|
40649
40855
|
{
|
|
40650
40856
|
id: "JSON-JUNOS-004",
|
|
40651
40857
|
selector: "ospf",
|
|
40858
|
+
notUnder: ["groups"],
|
|
40652
40859
|
vendor: "juniper-junos",
|
|
40653
40860
|
category: "Routing",
|
|
40654
40861
|
metadata: {
|
|
@@ -40694,6 +40901,7 @@ var juniper_json_rules_default = {
|
|
|
40694
40901
|
{
|
|
40695
40902
|
id: "JSON-JUNOS-005",
|
|
40696
40903
|
selector: "system",
|
|
40904
|
+
topLevelOnly: true,
|
|
40697
40905
|
vendor: "juniper-junos",
|
|
40698
40906
|
category: "Logging",
|
|
40699
40907
|
metadata: {
|
|
@@ -40894,7 +41102,7 @@ function resolveVersion(injected) {
|
|
|
40894
41102
|
|
|
40895
41103
|
// src/sarif.ts
|
|
40896
41104
|
var TOOL_VERSION = resolveVersion(
|
|
40897
|
-
true ? "0.11.0-rc.
|
|
41105
|
+
true ? "0.11.0-rc.3" : void 0
|
|
40898
41106
|
);
|
|
40899
41107
|
var CWE_GUID = "1A0F2A4E-3B93-4C4E-8CC7-9A4E3A5B9A3A";
|
|
40900
41108
|
function cweNumber(cweId) {
|
|
@@ -43348,7 +43556,7 @@ async function exitIfVendorUndetected() {
|
|
|
43348
43556
|
}
|
|
43349
43557
|
}
|
|
43350
43558
|
var program = new Command2();
|
|
43351
|
-
var cliVersion = resolveVersion(true ? "0.11.0-rc.
|
|
43559
|
+
var cliVersion = resolveVersion(true ? "0.11.0-rc.3" : void 0);
|
|
43352
43560
|
var pluginPackLoaders = [];
|
|
43353
43561
|
var pluginRequests = pluginRequestsFromEnv(process.env);
|
|
43354
43562
|
program.name("sentriflow").description("SentriFlow Network Configuration Validator").version(cliVersion).argument("[files...]", "Path(s) to configuration file(s) (supports multiple files)").option("--ast", "Output the AST instead of rule results").option(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentriflow/cli",
|
|
3
|
-
"version": "0.11.0-rc.
|
|
3
|
+
"version": "0.11.0-rc.3",
|
|
4
4
|
"description": "SentriFlow CLI - Network configuration linter and validator",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"commander": "^14.0.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@sentriflow/core": "0.11.0-rc.
|
|
44
|
-
"@sentriflow/rules-default": "0.11.0-rc.
|
|
43
|
+
"@sentriflow/core": "0.11.0-rc.3",
|
|
44
|
+
"@sentriflow/rules-default": "0.11.0-rc.3",
|
|
45
45
|
"bun-types": "latest",
|
|
46
46
|
"esbuild": "^0.27.0"
|
|
47
47
|
},
|