[GitHub] groovy pull request #804: Fix variable type

2018-10-03 Thread dpolivaev
Github user dpolivaev closed the pull request at:

https://github.com/apache/groovy/pull/804


---


[GitHub] groovy pull request #804: Fix variable type

2018-10-03 Thread dpolivaev
GitHub user dpolivaev opened a pull request:

https://github.com/apache/groovy/pull/804

Fix variable type

https://issues.apache.org/jira/browse/GROOVY-8817

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/dpolivaev/groovy GROOVY_2_5_X

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/groovy/pull/804.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #804


commit 7dd44f042b255d3a03b247e0cf6edcbfc4855d3e
Author: Dimitry Polivaev 
Date:   2018-10-03T07:25:58Z

Fix variable type

https://issues.apache.org/jira/browse/GROOVY-8817




---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-20 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r117609738
  
--- Diff: src/main/groovy/lang/MetaClassImpl.java ---
@@ -1832,6 +1832,9 @@ public Object getProperty(Class sender, Object 
object, String name, boolean useS
 } catch (IllegalArgumentException e) {
 // can't access the field directly but there may be a 
getter
 mp = null;
+} catch (GroovyRuntimeException e) {
--- End diff --

Done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-18 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r117188820
  
--- Diff: src/main/groovy/lang/MetaClassImpl.java ---
@@ -1832,6 +1832,9 @@ public Object getProperty(Class sender, Object 
object, String name, boolean useS
 } catch (IllegalArgumentException e) {
 // can't access the field directly but there may be a 
getter
 mp = null;
+} catch (GroovyRuntimeException e) {
--- End diff --

How do you see it?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-18 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r117188688
  
--- Diff: src/main/groovy/lang/MetaClassImpl.java ---
@@ -1832,6 +1832,9 @@ public Object getProperty(Class sender, Object 
object, String name, boolean useS
 } catch (IllegalArgumentException e) {
 // can't access the field directly but there may be a 
getter
 mp = null;
+} catch (GroovyRuntimeException e) {
--- End diff --

On the other side if it does not work because AccessControlExceptions are 
not handled by the calling code properly `public class 
CacheAccessControlException extends GroovyRuntimeException` could also be taken 
as a hack.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-18 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r117188226
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedMethod.java ---
@@ -90,6 +92,12 @@ public CachedClass getDeclaringClass() {
 
 public final Object invoke(Object object, Object[] arguments) {
 try {
+AccessPermissionChecker.checkAccessPermission(cachedMethod);
+}
+catch (AccessControlException ex) {
+throw new InvokerInvocationException(new 
GroovyRuntimeException("Illegal access to method" + cachedMethod.getName()));
+}
+try {
 return cachedMethod.invoke(object, arguments);
--- End diff --

I think that InvokerInvocationException is specific to call of invoke() and 
it should be not thrown  by AccessPermissionChecker directly.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-18 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r117188013
  
--- Diff: src/main/groovy/lang/MetaClassImpl.java ---
@@ -1832,6 +1832,9 @@ public Object getProperty(Class sender, Object 
object, String name, boolean useS
 } catch (IllegalArgumentException e) {
 // can't access the field directly but there may be a 
getter
 mp = null;
+} catch (GroovyRuntimeException e) {
--- End diff --

I think AccessPermissionChecker should only throw exceptions extending from 
AccessControlException. because it specifically checks access permissions. 

So I suggest to introduce `public class CacheAccessControlException extends 
AccessControlException`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377499
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedMethod.java ---
@@ -124,6 +131,12 @@ public String getSignature() {
 }
 
 public final Method setAccessible() {
+try {
+AccessPermissionChecker.checkAccessPermission(cachedMethod);
+}
+catch (AccessControlException ex) {
+throw new IllegalArgumentException("Illegal access to method" 
+ cachedMethod.getName());
--- End diff --

As above


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377497
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedMethod.java ---
@@ -90,6 +91,12 @@ public CachedClass getDeclaringClass() {
 
 public final Object invoke(Object object, Object[] arguments) {
 try {
+AccessPermissionChecker.checkAccessPermission(cachedMethod);
+}
+catch (AccessControlException ex) {
+throw new InvokerInvocationException(new 
IllegalArgumentException("Illegal access to method" + cachedMethod.getName()));
--- End diff --

As above


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377501
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedMethod.java ---
@@ -324,6 +337,12 @@ else if (o2 instanceof CachedMethod)
 }
 
 public Method getCachedMethod() {
+try {
+AccessPermissionChecker.checkAccessPermission(cachedMethod);
+}
+catch (AccessControlException ex) {
+throw new IllegalArgumentException("Illegal access to method" 
+ cachedMethod.getName());
--- End diff --

As above


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377495
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedField.java ---
@@ -65,6 +72,12 @@ public Object getProperty(final Object object) {
  * @throws RuntimeException if the property could not be set
  */
 public void setProperty(final Object object, Object newValue) {
+try {
+AccessPermissionChecker.checkAccessPermission(field);
+}
+catch (AccessControlException ex) {
+throw new IllegalArgumentException("Illegal access to field" + 
" " + field.getName());
--- End diff --

As above


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377482
  
--- Diff: src/main/org/codehaus/groovy/reflection/CachedField.java ---
@@ -51,6 +52,12 @@ public int getModifiers() {
  */
 public Object getProperty(final Object object) {
 try {
+AccessPermissionChecker.checkAccessPermission(field);
+}
+catch (AccessControlException ex) {
+throw new IllegalArgumentException("Illegal access to field" + 
" " + field.getName());
--- End diff --

To use GroovyRuntimeException we need to patch also 
MetaClassImpl.getProperty . It was not possible with byte buddy, but as a 
groovy patch it is possible. I shall do it in a separate commit.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-14 Thread dpolivaev
Github user dpolivaev commented on a diff in the pull request:

https://github.com/apache/groovy/pull/532#discussion_r116377418
  
--- Diff: 
src/main/org/codehaus/groovy/reflection/AccessPermissionChecker.java ---
@@ -0,0 +1,62 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.reflection;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ReflectPermission;
+
+import groovy.lang.GroovyObject;
+
+class AccessPermissionChecker {
+
+   private static final ReflectPermission REFLECT_PERMISSION = new 
ReflectPermission("suppressAccessChecks");
+
+   static private void checkAccessPermission(Class declaringClass, 
final int modifiers, boolean isAccessible) {
+   final SecurityManager securityManager = 
System.getSecurityManager();
--- End diff --

Signature changed. The check is performed only if (securityManager != null 
&& isAccessible)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] groovy pull request #532: Prevent CachedField and CachedMethod from leaking ...

2017-05-01 Thread dpolivaev
GitHub user dpolivaev opened a pull request:

https://github.com/apache/groovy/pull/532

Prevent CachedField and CachedMethod from leaking access permissions …

…to scripts

https://issues.apache.org/jira/browse/GROOVY-8163

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/dpolivaev/groovy master

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/groovy/pull/532.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #532


commit 20741fe4f61940a2e5ab56c67d0710a17ac5583f
Author: Dimitry Polivaev <dpoliv...@gmx.de>
Date:   2017-05-01T20:58:12Z

Prevent CachedField and CachedMethod from leaking access permissions to 
scripts

https://issues.apache.org/jira/browse/GROOVY-8163




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---