Skip to content

Add New Security Script Settings #24637

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

Merged
merged 3 commits into from
May 15, 2017
Merged

Add New Security Script Settings #24637

merged 3 commits into from
May 15, 2017

Conversation

jdconrad
Copy link
Contributor

@jdconrad jdconrad commented May 12, 2017

Adds allowed_types and allowed_contexts as new security settings for scripts described in detail in the issue #24532.

Closes #24532

@jdconrad jdconrad added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement v5.5.0 v6.0.0 labels May 12, 2017
@jdconrad jdconrad requested a review from rjernst May 12, 2017 01:42
@jdconrad
Copy link
Contributor Author

@elasticmachine please test this

@jdconrad
Copy link
Contributor Author

@rjernst If you're feeling up to it, I would appreciate a review on this :)

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I left a few minor comments.


/**
* @return <tt>true</tt> if the provided {@link ScriptContext} is supported, <tt>false</tt> otherwise
*/
boolean isSupportedContext(ScriptContext scriptContext) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the callers of isSupportedContext to call getKey() so there is only one variant of this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. There were only two callers and one was a test.

HashMap<String, Boolean> scriptModes = new HashMap<>();
for (Setting<Boolean> scriptModeSetting : scriptSettings.getScriptLanguageSettings()) {
scriptModes.put(scriptModeSetting.getKey(), scriptModeSetting.get(settings));
}
this.scriptEnabled = Collections.unmodifiableMap(scriptModes);

typesAllowed = TYPES_ALLOWED_SETTING.exists(settings) ? new HashSet<>() : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the future we can simplify this a bit, so the Setting value is not a List, but that can be in future work as I know this class will probably go away in master with context work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree completely on this.

[float]
=== Allowed script types setting

By default all script types are allowed to be executed. This can modified using the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can -> can be

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

=== Allowed script types setting

By default all script types are allowed to be executed. This can modified using the
setting `script.allowed_types`. Should this setting be used, only the types specified
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can remove the "Should this setting be used" part.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jdconrad
Copy link
Contributor Author

@rjernst Thanks for the review! As soon as the CI build passes I will commit.

@jdconrad jdconrad merged commit 4329297 into elastic:master May 15, 2017
jdconrad added a commit that referenced this pull request May 15, 2017
Settings are simplified to allowed_types and allowed_contexts.  If a setting is not specified the default is to enable all for that setting.
@jdconrad jdconrad deleted the settings branch May 15, 2017 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement v5.5.0 v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants