Skip to content

Commit f311bd1

Browse files
authored
fix: Remove the requirement for a prefix on secret strings (#1446)
Rather than requiring strings start with either plaintext: or gsm: we are going to use a string interpolation like we use in multihttp checks.
1 parent f31a1d1 commit f311bd1

File tree

2 files changed

+0
-105
lines changed

2 files changed

+0
-105
lines changed

pkg/pb/synthetic_monitoring/checks_extra.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -675,17 +675,6 @@ func (s *HttpSettings) Validate() error {
675675
}
676676
}
677677

678-
// Validate secret manager enabled settings
679-
if s.SecretManagerEnabled {
680-
if !isValidSecretManagerValue(s.BearerToken) {
681-
return ErrInvalidHttpBearerToken
682-
}
683-
684-
if s.BasicAuth != nil && !isValidSecretManagerValue(s.BasicAuth.Password) {
685-
return ErrInvalidHttpBasicAuthPassword
686-
}
687-
}
688-
689678
return nil
690679
}
691680

@@ -1465,15 +1454,6 @@ func inClosedRange[T constraints.Ordered](v, lower, upper T) bool {
14651454
return v >= lower && v <= upper
14661455
}
14671456

1468-
// isValidSecretManagerValue returns true if the value is valid for secret manager.
1469-
// A value is valid if it's empty or starts with "plaintext:" or "gsm:".
1470-
func isValidSecretManagerValue(value string) bool {
1471-
if len(value) == 0 {
1472-
return true
1473-
}
1474-
return strings.HasPrefix(value, "plaintext:") || strings.HasPrefix(value, "gsm:")
1475-
}
1476-
14771457
func GetCheckInstance(checkType CheckType) Check {
14781458
var validCheckCases = map[CheckType]Check{
14791459
CheckTypeDns: {

pkg/pb/synthetic_monitoring/checks_extra_test.go

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,91 +1214,6 @@ func TestHttpSettingsValidate(t *testing.T) {
12141214
},
12151215
expectError: false,
12161216
},
1217-
"secret manager enabled with valid bearer token": {
1218-
input: HttpSettings{
1219-
SecretManagerEnabled: true,
1220-
BearerToken: "plaintext:valid-token",
1221-
},
1222-
expectError: false,
1223-
},
1224-
"secret manager enabled with gsm bearer token": {
1225-
input: HttpSettings{
1226-
SecretManagerEnabled: true,
1227-
BearerToken: "gsm:my-bearer-token",
1228-
},
1229-
expectError: false,
1230-
},
1231-
"secret manager enabled with empty bearer token": {
1232-
input: HttpSettings{
1233-
SecretManagerEnabled: true,
1234-
BearerToken: "",
1235-
},
1236-
expectError: false,
1237-
},
1238-
"secret manager enabled with invalid bearer token": {
1239-
input: HttpSettings{
1240-
SecretManagerEnabled: true,
1241-
BearerToken: "invalid-token",
1242-
},
1243-
expectError: true,
1244-
},
1245-
"secret manager enabled with valid basic auth password": {
1246-
input: HttpSettings{
1247-
SecretManagerEnabled: true,
1248-
BasicAuth: &BasicAuth{
1249-
Username: "user",
1250-
Password: "plaintext:valid-password",
1251-
},
1252-
},
1253-
expectError: false,
1254-
},
1255-
"secret manager enabled with gsm basic auth password": {
1256-
input: HttpSettings{
1257-
SecretManagerEnabled: true,
1258-
BasicAuth: &BasicAuth{
1259-
Username: "user",
1260-
Password: "gsm:my-password",
1261-
},
1262-
},
1263-
expectError: false,
1264-
},
1265-
"secret manager enabled with empty basic auth password": {
1266-
input: HttpSettings{
1267-
SecretManagerEnabled: true,
1268-
BasicAuth: &BasicAuth{
1269-
Username: "user",
1270-
Password: "",
1271-
},
1272-
},
1273-
expectError: false,
1274-
},
1275-
"secret manager enabled with invalid basic auth password": {
1276-
input: HttpSettings{
1277-
SecretManagerEnabled: true,
1278-
BasicAuth: &BasicAuth{
1279-
Username: "user",
1280-
Password: "invalid-password",
1281-
},
1282-
},
1283-
expectError: true,
1284-
},
1285-
"secret manager disabled with invalid bearer token": {
1286-
input: HttpSettings{
1287-
SecretManagerEnabled: false,
1288-
BearerToken: "invalid-token",
1289-
},
1290-
expectError: false,
1291-
},
1292-
"secret manager disabled with invalid basic auth password": {
1293-
input: HttpSettings{
1294-
SecretManagerEnabled: false,
1295-
BasicAuth: &BasicAuth{
1296-
Username: "user",
1297-
Password: "invalid-password",
1298-
},
1299-
},
1300-
expectError: false,
1301-
},
13021217
}
13031218

13041219
for name, testcase := range testcases {

0 commit comments

Comments
 (0)