opensearch-project / cross-cluster-replication

Synchronize your data across multiple clusters for lower latencies and higher availability
https://opensearch.org/docs/latest/replication-plugin/index/
Apache License 2.0
47 stars 57 forks source link

Added validations for indexPattern in autofollow API #1358

Closed skumarp7 closed 4 months ago

skumarp7 commented 5 months ago

Description

This PR adds validations for the indexPattern configured in autofollow API

Existing behavior of the autofollow API with invalid indexPattern:

  curl -Method POST -Uri "http://localhost:9201/_plugins/_replication/_autofollow?pretty"  -H @{'Content-Typ
e' = 'application/json'} -body '{"leader_alias":"leader", "name": "test", "pattern": "test/abcd"}'                   

StatusCode        : 200
StatusDescription : OK
Content           : {
                      "acknowledged" : true
                    }

Behaviour after adding validations on indexPattern:

curl -Method POST -Uri "http://localhost:9201/_plugins/_replication/_autofollow?pretty"  -H @{'Content-Typ
e' = 'application/json'} -body '{"leader_alias":"leader_sanjay", "name": "test", "pattern": "test/adfas"}'

curl : { "error" : { "root_cause" : [ { "type" : "action_request_validation_exception", "reason" : "Validation Failed: 1: Autofollow pattern: 
test/adfas must not contain the following characters [ , \", *, \\, <, |, ,, >, /, ?];" } ], "type" : "action_request_validation_exception", 
"reason" : "Validation Failed: 1: Autofollow pattern: test/adfas must not contain the following characters [ , \", *, \\, <, |, ,, >, /, ?];" },    
"status" : 400 }

Issues Resolved

https://github.com/opensearch-project/cross-cluster-replication/issues/1034

Check List

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

skumarp7 commented 4 months ago

Hi All,

Please let me know if the above made changes are good to go. Feedback is much appreciated :)

skumarp7 commented 4 months ago

Hi @monusingh-1 , Any update ?

monusingh-1 commented 4 months ago

Enabled approval workflow

monusingh-1 commented 4 months ago

Security tests have started to fail, investigating