From 80a80fdeb3a369319f28a15b32bc64a32069d639 Mon Sep 17 00:00:00 2001 From: Jason Conger Date: Thu, 18 Aug 2022 18:27:59 -0500 Subject: [PATCH] fix: stanzas not supported for searchbnf.conf Addresses issue #49 --- out/spec.js | 8 +++++++- test/spec.test.js | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/out/spec.js b/out/spec.js index a580914..e6d228b 100644 --- a/out/spec.js +++ b/out/spec.js @@ -25,7 +25,7 @@ const STANZA_ABSOLUTE_REGEX = /^\[(?|[^\<\>\:\/]+)\]/ // matches th const SETTING_REGEX = /^(?((\w)|\|\|\<.+\>).*?)\s*=\s*(?[^\r\n]+)/ const SETTING_PREFIX_REGEX = /^(?[^-\.].*?)\<.*?\>/ const SETTING_FREEFORM_REGEX = /^\<(?.*?)\>/ -const modularSpecFiles = ["inputs.conf.spec", "alert_actions.conf.spec", "indexes.conf.spec"]; +const modularSpecFiles = ["inputs.conf.spec", "alert_actions.conf.spec", "indexes.conf.spec", "searchbnf.conf.spec"]; const DROPDOWN_PLACEHOLDER_REGEX = /(\[|{)\w+(\|\w+)+(]|})/g const lineTypes = { @@ -137,6 +137,12 @@ function parseSpecConfig (str, name) { str = str.replace(BLANK_LINE_REGEX, "") } + + // Special case: searchbnf.conf.spec has a postfix stanza that is commented out. Add it here. + if(name == "searchbnf.conf.spec") { + specConfig.stanzas[0].stanzaName = "-command" + specConfig.stanzas[0].stanzaType = stanzaTypes.FREEFORM + } return specConfig } diff --git a/test/spec.test.js b/test/spec.test.js index 7f780ad..892362a 100644 --- a/test/spec.test.js +++ b/test/spec.test.js @@ -113,6 +113,16 @@ describe('inputs.conf', () => { }); +describe('searchbnf.conf', () => { + let specFileName = "searchbnf.conf.spec"; + let specFilePath = path.join(specFolderLocation, specFileVersion, specFileName) + let specConfig = splunkSpec.getSpecConfig(specFilePath); + + it('setting "syntax = mything" should be valid for stanza [mything-command]', () => { + assert.equal(splunkSpec.isSettingValid(specConfig, "[mything-command]", "syntax = mything"), true); + }); +}); + describe('serverclass.conf', () => { let specFileName = "serverclass.conf.spec"; let specFilePath = path.join(specFolderLocation, specFileVersion, specFileName)