Skip to content

Commit 1f0b772

Browse files
Address automated CodeRabbit review feedback
- Assert root ownership and group for /etc/profile.d/01-tmout.sh in rspec tests - Ensure MaxStartups scan validates single directive in sshd_config - Normalize MaxStartups sed pattern to match tab/space indentations and quote chroot paths - Quote chroot path expansions in TMOUT profile script creation
1 parent 438eb27 commit 1f0b772

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

bosh-stemcell/spec/support/os_image_shared_examples.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
describe file("/etc/profile.d/01-tmout.sh") do
7575
it { should be_file }
7676
it { should be_mode(0o644) }
77+
it { should be_owned_by("root") }
78+
its(:group) { should eq("root") }
7779
its(:content) { should match(/^readonly TMOUT=900$/) }
7880
its(:content) { should match(/^export TMOUT$/) }
7981
end
@@ -239,7 +241,7 @@
239241
end
240242

241243
it "sets MaxStartups to 10:30:60" do
242-
expect(sshd_config.content).to match(/^MaxStartups 10:30:60$/)
244+
expect(sshd_config.content.scan(/^[ \t]*MaxStartups\s+\S+$/)).to contain_exactly("MaxStartups 10:30:60")
243245
end
244246

245247
it "sets PermitEmptyPasswords to no (stig: V-38614)" do

stemcell_builder/stages/base_ssh/apply.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ echo 'X11Forwarding no' >> $chroot/etc/ssh/sshd_config
2424
sed "/^ *MaxAuthTries/d" -i $chroot/etc/ssh/sshd_config
2525
echo 'MaxAuthTries 3' >> $chroot/etc/ssh/sshd_config
2626

27-
sed "/^ *MaxStartups/d" -i $chroot/etc/ssh/sshd_config
28-
echo 'MaxStartups 10:30:60' >> $chroot/etc/ssh/sshd_config
27+
sed "/^[ \t]*MaxStartups/d" -i "$chroot/etc/ssh/sshd_config"
28+
echo 'MaxStartups 10:30:60' >> "$chroot/etc/ssh/sshd_config"
2929

3030
sed "/^ *PermitEmptyPasswords/d" -i $chroot/etc/ssh/sshd_config
3131
echo 'PermitEmptyPasswords no' >> $chroot/etc/ssh/sshd_config

stemcell_builder/stages/bosh_users/apply.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ echo "source /etc/profile.d/00-bosh-ps1" >> $chroot/home/vcap/.bashrc
3838
echo "source /etc/profile.d/00-bosh-ps1" >> $chroot/etc/skel/.bashrc
3939

4040
# configure idle session shell timeout
41-
cat << 'EOF' > $chroot/etc/profile.d/01-tmout.sh
41+
cat << 'EOF' > "$chroot/etc/profile.d/01-tmout.sh"
4242
readonly TMOUT=900
4343
export TMOUT
4444
EOF
45-
chmod 0644 $chroot/etc/profile.d/01-tmout.sh
45+
chmod 0644 "$chroot/etc/profile.d/01-tmout.sh"

0 commit comments

Comments
 (0)