-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix describe block extraction bug (#18)
* Add test for metadata in describe block Signed-off-by: Pavan Kumar Bondalapati <pbondalapati@mitre.org> * Apply cookstyle format * Add test cases for describe block * Handle describe block test cases * Update test description * Update JSON object after cookstyle format * Overhaul * Fix describe block extraction bug * Add test case for multi-line describe block * Add escaped newline after joining strings * added test case for keywords showing up inside strings in the test code Signed-off-by: Will Dower <wdower@mitre.org> * fixed whitespacing in test case for keywords in strings Signed-off-by: Will Dower <wdower@mitre.org> * changed test controls dir name * Rename test suite for describe block extraction * Add comments to helper functions * Implement enum to specify magic numbers * Eliminate unneeded function and update some variable names Signed-off-by: Emily Rodriguez <ecrodriguez@mm279976-pc.lan> * Add example of percent string/literal in comment * Transfer stack push/pop conditions to constants * Update file name for backticks.rb * Add test cases for delimiters in header * Add handling for variable delimiters * Remove dependency on getDistinctRanges() * Update package-lock.json from npm upgrade * Remove unnecessary index update * Delete commented index update * add comments and update some variable names for clarity Signed-off-by: Emily Rodriguez <ecrodriguez@mm279976-pc.lan> * update to include the filtering for only multiline ranges Signed-off-by: Emily Rodriguez <ecrodriguez@mm279976-pc.lan> --------- Signed-off-by: Pavan Kumar Bondalapati <pbondalapati@mitre.org> Signed-off-by: Will Dower <wdower@mitre.org> Signed-off-by: Emily Rodriguez <ecrodriguez@mm279976-pc.lan> Co-authored-by: Pavan Kumar Bondalapati <pbondalapati@mitre.org> Co-authored-by: Will Dower <wdower@mitre.org> Co-authored-by: George Dias <gdias@mitre.org> Co-authored-by: Emily Rodriguez <ecrodriguez@mm279976-pc.lan>
- Loading branch information
1 parent
87ed0a8
commit 54a3888
Showing
26 changed files
with
608 additions
and
61 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
control 'SV-230385' do | ||
title 'RHEL 8 must define default permissions for logon and non-logon shells.' | ||
desc "The umask controls the default access mode assigned to newly created | ||
files. A umask of 077 limits new files to mode 600 or less permissive. Although | ||
umask can be represented as a four-digit number, the first digit representing | ||
special access modes is typically ignored or required to be \"0\". This | ||
requirement applies to the globally configured system defaults and the local | ||
interactive user defaults for each account on the system." | ||
desc 'rationale', '' | ||
desc 'check', " | ||
Verify that the umask default for installed shells is \"077\". | ||
Check for the value of the \"UMASK\" parameter in the \"/etc/bashrc\" and | ||
\"/etc/csh.cshrc\" files with the following command: | ||
Note: If the value of the \"UMASK\" parameter is set to \"000\" in either | ||
the \"/etc/bashrc\" or the \"/etc/csh.cshrc\" files, the Severity is raised to | ||
a CAT I. | ||
# grep -i umask /etc/bashrc /etc/csh.cshrc | ||
/etc/bashrc: umask 077 | ||
/etc/bashrc: umask 077 | ||
/etc/csh.cshrc: umask 077 | ||
/etc/csh.cshrc: umask 077 | ||
If the value for the \"UMASK\" parameter is not \"077\", or the \"UMASK\" | ||
parameter is missing or is commented out, this is a finding. | ||
" | ||
desc 'fix', " | ||
Configure the operating system to define default permissions for all | ||
authenticated users in such a way that the user can only read and modify their | ||
own files. | ||
Add or edit the lines for the \"UMASK\" parameter in the \"/etc/bashrc\" | ||
and \"etc/csh.cshrc\" files to \"077\": | ||
UMASK 077 | ||
" | ||
impact 0.5 | ||
tag severity: 'medium' | ||
tag gtitle: 'SRG-OS-000480-GPOS-00227' | ||
tag gid: 'V-230385' | ||
tag rid: 'SV-230385r627750_rule' | ||
tag stig_id: 'RHEL-08-020353' | ||
tag fix_id: 'F-33029r567902_fix' | ||
tag cci: ['CCI-000366'] | ||
tag nist: ['CM-6 b'] | ||
|
||
umask_regexp = /umask\s*(?<umask_code>\d\d\d)/ | ||
|
||
bashrc_umask = file('/etc/bashrc').content.match(umask_regexp)[:umask_code] | ||
cshrc_umask = file('/etc/csh.cshrc').content.match(umask_regexp)[:umask_code] | ||
|
||
if bashrc_umask == '000' || cshrc_umask == '000' | ||
impact 0.7 | ||
tag severity: 'high' | ||
end | ||
|
||
describe 'umask value defined in /etc/bashrc' do | ||
subject { bashrc_umask } | ||
it { should cmp '077' } | ||
end | ||
describe 'umask value defined in /etc/csh.cshrc' do | ||
subject { cshrc_umask } | ||
it { should cmp '077' } | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
test/sample_data/controls-for-describe-tests/array-in-header.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
control 'array-in-header' do | ||
tag array: [1, 2, 3, 4, 5] | ||
tag array: [1, 2, | ||
3, 4, 5] | ||
tag array: [1, | ||
2, | ||
|
||
3, | ||
4, 5] | ||
|
||
describe_block = nil | ||
end |
15 changes: 15 additions & 0 deletions
15
test/sample_data/controls-for-describe-tests/back-ticks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
control `back-ticks` do | ||
title `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | ||
eiusmod tempor incididunt ut labore et dolore magna aliqua.` | ||
desc `Enim lobortis scelerisque \`fermentum\` dui faucibus.` | ||
desc `\`Amet dictum sit amet justo. Massa id neque aliquam vestibulum | ||
morbi blandit cursus risus. Rutrum tellus pellentesque eu tincidunt | ||
tortor aliquam nulla facilisi. Molestie nunc non blandit massa enim. | ||
At urna condimentum mattis pellentesque id nibh tortor. Amet luctus | ||
venenatis lectus magna fringilla.\`` | ||
impact 0.5 | ||
tag `back-ticks`: `back ticks` | ||
tag `escape` : `\`ticks\`` | ||
|
||
describe_block = nil | ||
end |
Oops, something went wrong.