diff --git a/package-lock.json b/package-lock.json index fd2765b0..4e6b62b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mitre/inspec-objects", - "version": "0.0.34", + "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@mitre/inspec-objects", - "version": "0.0.34", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { "@types/flat": "^5.0.2", diff --git a/src/objects/control.ts b/src/objects/control.ts index e058d096..17b3e7d7 100644 --- a/src/objects/control.ts +++ b/src/objects/control.ts @@ -200,7 +200,6 @@ export default class Control { } else { result += ` ref ${escapeQuotes(ref.ref?.toString() || '')}, url: ${escapeQuotes(ref.url || '')}` } - }); } @@ -228,7 +227,14 @@ export default class Control { result += ` tag ${tag}: ${escapeQuotes(value)}\n`; } } else { - result += ` tag ${tag}: nil\n`; + const nilTagList = ['severity', 'satisfies'] + if (nilTagList.includes(tag)) { + result += ` tag ${tag}: nil\n`; + } + else { + result += ` tag '${tag}'\n`; + } + if (verbose) {logger.info(`${this.id} does not have a value for tag: ${tag}`);} } }); diff --git a/test/sample_data/controls-cookstyle/inputs-interpolation/SV-204392.rb b/test/sample_data/controls-cookstyle/inputs-interpolation/SV-204392.rb index bdc5dcfc..c1165fda 100644 --- a/test/sample_data/controls-cookstyle/inputs-interpolation/SV-204392.rb +++ b/test/sample_data/controls-cookstyle/inputs-interpolation/SV-204392.rb @@ -45,8 +45,8 @@ tag cci: ['CCI-001494', 'CCI-001496', 'CCI-002165', 'CCI-002235'] tag nist: ['AU-9', 'AU-9 (3)', 'AC-3 (4)', 'AC-6 (10)'] tag subsystems: ['permissions', 'package', 'rpm'] - tag host: nil - tag container: nil + tag 'host' + tag 'container' if input('disable_slow_controls') describe "This control consistently takes a long time to run and has been disabled diff --git a/test/tests/control.spec.ts b/test/tests/control.spec.ts index 23df5a95..0f22c0cc 100644 --- a/test/tests/control.spec.ts +++ b/test/tests/control.spec.ts @@ -17,9 +17,11 @@ TEST_USE_CASES.set('V-93149','should properly write a control with special chara describe('The control functionality', () => { const cookstyle_profile = processInSpecProfile(fs.readFileSync('test/sample_data/inspec/json/cookstyle-controls-profile.json', 'utf-8')) + const allKeys =[ ...TEST_USE_CASES.keys() ]; cookstyle_profile.controls.forEach(control => { - // Write the new control to the controls folder - fs.writeFileSync(path.join('test/sample_data/', 'controls-test-results', `${control.id}.rb`), control.toRuby(true)) + if (allKeys.includes(control.id)) { + fs.writeFileSync(path.join('test/sample_data/', 'controls-test-results', `${control.id}.rb`), control.toRuby(true)) + } }) // These checks are comparing what the function "toRuby" is outputting with a small sample profile created from