diff --git a/service/module/service.go b/service/module/service.go index 7c1d19d..aa01811 100644 --- a/service/module/service.go +++ b/service/module/service.go @@ -375,11 +375,12 @@ func (s Service) FilterSecretParams(ctx context.Context, config json.RawMessage, continue } sort.Strings(secrets) - plural := "variable" + plural := "переменную" if len(secrets) > 1 { - plural = "variables" + plural = "переменные" } - errorDetails[policyFieldPath(path)] = fmt.Sprintf("UI экспортируемое поле не должно ссылаться на переменную с типом SECRET %s %s", plural, strings.Join(secrets, ", ")) + msg := fmt.Sprintf("UI-экспортируемое поле не должно ссылаться на %s с типом SECRET: %s", plural, strings.Join(secrets, ", ")) + errorDetails[policyFieldPath(path)] = msg } if len(sensitivePaths) > 0 { @@ -397,7 +398,8 @@ func (s Service) FilterSecretParams(ctx context.Context, config json.RawMessage, } if name, ok := rc.SingleVariableRef(value); ok { if t, known := variableTypes[name]; known && t != entity.SecretType { - errorDetails[policyFieldPath(path)] = fmt.Sprintf("sensitive поле должно ссылаться на переменную с типом SECRET в %s", name) + msg := fmt.Sprintf("sensitive-поле должно ссылаться только на переменные с типом SECRET: переменная %s имеет тип %s", name, t) + errorDetails[policyFieldPath(path)] = msg } continue } diff --git a/service/module/service_test.go b/service/module/service_test.go index 0ec3942..54f50ae 100644 --- a/service/module/service_test.go +++ b/service/module/service_test.go @@ -62,6 +62,7 @@ func TestFilterSecretParams(t *testing.T) { const moduleId = "m1" varRepo := fakeVariableRepo{variables: []entity.Variable{ {Name: "sec_var", Type: entity.SecretType}, + {Name: "sec_var2", Type: entity.SecretType}, {Name: "txt_var", Type: entity.TextType}, }} @@ -76,7 +77,15 @@ func TestFilterSecretParams(t *testing.T) { config: `{"secrets": "_Var(sec_var)"}`, wantErr: true, wantDetails: map[string]string{ - "secrets": "references SECRET variable sec_var", + "secrets": "UI-экспортируемое поле не должно ссылаться на переменную с типом SECRET: sec_var", + }, + }, + { + name: "ui-exposed multiple secret references", + config: `{"secrets": "_Var(sec_var) _Var(sec_var2)"}`, + wantErr: true, + wantDetails: map[string]string{ + "secrets": "UI-экспортируемое поле не должно ссылаться на переменные с типом SECRET: sec_var, sec_var2", }, }, { @@ -90,7 +99,7 @@ func TestFilterSecretParams(t *testing.T) { config: `{"token": "_Var(txt_var)"}`, wantErr: true, wantDetails: map[string]string{ - "token": "references non-SECRET variable txt_var", + "token": "sensitive-поле должно ссылаться только на переменные с типом SECRET: переменная txt_var имеет тип TEXT", }, }, { @@ -132,7 +141,7 @@ func TestFilterSecretParams(t *testing.T) { config: `{"secrets": "_Var(sec_var)", "token": "plain-pass"}`, wantErr: true, wantDetails: map[string]string{ - "secrets": "references SECRET variable sec_var", + "secrets": "UI-экспортируемое поле не должно ссылаться на переменную с типом SECRET: sec_var", "token": "plain value in sensitive field", }, },