Skip to content

Commit c974a08

Browse files
committed
Merge remote-tracking branch 'upstream/SLE-15-SP6' into huha-pw-leak-master
1 parent 2ac81c0 commit c974a08

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

package/yast2-network.changes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
-------------------------------------------------------------------
2+
Wed Mar 13 14:20:25 UTC 2024 - Stefan Hundhammer <[email protected]>
3+
4+
- Guard secret attributes against leaking to the log (bsc#1221194)
5+
- 5.0.3
6+
17
-------------------------------------------------------------------
28
Tue Jan 16 10:34:01 UTC 2024 - Knut Anderssen <[email protected]>
39

package/yast2-network.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818

1919
Name: yast2-network
20-
Version: 5.0.2
20+
Version: 5.0.3
2121
Release: 0
2222
Summary: YaST2 - Network Configuration
2323
License: GPL-2.0-only

src/lib/y2network/connection_config/wireless.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@
1919

2020
require "y2network/connection_config/base"
2121
require "yast2/equatable"
22+
require "yast2/secret_attributes"
2223

2324
module Y2Network
2425
module ConnectionConfig
2526
# Configuration for wireless connections
2627
class Wireless < Base
2728
include Yast2::Equatable
29+
include Yast2::SecretAttributes
2830

2931
# wireless options
3032
#
@@ -37,13 +39,15 @@ class Wireless < Base
3739
attr_accessor :nwid
3840
# @return [Symbol] Authorization mode (:open, :shared, :psk, :eap)
3941
attr_accessor :auth_mode
42+
4043
# FIXME: Consider moving keys to different classes.
4144
# @return [String] WPA preshared key
42-
attr_accessor :wpa_psk
45+
secret_attr :wpa_psk
4346
# @return [Integer]
4447
attr_accessor :key_length
48+
4549
# @return [Array<String>] WEP keys
46-
attr_accessor :keys
50+
secret_attr :keys
4751
# @return [Integer] default WEP key
4852
attr_accessor :default_key
4953
# @return [String]
@@ -63,9 +67,10 @@ class Wireless < Base
6367
# FIXME: Consider an enum
6468
# @return [Integer] (0, 1, 2)
6569
attr_accessor :ap_scanmode
70+
6671
# TODO: unify psk and password and write correct one depending on mode
6772
# @return [String]
68-
attr_accessor :wpa_password
73+
secret_attr :wpa_password
6974
# @return [String]
7075
attr_accessor :wpa_identity
7176
# @return [String] initial identity used for creating tunnel
@@ -76,8 +81,9 @@ class Wireless < Base
7681
attr_accessor :client_cert
7782
# @return [String] client private key used to encrypt for TLS
7883
attr_accessor :client_key
84+
7985
# @return [String] client private key password
80-
attr_accessor :client_key_password
86+
secret_attr :client_key_password
8187

8288
def initialize
8389
super

test/y2network/config_test.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,4 +604,45 @@
604604
expect(new_config.connections).to eq(updated_connections)
605605
end
606606
end
607+
608+
context "secret attributes (passwords, keys)" do
609+
let(:conn) do
610+
Y2Network::ConnectionConfig::Wireless.new.tap do |c|
611+
c.wpa_psk = "s3cr3t"
612+
c.wpa_password = "s3cr3t"
613+
c.client_key_password = "s3cr3t"
614+
end
615+
end
616+
617+
describe ".inspect" do
618+
it "does not leak a password" do
619+
expect(conn.inspect).to_not match(/s3cr3t/)
620+
end
621+
622+
it "contains <secret> instead of passwords" do
623+
expect(conn.inspect).to match(/<secret>/)
624+
end
625+
end
626+
627+
describe ".to_s" do
628+
it "does not leak a password" do
629+
# it's usually something like
630+
# "#<Y2Network::ConnectionConfig::Wireless:0x000055b752576318>"
631+
# so there shouldn't be any attributes - just making sure
632+
expect(conn.to_s).to_not match(/s3cr3t/)
633+
end
634+
end
635+
636+
describe ".wpa_psk" do
637+
it "returns the real password" do
638+
expect(conn.wpa_psk).to eq("s3cr3t")
639+
end
640+
end
641+
642+
describe ".wpa_psk.to_s" do
643+
it "returns the real password" do
644+
expect(conn.wpa_psk.to_s).to eq("s3cr3t")
645+
end
646+
end
647+
end
607648
end

0 commit comments

Comments
 (0)