Skip to content

Commit ba23d03

Browse files
committed
Increase pwd obfuscation min length [ci fast]
Signed-off-by: Paolo Di Tommaso <[email protected]>
1 parent 7236f83 commit ba23d03

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

modules/nextflow/src/main/groovy/nextflow/util/ProxyConfig.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ProxyConfig {
4141
def result = protocol ? "protocol=$protocol; host=$host" : "host=$host"
4242
if( port ) result += "; port=$port"
4343
if( username ) result += "; username=$username"
44-
if( password ) result += "; password=${password.redact()}"
44+
if( password ) result += "; password=${StringUtils.redact(password)}"
4545
return "ProxyConfig[$result]"
4646
}
4747

modules/nextflow/src/test/groovy/nextflow/scm/RepositoryProviderTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ class RepositoryProviderTest extends Specification {
8080
when:
8181
result = provider.getAuthObfuscated()
8282
then:
83-
provider.getUser() >> 'foo123'
84-
provider.getPassword() >> 'bar456'
83+
provider.getUser() >> 'foo1234567890'
84+
provider.getPassword() >> 'bar4567890'
8585
and:
8686
result == 'foo****:bar****'
8787

modules/nf-commons/src/main/nextflow/extension/Bolts.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ class Bolts {
893893
}
894894
}
895895

896+
@Deprecated
896897
static redact(String self, int max=5, String suffix='...') {
897898
if( !self )
898899
return self

modules/nf-commons/src/main/nextflow/util/StringUtils.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class StringUtils {
9898
if( !value )
9999
return '(empty)'
100100
final str = value.toString()
101-
return str.length()>=5 ? str[0..2] + '****' : '****'
101+
return str.length()>=10 ? str[0..2] + '****' : '****'
102102
}
103103

104104
static String redactUrlPassword(value) {

modules/nf-commons/src/test/nextflow/util/StringUtilsTest.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ class StringUtilsTest extends Specification {
8686
[foo:'Hello'] | [foo:'Hello']
8787
[foo: [bar: 'World']] | [foo: [bar: 'World']]
8888
[foo: [password:'hola', token:'hi']] | [foo: [password:'****', token:'****']]
89-
[foo: [password:'12345678']] | [foo: [password:'123****']]
89+
[foo: [password:'1234567890']] | [foo: [password:'123****']]
9090
[foo: [customPassword:'hola']] | [foo: [customPassword:'****']]
9191
[foo: [towerLicense:'hola']] | [foo: [towerLicense:'****']]
9292
[url: 'redis://host:port'] | [url: 'redis://host:port']
93-
[url: 'redis://secret@host:port'] | [url: 'redis://sec****@host:port']
94-
[url: 'ftp://secret@host:port/x/y'] | [url: 'ftp://sec****@host:port/x/y']
93+
[url: 'redis://secret@host:port'] | [url: 'redis://****@host:port']
94+
[url: 'ftp://secretlong@host:port/x/y'] | [url: 'ftp://sec****@host:port/x/y']
9595
}
9696

9797
@Unroll
@@ -117,9 +117,9 @@ class StringUtilsTest extends Specification {
117117
where:
118118
SECRET | EXPECTED
119119
'hi' | '****'
120-
'Hello' | 'Hel****'
121-
'World' | 'Wor****'
122-
'12345678' | '123****'
120+
'Hello' | '****'
121+
'World' | '****'
122+
'1234567890' | '123****'
123123
'hola' | '****'
124124
null | '(null)'
125125
'' | '(empty)'
@@ -134,7 +134,7 @@ class StringUtilsTest extends Specification {
134134
SECRET | EXPECTED
135135
'hi' | 'hi'
136136
'http://foo/bar' | 'http://foo/bar'
137-
'http://secret@foo/bar' | 'http://sec****@foo/bar'
137+
'http://secret@foo/bar' | 'http://****@foo/bar'
138138
}
139139

140140
def 'should check ipv6' () {

plugins/nf-azure/src/main/nextflow/cloud/azure/config/AzBatchOpts.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import java.util.regex.Pattern
2323
import groovy.transform.CompileStatic
2424
import nextflow.cloud.CloudTransferOptions
2525
import nextflow.util.Duration
26+
import nextflow.util.StringUtils
27+
2628
/**
2729
* Model Azure Batch pool config settings
2830
*
@@ -88,7 +90,7 @@ class AzBatchOpts implements CloudTransferOptions {
8890
}
8991

9092
String toString() {
91-
"endpoint=$endpoint; account-name=$accountName; account-key=${accountKey?.redact()}"
93+
"endpoint=$endpoint; account-name=$accountName; account-key=${StringUtils.redact(accountKey)}"
9294
}
9395

9496
private List<String> endpointParts() {

0 commit comments

Comments
 (0)