Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the toRuby Process #25

Merged
merged 2 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/objects/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ export default class Control {
} else {
result += ` ref ${escapeQuotes(ref.ref?.toString() || '')}, url: ${escapeQuotes(ref.url || '')}`
}

});
}

Expand Down Expand Up @@ -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}`);}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions test/tests/control.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down