Skip to content

Commit e9e3df7

Browse files
committed
apply lint fixes
1 parent 65402ce commit e9e3df7

125 files changed

Lines changed: 1178 additions & 1022 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.rubocop.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
AllCops:
2+
NewCops: enable
3+
Exclude:
4+
- "libraries/**/*"
5+
6+
Layout/LineLength:
7+
Max: 1500
8+
AllowURI: true
9+
IgnoreCopDirectives: true
10+
11+
Naming/FileName:
12+
Enabled: false
13+
14+
Metrics/BlockLength:
15+
Max: 1000
16+
17+
Layout/MultilineBlockLayout:
18+
Enabled: true
19+
20+
Lint/ConstantDefinitionInBlock:
21+
Enabled: false
22+
23+
# Required for Profiles as it can introduce profile errors
24+
Style/NumericPredicate:
25+
Enabled: false
26+
27+
Style/WordArray:
28+
Description: "Use %w or %W for an array of words. (https://rubystyle.guide#percent-w)"
29+
Enabled: false
30+
31+
Style/RedundantPercentQ:
32+
Enabled: true
33+
34+
Style/NestedParenthesizedCalls:
35+
Enabled: false
36+
37+
Style/TrailingCommaInHashLiteral:
38+
Description: "https://docs.rubocop.org/rubocop/cops_style.html#styletrailingcommainhashliteral"
39+
Enabled: true
40+
EnforcedStyleForMultiline: no_comma
41+
42+
Style/TrailingCommaInArrayLiteral:
43+
Enabled: true
44+
EnforcedStyleForMultiline: no_comma
45+
46+
Style/BlockDelimiters:
47+
Enabled: false
48+
49+
Lint/AmbiguousBlockAssociation:
50+
Enabled: false
51+
52+
Metrics/BlockNesting:
53+
Enabled: false
54+
55+
Lint/ShadowingOuterLocalVariable:
56+
Enabled: false
57+
58+
Style/FormatStringToken:
59+
Enabled: false
60+
61+
Style/FrozenStringLiteralComment:
62+
Enabled: false
63+
64+
# The following cops were added to RuboCop, but are not configured.
65+
# Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
66+
# For more information: https://docs.rubocop.org/rubocop/versioning.html
67+
Gemspec/DeprecatedAttributeAssignment:
68+
Enabled: true
69+
Gemspec/RequireMFA: # new in 1.23
70+
Enabled: true
71+
Layout/LineEndStringConcatenationIndentation: # new in 1.18
72+
Enabled: true
73+
Layout/SpaceBeforeBrackets: # new in 1.7
74+
Enabled: true
75+
Lint/AmbiguousAssignment: # new in 1.7
76+
Enabled: true
77+
Lint/AmbiguousOperatorPrecedence: # new in 1.21
78+
Enabled: true
79+
Lint/AmbiguousRange: # new in 1.19
80+
Enabled: true
81+
Lint/DeprecatedConstants: # new in 1.8
82+
Enabled: true
83+
Lint/DuplicateBranch: # new in 1.3
84+
Enabled: true
85+
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
86+
Enabled: true
87+
Lint/EmptyBlock: # new in 1.1
88+
Enabled: true
89+
Lint/EmptyClass: # new in 1.3
90+
Enabled: true
91+
Lint/EmptyInPattern: # new in 1.16
92+
Enabled: true
93+
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
94+
Enabled: true
95+
Lint/LambdaWithoutLiteralBlock: # new in 1.8
96+
Enabled: true
97+
Lint/NoReturnInBeginEndBlocks: # new in 1.2
98+
Enabled: true
99+
Lint/NumberedParameterAssignment: # new in 1.9
100+
Enabled: true
101+
Lint/OrAssignmentToConstant: # new in 1.9
102+
Enabled: true
103+
Lint/RedundantDirGlobSort: # new in 1.8
104+
Enabled: true
105+
Lint/RequireRelativeSelfPath: # new in 1.22
106+
Enabled: true
107+
Lint/SymbolConversion: # new in 1.9
108+
Enabled: true
109+
Lint/ToEnumArguments: # new in 1.1
110+
Enabled: true
111+
Lint/TripleQuotes: # new in 1.9
112+
Enabled: true
113+
Lint/UnexpectedBlockArity: # new in 1.5
114+
Enabled: true
115+
Lint/UnmodifiedReduceAccumulator: # new in 1.1
116+
Enabled: true
117+
Lint/UselessRuby2Keywords: # new in 1.23
118+
Enabled: true
119+
Naming/BlockForwarding: # new in 1.24
120+
Enabled: true
121+
Security/IoMethods: # new in 1.22
122+
Enabled: true
123+
Style/ArgumentsForwarding: # new in 1.1
124+
Enabled: true
125+
Style/CollectionCompact: # new in 1.2
126+
Enabled: true
127+
Style/DocumentDynamicEvalDefinition: # new in 1.1
128+
Enabled: true
129+
Style/EndlessMethod: # new in 1.8
130+
Enabled: true
131+
Style/FileRead: # new in 1.24
132+
Enabled: true
133+
Style/FileWrite: # new in 1.24
134+
Enabled: true
135+
Style/HashConversion: # new in 1.10
136+
Enabled: true
137+
Style/HashExcept: # new in 1.7
138+
Enabled: true
139+
Style/IfWithBooleanLiteralBranches: # new in 1.9
140+
Enabled: true
141+
Style/InPatternThen: # new in 1.16
142+
Enabled: true
143+
Style/MapToHash: # new in 1.24
144+
Enabled: true
145+
Style/MultilineInPatternThen: # new in 1.16
146+
Enabled: true
147+
Style/NegatedIfElseCondition: # new in 1.2
148+
Enabled: true
149+
Style/NilLambda: # new in 1.3
150+
Enabled: true
151+
Style/NumberedParameters: # new in 1.22
152+
Enabled: true
153+
Style/NumberedParametersLimit: # new in 1.22
154+
Enabled: true
155+
Style/OpenStructUse: # new in 1.23
156+
Enabled: true
157+
Style/QuotedSymbols: # new in 1.16
158+
Enabled: true
159+
Style/RedundantArgument: # new in 1.4
160+
Enabled: true
161+
Style/RedundantSelfAssignmentBranch: # new in 1.19
162+
Enabled: true
163+
Style/SelectByRegexp: # new in 1.22
164+
Enabled: true
165+
Style/StringChars: # new in 1.12
166+
Enabled: true
167+
Style/SwapValues: # new in 1.1
168+
Enabled: true

