-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some checks before removing directories #7829
Conversation
@@ -305,6 +305,10 @@ func (e *StatementExecutor) executeDropContinuousQueryStatement(q *influxql.Drop | |||
// It does not return an error if the database was not found on any of | |||
// the nodes, or in the Meta store. | |||
func (e *StatementExecutor) executeDropDatabaseStatement(stmt *influxql.DropDatabaseStatement) error { | |||
if e.MetaClient.Database(stmt.Name) == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be a no-op instead of returning an error for API compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. The conditional won't change, though.
|
||
dbi := e.MetaClient.Database(stmt.Database) | ||
if dbi == nil { | ||
return influxql.ErrDatabaseNotFound(stmt.Database) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for both of these.
f7b37a7
to
e5b972f
Compare
Fixes #7822 This change first ensures that databases and retention policies exist before attempting to remove them from the Store. It also adds some checks in the `DeleteDatabase` and `DeleteRetentionPolicy` to ensure that maliciously named entries won't remove anything outside of the configured data directory.
This change adds some very basic name validation with the following plain-english description: names must be non-zero sequence of printable characters that do not contain slashes ('/' or '\') and are not equal to either "." or "..". The intent is that, since we currently just use database and retention policy names directly as path elements, these rules will hopefully leave us with names that should be at least close to valid directory names. Ideally, we would restrict names even further or not use them as path elements directly, but this should be a step towards the former without restricting names "too much"
e5b972f
to
2db0250
Compare
Fixes #7822
This change first ensures that databases and retention policies exist
before attempting to remove them from the Store. It also adds some
checks in the
DeleteDatabase
andDeleteRetentionPolicy
to ensurethat maliciously named entries won't remove anything outside of the
configured data directory.
This also adds some very basic name validation with the following
plain-english description: names must be non-zero sequence of printable
characters that do not contain slashes ('/' or '') and are not equal to
either "." or "..".
The intent is that, since we currently just use database and retention
policy names directly as path elements, these rules will hopefully leave
us with names that should be at least close to valid directory names.
Ideally, we would restrict names even further or not use them as path
elements directly, but this should be a step towards the former without
restricting names "too much"
Required for all non-trivial PRs