-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add IncludeInsecureCiphers option to FTP backend. (#205)
* Add IncludeInsecureCiphers option to FTP backend. * fix tests and add doc * added comment fixes #204 * fixed changelog header
- Loading branch information
Showing
4 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -215,10 +215,11 @@ func (s *optionsSuite) TestFetchTLSConfig() { | |
} | ||
|
||
tests := []struct { | ||
description string | ||
authority string | ||
options Options | ||
expected *tls.Config | ||
description string | ||
authority string | ||
options Options | ||
expected *tls.Config | ||
expectInsecureCipherSuites bool | ||
}{ | ||
{ | ||
description: "check defaults", | ||
|
@@ -239,15 +240,50 @@ func (s *optionsSuite) TestFetchTLSConfig() { | |
}, | ||
expected: cfg, | ||
}, | ||
{ | ||
description: "include insecure cipher suites", | ||
authority: "[email protected]", | ||
options: Options{ | ||
IncludeInsecureCiphers: true, | ||
}, | ||
expected: &tls.Config{ | ||
MinVersion: tls.VersionTLS12, | ||
InsecureSkipVerify: true, //nolint:gosec | ||
ClientSessionCache: tls.NewLRUClientSessionCache(0), | ||
ServerName: "host.com", | ||
}, | ||
expectInsecureCipherSuites: true, | ||
}, | ||
} | ||
|
||
for i := range tests { | ||
auth, err := utils.NewAuthority(tests[i].authority) | ||
s.NoError(err, tests[i].description) | ||
|
||
tlsCfg := fetchTLSConfig(auth, tests[i].options) | ||
s.Equal(tests[i].expected, tlsCfg, tests[i].description) | ||
s.Equal(tests[i].expected.MinVersion, tlsCfg.MinVersion, tests[i].description) | ||
s.Equal(tests[i].expected.InsecureSkipVerify, tlsCfg.InsecureSkipVerify, tests[i].description) | ||
s.Equal(tests[i].expected.ClientSessionCache, tlsCfg.ClientSessionCache, tests[i].description) | ||
s.Equal(tests[i].expected.ServerName, tlsCfg.ServerName, tests[i].description) | ||
s.Equal(tests[i].expected.SessionTicketsDisabled, tlsCfg.SessionTicketsDisabled, tests[i].description) | ||
|
||
if tests[i].expectInsecureCipherSuites { | ||
s.NotEmpty(tlsCfg.CipherSuites, tests[i].description) | ||
s.True(containsInsecureCipherSuites(tlsCfg.CipherSuites), tests[i].description) | ||
} | ||
} | ||
} | ||
|
||
func containsInsecureCipherSuites(suites []uint16) bool { | ||
insecureSuites := tls.InsecureCipherSuites() | ||
for _, s := range suites { | ||
for _, insecureSuite := range insecureSuites { | ||
if s == insecureSuite.ID { | ||
return true | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func (s *optionsSuite) TestFetchProtocol() { | ||
|