Skip to content

Commit

Permalink
fix: stanzas not supported for searchbnf.conf
Browse files Browse the repository at this point in the history
Addresses issue #49
  • Loading branch information
JasonConger committed Aug 18, 2022
1 parent 4dbaa8f commit 80a80fd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion out/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const STANZA_ABSOLUTE_REGEX = /^\[(?<stanza>|[^\<\>\:\/]+)\]/ // matches th
const SETTING_REGEX = /^(?<setting>((\w)|\<name\>|\<tag\d\>|\<.+\>).*?)\s*=\s*(?<value>[^\r\n]+)/
const SETTING_PREFIX_REGEX = /^(?<prefix>[^-\.].*?)\<.*?\>/
const SETTING_FREEFORM_REGEX = /^\<(?<setting>.*?)\>/
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 = {
Expand Down Expand Up @@ -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-name>-command"
specConfig.stanzas[0].stanzaType = stanzaTypes.FREEFORM
}
return specConfig
}

Expand Down
10 changes: 10 additions & 0 deletions test/spec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 80a80fd

Please sign in to comment.