controls/SV-238197.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
end
107107
else
108108
describe command('which Xorg').exit_status do
109-
skip("GUI not installed.\nwhich Xorg exit_status: " + command('which Xorg').exit_status.to_s)
109+
skip("GUI not installed.\nwhich Xorg exit_status: #{command('which Xorg').exit_status}")
110110
end
111111
end
112112
end

controls/SV-238198.rb

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
control 'SV-238198' do
22
title 'The Ubuntu operating system must display the Standard Mandatory DOD Notice and Consent Banner before granting local access to the system via a graphical user logon.'
3-
desc %q(Display of a standardized and approved use notification before granting access to the Ubuntu operating system ensures privacy and security notification verbiage used is consistent with applicable federal laws, Executive Orders, directives, policies, regulations, standards, and guidance.
4-
5-
System use notifications are required only for access via logon interfaces with human users and are not required when such human interfaces do not exist.
6-
7-
The banner must be formatted in accordance with applicable DOD policy. Use the following verbiage for operating systems that can accommodate banners of 1300 characters:
8-
9-
"You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only.
10-
11-
By using this IS (which includes any device attached to this IS), you consent to the following conditions:
12-
13-
-The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM), law enforcement (LE), and counterintelligence (CI) investigations.
14-
15-
-At any time, the USG may inspect and seize data stored on this IS.
16-
17-
-Communications using, or data stored on, this IS are not private, are subject to routine monitoring, interception, and search, and may be disclosed or used for any USG-authorized purpose.
18-
19-
-This IS includes security measures (e.g., authentication and access controls) to protect USG interests--not for your personal benefit or privacy.
20-
21-
-Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching or monitoring of the content of privileged communications, or work product, related to personal representation or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product are private and confidential. See User Agreement for details."
22-
23-
Use the following verbiage for operating systems that have severe limitations on the number of characters that can be displayed in the banner:
24-
3+
desc %q(Display of a standardized and approved use notification before granting access to the Ubuntu operating system ensures privacy and security notification verbiage used is consistent with applicable federal laws, Executive Orders, directives, policies, regulations, standards, and guidance.
4+
5+
System use notifications are required only for access via logon interfaces with human users and are not required when such human interfaces do not exist.
6+
7+
The banner must be formatted in accordance with applicable DOD policy. Use the following verbiage for operating systems that can accommodate banners of 1300 characters:
8+
9+
"You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only.
10+
11+
By using this IS (which includes any device attached to this IS), you consent to the following conditions:
12+
13+
-The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM), law enforcement (LE), and counterintelligence (CI) investigations.
14+
15+
-At any time, the USG may inspect and seize data stored on this IS.
16+
17+
-Communications using, or data stored on, this IS are not private, are subject to routine monitoring, interception, and search, and may be disclosed or used for any USG-authorized purpose.
18+
19+
-This IS includes security measures (e.g., authentication and access controls) to protect USG interests--not for your personal benefit or privacy.
20+
21+
-Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching or monitoring of the content of privileged communications, or work product, related to personal representation or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product are private and confidential. See User Agreement for details."
22+
23+
Use the following verbiage for operating systems that have severe limitations on the number of characters that can be displayed in the banner:
24+
2525
"I've read & consent to terms in IS user agreem't.")
26-
desc 'check', "Verify the Ubuntu operating system displays the Standard Mandatory DOD Notice and Consent Banner before granting access to the operating system via a graphical user logon.
27-
28-
Note: If the system does not have a graphical user interface installed, this requirement is Not Applicable.
29-
30-
Verify the operating system displays the exact approved Standard Mandatory DOD Notice and Consent Banner text with the command:
31-
32-
$ grep ^banner-message-text /etc/gdm3/greeter.dconf-defaults
33-
34-
banner-message-text='You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only.\\n\\nBy using this IS (which includes any device attached to this IS), you consent to the following conditions:\\n\\n-The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM), law enforcement (LE), and counterintelligence (CI) investigations.\\n\\n-At any time, the USG may inspect and seize data stored on this IS.\\n\\n-Communications using, or data stored on, this IS are not private, are subject to routine monitoring, interception, and search, and may be disclosed or used for any USG-authorized purpose.\\n\\n-This IS includes security measures (e.g., authentication and access controls) to protect USG interests--not for your personal benefit or privacy.\\n\\n-Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching or monitoring of the content of privileged communications, or work product, related to personal representation or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product are private and confidential. See User Agreement for details.'
35-
26+
desc 'check', "Verify the Ubuntu operating system displays the Standard Mandatory DOD Notice and Consent Banner before granting access to the operating system via a graphical user logon.
27+
28+
Note: If the system does not have a graphical user interface installed, this requirement is Not Applicable.
29+
30+
Verify the operating system displays the exact approved Standard Mandatory DOD Notice and Consent Banner text with the command:
31+
32+
$ grep ^banner-message-text /etc/gdm3/greeter.dconf-defaults
33+
34+
banner-message-text='You are accessing a U.S. Government (USG) Information System (IS) that is provided for USG-authorized use only.\\n\\nBy using this IS (which includes any device attached to this IS), you consent to the following conditions:\\n\\n-The USG routinely intercepts and monitors communications on this IS for purposes including, but not limited to, penetration testing, COMSEC monitoring, network operations and defense, personnel misconduct (PM), law enforcement (LE), and counterintelligence (CI) investigations.\\n\\n-At any time, the USG may inspect and seize data stored on this IS.\\n\\n-Communications using, or data stored on, this IS are not private, are subject to routine monitoring, interception, and search, and may be disclosed or used for any USG-authorized purpose.\\n\\n-This IS includes security measures (e.g., authentication and access controls) to protect USG interests--not for your personal benefit or privacy.\\n\\n-Notwithstanding the above, using this IS does not constitute consent to PM, LE or CI investigative searching or monitoring of the content of privileged communications, or work product, related to personal representation or services by attorneys, psychotherapists, or clergy, and their assistants. Such communications and work product are private and confidential. See User Agreement for details.'
35+
3636
If the banner-message-text is missing, commented out, or does not match the Standard Mandatory DOD Notice and Consent Banner exactly, this is a finding."
3737
desc 'fix', %q(Edit the "/etc/gdm3/greeter.dconf-defaults" file.
3838
@@ -76,10 +76,10 @@
7676

7777
expected_banner_text = input('banner_text')
7878
clean_banner = expected_banner_text.gsub(/[\r\n\s]/, '')
79-
gdm3_defaults_file = input('gdm3_config_file')
79+
input('gdm3_config_file')
8080

8181
actual_banner_text = parse_config_file('/etc/gdm3/greeter.dconf-defaults').params['org/gnome/login-screen']['banner-message-text']
82-
clean_actual_banner = actual_banner_text.gsub(/[\r\n\s]/, '').gsub(/\\n/, '').gsub(/'/, '')
82+
clean_actual_banner = actual_banner_text.gsub(/[\r\n\s]/, '').gsub('\\n', '').gsub('\'', '')
8383

8484
if package('gdm3').installed?
8585
describe 'The SSHD Banner is set to the standard banner and has the correct text' do

controls/SV-238199.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
end
6161
else
6262
describe command('which Xorg').exit_status do
63-
skip("GUI not installed.\nwhich Xorg exit_status: " + command('which Xorg').exit_status.to_s)
63+
skip("GUI not installed.\nwhich Xorg exit_status: #{command('which Xorg').exit_status}")
6464
end
6565
end
6666
end

controls/SV-238201.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
its('use_mappers') { should cmp 'pwent' }
5151
end
5252
else
53-
describe(config_file + ' exists') do
53+
describe("#{config_file} exists") do
5454
subject { config_file_exists }
5555
it { should be true }
5656
end

controls/SV-238203.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
be changed periodically. If the operating system does not limit the lifetime of passwords and
66
force users to change their passwords, there is the risk that the operating system passwords
77
could be compromised.'
8-
desc 'check', 'Verify the Ubuntu operating system enforces a 60-day maximum password lifetime for new user accounts by running the following command:
9-
10-
$ grep -i ^pass_max_days /etc/login.defs
11-
PASS_MAX_DAYS 60
12-
8+
desc 'check', 'Verify the Ubuntu operating system enforces a 60-day maximum password lifetime for new user accounts by running the following command:
9+
10+
$ grep -i ^pass_max_days /etc/login.defs
11+
PASS_MAX_DAYS 60
12+
1313
If the "PASS_MAX_DAYS" parameter value is greater than 60, or commented out, this is a finding.'
1414
desc 'fix', 'Configure the Ubuntu operating system to enforce a 60-day maximum password lifetime.
1515

controls/SV-238204.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@
3030
3131
If the root password
3232
entry does not begin with "password_pbkdf2", this is a finding.'
33-
desc 'fix', %q(Configure the system to require a password for authentication upon booting into single-user and maintenance modes.
34-
35-
Generate an encrypted (grub) password for root with the following command:
36-
37-
$ grub-mkpasswd-pbkdf2
38-
Enter Password:
39-
Reenter Password:
40-
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.MFU48934NJD84NF8NSD39993JDHF84NG
41-
42-
Using the hash from the output, modify the "/etc/grub.d/40_custom" file with the following command to add a boot password:
43-
44-
$ sudo sed -i '$i set superusers=\"root\"\npassword_pbkdf2 root <hash>' /etc/grub.d/40_custom
45-
46-
where <hash> is the hash generated by grub-mkpasswd-pbkdf2 command.
47-
48-
Generate an updated "grub.conf" file with the new password by using the following command:
49-
33+
desc 'fix', %q(Configure the system to require a password for authentication upon booting into single-user and maintenance modes.
34+
35+
Generate an encrypted (grub) password for root with the following command:
36+
37+
$ grub-mkpasswd-pbkdf2
38+
Enter Password:
39+
Reenter Password:
40+
PBKDF2 hash of your password is grub.pbkdf2.sha512.10000.MFU48934NJD84NF8NSD39993JDHF84NG
41+
42+
Using the hash from the output, modify the "/etc/grub.d/40_custom" file with the following command to add a boot password:
43+
44+
$ sudo sed -i '$i set superusers=\"root\"\npassword_pbkdf2 root <hash>' /etc/grub.d/40_custom
45+
46+
where <hash> is the hash generated by grub-mkpasswd-pbkdf2 command.
47+
48+
Generate an updated "grub.conf" file with the new password by using the following command:
49+
5050
$ sudo update-grub)
5151
impact 0.7
5252
tag severity: 'high'

controls/SV-238205.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
findings = Set[]
4444

4545
user_list.each do |user_name|
46-
findings = findings << user_name
46+
findings <<= user_name
4747
end
4848
describe 'Duplicate User IDs (UIDs) must not exist for interactive users' do
4949
subject { findings.to_a }

controls/SV-238206.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
3232
If the sudo group contains users not needing access to
3333
security functions, this is a finding.'
34-
desc 'fix', 'Configure the sudo group with only members requiring access to security functions.
35-
36-
To remove a user from the sudo group, run:
37-
34+
desc 'fix', 'Configure the sudo group with only members requiring access to security functions.
35+
36+
To remove a user from the sudo group, run:
37+
3838
$ sudo gpasswd -d <username> sudo'
3939
impact 0.7
4040
tag severity: 'high'
@@ -50,7 +50,7 @@
5050

5151
sudo_accounts = input('sudo_accounts')
5252

53-
if sudo_accounts.count > 0
53+
if sudo_accounts.any?
5454
sudo_accounts.each do |account|
5555
describe group('sudo') do
5656
its('members') { should include account }

controls/SV-238207.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
This capability is typically reserved for specific operating
2222
system functionality where the system owner, data owner, or organization requires
2323
additional assurance."
24-
desc 'check', 'Verify the operating system automatically terminates a user session after inactivity timeouts have expired.
25-
26-
Check that the "TMOUT" environment variable is set in the "/etc/bash.bashrc" file or in any file inside the "/etc/profile.d/" directory by performing the following command:
27-
28-
$ sudo grep -E "\\bTMOUT=[0-9]+" /etc/bash.bashrc /etc/profile.d/*
29-
30-
TMOUT=600
31-
24+
desc 'check', 'Verify the operating system automatically terminates a user session after inactivity timeouts have expired.
25+
26+
Check that the "TMOUT" environment variable is set in the "/etc/bash.bashrc" file or in any file inside the "/etc/profile.d/" directory by performing the following command:
27+
28+
$ sudo grep -E "\\bTMOUT=[0-9]+" /etc/bash.bashrc /etc/profile.d/*
29+
30+
TMOUT=600
31+
3232
If "TMOUT" is not set, or if the value is "0" or is commented out, this is a finding.'
3333
desc 'fix', 'Configure the operating system to automatically terminate a user session after inactivity
3434
timeouts have expired or at shutdown.

0 commit comments

Comments
 (0)